Skip to content
Permalink
Browse files

Add options to override locale and number group sep.

  • Loading branch information
elpaso committed Jun 29, 2018
1 parent 9e5dccd commit c4b3ada924fab01c31bd5fae69212fb14d59d791
Showing with 92 additions and 39 deletions.
  1. +28 −3 src/app/main.cpp
  2. +13 −3 src/app/qgsoptions.cpp
  3. +51 −33 src/ui/qgsoptionsbase.ui
@@ -1142,7 +1142,9 @@ int main( int argc, char *argv[] )
/* Translation file for QGIS.
*/
QString i18nPath = QgsApplication::i18nPath();
QString myUserLocale = mySettings.value( QStringLiteral( "locale/userLocale" ), "" ).toString();
QString myUserTranslation = mySettings.value( QStringLiteral( "locale/userLocale" ), "" ).toString();
QString myGlobalLocale = mySettings.value( QStringLiteral( "locale/globalLocale" ), "" ).toString();
bool myOmitGroupSeparatorFlag = mySettings.value( QStringLiteral( "locale/omitGroupSeparator" ), true ).toBool();
bool myLocaleOverrideFlag = mySettings.value( QStringLiteral( "locale/overrideFlag" ), false ).toBool();

//
@@ -1160,7 +1162,7 @@ int main( int argc, char *argv[] )
}
else
{
if ( !myLocaleOverrideFlag || myUserLocale.isEmpty() )
if ( !myLocaleOverrideFlag || myUserTranslation.isEmpty() )
{
myTranslationCode = QLocale().name();
//setting the locale/userLocale when the --lang= option is not set will allow third party
@@ -1169,10 +1171,33 @@ int main( int argc, char *argv[] )
}
else
{
myTranslationCode = myUserLocale;
myTranslationCode = myUserTranslation;
}
}

// Global locale settings
if ( myLocaleOverrideFlag && ! myGlobalLocale.isEmpty( ) )
{
QLocale currentLocale( myGlobalLocale );
QLocale::setDefault( currentLocale );
}

// Number settings
if ( myLocaleOverrideFlag )
{
QLocale currentLocale;
if ( myOmitGroupSeparatorFlag )
{
currentLocale.setNumberOptions( currentLocale.numberOptions() |= QLocale::NumberOption::OmitGroupSeparator );
}
else
{
currentLocale.setNumberOptions( currentLocale.numberOptions() &= ! QLocale::NumberOption::OmitGroupSeparator );
}
QLocale::setDefault( currentLocale );
}


QTranslator qgistor( nullptr );
QTranslator qttor( nullptr );
if ( myTranslationCode != QLatin1String( "C" ) )
@@ -906,16 +906,22 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
QString mySystemLocale = QLocale().name();
lblSystemLocale->setText( tr( "Detected active locale on your system: %1" ).arg( mySystemLocale ) );
QString myUserLocale = mSettings->value( QStringLiteral( "locale/userLocale" ), QString() ).toString();
bool omitGroupSeparator = mSettings->value( QStringLiteral( "locale/omitGroupSeparator" ), false ).toBool();
QString myGlobalLocale = mSettings->value( QStringLiteral( "locale/globalLocale" ), QString() ).toString();
QStringList myI18nList = i18nList();
Q_FOREACH ( const QString &l, myI18nList )
{
// QTBUG-57802: eo locale is improperly handled
QString displayName = l.startsWith( QLatin1String( "eo" ) ) ? QLocale::languageToString( QLocale::Esperanto ) : QLocale( l ).nativeLanguageName();
cboLocale->addItem( QIcon( QString( ":/images/flags/%1.svg" ).arg( l ) ), displayName, l );
cboTranslation->addItem( QIcon( QString( ":/images/flags/%1.svg" ).arg( l ) ), displayName, l );
cboGlobalLocale->addItem( QIcon( QString( ":/images/flags/%1.svg" ).arg( l ) ), displayName, l );
}
cboLocale->setCurrentIndex( cboLocale->findData( myUserLocale ) );
cboTranslation->setCurrentIndex( cboTranslation->findData( myUserLocale ) );
cboGlobalLocale->setCurrentIndex( cboGlobalLocale->findData( myGlobalLocale ) );
bool myLocaleOverrideFlag = mSettings->value( QStringLiteral( "locale/overrideFlag" ), false ).toBool();
grpLocale->setChecked( myLocaleOverrideFlag );
cbOmitGroupSeparator->setChecked( omitGroupSeparator );


