QuantitySpinBox: Fixed placement of expression editor pop-up.
This commit is contained in:
parent
90ccc1cee4
commit
28fe9b481d
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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())
|
||||
|
|
Loading…
Reference in New Issue
Block a user