24 #include <QDialogButtonBox> 35 mThousandsLineEdit->setShowClearButton(
true );
36 mDecimalLineEdit->setShowClearButton(
true );
38 connect( mShowPlusCheckBox, &QCheckBox::toggled,
this, [ = ](
bool checked )
40 mFormat->setShowPlusSign( checked );
45 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled,
this, [ = ](
bool checked )
47 mFormat->setShowTrailingZeros( checked );
52 connect( mShowThousandsCheckBox, &QCheckBox::toggled,
this, [ = ](
bool checked )
54 mFormat->setShowThousandsSeparator( checked );
59 connect( mDecimalsSpinBox, qgis::overload<int>::of( &QSpinBox::valueChanged ),
this, [ = ](
int value )
61 mFormat->setNumberDecimalPlaces( value );
66 connect( mRadDecimalPlaces, &QRadioButton::toggled,
this, [ = ](
bool checked )
76 connect( mRadSignificantFigures, &QRadioButton::toggled,
this, [ = ](
bool checked )
86 connect( mThousandsLineEdit, &QLineEdit::textChanged,
this, [ = ](
const QString & text )
88 mFormat->setThousandsSeparator( text.isEmpty() ? QChar() : text.at( 0 ) );
93 connect( mDecimalLineEdit, &QLineEdit::textChanged,
this, [ = ](
const QString & text )
95 mFormat->setDecimalSeparator( text.isEmpty() ? QChar() : text.at( 0 ) );
105 mFormat.reset( static_cast< QgsBasicNumericFormat * >( format ) );
107 mBlockSignals =
true;
108 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
109 mShowPlusCheckBox->setChecked( mFormat->showPlusSign() );
110 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
111 mShowThousandsCheckBox->setChecked( mFormat->showThousandsSeparator() );
112 mThousandsLineEdit->setText( mFormat->thousandsSeparator().isNull() ? QString() : mFormat->thousandsSeparator() );
113 mDecimalLineEdit->setText( mFormat->decimalSeparator().isNull() ? QString() : mFormat->decimalSeparator() );
114 switch ( mFormat->roundingType() )
117 mRadDecimalPlaces->setChecked(
true );
121 mRadSignificantFigures->setChecked(
true );
125 mBlockSignals =
false;
130 return mFormat->clone();
148 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled,
this, [ = ](
bool checked )
150 mFormat->setShowTrailingZeros( checked );
151 if ( !mBlockSignals )
155 connect( mDecimalsSpinBox, qgis::overload<int>::of( &QSpinBox::valueChanged ),
this, [ = ](
int value )
157 mFormat->setNumberDecimalPlaces( value );
158 if ( !mBlockSignals )
162 connect( mFormatComboBox, qgis::overload<int>::of( &QComboBox::currentIndexChanged ),
this, [ = ](
int )
164 mFormat->setDirectionFormat( static_cast < QgsBearingNumericFormat::FormatDirectionOption >( mFormatComboBox->currentData().toInt() ) );
165 if ( !mBlockSignals )
174 mFormat.reset( static_cast< QgsBearingNumericFormat * >( format ) );
176 mBlockSignals =
true;
177 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
178 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
179 mFormatComboBox->setCurrentIndex( mFormatComboBox->findData( static_cast< int >( mFormat->directionFormat() ) ) );
180 mBlockSignals =
false;
185 return mFormat->clone();
195 setLayout(
new QVBoxLayout() );
197 QDialogButtonBox *buttonBox =
new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Ok );
199 connect( buttonBox, &QDialogButtonBox::accepted,
this, &QDialog::accept );
200 connect( buttonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject );
202 layout()->addWidget( mWidget );
203 layout()->addWidget( buttonBox );
207 setObjectName( QStringLiteral(
"QgsBearingNumericFormatDialog" ) );
227 connect( mShowPlusCheckBox, &QCheckBox::toggled,
this, [ = ](
bool checked )
229 mFormat->setShowPlusSign( checked );
230 if ( !mBlockSignals )
234 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled,
this, [ = ](
bool checked )
236 mFormat->setShowTrailingZeros( checked );
237 if ( !mBlockSignals )
241 connect( mShowThousandsCheckBox, &QCheckBox::toggled,
this, [ = ](
bool checked )
243 mFormat->setShowThousandsSeparator( checked );
244 if ( !mBlockSignals )
248 connect( mDecimalsSpinBox, qgis::overload<int>::of( &QSpinBox::valueChanged ),
this, [ = ](
int value )
250 mFormat->setNumberDecimalPlaces( value );
251 if ( !mBlockSignals )
255 connect( mPrefixLineEdit, &QLineEdit::textChanged,
this, [ = ](
const QString & text )
257 mFormat->setPrefix( text );
258 if ( !mBlockSignals )
262 connect( mSuffixLineEdit, &QLineEdit::textChanged,
this, [ = ](
const QString & text )
264 mFormat->setSuffix( text );
265 if ( !mBlockSignals )
274 mFormat.reset( static_cast< QgsCurrencyNumericFormat * >( format ) );
276 mBlockSignals =
true;
277 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
278 mShowPlusCheckBox->setChecked( mFormat->showPlusSign() );
279 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
280 mShowThousandsCheckBox->setChecked( mFormat->showThousandsSeparator() );
281 mPrefixLineEdit->setText( mFormat->prefix() );
282 mSuffixLineEdit->setText( mFormat->suffix() );
284 mBlockSignals =
false;
289 return mFormat->clone();
307 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled,
this, [ = ](
bool checked )
309 mFormat->setShowTrailingZeros( checked );
310 if ( !mBlockSignals )
314 connect( mShowPlusCheckBox, &QCheckBox::toggled,
this, [ = ](
bool checked )
316 mFormat->setShowPlusSign( checked );
317 if ( !mBlockSignals )
321 connect( mShowThousandsCheckBox, &QCheckBox::toggled,
this, [ = ](
bool checked )
323 mFormat->setShowThousandsSeparator( checked );
324 if ( !mBlockSignals )
328 connect( mDecimalsSpinBox, qgis::overload<int>::of( &QSpinBox::valueChanged ),
this, [ = ](
int value )
330 mFormat->setNumberDecimalPlaces( value );
331 if ( !mBlockSignals )
335 connect( mScalingComboBox, qgis::overload<int>::of( &QComboBox::currentIndexChanged ),
this, [ = ](
int )
337 mFormat->setInputValues( static_cast < QgsPercentageNumericFormat::InputValues >( mScalingComboBox->currentData().toInt() ) );
338 if ( !mBlockSignals )
347 mFormat.reset( static_cast< QgsPercentageNumericFormat * >( format ) );
349 mBlockSignals =
true;
350 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
351 mShowPlusCheckBox->setChecked( mFormat->showPlusSign() );
352 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
353 mShowThousandsCheckBox->setChecked( mFormat->showThousandsSeparator() );
354 mScalingComboBox->setCurrentIndex( mScalingComboBox->findData( static_cast< int >( mFormat->inputValues() ) ) );
355 mBlockSignals =
false;
360 return mFormat->clone();
372 connect( mShowPlusCheckBox, &QCheckBox::toggled,
this, [ = ](
bool checked )
374 mFormat->setShowPlusSign( checked );
375 if ( !mBlockSignals )
379 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled,
this, [ = ](
bool checked )
381 mFormat->setShowTrailingZeros( checked );
382 if ( !mBlockSignals )
386 connect( mDecimalsSpinBox, qgis::overload<int>::of( &QSpinBox::valueChanged ),
this, [ = ](
int value )
388 mFormat->setNumberDecimalPlaces( value );
389 if ( !mBlockSignals )
398 mFormat.reset( static_cast< QgsScientificNumericFormat * >( format ) );
400 mBlockSignals =
true;
401 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
402 mShowPlusCheckBox->setChecked( mFormat->showPlusSign() );
403 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
404 mBlockSignals =
false;
409 return mFormat->clone();
static QgsGui * instance()
Returns a pointer to the singleton instance.
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...