summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2024-11-24 01:20:31 +0100
committerMichael Weghorn <m.weghorn@posteo.de>2024-11-24 17:04:48 +0100
commitec760b211087b90f9cddec96d1e097bf68ad3e1f (patch)
treedbc67213d794f67fce54c1321e10efd6ba746da5 /vcl
parenta60ccb091ed26e5287d29ea1df885bf144c74b3f (diff)
tdf#130857 qt weld: Add QtInstanceExpander
Add a new QtInstanceExpander class that is the weld::Expander implementation using a native Qt widget. It uses the custom QtExpander widget added in Change-Id: Id2366834cb542eba613ea087e70f3a812d20fa89 Author: Michael Weghorn <m.weghorn@posteo.de> Date: Sun Nov 24 00:07:44 2024 +0100 tdf#130857 qt weld: Implement "GtkExpander" equivalent Extend QtExpander to provide what's needed to implement the QtInstanceExpander methods. Let QtInstanceBuilder::weld_expander return an instance of the new class. Signal handling still needs to be implemented (calling `weld::Expander::signal_expanded` when the expanded state is toggled). QtInstanceExpander is e.g. needed by the "Set Password" dialog. ("File" -> "Save As", check "Save with password" checkbox and press "Save" to trigger the dialog.) Change-Id: I7e3a332c0417b1897ae57d7d4c29609245fb5e19 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177197 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/CustomTarget_qt5_moc.mk1
-rw-r--r--vcl/CustomTarget_qt6_moc.mk1
-rw-r--r--vcl/Library_vclplug_qt5.mk1
-rw-r--r--vcl/Library_vclplug_qt6.mk1
-rw-r--r--vcl/inc/qt5/QtExpander.hxx5
-rw-r--r--vcl/inc/qt5/QtInstanceBuilder.hxx2
-rw-r--r--vcl/inc/qt5/QtInstanceExpander.hxx30
-rw-r--r--vcl/inc/qt6/QtInstanceExpander.hxx12
-rw-r--r--vcl/qt5/QtExpander.cxx13
-rw-r--r--vcl/qt5/QtInstanceBuilder.cxx9
-rw-r--r--vcl/qt5/QtInstanceExpander.cxx50
-rw-r--r--vcl/qt6/QtInstanceExpander.cxx12
12 files changed, 131 insertions, 6 deletions
diff --git a/vcl/CustomTarget_qt5_moc.mk b/vcl/CustomTarget_qt5_moc.mk
index 184787590282..48dea66e2136 100644
--- a/vcl/CustomTarget_qt5_moc.mk
+++ b/vcl/CustomTarget_qt5_moc.mk
@@ -21,6 +21,7 @@ $(call gb_CustomTarget_get_target,vcl/qt5) : \
$(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceDialog.moc \
$(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceDrawingArea.moc \
$(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceEntry.moc \
+ $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceExpander.moc \
$(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceLevelBar.moc \
$(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceLinkButton.moc \
$(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceMessageDialog.moc \
diff --git a/vcl/CustomTarget_qt6_moc.mk b/vcl/CustomTarget_qt6_moc.mk
index 1ca3042eddc5..8c72cb8b70fe 100644
--- a/vcl/CustomTarget_qt6_moc.mk
+++ b/vcl/CustomTarget_qt6_moc.mk
@@ -21,6 +21,7 @@ $(call gb_CustomTarget_get_target,vcl/qt6) : \
$(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceDialog.moc \
$(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceDrawingArea.moc \
$(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceEntry.moc \
+ $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceExpander.moc \
$(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceLevelBar.moc \
$(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceLinkButton.moc \
$(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceMessageDialog.moc \
diff --git a/vcl/Library_vclplug_qt5.mk b/vcl/Library_vclplug_qt5.mk
index 46d5eba4266a..664f4153ebc1 100644
--- a/vcl/Library_vclplug_qt5.mk
+++ b/vcl/Library_vclplug_qt5.mk
@@ -106,6 +106,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_qt5,\
vcl/qt5/QtInstanceDialog \
vcl/qt5/QtInstanceDrawingArea \
vcl/qt5/QtInstanceEntry \
+ vcl/qt5/QtInstanceExpander \
vcl/qt5/QtInstanceFrame \
vcl/qt5/QtInstanceImage \
vcl/qt5/QtInstanceLabel \
diff --git a/vcl/Library_vclplug_qt6.mk b/vcl/Library_vclplug_qt6.mk
index 9a01ca63f7f6..da06490af0e9 100644
--- a/vcl/Library_vclplug_qt6.mk
+++ b/vcl/Library_vclplug_qt6.mk
@@ -105,6 +105,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_qt6,\
vcl/qt6/QtInstanceDialog \
vcl/qt6/QtInstanceDrawingArea \
vcl/qt6/QtInstanceEntry \
+ vcl/qt6/QtInstanceExpander \
vcl/qt6/QtInstanceFrame \
vcl/qt6/QtInstanceImage \
vcl/qt6/QtInstanceLabel \
diff --git a/vcl/inc/qt5/QtExpander.hxx b/vcl/inc/qt5/QtExpander.hxx
index 135841c039f7..394712a55a77 100644
--- a/vcl/inc/qt5/QtExpander.hxx
+++ b/vcl/inc/qt5/QtExpander.hxx
@@ -25,7 +25,12 @@ class QtExpander : public QWidget
public:
QtExpander(QWidget* pParent);
void setContentWidget(QWidget* pWidget);
+
void setText(const QString& rText);
+ QString text() const;
+
+ void setExpanded(bool bExpand);
+ bool isExpanded() const;
private:
void update();
diff --git a/vcl/inc/qt5/QtInstanceBuilder.hxx b/vcl/inc/qt5/QtInstanceBuilder.hxx
index caf264735275..547d7aec1b8e 100644
--- a/vcl/inc/qt5/QtInstanceBuilder.hxx
+++ b/vcl/inc/qt5/QtInstanceBuilder.hxx
@@ -68,7 +68,7 @@ public:
virtual std::unique_ptr<weld::IconView> weld_icon_view(const OUString&) override;
virtual std::unique_ptr<weld::Label> weld_label(const OUString&) override;
virtual std::unique_ptr<weld::TextView> weld_text_view(const OUString& rId) override;
- virtual std::unique_ptr<weld::Expander> weld_expander(const OUString&) override;
+ virtual std::unique_ptr<weld::Expander> weld_expander(const OUString& rId) override;
virtual std::unique_ptr<weld::DrawingArea>
weld_drawing_area(const OUString&, const a11yref& rA11yImpl = nullptr,
FactoryFunction pUITestFactoryFunction = nullptr,
diff --git a/vcl/inc/qt5/QtInstanceExpander.hxx b/vcl/inc/qt5/QtInstanceExpander.hxx
new file mode 100644
index 000000000000..d596acb9ba94
--- /dev/null
+++ b/vcl/inc/qt5/QtInstanceExpander.hxx
@@ -0,0 +1,30 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#pragma once
+
+#include "QtInstanceWidget.hxx"
+#include "QtExpander.hxx"
+
+class QtInstanceExpander : public QObject, public QtInstanceWidget, public virtual weld::Expander
+{
+ Q_OBJECT
+
+ QtExpander* m_pExpander;
+
+public:
+ QtInstanceExpander(QtExpander* pExpander);
+
+ virtual void set_label(const OUString& rText);
+ virtual OUString get_label() const;
+ virtual bool get_expanded() const;
+ virtual void set_expanded(bool bExpand);
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/vcl/inc/qt6/QtInstanceExpander.hxx b/vcl/inc/qt6/QtInstanceExpander.hxx
new file mode 100644
index 000000000000..1dd97000e6bd
--- /dev/null
+++ b/vcl/inc/qt6/QtInstanceExpander.hxx
@@ -0,0 +1,12 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "../qt5/QtInstanceExpander.hxx"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/vcl/qt5/QtExpander.cxx b/vcl/qt5/QtExpander.cxx
index b7e9b499f285..433244999905 100644
--- a/vcl/qt5/QtExpander.cxx
+++ b/vcl/qt5/QtExpander.cxx
@@ -41,6 +41,16 @@ void QtExpander::setContentWidget(QWidget* pWidget)
void QtExpander::setText(const QString& rText) { m_pButton->setText(rText); }
+QString QtExpander::text() const { return m_pButton->text(); }
+
+void QtExpander::setExpanded(bool bExpand)
+{
+ m_bExpanded = bExpand;
+ update();
+}
+
+bool QtExpander::isExpanded() const { return m_bExpanded; }
+
void QtExpander::update()
{
const QString sIcon = m_bExpanded ? "go-down" : "go-next";
@@ -53,8 +63,7 @@ void QtExpander::update()
void QtExpander::handleButtonClick()
{
// toggle
- m_bExpanded = !m_bExpanded;
- update();
+ setExpanded(!isExpanded());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/vcl/qt5/QtInstanceBuilder.cxx b/vcl/qt5/QtInstanceBuilder.cxx
index 8971fbcda96e..c0512b5929aa 100644
--- a/vcl/qt5/QtInstanceBuilder.cxx
+++ b/vcl/qt5/QtInstanceBuilder.cxx
@@ -16,6 +16,7 @@
#include <QtInstanceComboBox.hxx>
#include <QtInstanceDrawingArea.hxx>
#include <QtInstanceEntry.hxx>
+#include <QtInstanceExpander.hxx>
#include <QtInstanceFrame.hxx>
#include <QtInstanceImage.hxx>
#include <QtInstanceLabel.hxx>
@@ -329,10 +330,12 @@ std::unique_ptr<weld::TextView> QtInstanceBuilder::weld_text_view(const OUString
return xRet;
}
-std::unique_ptr<weld::Expander> QtInstanceBuilder::weld_expander(const OUString&)
+std::unique_ptr<weld::Expander> QtInstanceBuilder::weld_expander(const OUString& rId)
{
- assert(false && "Not implemented yet");
- return nullptr;
+ QtExpander* pExpander = m_xBuilder->get<QtExpander>(rId);
+ std::unique_ptr<weld::Expander> xRet(pExpander ? std::make_unique<QtInstanceExpander>(pExpander)
+ : nullptr);
+ return xRet;
}
std::unique_ptr<weld::DrawingArea>
diff --git a/vcl/qt5/QtInstanceExpander.cxx b/vcl/qt5/QtInstanceExpander.cxx
new file mode 100644
index 000000000000..7594af8f0a26
--- /dev/null
+++ b/vcl/qt5/QtInstanceExpander.cxx
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <QtInstanceExpander.hxx>
+#include <QtInstanceExpander.moc>
+
+#include <vcl/qt/QtUtils.hxx>
+
+QtInstanceExpander::QtInstanceExpander(QtExpander* pExpander)
+ : QtInstanceWidget(pExpander)
+ , m_pExpander(pExpander)
+{
+ assert(m_pExpander);
+}
+
+void QtInstanceExpander::set_label(const OUString& rText)
+{
+ SolarMutexGuard g;
+ GetQtInstance().RunInMainThread([&] { m_pExpander->setText(toQString(rText)); });
+}
+
+OUString QtInstanceExpander::get_label() const
+{
+ SolarMutexGuard g;
+ OUString sLabel;
+ GetQtInstance().RunInMainThread([&] { sLabel = toOUString(m_pExpander->text()); });
+ return sLabel;
+}
+
+bool QtInstanceExpander::get_expanded() const
+{
+ SolarMutexGuard g;
+ bool bExpanded = false;
+ GetQtInstance().RunInMainThread([&] { bExpanded = m_pExpander->isExpanded(); });
+ return bExpanded;
+}
+
+void QtInstanceExpander::set_expanded(bool bExpand)
+{
+ SolarMutexGuard g;
+ GetQtInstance().RunInMainThread([&] { m_pExpander->setExpanded(bExpand); });
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/vcl/qt6/QtInstanceExpander.cxx b/vcl/qt6/QtInstanceExpander.cxx
new file mode 100644
index 000000000000..584bb0bc3fab
--- /dev/null
+++ b/vcl/qt6/QtInstanceExpander.cxx
@@ -0,0 +1,12 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "../qt5/QtInstanceExpander.cxx"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */