21#include <QDialogButtonBox>
25#include "moc_qgsmeshvariablestrokewidthwidget.cpp"
27using namespace Qt::StringLiterals;
31 double defaultMinimumvalue,
32 double defaultMaximumValue,
35 :
QgsPanelWidget( parent ), mDefaultMinimumValue( defaultMinimumvalue ), mDefaultMaximumValue( defaultMaximumValue )
39 mValueMinimumSpinBox->setSpecialValueText( QString() );
41 mValueMaximumSpinBox->setSpecialValueText( QString() );
48 connect( mDefaultMinMaxButton, &QPushButton::clicked,
this, &QgsMeshVariableStrokeWidthWidget::defaultMinMax );
70 mMinimumDefaultValue = minimum;
71 mMaximumDefaultValue = maximum;
86void QgsMeshVariableStrokeWidthWidget::defaultMinMax()
88 whileBlocking( mValueMinimumSpinBox )->setValue( mDefaultMinimumValue );
89 whileBlocking( mValueMaximumSpinBox )->setValue( mDefaultMaximumValue );
94 : QPushButton( parent )
97 connect(
this, &QPushButton::clicked,
this, &QgsMeshVariableStrokeWidthButton::openWidget );
102 return mVariableStrokeWidth;
111void QgsMeshVariableStrokeWidthButton::openWidget()
130 QDialog *dlg =
new QDialog(
this );
131 const QString key = u
"/UI/paneldialog/%1"_s.arg( widget->
panelTitle() );
132 QgsSettings settings;
133 dlg->restoreGeometry( settings.
value( key ).toByteArray() );
135 dlg->setLayout(
new QVBoxLayout() );
136 dlg->layout()->addWidget( widget );
137 QDialogButtonBox *buttonBox =
new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Ok );
138 connect( buttonBox, &QDialogButtonBox::accepted, dlg, &QDialog::accept );
139 connect( buttonBox, &QDialogButtonBox::rejected, dlg, &QDialog::reject );
140 dlg->layout()->addWidget( buttonBox );
142 if ( dlg->exec() == QDialog::Accepted )
147 settings.
setValue( key, dlg->saveGeometry() );
151void QgsMeshVariableStrokeWidthButton::updateText()
153 setText( QString(
"%1 - %2" ).arg( QLocale().toString( mVariableStrokeWidth.minimumWidth(),
'g', 3 ), QLocale().toString( mVariableStrokeWidth.maximumWidth(),
'g', 3 ) ) );
156double QgsMeshVariableStrokeWidthWidget::lineEditValue(
const QgsDoubleSpinBox *lineEdit )
const
158 if ( lineEdit->value() == lineEdit->
clearValue() )
160 return std::numeric_limits<double>::quiet_NaN();
163 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.