//set elements in digitizing tab
mLineWidthSpinBox->setValue( mSettings->value( QStringLiteral( "/qgis/digitizing/line_width" ), 1 ).toInt() );
@@ -1586,8 +1592,12 @@ void QgsOptions::saveOptions()
//
// Locale settings
//
mSettings->setValue( QStringLiteral( "locale/userLocale" ), cboLocale->currentData().toString() );
mSettings->setValue( QStringLiteral( "locale/userLocale" ), cboTranslation->currentData().toString() );
mSettings->setValue( QStringLiteral( "locale/overrideFlag" ), grpLocale->isChecked() );
mSettings->setValue( QStringLiteral( "locale/globalLocale" ), cboGlobalLocale->currentData( ).toString() );

// Number settings
mSettings->setValue( QStringLiteral( "locale/omitGroupSeparator" ), cbOmitGroupSeparator->isChecked( ) );

// Gdal skip driver list
if ( mLoadedGdalDriverList )
@@ -320,7 +320,7 @@
<item>
<widget class="QStackedWidget" name="mOptionsStackedWidget">
<property name="currentIndex">
<number>8</number>
<number>0</number>
</property>
<widget class="QWidget" name="mOptionsPageGeneral">
<layout class="QVBoxLayout" name="verticalLayout_3">
@@ -349,8 +349,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>411</width>
<height>662</height>
<width>843</width>
<height>855</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_28">
@@ -368,6 +368,23 @@
</property>
<item>
<layout class="QGridLayout" name="gridLayout_25">
<item row="6" column="0" colspan="2">
<widget class="QLabel" name="label_7">
<property name="text">
<string>&lt;b&gt;Note:&lt;/b&gt; Enabling / changing override on locale requires an application restart</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_52">
<property name="text">
<string>Locale (affects numbers representation)</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
@@ -376,15 +393,15 @@
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="cboLocale"/>
<widget class="QComboBox" name="cboTranslation"/>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="label_7">
<item row="2" column="1">
<widget class="QComboBox" name="cboGlobalLocale"/>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="cbOmitGroupSeparator">
<property name="text">
<string>&lt;b&gt;Note:&lt;/b&gt; Enabling / changing override on locale requires an application restart</string>
</property>
<property name="wordWrap">
<bool>true</bool>
<string>Omit group (thousand) separator</string>
</property>
</widget>
</item>
@@ -1043,8 +1060,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>437</width>
<height>1011</height>
<width>544</width>
<height>1096</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_22">
@@ -1579,8 +1596,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>443</width>
<height>312</height>
<width>556</width>
<height>369</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_15">
@@ -1746,8 +1763,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>393</width>
<height>648</height>
<width>496</width>
<height>753</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_27">
@@ -2114,8 +2131,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>541</width>
<height>866</height>
<width>675</width>
<height>1052</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_22">
@@ -2865,8 +2882,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>449</width>
<height>195</height>
<width>507</width>
<height>314</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_25">
@@ -3176,8 +3193,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>515</width>
<height>527</height>
<width>613</width>
<height>646</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_30">
@@ -3620,8 +3637,8 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
<rect>
<x>0</x>
<y>0</y>
<width>124</width>
<height>230</height>
<width>154</width>
<height>271</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_46">
@@ -3788,8 +3805,8 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
<rect>
<x>0</x>
<y>0</y>
<width>862</width>
<height>838</height>
<width>547</width>
<height>873</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_31">
@@ -4390,8 +4407,8 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
<rect>
<x>0</x>
<y>0</y>
<width>390</width>
<height>539</height>
<width>474</width>
<height>606</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_39">
@@ -4659,8 +4676,8 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
<rect>
<x>0</x>
<y>0</y>
<width>862</width>
<height>838</height>
<width>415</width>
<height>392</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
@@ -4828,8 +4845,8 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
<rect>
<x>0</x>
<y>0</y>
<width>862</width>
<height>838</height>
<width>616</width>
<height>737</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_33">
@@ -5449,7 +5466,7 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
<tabstop>mOptionsListWidget</tabstop>
<tabstop>mOptionsScrollArea_01</tabstop>
<tabstop>grpLocale</tabstop>
<tabstop>cboLocale</tabstop>
<tabstop>cboTranslation</tabstop>
<tabstop>cmbStyle</tabstop>
<tabstop>cmbUITheme</tabstop>
<tabstop>cmbIconSize</tabstop>
@@ -5672,6 +5689,7 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
</resources>
<connections>
<connection>

0 comments on commit c4b3ada

Please sign in to comment.
You can’t perform that action at this time.