@@ -123,7 +123,7 @@ void usage( const QString &appName )
123
123
<< QStringLiteral ( " \t [--snapshot filename]\t emit snapshot of loaded datasets to given file\n " )
124
124
<< QStringLiteral ( " \t [--width width]\t width of snapshot to emit\n " )
125
125
<< QStringLiteral ( " \t [--height height]\t height of snapshot to emit\n " )
126
- << QStringLiteral ( " \t [--lang language]\t use language for interface text\n " )
126
+ << QStringLiteral ( " \t [--lang language]\t use language for interface text (changes existing override) \n " )
127
127
<< QStringLiteral ( " \t [--project projectfile]\t load the given QGIS project\n " )
128
128
<< QStringLiteral ( " \t [--extent xmin,ymin,xmax,ymax]\t set initial map extent\n " )
129
129
<< QStringLiteral ( " \t [--nologo]\t hide splash screen\n " )
@@ -510,7 +510,7 @@ int main( int argc, char *argv[] )
510
510
int mySnapshotHeight = 600 ;
511
511
512
512
bool myHideSplash = false ;
513
- bool mySettingsMigrationForce = false ;
513
+ bool settingsMigrationForce = false ;
514
514
bool mySkipVersionCheck = false ;
515
515
bool hideBrowser = false ;
516
516
#if defined(ANDROID)
@@ -565,193 +565,201 @@ int main( int argc, char *argv[] )
565
565
566
566
QStringList args;
567
567
568
- if ( !bundleclicked ( argc, argv ) )
569
568
{
570
- // Build a local QCoreApplication from arguments. This way, arguments are correctly parsed from their native locale
571
- // It will use QString::fromLocal8Bit( argv ) under Unix and GetCommandLine() under Windows.
572
569
QCoreApplication coreApp ( argc, argv );
573
- args = QCoreApplication::arguments ();
570
+ ( void ) QgsApplication::resolvePkgPath (); // trigger storing of application path in QgsApplication
574
571
575
- for ( int i = 1 ; i < args. size (); ++i )
572
+ if ( ! bundleclicked ( argc, argv ) )
576
573
{
577
- const QString &arg = args[i];
574
+ // Build a local QCoreApplication from arguments. This way, arguments are correctly parsed from their native locale
575
+ // It will use QString::fromLocal8Bit( argv ) under Unix and GetCommandLine() under Windows.
576
+ args = QCoreApplication::arguments ();
578
577
579
- if ( arg == QLatin1String ( " --help " ) || arg == QLatin1String ( " -? " ) )
578
+ for ( int i = 1 ; i < args. size (); ++i )
580
579
{
581
- usage ( args[0 ] );
582
- return 2 ;
583
- }
584
- else if ( arg == QLatin1String ( " --nologo" ) || arg == QLatin1String ( " -n" ) )
585
- {
586
- myHideSplash = true ;
587
- }
588
- else if ( arg == QLatin1String ( " --version-migration" ) )
589
- {
590
- mySettingsMigrationForce = true ;
591
- }
592
- else if ( arg == QLatin1String ( " --noversioncheck" ) || arg == QLatin1String ( " -V" ) )
593
- {
594
- mySkipVersionCheck = true ;
595
- }
596
- else if ( arg == QLatin1String ( " --noplugins" ) || arg == QLatin1String ( " -P" ) )
597
- {
598
- myRestorePlugins = false ;
599
- }
600
- else if ( arg == QLatin1String ( " --nocustomization" ) || arg == QLatin1String ( " -C" ) )
601
- {
602
- myCustomization = false ;
603
- }
604
- else if ( i + 1 < argc && ( arg == QLatin1String ( " --profile" ) ) )
605
- {
606
- profileName = args[++i];
607
- }
608
- else if ( i + 1 < argc && ( arg == QLatin1String ( " --profiles-path" ) || arg == QLatin1String ( " -s" ) ) )
609
- {
610
- configLocalStorageLocation = QDir::toNativeSeparators ( QFileInfo ( args[++i] ).absoluteFilePath () );
611
- }
612
- else if ( i + 1 < argc && ( arg == QLatin1String ( " --snapshot" ) || arg == QLatin1String ( " -s" ) ) )
613
- {
614
- mySnapshotFileName = QDir::toNativeSeparators ( QFileInfo ( args[++i] ).absoluteFilePath () );
615
- }
616
- else if ( i + 1 < argc && ( arg == QLatin1String ( " --width" ) || arg == QLatin1String ( " -w" ) ) )
617
- {
618
- mySnapshotWidth = QString ( args[++i] ).toInt ();
619
- }
620
- else if ( i + 1 < argc && ( arg == QLatin1String ( " --height" ) || arg == QLatin1String ( " -h" ) ) )
621
- {
622
- mySnapshotHeight = QString ( args[++i] ).toInt ();
623
- }
624
- else if ( i + 1 < argc && ( arg == QLatin1String ( " --lang" ) || arg == QLatin1String ( " -l" ) ) )
625
- {
626
- translationCode = args[++i];
627
- }
628
- else if ( i + 1 < argc && ( arg == QLatin1String ( " --project" ) || arg == QLatin1String ( " -p" ) ) )
629
- {
630
- sProjectFileName = QDir::toNativeSeparators ( QFileInfo ( args[++i] ).absoluteFilePath () );
631
- }
632
- else if ( i + 1 < argc && ( arg == QLatin1String ( " --extent" ) || arg == QLatin1String ( " -e" ) ) )
633
- {
634
- myInitialExtent = args[++i];
635
- }
636
- else if ( i + 1 < argc && ( arg == QLatin1String ( " --authdbdirectory" ) || arg == QLatin1String ( " -a" ) ) )
637
- {
638
- authdbdirectory = QDir::toNativeSeparators ( QDir ( args[++i] ).absolutePath () );
639
- }
640
- else if ( i + 1 < argc && ( arg == QLatin1String ( " --code" ) || arg == QLatin1String ( " -f" ) ) )
641
- {
642
- pythonfile = QDir::toNativeSeparators ( QFileInfo ( args[++i] ).absoluteFilePath () );
643
- }
644
- else if ( i + 1 < argc && ( arg == QLatin1String ( " --customizationfile" ) || arg == QLatin1String ( " -z" ) ) )
645
- {
646
- customizationfile = QDir::toNativeSeparators ( QFileInfo ( args[++i] ).absoluteFilePath () );
647
- }
648
- else if ( i + 1 < argc && ( arg == QLatin1String ( " --globalsettingsfile" ) || arg == QLatin1String ( " -g" ) ) )
649
- {
650
- globalsettingsfile = QDir::toNativeSeparators ( QFileInfo ( args[++i] ).absoluteFilePath () );
651
- }
652
- else if ( arg == QLatin1String ( " --defaultui" ) || arg == QLatin1String ( " -d" ) )
653
- {
654
- myRestoreDefaultWindowState = true ;
655
- }
656
- else if ( arg == QLatin1String ( " --dxf-export" ) )
657
- {
658
- dxfOutputFile = args[++i];
659
- }
660
- else if ( arg == QLatin1String ( " --dxf-extent" ) )
661
- {
662
- QgsLocaleNumC l;
663
- QString ext ( args[++i] );
664
- QStringList coords ( ext.split ( ' ,' ) );
580
+ const QString &arg = args[i];
665
581
666
- if ( coords. size () != 4 )
582
+ if ( arg == QLatin1String ( " --help " ) || arg == QLatin1String ( " -? " ) )
667
583
{
668
- std::cerr << " invalid dxf extent " << ext. toStdString () << std::endl ;
584
+ usage ( args[ 0 ] ) ;
669
585
return 2 ;
670
586
}
671
-
672
- for ( int i = 0 ; i < 4 ; i++ )
587
+ else if ( arg == QLatin1String ( " --nologo" ) || arg == QLatin1String ( " -n" ) )
673
588
{
674
- bool ok;
675
- double d;
589
+ myHideSplash = true ;
590
+ }
591
+ else if ( arg == QLatin1String ( " --version-migration" ) )
592
+ {
593
+ settingsMigrationForce = true ;
594
+ }
595
+ else if ( arg == QLatin1String ( " --noversioncheck" ) || arg == QLatin1String ( " -V" ) )
596
+ {
597
+ mySkipVersionCheck = true ;
598
+ }
599
+ else if ( arg == QLatin1String ( " --noplugins" ) || arg == QLatin1String ( " -P" ) )
600
+ {
601
+ myRestorePlugins = false ;
602
+ }
603
+ else if ( arg == QLatin1String ( " --nocustomization" ) || arg == QLatin1String ( " -C" ) )
604
+ {
605
+ myCustomization = false ;
606
+ }
607
+ else if ( i + 1 < argc && ( arg == QLatin1String ( " --profile" ) ) )
608
+ {
609
+ profileName = args[++i];
610
+ }
611
+ else if ( i + 1 < argc && ( arg == QLatin1String ( " --profiles-path" ) || arg == QLatin1String ( " -s" ) ) )
612
+ {
613
+ configLocalStorageLocation = QDir::toNativeSeparators ( QFileInfo ( args[++i] ).absoluteFilePath () );
614
+ }
615
+ else if ( i + 1 < argc && ( arg == QLatin1String ( " --snapshot" ) || arg == QLatin1String ( " -s" ) ) )
616
+ {
617
+ mySnapshotFileName = QDir::toNativeSeparators ( QFileInfo ( args[++i] ).absoluteFilePath () );
618
+ }
619
+ else if ( i + 1 < argc && ( arg == QLatin1String ( " --width" ) || arg == QLatin1String ( " -w" ) ) )
620
+ {
621
+ mySnapshotWidth = QString ( args[++i] ).toInt ();
622
+ }
623
+ else if ( arg == QLatin1String ( " --hide-browser" ) )
624
+ {
625
+ hideBrowser = true ;
626
+ }
627
+ else if ( i + 1 < argc && ( arg == QLatin1String ( " --height" ) || arg == QLatin1String ( " -h" ) ) )
628
+ {
629
+ mySnapshotHeight = QString ( args[++i] ).toInt ();
630
+ }
631
+ else if ( i + 1 < argc && ( arg == QLatin1String ( " --lang" ) || arg == QLatin1String ( " -l" ) ) )
632
+ {
633
+ translationCode = args[++i];
634
+ }
635
+ else if ( i + 1 < argc && ( arg == QLatin1String ( " --project" ) || arg == QLatin1String ( " -p" ) ) )
636
+ {
637
+ sProjectFileName = QDir::toNativeSeparators ( QFileInfo ( args[++i] ).absoluteFilePath () );
638
+ }
639
+ else if ( i + 1 < argc && ( arg == QLatin1String ( " --extent" ) || arg == QLatin1String ( " -e" ) ) )
640
+ {
641
+ myInitialExtent = args[++i];
642
+ }
643
+ else if ( i + 1 < argc && ( arg == QLatin1String ( " --authdbdirectory" ) || arg == QLatin1String ( " -a" ) ) )
644
+ {
645
+ authdbdirectory = QDir::toNativeSeparators ( QDir ( args[++i] ).absolutePath () );
646
+ }
647
+ else if ( i + 1 < argc && ( arg == QLatin1String ( " --code" ) || arg == QLatin1String ( " -f" ) ) )
648
+ {
649
+ pythonfile = QDir::toNativeSeparators ( QFileInfo ( args[++i] ).absoluteFilePath () );
650
+ }
651
+ else if ( i + 1 < argc && ( arg == QLatin1String ( " --customizationfile" ) || arg == QLatin1String ( " -z" ) ) )
652
+ {
653
+ customizationfile = QDir::toNativeSeparators ( QFileInfo ( args[++i] ).absoluteFilePath () );
654
+ }
655
+ else if ( i + 1 < argc && ( arg == QLatin1String ( " --globalsettingsfile" ) || arg == QLatin1String ( " -g" ) ) )
656
+ {
657
+ globalsettingsfile = QDir::toNativeSeparators ( QFileInfo ( args[++i] ).absoluteFilePath () );
658
+ }
659
+ else if ( arg == QLatin1String ( " --defaultui" ) || arg == QLatin1String ( " -d" ) )
660
+ {
661
+ myRestoreDefaultWindowState = true ;
662
+ }
663
+ else if ( arg == QLatin1String ( " --dxf-export" ) )
664
+ {
665
+ dxfOutputFile = args[++i];
666
+ }
667
+ else if ( arg == QLatin1String ( " --dxf-extent" ) )
668
+ {
669
+ QgsLocaleNumC l;
670
+ QString ext ( args[++i] );
671
+ QStringList coords ( ext.split ( ' ,' ) );
676
672
677
- d = coords[i].toDouble ( &ok );
678
- if ( !ok )
673
+ if ( coords.size () != 4 )
679
674
{
680
- std::cerr << " invalid dxf coordinate " << coords[i]. toStdString () << " in extent " << ext.toStdString () << std::endl;
675
+ std::cerr << " invalid dxf extent " << ext.toStdString () << std::endl;
681
676
return 2 ;
682
677
}
683
678
684
- switch ( i )
679
+ for ( int i = 0 ; i < 4 ; i++ )
685
680
{
686
- case 0 :
687
- dxfExtent.setXMinimum ( d );
688
- break ;
689
- case 1 :
690
- dxfExtent.setYMinimum ( d );
691
- break ;
692
- case 2 :
693
- dxfExtent.setXMaximum ( d );
694
- break ;
695
- case 3 :
696
- dxfExtent.setYMaximum ( d );
697
- break ;
681
+ bool ok;
682
+ double d;
683
+
684
+ d = coords[i].toDouble ( &ok );
685
+ if ( !ok )
686
+ {
687
+ std::cerr << " invalid dxf coordinate " << coords[i].toStdString () << " in extent " << ext.toStdString () << std::endl;
688
+ return 2 ;
689
+ }
690
+
691
+ switch ( i )
692
+ {
693
+ case 0 :
694
+ dxfExtent.setXMinimum ( d );
695
+ break ;
696
+ case 1 :
697
+ dxfExtent.setYMinimum ( d );
698
+ break ;
699
+ case 2 :
700
+ dxfExtent.setXMaximum ( d );
701
+ break ;
702
+ case 3 :
703
+ dxfExtent.setYMaximum ( d );
704
+ break ;
705
+ }
698
706
}
699
707
}
700
- }
701
- else if ( arg == QLatin1String ( " --dxf-symbology-mode" ) )
702
- {
703
- QString mode ( args[++i] );
704
- if ( mode == QLatin1String ( " none" ) )
708
+ else if ( arg == QLatin1String ( " --dxf-symbology-mode" ) )
705
709
{
706
- dxfSymbologyMode = QgsDxfExport::NoSymbology;
710
+ QString mode ( args[++i] );
711
+ if ( mode == QLatin1String ( " none" ) )
712
+ {
713
+ dxfSymbologyMode = QgsDxfExport::NoSymbology;
714
+ }
715
+ else if ( mode == QLatin1String ( " symbollayer" ) )
716
+ {
717
+ dxfSymbologyMode = QgsDxfExport::SymbolLayerSymbology;
718
+ }
719
+ else if ( mode == QLatin1String ( " feature" ) )
720
+ {
721
+ dxfSymbologyMode = QgsDxfExport::FeatureSymbology;
722
+ }
723
+ else
724
+ {
725
+ std::cerr << " invalid dxf symbology mode " << mode.toStdString () << std::endl;
726
+ return 2 ;
727
+ }
707
728
}
708
- else if ( mode == QLatin1String ( " symbollayer " ) )
729
+ else if ( arg == QLatin1String ( " --dxf-scale-denom " ) )
709
730
{
710
- dxfSymbologyMode = QgsDxfExport::SymbolLayerSymbology;
731
+ bool ok;
732
+ QString scale ( args[++i] );
733
+ dxfScale = scale.toDouble ( &ok );
734
+ if ( !ok )
735
+ {
736
+ std::cerr << " invalid dxf scale " << scale.toStdString () << std::endl;
737
+ return 2 ;
738
+ }
711
739
}
712
- else if ( mode == QLatin1String ( " feature " ) )
740
+ else if ( arg == QLatin1String ( " --dxf-encoding " ) )
713
741
{
714
- dxfSymbologyMode = QgsDxfExport::FeatureSymbology ;
742
+ dxfEncoding = args[++i] ;
715
743
}
716
- else
744
+ else if ( arg == QLatin1String ( " --dxf-map-theme " ) )
717
745
{
718
- std::cerr << " invalid dxf symbology mode " << mode.toStdString () << std::endl;
719
- return 2 ;
746
+ dxfMapTheme = args[++i];
720
747
}
721
- }
722
- else if ( arg == QLatin1String ( " --dxf-scale-denom" ) )
723
- {
724
- bool ok;
725
- QString scale ( args[++i] );
726
- dxfScale = scale.toDouble ( &ok );
727
- if ( !ok )
748
+ #ifdef HAVE_OPENCL
749
+ else if ( arg == QLatin1String ( " --openclprogramfolder" ) )
728
750
{
729
- std::cerr << " invalid dxf scale " << scale.toStdString () << std::endl;
730
- return 2 ;
751
+ openClProgramFolder = args[++i];
731
752
}
732
- }
733
- else if ( arg == QLatin1String ( " --dxf-encoding" ) )
734
- {
735
- dxfEncoding = args[++i];
736
- }
737
- else if ( arg == QLatin1String ( " --dxf-map-theme" ) )
738
- {
739
- dxfMapTheme = args[++i];
740
- }
741
- #ifdef HAVE_OPENCL
742
- else if ( arg == QLatin1String ( " --openclprogramfolder" ) )
743
- {
744
- openClProgramFolder = args[++i];
745
- }
746
753
#endif
747
- else if ( arg == QLatin1String ( " --" ) )
748
- {
749
- for ( i++; i < args.size (); ++i )
754
+ else if ( arg == QLatin1String ( " --" ) )
755
+ {
756
+ for ( i++; i < args.size (); ++i )
757
+ sFileList .append ( QDir::toNativeSeparators ( QFileInfo ( args[i] ).absoluteFilePath () ) );
758
+ }
759
+ else
760
+ {
750
761
sFileList .append ( QDir::toNativeSeparators ( QFileInfo ( args[i] ).absoluteFilePath () ) );
751
- }
752
- else
753
- {
754
- sFileList .append ( QDir::toNativeSeparators ( QFileInfo ( args[i] ).absoluteFilePath () ) );
762
+ }
755
763
}
756
764
}
757
765
}
@@ -777,10 +785,9 @@ int main( int argc, char *argv[] )
777
785
}
778
786
}
779
787
780
-
781
788
// ///////////////////////////////////////////////////////////////////
782
789
// Now we have the handlers for the different behaviors...
783
- // //////////////////////////////////////////////////////////////////
790
+ // ///////////////////////////////////////////////////////////////////
784
791
785
792
// ///////////////////////////////////////////////////////////////////
786
793
// Initialize the application and the translation stuff
@@ -816,74 +823,7 @@ int main( int argc, char *argv[] )
816
823
QCoreApplication::setAttribute ( Qt::AA_DisableWindowContextHelpButton, true );
817
824
#endif
818
825
819
- /* Translation file for QGIS.
820
- */
821
- QString i18nPath = QgsApplication::i18nPath ();
822
- QgsSettings mySettings;
823
- QString myUserTranslation = mySettings.value ( QStringLiteral ( " locale/userLocale" ), " " ).toString ();
824
- QString myGlobalLocale = mySettings.value ( QStringLiteral ( " locale/globalLocale" ), " " ).toString ();
825
- bool myShowGroupSeparatorFlag = false ; // Default to false
826
- bool myLocaleOverrideFlag = mySettings.value ( QStringLiteral ( " locale/overrideFlag" ), false ).toBool ();
827
-
828
- // Override Show Group Separator if the global override flag is set
829
- if ( myLocaleOverrideFlag )
830
- {
831
- // Default to false again
832
- myShowGroupSeparatorFlag = mySettings.value ( QStringLiteral ( " locale/showGroupSeparator" ), false ).toBool ();
833
- }
834
-
835
- //
836
- // Priority of translation is:
837
- // - command line
838
- // - user specified in options dialog (with group checked on)
839
- // - system locale
840
- //
841
- // When specifying from the command line it will change the user
842
- // specified user locale
843
- //
844
- if ( !translationCode.isNull () && !translationCode.isEmpty () )
845
- {
846
- mySettings.setValue ( QStringLiteral ( " locale/userLocale" ), translationCode );
847
- }
848
- else
849
- {
850
- if ( !myLocaleOverrideFlag || myUserTranslation.isEmpty () )
851
- {
852
- translationCode = QLocale ().name ();
853
- // setting the locale/userLocale when the --lang= option is not set will allow third party
854
- // plugins to always use the same locale as the QGIS, otherwise they can be out of sync
855
- mySettings.setValue ( QStringLiteral ( " locale/userLocale" ), translationCode );
856
- }
857
- else
858
- {
859
- translationCode = myUserTranslation;
860
- }
861
- }
862
-
863
- // Global locale settings
864
- if ( myLocaleOverrideFlag && ! myGlobalLocale.isEmpty ( ) )
865
- {
866
- QLocale currentLocale ( myGlobalLocale );
867
- QLocale::setDefault ( currentLocale );
868
- }
869
-
870
- // Number settings
871
- QLocale currentLocale;
872
- if ( myShowGroupSeparatorFlag )
873
- {
874
- currentLocale.setNumberOptions ( currentLocale.numberOptions () &= ~QLocale::NumberOption::OmitGroupSeparator );
875
- }
876
- else
877
- {
878
- currentLocale.setNumberOptions ( currentLocale.numberOptions () |= QLocale::NumberOption::OmitGroupSeparator );
879
- }
880
- QLocale::setDefault ( currentLocale );
881
-
882
- QgsApplication::setTranslation ( translationCode );
883
-
884
- QgsApplication myApp ( argc, argv, myUseGuiFlag );
885
-
886
- // SetUp the QgsSettings Global Settings:
826
+ // Set up the QgsSettings Global Settings:
887
827
// - use the path specified with --globalsettingsfile path,
888
828
// - use the environment if not found
889
829
// - use a default location as a fallback
@@ -903,7 +843,7 @@ int main( int argc, char *argv[] )
903
843
904
844
if ( !globalsettingsfile.isEmpty () )
905
845
{
906
- if ( ! QgsSettings::setGlobalSettingsPath ( globalsettingsfile ) )
846
+ if ( !QgsSettings::setGlobalSettingsPath ( globalsettingsfile ) )
907
847
{
908
848
QgsMessageLog::logMessage ( QObject::tr ( " Invalid globalsettingsfile path: %1" ).arg ( globalsettingsfile ), QStringLiteral ( " QGIS" ) );
909
849
}
@@ -940,37 +880,95 @@ int main( int argc, char *argv[] )
940
880
profileName = profile->name ();
941
881
delete profile;
942
882
943
- // We can't use QgsSettings until this point because the format and
944
- // folder isn't set until profile is fetch.
945
- // Should be cleaned up in future to make this cleaner.
946
- QgsSettings settings;
883
+ {
884
+ QgsSettings settings;
947
885
948
- QgsDebugMsgLevel ( QStringLiteral ( " User profile details:" ), 2 );
949
- QgsDebugMsgLevel ( QStringLiteral ( " \t - %1" ).arg ( profileName ), 2 );
950
- QgsDebugMsgLevel ( QStringLiteral ( " \t - %1" ).arg ( profileFolder ), 2 );
951
- QgsDebugMsgLevel ( QStringLiteral ( " \t - %1" ).arg ( rootProfileFolder ), 2 );
886
+ /* Translation file for QGIS.
887
+ */
888
+ QString myUserTranslation = settings.value ( QStringLiteral ( " locale/userLocale" ), " " ).toString ();
889
+ QString myGlobalLocale = settings.value ( QStringLiteral ( " locale/globalLocale" ), " " ).toString ();
890
+ bool myShowGroupSeparatorFlag = false ; // Default to false
891
+ bool myLocaleOverrideFlag = settings.value ( QStringLiteral ( " locale/overrideFlag" ), false ).toBool ();
952
892
953
- myApp.init ( profileFolder );
893
+ // Override Show Group Separator if the global override flag is set
894
+ if ( myLocaleOverrideFlag )
895
+ {
896
+ // Default to false again
897
+ myShowGroupSeparatorFlag = settings.value ( QStringLiteral ( " locale/showGroupSeparator" ), false ).toBool ();
898
+ }
899
+
900
+ //
901
+ // Priority of translation is:
902
+ // - command line
903
+ // - user specified in options dialog (with group checked on)
904
+ // - system locale
905
+ //
906
+ // When specifying from the command line it will change the user
907
+ // specified user locale
908
+ //
909
+ if ( !translationCode.isNull () && !translationCode.isEmpty () )
910
+ {
911
+ settings.setValue ( QStringLiteral ( " locale/userLocale" ), translationCode );
912
+ }
913
+ else
914
+ {
915
+ if ( !myLocaleOverrideFlag || myUserTranslation.isEmpty () )
916
+ {
917
+ translationCode = QLocale ().name ();
918
+ // setting the locale/userLocale when the --lang= option is not set will allow third party
919
+ // plugins to always use the same locale as the QGIS, otherwise they can be out of sync
920
+ settings.setValue ( QStringLiteral ( " locale/userLocale" ), translationCode );
921
+ }
922
+ else
923
+ {
924
+ translationCode = myUserTranslation;
925
+ }
926
+ }
927
+
928
+ // Global locale settings
929
+ if ( myLocaleOverrideFlag && ! myGlobalLocale.isEmpty ( ) )
930
+ {
931
+ QLocale currentLocale ( myGlobalLocale );
932
+ QLocale::setDefault ( currentLocale );
933
+ }
934
+
935
+ // Number settings
936
+ QLocale currentLocale;
937
+ if ( myShowGroupSeparatorFlag )
938
+ {
939
+ currentLocale.setNumberOptions ( currentLocale.numberOptions () &= ~QLocale::NumberOption::OmitGroupSeparator );
940
+ }
941
+ else
942
+ {
943
+ currentLocale.setNumberOptions ( currentLocale.numberOptions () |= QLocale::NumberOption::OmitGroupSeparator );
944
+ }
945
+ QLocale::setDefault ( currentLocale );
946
+
947
+ QgsApplication::setTranslation ( translationCode );
948
+ }
949
+
950
+ QgsApplication myApp ( argc, argv, myUseGuiFlag );
954
951
955
952
// Settings migration is only supported on the default profile for now.
956
953
if ( profileName == " default" )
957
954
{
958
955
// Note: this flag is ka version number so that we can reset it once we change the version.
959
956
// Note2: Is this a good idea can we do it better.
960
957
961
- int firstRunVersion = settings.value ( QStringLiteral ( " migration/firstRunVersionFlag" ), 0 ).toInt ();
958
+ QgsSettings migSettings;
959
+ int firstRunVersion = migSettings.value ( QStringLiteral ( " migration/firstRunVersionFlag" ), 0 ).toInt ();
962
960
bool showWelcome = ( firstRunVersion == 0 || Qgis::QGIS_VERSION_INT > firstRunVersion );
963
961
964
962
std::unique_ptr< QgsVersionMigration > migration ( QgsVersionMigration::canMigrate ( 20000 , Qgis::QGIS_VERSION_INT ) );
965
- if ( migration && ( mySettingsMigrationForce || migration->requiresMigration () ) )
963
+ if ( migration && ( settingsMigrationForce || migration->requiresMigration () ) )
966
964
{
967
965
bool runMigration = true ;
968
- if ( !mySettingsMigrationForce && showWelcome )
966
+ if ( !settingsMigrationForce && showWelcome )
969
967
{
970
968
QgsFirstRunDialog dlg;
971
969
dlg.exec ();
972
970
runMigration = dlg.migrateSettings ();
973
- settings .setValue ( QStringLiteral ( " migration/firstRunVersionFlag" ), Qgis::QGIS_VERSION_INT );
971
+ migSettings .setValue ( QStringLiteral ( " migration/firstRunVersionFlag" ), Qgis::QGIS_VERSION_INT );
974
972
}
975
973
976
974
if ( runMigration )
@@ -981,6 +979,18 @@ int main( int argc, char *argv[] )
981
979
}
982
980
}
983
981
982
+ // We can't use QgsSettings until this point because the format and
983
+ // folder isn't set until profile is fetch.
984
+ // Should be cleaned up in future to make this cleaner.
985
+ QgsSettings settings;
986
+
987
+ QgsDebugMsgLevel ( QStringLiteral ( " User profile details:" ), 2 );
988
+ QgsDebugMsgLevel ( QStringLiteral ( " \t - %1" ).arg ( profileName ), 2 );
989
+ QgsDebugMsgLevel ( QStringLiteral ( " \t - %1" ).arg ( profileFolder ), 2 );
990
+ QgsDebugMsgLevel ( QStringLiteral ( " \t - %1" ).arg ( rootProfileFolder ), 2 );
991
+
992
+ myApp.init ( profileFolder );
993
+
984
994
// Redefine QgsApplication::libraryPaths as necessary.
985
995
// IMPORTANT: Do *after* QgsApplication myApp(...), but *before* Qt uses any plugins,
986
996
// e.g. loading splash screen, setting window icon, etc.
@@ -1123,24 +1133,12 @@ int main( int argc, char *argv[] )
1123
1133
}
1124
1134
#endif
1125
1135
1126
- // update any saved setting for older themes to new default 'gis' theme (2013-04-15)
1127
- if ( mySettings.contains ( QStringLiteral ( " /Themes" ) ) )
1128
- {
1129
- QString theme = mySettings.value ( QStringLiteral ( " Themes" ), " default" ).toString ();
1130
- if ( theme == QLatin1String ( " gis" )
1131
- || theme == QLatin1String ( " classic" )
1132
- || theme == QLatin1String ( " nkids" ) )
1133
- {
1134
- mySettings.setValue ( QStringLiteral ( " Themes" ), QStringLiteral ( " default" ) );
1135
- }
1136
- }
1137
-
1138
1136
// custom environment variables
1139
1137
QMap<QString, QString> systemEnvVars = QgsApplication::systemEnvVars ();
1140
- bool useCustomVars = mySettings .value ( QStringLiteral ( " qgis/customEnvVarsUse" ), QVariant ( false ) ).toBool ();
1138
+ bool useCustomVars = settings .value ( QStringLiteral ( " qgis/customEnvVarsUse" ), QVariant ( false ) ).toBool ();
1141
1139
if ( useCustomVars )
1142
1140
{
1143
- QStringList customVarsList = mySettings .value ( QStringLiteral ( " qgis/customEnvVars" ), " " ).toStringList ();
1141
+ QStringList customVarsList = settings .value ( QStringLiteral ( " qgis/customEnvVars" ), " " ).toStringList ();
1144
1142
if ( !customVarsList.isEmpty () )
1145
1143
{
1146
1144
Q_FOREACH ( const QString &varStr, customVarsList )
@@ -1195,7 +1193,7 @@ int main( int argc, char *argv[] )
1195
1193
1196
1194
// Set the application style. If it's not set QT will use the platform style except on Windows
1197
1195
// as it looks really ugly so we use QPlastiqueStyle.
1198
- QString presetStyle = mySettings .value ( QStringLiteral ( " qgis/style" ) ).toString ();
1196
+ QString presetStyle = settings .value ( QStringLiteral ( " qgis/style" ) ).toString ();
1199
1197
QString activeStyleName = presetStyle;
1200
1198
if ( activeStyleName.isEmpty () ) // not set, using default style
1201
1199
{
@@ -1218,7 +1216,7 @@ int main( int argc, char *argv[] )
1218
1216
if ( !presetStyle.isEmpty () )
1219
1217
{
1220
1218
QApplication::setStyle ( presetStyle );
1221
- mySettings .setValue ( QStringLiteral ( " qgis/style" ), QApplication::style ()->objectName () );
1219
+ settings .setValue ( QStringLiteral ( " qgis/style" ), QApplication::style ()->objectName () );
1222
1220
}
1223
1221
1224
1222
// set authentication database directory
@@ -1235,7 +1233,7 @@ int main( int argc, char *argv[] )
1235
1233
int h = 300 * qApp->desktop ()->logicalDpiY () / 96 ;
1236
1234
1237
1235
QSplashScreen *mypSplash = new QSplashScreen ( myPixmap.scaled ( w, h, Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
1238
- if ( !myHideSplash && !mySettings .value ( QStringLiteral ( " qgis/hideSplash" ) ).toBool () )
1236
+ if ( !myHideSplash && !settings .value ( QStringLiteral ( " qgis/hideSplash" ) ).toBool () )
1239
1237
{
1240
1238
// for win and linux we can just automask and png transparency areas will be used
1241
1239
mypSplash->setMask ( myPixmap.mask () );
@@ -1244,23 +1242,23 @@ int main( int argc, char *argv[] )
1244
1242
1245
1243
// optionally restore default window state
1246
1244
// use restoreDefaultWindowState setting only if NOT using command line (then it is set already)
1247
- if ( myRestoreDefaultWindowState || mySettings .value ( QStringLiteral ( " qgis/restoreDefaultWindowState" ), false ).toBool () )
1245
+ if ( myRestoreDefaultWindowState || settings .value ( QStringLiteral ( " qgis/restoreDefaultWindowState" ), false ).toBool () )
1248
1246
{
1249
1247
QgsDebugMsg ( " Resetting /UI/state settings!" );
1250
- mySettings .remove ( QStringLiteral ( " /UI/state" ) );
1251
- mySettings .remove ( QStringLiteral ( " /qgis/restoreDefaultWindowState" ) );
1248
+ settings .remove ( QStringLiteral ( " /UI/state" ) );
1249
+ settings .remove ( QStringLiteral ( " /qgis/restoreDefaultWindowState" ) );
1252
1250
}
1253
1251
1254
1252
if ( hideBrowser )
1255
1253
{
1256
- if ( mySettings .value ( QStringLiteral ( " /Windows/Data Source Manager/tab" ) ).toInt () == 0 )
1257
- mySettings .setValue ( QStringLiteral ( " /Windows/Data Source Manager/tab" ), 1 );
1258
- mySettings .setValue ( QStringLiteral ( " /UI/hidebrowser" ), true );
1254
+ if ( settings .value ( QStringLiteral ( " /Windows/Data Source Manager/tab" ) ).toInt () == 0 )
1255
+ settings .setValue ( QStringLiteral ( " /Windows/Data Source Manager/tab" ), 1 );
1256
+ settings .setValue ( QStringLiteral ( " /UI/hidebrowser" ), true );
1259
1257
}
1260
1258
1261
1259
// set max. thread count
1262
1260
// this should be done in QgsApplication::init() but it doesn't know the settings dir.
1263
- QgsApplication::setMaxThreads ( mySettings .value ( QStringLiteral ( " qgis/max_threads" ), -1 ).toInt () );
1261
+ QgsApplication::setMaxThreads ( settings .value ( QStringLiteral ( " qgis/max_threads" ), -1 ).toInt () );
1264
1262
1265
1263
QgisApp *qgis = new QgisApp ( mypSplash, myRestorePlugins, mySkipVersionCheck, rootProfileFolder, profileName ); // "QgisApp" used to find canonical instance
1266
1264
qgis->setObjectName ( QStringLiteral ( " QgisApp" ) );
0 commit comments