Skip to content

Commit

Permalink
Omit group separator by default
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Jul 3, 2018
1 parent 879c699 commit 9404200
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
28 changes: 16 additions & 12 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1144,9 +1144,16 @@ int main( int argc, char *argv[] )
QString i18nPath = QgsApplication::i18nPath();
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 myShowGroupSeparatorFlag = false; // Default to false
bool myLocaleOverrideFlag = mySettings.value( QStringLiteral( "locale/overrideFlag" ), false ).toBool();

// Override Show Group Separator if the global override flag is set
if ( myLocaleOverrideFlag )
{
// Default to false again
myShowGroupSeparatorFlag = mySettings.value( QStringLiteral( "locale/showGroupSeparator" ), false ).toBool();
}

//
// Priority of translation is:
// - command line
Expand Down Expand Up @@ -1183,19 +1190,16 @@ int main( int argc, char *argv[] )
}

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


QTranslator qgistor( nullptr );
Expand Down
14 changes: 7 additions & 7 deletions src/app/qgsoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
connect( mCurrentVariablesQGISChxBx, &QCheckBox::toggled, this, &QgsOptions::mCurrentVariablesQGISChxBx_toggled );
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsOptions::showHelp );
connect( cboGlobalLocale, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), [ = ]( int ) { updateSampleLocaleText( ); } );
connect( cbOmitGroupSeparator, &QCheckBox::toggled, this, [ = ]( bool ) { updateSampleLocaleText(); } );
connect( cbShowGroupSeparator, &QCheckBox::toggled, this, [ = ]( bool ) { updateSampleLocaleText(); } );

// QgsOptionsDialogBase handles saving/restoring of geometry, splitter and current tab states,
// switching vertical tabs between icon/text to icon-only modes (splitter collapsed to left),
Expand Down Expand Up @@ -908,7 +908,7 @@ 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();
bool showGroupSeparator = mSettings->value( QStringLiteral( "locale/showGroupSeparator" ), false ).toBool();
QString myGlobalLocale = mSettings->value( QStringLiteral( "locale/globalLocale" ), QString() ).toString();
QStringList myI18nList = i18nList();
Q_FOREACH ( const QString &l, myI18nList )
Expand All @@ -922,7 +922,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
cboGlobalLocale->setCurrentIndex( cboGlobalLocale->findData( myGlobalLocale ) );
bool myLocaleOverrideFlag = mSettings->value( QStringLiteral( "locale/overrideFlag" ), false ).toBool();
grpLocale->setChecked( myLocaleOverrideFlag );
cbOmitGroupSeparator->setChecked( omitGroupSeparator );
cbShowGroupSeparator->setChecked( showGroupSeparator );


//set elements in digitizing tab
Expand Down Expand Up @@ -1599,7 +1599,7 @@ void QgsOptions::saveOptions()
mSettings->setValue( QStringLiteral( "locale/globalLocale" ), cboGlobalLocale->currentData( ).toString() );

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

// Gdal skip driver list
if ( mLoadedGdalDriverList )
Expand Down Expand Up @@ -2370,13 +2370,13 @@ void QgsOptions::refreshSchemeComboBox()
void QgsOptions::updateSampleLocaleText()
{
QLocale locale( cboGlobalLocale->currentData( ).toString() );
if ( cbOmitGroupSeparator->isChecked( ) )
if ( cbShowGroupSeparator->isChecked( ) )
{
locale.setNumberOptions( locale.numberOptions() |= QLocale::NumberOption::OmitGroupSeparator );
locale.setNumberOptions( locale.numberOptions() &= ! QLocale::NumberOption::OmitGroupSeparator );
}
else
{
locale.setNumberOptions( locale.numberOptions() &= ! QLocale::NumberOption::OmitGroupSeparator );
locale.setNumberOptions( locale.numberOptions() |= QLocale::NumberOption::OmitGroupSeparator );
}
lblLocaleSample->setText( tr( "Sample date: %1 money: %2 int: %3 float: %4" ).arg(
QDate::currentDate().toString( locale.dateFormat( QLocale::FormatType::ShortFormat ) ),
Expand Down
4 changes: 2 additions & 2 deletions src/ui/qgsoptionsbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,9 @@
<widget class="QComboBox" name="cboGlobalLocale"/>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="cbOmitGroupSeparator">
<widget class="QCheckBox" name="cbShowGroupSeparator">
<property name="text">
<string>Omit group (thousand) separator</string>
<string>Show group (thousand) separator</string>
</property>
</widget>
</item>
Expand Down

0 comments on commit 9404200

Please sign in to comment.