summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2024-09-28 00:07:28 +0200
committerMichael Weghorn <m.weghorn@posteo.de>2024-09-28 09:35:41 +0200
commit4c7f4ed28e093963f58130c52ebcd5f6c66b4bbc (patch)
tree1ea80a0b2bc31ab57354d922fffbae06f145a264 /vcl
parentf14b6a9c2d906f11049326a69cd4bddd072ab626 (diff)
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.weghorn@posteo.de> Tested-by: Jenkins
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/qt5/QtInstanceBuilder.hxx2
-rw-r--r--vcl/qt5/QtBuilder.cxx19
-rw-r--r--vcl/qt5/QtInstanceBuilder.cxx8
3 files changed, 25 insertions, 4 deletions
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&)