[Bugfix]Spreadsheet: fix multi-screen management of QtColorPicker

+ set parent when instantiating
This commit is contained in:
0penBrain
2022-10-21 09:31:55 -05:00
committed by Chris Hennes
parent f7f717db9e
commit cf6e561e5a
2 changed files with 6 additions and 5 deletions
+2 -2
View File
@@ -81,7 +81,7 @@ void Workbench::activated()
if (fgList.size() > 0)
foregroundColor = fgList[0];
else {
foregroundColor = new QtColorPicker();
foregroundColor = new QtColorPicker(bar);
foregroundColor->setObjectName(QString::fromLatin1("Spreadsheet_ForegroundColor"));
foregroundColor->setStandardColors();
foregroundColor->setCurrentColor(palette.color(QPalette::WindowText));
@@ -96,7 +96,7 @@ void Workbench::activated()
if (bgList.size() > 0)
backgroundColor = bgList[0];
else {
backgroundColor = new QtColorPicker();
backgroundColor = new QtColorPicker(bar);
backgroundColor->setObjectName(QString::fromLatin1("Spreadsheet_BackgroundColor"));
backgroundColor->setStandardColors();
backgroundColor->setCurrentColor(palette.color(QPalette::Base));
+4 -3
View File
@@ -3,6 +3,7 @@
** This file is part of a Qt Solutions component.
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Modified 2022 by 0penBrain under LGPL : fix issues about popup positioning
**
** Contact: Qt Software Information ([email protected])
**
@@ -314,7 +315,7 @@ void QtColorPicker::buttonPressed(bool toggled)
if (!toggled)
return;
const QRect desktop = QApplication::primaryScreen()->geometry();
const QRect desktop = QApplication::activeWindow()->geometry();
// Make sure the popup is inside the desktop.
QPoint pos = mapToGlobal(rect().bottomLeft());
@@ -323,8 +324,8 @@ void QtColorPicker::buttonPressed(bool toggled)
if (pos.y() < desktop.top())
pos.setY(desktop.top());
if ((pos.x() + popup->sizeHint().width()) > desktop.width())
pos.setX(desktop.width() - popup->sizeHint().width());
if ((pos.x() + popup->sizeHint().width()) > desktop.right())
pos.setX(desktop.right() - popup->sizeHint().width());
if ((pos.y() + popup->sizeHint().height()) > desktop.bottom())
pos.setY(desktop.bottom() - popup->sizeHint().height());
popup->move(pos);