21#include <QDialogButtonBox>
24#include "moc_qgsmeshvariablestrokewidthwidget.cpp"
28 double defaultMinimumvalue,
29 double defaultMaximumValue,
32 :
QgsPanelWidget( parent ), mDefaultMinimumValue( defaultMinimumvalue ), mDefaultMaximumValue( defaultMaximumValue )
36 mValueMinimumSpinBox->setSpecialValueText( QString() );
38 mValueMaximumSpinBox->setSpecialValueText( QString() );
45 connect( mDefaultMinMaxButton, &QPushButton::clicked,
this, &QgsMeshVariableStrokeWidthWidget::defaultMinMax );
67 mMinimumDefaultValue = minimum;
68 mMaximumDefaultValue = maximum;
83void QgsMeshVariableStrokeWidthWidget::defaultMinMax()
85 whileBlocking( mValueMinimumSpinBox )->setValue( mDefaultMinimumValue );
86 whileBlocking( mValueMaximumSpinBox )->setValue( mDefaultMaximumValue );
91 : QPushButton( parent )
94 connect(
this, &QPushButton::clicked,
this, &QgsMeshVariableStrokeWidthButton::openWidget );
99 return mVariableStrokeWidth;
108void QgsMeshVariableStrokeWidthButton::openWidget()
127 QDialog *dlg =
new QDialog(
this );
128 const QString key = QStringLiteral(
"/UI/paneldialog/%1" ).arg( widget->
panelTitle() );
129 QgsSettings settings;
130 dlg->restoreGeometry( settings.
value( key ).toByteArray() );
132 dlg->setLayout(
new QVBoxLayout() );
133 dlg->layout()->addWidget( widget );
134 QDialogButtonBox *buttonBox =
new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Ok );
135 connect( buttonBox, &QDialogButtonBox::accepted, dlg, &QDialog::accept );
136 connect( buttonBox, &QDialogButtonBox::rejected, dlg, &QDialog::reject );
137 dlg->layout()->addWidget( buttonBox );
139 if ( dlg->exec() == QDialog::Accepted )
144 settings.
setValue( key, dlg->saveGeometry() );
148void QgsMeshVariableStrokeWidthButton::updateText()
150 setText( QString(
"%1 - %2" ).arg( QLocale().toString( mVariableStrokeWidth.minimumWidth(),
'g', 3 ), QLocale().toString( mVariableStrokeWidth.maximumWidth(),
'g', 3 ) ) );
153double QgsMeshVariableStrokeWidthWidget::lineEditValue(
const QgsDoubleSpinBox *lineEdit )
const
155 if ( lineEdit->value() == lineEdit->
clearValue() )
157 return std::numeric_limits<double>::quiet_NaN();
160 return lineEdit->value();
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value.
@ MinimumValue
Reset value to minimum().
Represents a width that can vary depending on values.
void setUseAbsoluteValue(bool useAbsoluteValue)
Sets whether absolute value are used as input.
void setIgnoreOutOfRange(bool ignoreOutOfRange)
Sets whether the variable width ignores out of range value.
void setMaximumValue(double maximumValue)
Sets the maximum value used to defined the variable width.
void setMinimumValue(double minimumValue)
Sets the minimum value used to defined the variable width.
void setMaximumWidth(double maximumWidth)
Sets the maximum width used to defined the variable width.
void setMinimumWidth(double minimumWidth)
Sets the minimum width used to defined the variable width.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.