Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add preview for locale settings
  • Loading branch information
elpaso committed Jun 29, 2018
1 parent 9976fc2 commit 13a727c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
20 changes: 20 additions & 0 deletions src/app/qgsoptions.cpp
Expand Up @@ -96,6 +96,8 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
connect( mCustomVariablesChkBx, &QCheckBox::toggled, this, &QgsOptions::mCustomVariablesChkBx_toggled );
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(); } );

// 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 @@ -2365,6 +2367,24 @@ void QgsOptions::refreshSchemeComboBox()
mColorSchemesComboBox->blockSignals( false );
}

void QgsOptions::updateSampleLocaleText()
{
QLocale locale( cboGlobalLocale->currentData( ).toString() );
if ( cbOmitGroupSeparator->isChecked( ) )
{
locale.setNumberOptions( locale.numberOptions() |= QLocale::NumberOption::OmitGroupSeparator );
}
else
{
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 ) ),
locale.toCurrencyString( 1000.00 ),
locale.toString( 1000 ),
locale.toString( 1000.00, 'f', 2 ) ) );
}

void QgsOptions::updateActionsForCurrentColorScheme( QgsColorScheme *scheme )
{
if ( !scheme )
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsoptions.h
Expand Up @@ -255,6 +255,8 @@ class APP_EXPORT QgsOptions : public QgsOptionsDialogBase, private Ui::QgsOption

void refreshSchemeComboBox();

void updateSampleLocaleText();

protected:
QgisAppStyleSheet *mStyleSheetBuilder = nullptr;
QMap<QString, QVariant> mStyleSheetNewOpts;
Expand Down
18 changes: 14 additions & 4 deletions src/ui/qgsoptionsbase.ui
Expand Up @@ -350,7 +350,7 @@
<x>0</x>
<y>0</y>
<width>843</width>
<height>855</height>
<height>885</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_28">
Expand Down Expand Up @@ -381,7 +381,7 @@
<item row="2" column="0">
<widget class="QLabel" name="label_52">
<property name="text">
<string>Locale (affects numbers representation)</string>
<string>Locale (numbers, date and currency formats)</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -417,6 +417,16 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblLocaleSample">
<property name="styleSheet">
<string notr="true">QLabel {background-color: #ffffff; }</string>
</property>
<property name="text">
<string>Sample text for locale formatting</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down Expand Up @@ -1061,7 +1071,7 @@
<x>0</x>
<y>0</y>
<width>544</width>
<height>1096</height>
<height>1094</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_22">
Expand Down Expand Up @@ -3194,7 +3204,7 @@
<x>0</x>
<y>0</y>
<width>613</width>
<height>646</height>
<height>636</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_30">
Expand Down

0 comments on commit 13a727c

Please sign in to comment.