vcl/inc/qt5/QtInstanceDialog.hxx | 6 ++++++ vcl/inc/qt5/QtInstanceMessageDialog.hxx | 6 ------ vcl/qt5/QtBuilder.cxx | 22 +++++++++++++++++++++- vcl/qt5/QtInstanceDialog.cxx | 2 ++ vcl/qt5/QtInstanceMessageDialog.cxx | 2 -- 5 files changed, 29 insertions(+), 9 deletions(-)
New commits: commit 8f5d8342e47852eac0fd5f42b69b6ac28ebfe7c5 Author: Michael Weghorn <[email protected]> AuthorDate: Sat Sep 28 00:30:29 2024 +0200 Commit: Michael Weghorn <[email protected]> CommitDate: Sat Sep 28 09:35:58 2024 +0200 tdf#130857 qt weld: Move button response prop to QtInstanceDialog It will be used for QDialog as well, not just QMessageBox Change-Id: I887b3fe45beea40cc92f2b0b77f316ad73d7f922 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174078 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/vcl/inc/qt5/QtInstanceDialog.hxx b/vcl/inc/qt5/QtInstanceDialog.hxx index 6efa77818745..dcfa0197aab0 100644 --- a/vcl/inc/qt5/QtInstanceDialog.hxx +++ b/vcl/inc/qt5/QtInstanceDialog.hxx @@ -47,6 +47,12 @@ public: virtual void set_default_response(int) override; virtual weld::Container* weld_content_area() override; + + /** + * Name of the property to set on a QPushButton that holds the + * int VCL response code of that button. + */ + static const char* const PROPERTY_VCL_RESPONSE_CODE; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/qt5/QtInstanceMessageDialog.hxx b/vcl/inc/qt5/QtInstanceMessageDialog.hxx index 2b73566bf574..5c09d5090781 100644 --- a/vcl/inc/qt5/QtInstanceMessageDialog.hxx +++ b/vcl/inc/qt5/QtInstanceMessageDialog.hxx @@ -52,12 +52,6 @@ public: const std::function<void(sal_Int32)>& func) override; virtual void response(int nResponse) override; - /** - * Name of the property to set on a QPushButton that holds the - * int VCL response code of that button. - */ - static const char* const PROPERTY_VCL_RESPONSE_CODE; - private: virtual QPushButton* buttonForResponseCode(int nResponse); diff --git a/vcl/qt5/QtInstanceDialog.cxx b/vcl/qt5/QtInstanceDialog.cxx index 3f1df87f2741..2fd0e0900a31 100644 --- a/vcl/qt5/QtInstanceDialog.cxx +++ b/vcl/qt5/QtInstanceDialog.cxx @@ -9,6 +9,8 @@ #include <QtInstanceDialog.hxx> +const char* const QtInstanceDialog::PROPERTY_VCL_RESPONSE_CODE = "response-code"; + QtInstanceDialog::QtInstanceDialog(QDialog* pDialog) : QtInstanceWindow(pDialog) , m_pDialog(pDialog) diff --git a/vcl/qt5/QtInstanceMessageDialog.cxx b/vcl/qt5/QtInstanceMessageDialog.cxx index 76e370ea10d7..a907f6740960 100644 --- a/vcl/qt5/QtInstanceMessageDialog.cxx +++ b/vcl/qt5/QtInstanceMessageDialog.cxx @@ -12,8 +12,6 @@ #include <QtWidgets/QPushButton> -const char* const QtInstanceMessageDialog::PROPERTY_VCL_RESPONSE_CODE = "response-code"; - QtInstanceMessageDialog::QtInstanceMessageDialog(QMessageBox* pMessageDialog) : QtInstanceDialog(pMessageDialog) , m_pMessageDialog(pMessageDialog) commit 70bbd7f6bd6719ecde1dd3fbb1c2a89e68575a2e Author: Michael Weghorn <[email protected]> AuthorDate: Sat Sep 28 00:26:52 2024 +0200 Commit: Michael Weghorn <[email protected]> CommitDate: Sat Sep 28 09:35:48 2024 +0200 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 <[email protected]> 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 <[email protected]> Tested-by: Jenkins 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"); }
