summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2024-02-14 10:54:59 +0100
committerMichael Weghorn <m.weghorn@posteo.de>2024-02-15 08:08:05 +0100
commit9e40fc8c9458b937200ea56c96b89113c74b67f5 (patch)
tree924a9368712f0554743be7b63e7c706f0c0438e7 /vcl
parent6712963e231e7ab50a3d11b8a8c75e54e0c79b32 (diff)
tdf#130857 qt weld: Set msg dialog parent
If a parent is passed to `QtInstance::CreateMessageDialog`, also set a parent for the `QMessageBox` that gets created there: If the passed parent is a native Qt one, use that one. Otherwise, fall back to using the current active top-level window, which is what usually makes most sense and is better than having no parent at all. With this change in place, the message dialog shown when doing 1) start Writer 2) "File" -> "Properties" -> "Security" -> "Protect" 3) type 2 different passwords and confirm is now modal and centered on top of the "Enter Password" dialog on KDE Plasma Wayland when using the qt6 VCL plugin, while it used to open at the top left of the screen and was non-modal before. The new behavior is in line with how it behaves for the SAL_VCL_QT_NO_WELDED_WIDGETS=1 case. Change-Id: Ibe95c2f0407edeba0fd9f76744bc087be7df6437 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163362 Tested-by: Jenkins Reviewed-by: Omkar Acharekar <omkaracharekar12@gmail.com> Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/qt5/QtInstance.cxx16
1 files changed, 15 insertions, 1 deletions
diff --git a/vcl/qt5/QtInstance.cxx b/vcl/qt5/QtInstance.cxx
index f2f8caa6b86a..6b3bd0cc301a 100644
--- a/vcl/qt5/QtInstance.cxx
+++ b/vcl/qt5/QtInstance.cxx
@@ -792,7 +792,21 @@ weld::MessageDialog* QtInstance::CreateMessageDialog(weld::Widget* pParent,
}
else
{
- QMessageBox* pMessageBox = new QMessageBox();
+ QWidget* pQtParent = nullptr;
+ if (pParent)
+ {
+ if (QtInstanceWidget* pQtInstanceWidget = dynamic_cast<QtInstanceWidget*>(pParent))
+ {
+ pQtParent = pQtInstanceWidget->getQWidget();
+ }
+ else
+ {
+ // the parent is not welded/not a native Qt widget; fall back to currently active window
+ pQtParent = QApplication::activeWindow();
+ }
+ }
+
+ QMessageBox* pMessageBox = new QMessageBox(pQtParent);
pMessageBox->setText(toQString(rPrimaryMessage));
pMessageBox->setIcon(vclMessageTypeToQtIcon(eMessageType));
pMessageBox->setWindowTitle(vclMessageTypeToQtTitle(eMessageType));