Improve usability of expression dialog:

+ add signal showFormulaDialog to QuantitySpinBox in order to indicate whether the formula dialog opens or closes
+ when formula dialog opens then hide the button box in the parent dialog, show it again when the formula dialog closes
This commit is contained in:
wmayer
2018-08-23 12:22:57 +02:00
parent 0252e491d5
commit 93163b28d0
3 changed files with 40 additions and 0 deletions

View File

@@ -587,6 +587,8 @@ void QuantitySpinBox::openFormulaDialog()
QPoint pos = mapToGlobal(QPoint(0,0));
box->move(pos-box->expressionPosition());
box->setExpressionInputSize(width(), height());
Q_EMIT showFormulaDialog(true);
}
void QuantitySpinBox::finishFormulaDialog()
@@ -603,6 +605,8 @@ void QuantitySpinBox::finishFormulaDialog()
setExpression(boost::shared_ptr<Expression>());
box->deleteLater();
Q_EMIT showFormulaDialog(false);
}
Base::Unit QuantitySpinBox::unit() const

View File

@@ -153,6 +153,10 @@ Q_SIGNALS:
* like: minimum, maximum and/or the right Unit (if specified).
*/
void valueChanged(double);
/** Gets emitted if formula dialog is about to be opened (true)
* or finished (false).
*/
void showFormulaDialog(bool);
private:
QScopedPointer<QuantitySpinBoxPrivate> d_ptr;

View File

@@ -48,6 +48,19 @@
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
@@ -65,6 +78,9 @@
<class>Gui::PrefQuantitySpinBox</class>
<extends>QWidget</extends>
<header>Gui/PrefWidgets.h</header>
<slots>
<signal>showFormulaDialog(bool)</signal>
</slots>
</customwidget>
</customwidgets>
<resources/>
@@ -101,5 +117,21 @@
</hint>
</hints>
</connection>
<connection>
<sender>labelEdit</sender>
<signal>showFormulaDialog(bool)</signal>
<receiver>buttonBox</receiver>
<slot>setHidden(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>212</x>
<y>26</y>
</hint>
<hint type="destinationlabel">
<x>171</x>
<y>101</y>
</hint>
</hints>
</connection>
</connections>
</ui>