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