19 #include <QDialogButtonBox>
26 double defaultMinimumvalue,
27 double defaultMaximumValue,
30 mDefaultMinimumValue( defaultMinimumvalue ),
31 mDefaultMaximumValue( defaultMaximumValue )
35 mValueMinimumSpinBox->setSpecialValueText( QString( ) );
36 mValueMinimumSpinBox->setClearValueMode( QgsDoubleSpinBox::ClearValueMode::MinimumValue );
37 mValueMaximumSpinBox->setSpecialValueText( QString( ) );
38 mValueMaximumSpinBox->setClearValueMode( QgsDoubleSpinBox::ClearValueMode::MinimumValue );
44 connect( mDefaultMinMaxButton, &QPushButton::clicked,
this, &QgsMeshVariableStrokeWidthWidget::defaultMinMax );
66 mMinimumDefaultValue = minimum;
67 mMaximumDefaultValue = maximum;
82 void QgsMeshVariableStrokeWidthWidget::defaultMinMax()
84 whileBlocking( mValueMinimumSpinBox )->setValue( mDefaultMinimumValue );
85 whileBlocking( mValueMaximumSpinBox )->setValue( mDefaultMaximumValue );
92 connect(
this, &QPushButton::clicked,
this, &QgsMeshVariableStrokeWidthButton::openWidget );
97 return mVariableStrokeWidth;
106 void QgsMeshVariableStrokeWidthButton::openWidget()
109 QgsMeshVariableStrokeWidthWidget *widget =
110 new QgsMeshVariableStrokeWidthWidget( mVariableStrokeWidth,
111 mMinimumDefaultValue,
112 mMaximumDefaultValue,
130 QDialog *dlg =
new QDialog(
this );
131 const QString key = QStringLiteral(
"/UI/paneldialog/%1" ).arg( widget->panelTitle() );
133 dlg->restoreGeometry( settings.
value( key ).toByteArray() );
134 dlg->setWindowTitle( widget->panelTitle() );
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() );
151 void QgsMeshVariableStrokeWidthButton::updateText()
153 setText( QString(
"%1 - %2" ).
154 arg( QLocale().toString( mVariableStrokeWidth.
minimumWidth(),
'g', 3 ),
155 QLocale().toString( mVariableStrokeWidth.
maximumWidth(),
'g', 3 ) ) );
158 double QgsMeshVariableStrokeWidthWidget::lineEditValue(
const QgsDoubleSpinBox *lineEdit )
const
160 if ( lineEdit->value() == lineEdit->
clearValue() )
162 return std::numeric_limits<double>::quiet_NaN();
165 return lineEdit->value();