Skip to content
Permalink
Browse files

Omit group separator by default

  • Loading branch information
elpaso committed Jul 3, 2018
1 parent 879c699 commit 9404200ee51ec359b0808f995fd93359349b9d31
Showing with 25 additions and 21 deletions.
  1. +16 −12 src/app/main.cpp
  2. +7 −7 src/app/qgsoptions.cpp
  3. +2 −2 src/ui/qgsoptionsbase.ui
@@ -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
@@ -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 );
@@ -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),
@@ -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 )
@@ -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
@@ -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 )
@@ -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 ) ),
@@ -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>

0 comments on commit 9404200

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