mirror of
https://github.com/leozide/leocad
synced 2025-01-13 08:01:38 +01:00
Match color popup width with the properties tree.
This commit is contained in:
parent
80adb54acf
commit
be41fa343d
1 changed files with 13 additions and 11 deletions
|
@ -795,7 +795,7 @@ void lcQPropertiesTree::slotColorButtonClicked()
|
||||||
|
|
||||||
lcQColorPickerPopup* Popup = new lcQColorPickerPopup(Button, ColorIndex);
|
lcQColorPickerPopup* Popup = new lcQColorPickerPopup(Button, ColorIndex);
|
||||||
connect(Popup, SIGNAL(selected(int)), SLOT(slotSetValue(int)));
|
connect(Popup, SIGNAL(selected(int)), SLOT(slotSetValue(int)));
|
||||||
Popup->setMinimumSize(300, 200);
|
Popup->setMinimumSize(qMax(300, width()), 200);
|
||||||
|
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||||
QScreen* Screen = QGuiApplication::screenAt(Button->mapToGlobal(Button->rect().bottomLeft()));
|
QScreen* Screen = QGuiApplication::screenAt(Button->mapToGlobal(Button->rect().bottomLeft()));
|
||||||
|
@ -804,18 +804,20 @@ void lcQPropertiesTree::slotColorButtonClicked()
|
||||||
const QRect ScreenRect = QApplication::desktop()->geometry();
|
const QRect ScreenRect = QApplication::desktop()->geometry();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QPoint pos = Button->mapToGlobal(Button->rect().bottomLeft());
|
int x = mapToGlobal(QPoint(0, 0)).x();
|
||||||
if (pos.x() < ScreenRect.left())
|
int y = Button->mapToGlobal(Button->rect().bottomLeft()).y();
|
||||||
pos.setX(ScreenRect.left());
|
|
||||||
if (pos.y() < ScreenRect.top())
|
|
||||||
pos.setY(ScreenRect.top());
|
|
||||||
|
|
||||||
if ((pos.x() + Popup->width()) > ScreenRect.right())
|
if (x < ScreenRect.left())
|
||||||
pos.setX(ScreenRect.right() - Popup->width());
|
x = ScreenRect.left();
|
||||||
if ((pos.y() + Popup->height()) > ScreenRect.bottom())
|
if (y < ScreenRect.top())
|
||||||
pos.setY(ScreenRect.bottom() - Popup->height());
|
y = ScreenRect.top();
|
||||||
Popup->move(pos);
|
|
||||||
|
|
||||||
|
if (x + Popup->width() > ScreenRect.right())
|
||||||
|
x = ScreenRect.right() - Popup->width();
|
||||||
|
if (y + Popup->height() > ScreenRect.bottom())
|
||||||
|
y = ScreenRect.bottom() - Popup->height();
|
||||||
|
|
||||||
|
Popup->move(QPoint(x, y));
|
||||||
Popup->setFocus();
|
Popup->setFocus();
|
||||||
Popup->show();
|
Popup->show();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue