diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2025-01-22 21:54:37 +0100 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2025-01-23 08:29:22 +0100 |
commit | d7fd4f2f84aba449dcd03b20ae4f295172164131 (patch) | |
tree | b1cb68023a92cf4ca8e36f60ec31fb625dab8f5a /vcl | |
parent | 18df81e1568f4944a8fd79fd81e85d263dc0325b (diff) |
tdf#130857 qt weld: Introduce QtInstanceBox
Introduce QtInstanceBox as the weld::Box implementation
using native Qt widgets.
weld::Box is used e.g. in the (not yet supported by
QtInstanceBuilder) macro security dialog, which however
doesn't make use of any weld::Box-specific API
(only uses the weld::Container API), so leave
implementing the logic for those for later.
Change-Id: I6d3948e1282dd6178a3762c235bd8fc97c6e9e34
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180609
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/CustomTarget_qt5_moc.mk | 1 | ||||
-rw-r--r-- | vcl/CustomTarget_qt6_moc.mk | 1 | ||||
-rw-r--r-- | vcl/Library_vclplug_qt5.mk | 1 | ||||
-rw-r--r-- | vcl/Library_vclplug_qt6.mk | 1 | ||||
-rw-r--r-- | vcl/inc/qt5/QtInstanceBox.hxx | 25 | ||||
-rw-r--r-- | vcl/inc/qt5/QtInstanceBuilder.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/qt6/QtInstanceBox.hxx | 12 | ||||
-rw-r--r-- | vcl/qt5/QtInstanceBox.cxx | 23 | ||||
-rw-r--r-- | vcl/qt5/QtInstanceBuilder.cxx | 11 | ||||
-rw-r--r-- | vcl/qt6/QtInstanceBox.cxx | 12 |
10 files changed, 85 insertions, 4 deletions
diff --git a/vcl/CustomTarget_qt5_moc.mk b/vcl/CustomTarget_qt5_moc.mk index b01d55097987..8dd45bc52e24 100644 --- a/vcl/CustomTarget_qt5_moc.mk +++ b/vcl/CustomTarget_qt5_moc.mk @@ -16,6 +16,7 @@ $(call gb_CustomTarget_get_target,vcl/qt5) : \ $(gb_CustomTarget_workdir)/vcl/qt5/QtFilePicker.moc \ $(gb_CustomTarget_workdir)/vcl/qt5/QtFrame.moc \ $(gb_CustomTarget_workdir)/vcl/qt5/QtInstance.moc \ + $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceBox.moc \ $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceCheckButton.moc \ $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceComboBox.moc \ $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceContainer.moc \ diff --git a/vcl/CustomTarget_qt6_moc.mk b/vcl/CustomTarget_qt6_moc.mk index 2646f8902677..b492cecf95eb 100644 --- a/vcl/CustomTarget_qt6_moc.mk +++ b/vcl/CustomTarget_qt6_moc.mk @@ -16,6 +16,7 @@ $(call gb_CustomTarget_get_target,vcl/qt6) : \ $(gb_CustomTarget_workdir)/vcl/qt6/QtFilePicker.moc \ $(gb_CustomTarget_workdir)/vcl/qt6/QtFrame.moc \ $(gb_CustomTarget_workdir)/vcl/qt6/QtInstance.moc \ + $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceBox.moc \ $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceCheckButton.moc \ $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceComboBox.moc \ $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceContainer.moc \ diff --git a/vcl/Library_vclplug_qt5.mk b/vcl/Library_vclplug_qt5.mk index bacca3f1bfb3..9b70d16ca1b2 100644 --- a/vcl/Library_vclplug_qt5.mk +++ b/vcl/Library_vclplug_qt5.mk @@ -99,6 +99,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_qt5,\ vcl/qt5/QtHyperlinkLabel \ vcl/qt5/QtInstance \ vcl/qt5/QtInstance_Print \ + vcl/qt5/QtInstanceBox \ vcl/qt5/QtInstanceBuilder \ vcl/qt5/QtInstanceButton \ vcl/qt5/QtInstanceCheckButton \ diff --git a/vcl/Library_vclplug_qt6.mk b/vcl/Library_vclplug_qt6.mk index 1945687c4b4b..21d7134b6a48 100644 --- a/vcl/Library_vclplug_qt6.mk +++ b/vcl/Library_vclplug_qt6.mk @@ -98,6 +98,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_qt6,\ vcl/qt6/QtHyperlinkLabel \ vcl/qt6/QtInstance \ vcl/qt6/QtInstance_Print \ + vcl/qt6/QtInstanceBox \ vcl/qt6/QtInstanceBuilder \ vcl/qt6/QtInstanceButton \ vcl/qt6/QtInstanceCheckButton \ diff --git a/vcl/inc/qt5/QtInstanceBox.hxx b/vcl/inc/qt5/QtInstanceBox.hxx new file mode 100644 index 000000000000..68ac5f22807b --- /dev/null +++ b/vcl/inc/qt5/QtInstanceBox.hxx @@ -0,0 +1,25 @@ +/* -*- 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 "QtInstanceContainer.hxx" + +class QtInstanceBox : public QtInstanceContainer, public virtual weld::Box +{ + Q_OBJECT + +public: + QtInstanceBox(QWidget* pWidget); + + virtual void reorder_child(weld::Widget* pWidget, int nPosition) override; + virtual void sort_native_button_order() override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/inc/qt5/QtInstanceBuilder.hxx b/vcl/inc/qt5/QtInstanceBuilder.hxx index 340d332a86e0..8b1051a4a3f0 100644 --- a/vcl/inc/qt5/QtInstanceBuilder.hxx +++ b/vcl/inc/qt5/QtInstanceBuilder.hxx @@ -35,7 +35,7 @@ public: virtual std::unique_ptr<weld::Window> create_screenshot_window() override; virtual std::unique_ptr<weld::Widget> weld_widget(const OUString& rId) override; virtual std::unique_ptr<weld::Container> weld_container(const OUString& rId) override; - virtual std::unique_ptr<weld::Box> weld_box(const OUString&) override; + virtual std::unique_ptr<weld::Box> weld_box(const OUString& rId) override; virtual std::unique_ptr<weld::Grid> weld_grid(const OUString& rId) override; virtual std::unique_ptr<weld::Paned> weld_paned(const OUString&) override; virtual std::unique_ptr<weld::Frame> weld_frame(const OUString& rId) override; diff --git a/vcl/inc/qt6/QtInstanceBox.hxx b/vcl/inc/qt6/QtInstanceBox.hxx new file mode 100644 index 000000000000..3917bce997e8 --- /dev/null +++ b/vcl/inc/qt6/QtInstanceBox.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/QtInstanceBox.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/qt5/QtInstanceBox.cxx b/vcl/qt5/QtInstanceBox.cxx new file mode 100644 index 000000000000..e98c220a330d --- /dev/null +++ b/vcl/qt5/QtInstanceBox.cxx @@ -0,0 +1,23 @@ +/* -*- 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 <QtInstanceBox.hxx> +#include <QtInstanceBox.moc> + +QtInstanceBox::QtInstanceBox(QWidget* pWidget) + : QtInstanceContainer(pWidget) +{ + assert(qobject_cast<QBoxLayout*>(pWidget->layout()) && "widget doesn't have a box layout"); +} + +void QtInstanceBox::reorder_child(weld::Widget*, int) { assert(false && "Not implemented yet"); } + +void QtInstanceBox::sort_native_button_order() { assert(false && "Not implemented yet"); } + +/* 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 6b0322b9ed70..9f84c8ffcaac 100644 --- a/vcl/qt5/QtInstanceBuilder.cxx +++ b/vcl/qt5/QtInstanceBuilder.cxx @@ -12,6 +12,7 @@ #include <unordered_set> #include <QtBuilder.hxx> +#include <QtInstanceBox.hxx> #include <QtInstanceCheckButton.hxx> #include <QtInstanceComboBox.hxx> #include <QtInstanceDrawingArea.hxx> @@ -155,10 +156,14 @@ std::unique_ptr<weld::Container> QtInstanceBuilder::weld_container(const OUStrin return std::make_unique<QtInstanceContainer>(pWidget); } -std::unique_ptr<weld::Box> QtInstanceBuilder::weld_box(const OUString&) +std::unique_ptr<weld::Box> QtInstanceBuilder::weld_box(const OUString& rId) { - assert(false && "Not implemented yet"); - return nullptr; + QWidget* pWidget = m_xBuilder->get<QWidget>(rId); + if (!pWidget) + return nullptr; + + assert(qobject_cast<QBoxLayout*>(pWidget->layout()) && "widget doesn't have a box layout"); + return std::make_unique<QtInstanceBox>(pWidget); } std::unique_ptr<weld::Grid> QtInstanceBuilder::weld_grid(const OUString& rId) diff --git a/vcl/qt6/QtInstanceBox.cxx b/vcl/qt6/QtInstanceBox.cxx new file mode 100644 index 000000000000..e8f01b5797e3 --- /dev/null +++ b/vcl/qt6/QtInstanceBox.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/QtInstanceBox.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |