vcl/inc/qt5/QtBuilder.hxx | 2 +- vcl/inc/qt5/QtInstanceBuilder.hxx | 2 +- vcl/qt5/QtBuilder.cxx | 29 +++++++++++++++++++++++++---- vcl/qt5/QtInstanceBuilder.cxx | 8 +++++--- 4 files changed, 32 insertions(+), 9 deletions(-)
New commits: commit 4c7f4ed28e093963f58130c52ebcd5f6c66b4bbc Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Sat Sep 28 00:07:28 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Sat Sep 28 09:35:41 2024 +0200 tdf#130857 qt weld: Add initial support for dialog and label Add initial support for the "GtkDialog" and "GtkLabel" objects in .ui files by creating corresponding Qt widgets (QDialog for "GtkDialog" and QLabel for "GtkLabel"). This makes the elements of the "Help" -> "License Information" show up once the .ui file of that that dialog ("sfx/ui/licensedialog.ui") is added to the set of supported .ui files. However, currently buttons and the label with the text are in the wrong order (i.e. buttons are above the text) and clicking the buttons doesn't yet have any effect. Those aspects will be addressed in separate commits before actually claiming support for the dialog in QtInstanceBuilder::IsUIFileSupported. Change-Id: Ic9393755ec474f77ff22a1115e3cccba9d7b26cb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174076 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/vcl/inc/qt5/QtInstanceBuilder.hxx b/vcl/inc/qt5/QtInstanceBuilder.hxx index 3c9fec8b1189..d98c85c1dee4 100644 --- a/vcl/inc/qt5/QtInstanceBuilder.hxx +++ b/vcl/inc/qt5/QtInstanceBuilder.hxx @@ -30,7 +30,7 @@ public: static bool IsUIFileSupported(const OUString& rUIFile); virtual std::unique_ptr<weld::MessageDialog> weld_message_dialog(const OUString& id) override; - virtual std::unique_ptr<weld::Dialog> weld_dialog(const OUString&) override; + virtual std::unique_ptr<weld::Dialog> weld_dialog(const OUString& rId) override; virtual std::unique_ptr<weld::Assistant> weld_assistant(const OUString&) override; virtual std::unique_ptr<weld::Window> create_screenshot_window() override; virtual std::unique_ptr<weld::Widget> weld_widget(const OUString&) override; diff --git a/vcl/qt5/QtBuilder.cxx b/vcl/qt5/QtBuilder.cxx index 36eaa3f6e96e..095b3b9c0b20 100644 --- a/vcl/qt5/QtBuilder.cxx +++ b/vcl/qt5/QtBuilder.cxx @@ -16,6 +16,7 @@ #include <QtWidgets/QDialog> #include <QtWidgets/QDialogButtonBox> +#include <QtWidgets/QLabel> #include <QtWidgets/QLayout> #include <QtWidgets/QPushButton> @@ -133,6 +134,14 @@ QObject* QtBuilder::makeObject(QObject* pParent, std::u16string_view sName, cons pObject = new QPushButton(pParentWidget); } } + else if (sName == u"GtkDialog") + { + pObject = new QDialog(pParentWidget); + } + else if (sName == u"GtkLabel") + { + pObject = new QLabel(pParentWidget); + } else { SAL_WARN("vcl.qt", "Widget type not supported yet: " @@ -212,6 +221,16 @@ void QtBuilder::setProperties(QObject* pObject, stringmap& rProps) } } } + else if (QLabel* pLabel = qobject_cast<QLabel*>(pObject)) + { + for (auto const & [ rKey, rValue ] : rProps) + { + if (rKey == u"label") + pLabel->setText(toQString(rValue)); + else if (rKey == u"wrap") + pLabel->setWordWrap(toBool(rValue)); + } + } else if (QPushButton* pButton = qobject_cast<QPushButton*>(pObject)) { for (auto const & [ rKey, rValue ] : rProps) diff --git a/vcl/qt5/QtInstanceBuilder.cxx b/vcl/qt5/QtInstanceBuilder.cxx index 611d5899063b..ee40033cfa86 100644 --- a/vcl/qt5/QtInstanceBuilder.cxx +++ b/vcl/qt5/QtInstanceBuilder.cxx @@ -47,10 +47,12 @@ std::unique_ptr<weld::MessageDialog> QtInstanceBuilder::weld_message_dialog(cons return xRet; } -std::unique_ptr<weld::Dialog> QtInstanceBuilder::weld_dialog(const OUString&) +std::unique_ptr<weld::Dialog> QtInstanceBuilder::weld_dialog(const OUString& rId) { - assert(false && "Not implemented yet"); - return nullptr; + QDialog* pDialog = m_xBuilder->get<QDialog>(rId); + std::unique_ptr<weld::Dialog> xRet(pDialog ? std::make_unique<QtInstanceDialog>(pDialog) + : nullptr); + return xRet; } std::unique_ptr<weld::Assistant> QtInstanceBuilder::weld_assistant(const OUString&) commit f14b6a9c2d906f11049326a69cd4bddd072ab626 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Sep 27 23:00:46 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Sat Sep 28 09:35:33 2024 +0200 tdf#130857 qt weld: Use QDialog* as param for findButtonBox Don't restrict to QMessageBox, but allow using the method with any QDialog, and don't assert that the dialog has a layout set in this case. The method will be reused in an upcoming commit. Change-Id: I1992f2eb4f34b25e487bbd349631b6ecd4365c95 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174075 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/inc/qt5/QtBuilder.hxx b/vcl/inc/qt5/QtBuilder.hxx index 3617f45f57fd..6ae06e3536b8 100644 --- a/vcl/inc/qt5/QtBuilder.hxx +++ b/vcl/inc/qt5/QtBuilder.hxx @@ -70,7 +70,7 @@ public: private: static void setProperties(QObject* obj, stringmap& rProps); static QWidget* windowForObject(QObject* pObject); - static QDialogButtonBox* findButtonBox(QMessageBox* pMessageBox); + static QDialogButtonBox* findButtonBox(QDialog* pDialog); }; template <typename T> inline T* QtBuilder::get(std::u16string_view sID) diff --git a/vcl/qt5/QtBuilder.cxx b/vcl/qt5/QtBuilder.cxx index 5d434dc58d71..36eaa3f6e96e 100644 --- a/vcl/qt5/QtBuilder.cxx +++ b/vcl/qt5/QtBuilder.cxx @@ -236,11 +236,13 @@ QWidget* QtBuilder::windowForObject(QObject* pObject) return nullptr; } -QDialogButtonBox* QtBuilder::findButtonBox(QMessageBox* pMessageBox) +QDialogButtonBox* QtBuilder::findButtonBox(QDialog* pDialog) { - assert(pMessageBox); - QLayout* pLayout = pMessageBox->layout(); - assert(pLayout && "QMessageBox has no layout"); + assert(pDialog); + QLayout* pLayout = pDialog->layout(); + if (!pLayout) + return nullptr; + for (int i = 0; i < pLayout->count(); i++) { QLayoutItem* pItem = pLayout->itemAt(i);