diff --git a/src/Gui/DlgExpressionInput.cpp b/src/Gui/DlgExpressionInput.cpp index a5bc87eed..99641c2dc 100644 --- a/src/Gui/DlgExpressionInput.cpp +++ b/src/Gui/DlgExpressionInput.cpp @@ -35,7 +35,6 @@ using namespace App; using namespace Gui::Dialog; const int DlgExpressionInput::h = 15; -const int DlgExpressionInput::l = 30; const int DlgExpressionInput::r = 30; const int DlgExpressionInput::d = 7; @@ -45,7 +44,8 @@ DlgExpressionInput::DlgExpressionInput(const App::ObjectIdentifier & _path, boos expression(_expression ? _expression->copy() : 0), path(_path), discarded(false), - impliedUnit(_impliedUnit) + impliedUnit(_impliedUnit), + l(30) { assert(path.getDocumentObject() != 0); @@ -91,6 +91,19 @@ QPoint DlgExpressionInput::tip() const return QPoint(l - d, 0); } +void DlgExpressionInput::setGeometry(int x, int y, int w, int h) +{ + QDesktopWidget widget; + int screenWidth = widget.availableGeometry(widget.primaryScreen()).width(); + + if (x + w > screenWidth) { + l = l + (x + w - screenWidth); + x = screenWidth - w - 10; + } + + QWidget::setGeometry(x, y, w, h); +} + void DlgExpressionInput::paintEvent(QPaintEvent * event) { QPainter painter(this); QPainterPath path; diff --git a/src/Gui/DlgExpressionInput.h b/src/Gui/DlgExpressionInput.h index dd985d836..ba1d80b48 100644 --- a/src/Gui/DlgExpressionInput.h +++ b/src/Gui/DlgExpressionInput.h @@ -62,6 +62,8 @@ public: QPoint tip() const; + void setGeometry(int x, int y, int w, int h); + private Q_SLOTS: void textChanged(const QString & text); void setDiscarded(); @@ -74,7 +76,7 @@ private: const Base::Unit impliedUnit; static const int h; - static const int l; + int l; static const int r; static const int d; }; diff --git a/src/Gui/QuantitySpinBox.cpp b/src/Gui/QuantitySpinBox.cpp index 5f42030cd..e0d8d583f 100644 --- a/src/Gui/QuantitySpinBox.cpp +++ b/src/Gui/QuantitySpinBox.cpp @@ -497,7 +497,7 @@ void QuantitySpinBox::openFormulaDialog() Gui::Dialog::DlgExpressionInput box(getPath(), getExpression(), d->unit, this); QPoint pos = mapToGlobal(QPoint(width() / 2, height() / 2)); - box.setGeometry(pos.x() - box.tip().x(), pos.y() - box.tip().y(), width(), height()); + box.setGeometry(pos.x() - box.tip().x(), pos.y() - box.tip().y(), box.width(), box.height()); if (box.exec() == QDialog::Accepted) setExpression(box.getExpression()); else if (box.discardedFormula())