Skip to content
Permalink
Browse files

Add preview for locale settings

  • Loading branch information
elpaso committed Jun 29, 2018
1 parent c4b3ada commit 879c699f6abfdf7755165bf3f80e94fbec9ecb15
Showing with 36 additions and 4 deletions.
  1. +20 −0 src/app/qgsoptions.cpp
  2. +2 −0 src/app/qgsoptions.h
  3. +14 −4 src/ui/qgsoptionsbase.ui
@@ -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),
@@ -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 )
@@ -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;
@@ -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">
@@ -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>
@@ -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>
@@ -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">
@@ -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">

0 comments on commit 879c699

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