Skip to content

Commit

Permalink
Improve usability of expression dialog:
Browse files Browse the repository at this point in the history
+ 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
  • Loading branch information
wwmayer committed Aug 23, 2018
1 parent 0252e49 commit 93163b2
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Gui/QuantitySpinBox.cpp
Expand Up @@ -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()
Expand All @@ -603,6 +605,8 @@ void QuantitySpinBox::finishFormulaDialog()
setExpression(boost::shared_ptr<Expression>());

box->deleteLater();

Q_EMIT showFormulaDialog(false);
}

Base::Unit QuantitySpinBox::unit() const
Expand Down
4 changes: 4 additions & 0 deletions src/Gui/QuantitySpinBox.h
Expand Up @@ -153,6 +153,10 @@ protected Q_SLOTS:
* 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;
Expand Down
32 changes: 32 additions & 0 deletions src/Mod/Sketcher/Gui/InsertDatum.ui
Expand Up @@ -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">
Expand All @@ -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/>
Expand Down Expand Up @@ -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>

0 comments on commit 93163b2

Please sign in to comment.