summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2024-09-28 00:26:52 +0200
committerMichael Weghorn <m.weghorn@posteo.de>2024-09-28 09:35:48 +0200
commit70bbd7f6bd6719ecde1dd3fbb1c2a89e68575a2e (patch)
tree120ed49234e06faaa07181ff375a2d081aeb6894 /vcl
parent4c7f4ed28e093963f58130c52ebcd5f6c66b4bbc (diff)
tdf#130857 qt weld: Ensure dialog button box is last in layout
For QDialog, make sure that if a button box is included in the dialog's layout, that this is the last item in the layout, by removing from the layout and adding it at the end again. I don't see any explicit child index explicitly being set in the .ui file for the "Help" -> "License Information" dialog ("sfx/ui/licensedialog.ui"). Potentially GTK implicitly visually makes the dialog's button box the last item in the dialog. Corresponding child is this one: <child internal-child="action_area"> <object class="GtkButtonBox" id="dialog-action_area1"> Potentially the `<child internal-child="action_area">` identifies this as the dialog's button box that should be last, at least dialog newly created in glade also has that set. For QMessageBox, which is a QDialog subclass, this special handling is not needed, as its default button box is used, which is already at the right place. This addresses the first aspect mentioned in previous commit: Change-Id: Ic9393755ec474f77ff22a1115e3cccba9d7b26cb Author: Michael Weghorn <m.weghorn@posteo.de> Date: Sat Sep 28 00:07:28 2024 +0200 tdf#130857 qt weld: Add initial support for dialog and label > However, currently buttons and the label with the text > are in the wrong order (i.e. buttons are above the text) Still missing: > and clicking the buttons doesn't yet have any effect. Change-Id: Id991551548c1e54fdf2e169886a6c67fc307931f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174077 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
Diffstat (limited to 'vcl')
-rw-r--r--vcl/qt5/QtBuilder.cxx22
1 files changed, 21 insertions, 1 deletions
diff --git a/vcl/qt5/QtBuilder.cxx b/vcl/qt5/QtBuilder.cxx
index 095b3b9c0b20..63fa67869d6d 100644
--- a/vcl/qt5/QtBuilder.cxx
+++ b/vcl/qt5/QtBuilder.cxx
@@ -162,7 +162,27 @@ QObject* QtBuilder::makeObject(QObject* pParent, std::u16string_view sName, cons
return pObject;
}
-void QtBuilder::tweakInsertedChild(QObject*, QObject*, std::string_view, std::string_view) {}
+void QtBuilder::tweakInsertedChild(QObject*, QObject* pCurrentChild, std::string_view,
+ std::string_view)
+{
+ // ensure that button box is the last item in QDialog's layout
+ // (that seems to be implicitly the case for GtkDialog)
+ // no action needed for QMessageBox, where the default button box is used,
+ // which is at the right place
+ if (QDialog* pDialog = qobject_cast<QDialog*>(pCurrentChild))
+ {
+ if (!qobject_cast<QMessageBox*>(pDialog))
+ {
+ if (QDialogButtonBox* pButtonBox = findButtonBox(pDialog))
+ {
+ QLayout* pLayout = pDialog->layout();
+ assert(pLayout && "dialog has no layout");
+ pLayout->removeWidget(pButtonBox);
+ pLayout->addWidget(pButtonBox);
+ }
+ }
+ }
+}
void QtBuilder::setPriority(QObject*, int) { SAL_WARN("vcl.qt", "Ignoring priority"); }