vcl/CustomTarget_qt5_moc.mk | 1 + vcl/CustomTarget_qt6_moc.mk | 1 + vcl/Library_vclplug_qt5.mk | 1 + vcl/Library_vclplug_qt6.mk | 1 + vcl/inc/qt5/QtInstanceBuilder.hxx | 2 +- vcl/inc/qt5/QtInstancePopover.hxx | 28 ++++++++++++++++++++++++++++ vcl/inc/qt6/QtInstancePopover.hxx | 12 ++++++++++++ vcl/qt5/QtBuilder.cxx | 6 ++++++ vcl/qt5/QtInstanceBuilder.cxx | 9 ++++++--- vcl/qt5/QtInstancePopover.cxx | 27 +++++++++++++++++++++++++++ vcl/qt5/QtInstanceWidget.cxx | 7 ++++++- vcl/qt6/QtInstancePopover.cxx | 12 ++++++++++++ 12 files changed, 102 insertions(+), 5 deletions(-)
New commits: commit 0664f11de7e654e4279559858c5f14206a85f22e Author: Michael Weghorn <[email protected]> AuthorDate: Sun Dec 22 01:07:10 2024 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Sun Dec 22 11:41:28 2024 +0100 tdf#130857 qt weld: Implement QtInstanceWidget::queue_resize Call QWidget::adjustSize [1]. [1] https://doc.qt.io/qt-6/qwidget.html#adjustSize Change-Id: Ic191d65b9c7a3aee5e0e9c945773d7732719d4e0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179099 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/vcl/qt5/QtInstanceWidget.cxx b/vcl/qt5/QtInstanceWidget.cxx index 48e4c9b77fa9..7aec0cbaad1b 100644 --- a/vcl/qt5/QtInstanceWidget.cxx +++ b/vcl/qt5/QtInstanceWidget.cxx @@ -527,7 +527,12 @@ std::unique_ptr<weld::Container> QtInstanceWidget::weld_parent() const return std::make_unique<QtInstanceContainer>(pParentWidget); } -void QtInstanceWidget::queue_resize() { assert(false && "Not implemented yet"); } +void QtInstanceWidget::queue_resize() +{ + SolarMutexGuard g; + + GetQtInstance().RunInMainThread([&] { m_pWidget->adjustSize(); }); +} void QtInstanceWidget::help_hierarchy_foreach(const std::function<bool(const OUString&)>&) { commit a7428730f7088e3eb22e22a094754d2c9cae2276 Author: Michael Weghorn <[email protected]> AuthorDate: Sun Dec 22 01:03:14 2024 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Sun Dec 22 11:41:20 2024 +0100 tdf#130857 qt weld: Introduce QtInstancePopover When encountering a "GtkPopover" object in a .ui file, create a QWidget with window flags Qt::Popup and set a layout, as weld::Popover is a weld::Container subclass. Add new QtInstancePopover that QtInstanceBuilder::weld_popover creates. For now, methods in that class simply trigger an assert; actual logic still needs to be implemented. Change-Id: I9a0dfefd9fb79d24fe40dd5efe13ef0c3ab9b7fb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179098 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/vcl/CustomTarget_qt5_moc.mk b/vcl/CustomTarget_qt5_moc.mk index 47fa70642760..8627b72d87b1 100644 --- a/vcl/CustomTarget_qt5_moc.mk +++ b/vcl/CustomTarget_qt5_moc.mk @@ -33,6 +33,7 @@ $(call gb_CustomTarget_get_target,vcl/qt5) : \ $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceMenuButton.moc \ $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceMessageDialog.moc \ $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceNotebook.moc \ + $(gb_CustomTarget_workdir)/vcl/qt5/QtInstancePopover.moc \ $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceProgressBar.moc \ $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceRadioButton.moc \ $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceScale.moc \ diff --git a/vcl/CustomTarget_qt6_moc.mk b/vcl/CustomTarget_qt6_moc.mk index 36828b2d00b4..1fae8dd27aca 100644 --- a/vcl/CustomTarget_qt6_moc.mk +++ b/vcl/CustomTarget_qt6_moc.mk @@ -33,6 +33,7 @@ $(call gb_CustomTarget_get_target,vcl/qt6) : \ $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceMenuButton.moc \ $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceMessageDialog.moc \ $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceNotebook.moc \ + $(gb_CustomTarget_workdir)/vcl/qt6/QtInstancePopover.moc \ $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceProgressBar.moc \ $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceRadioButton.moc \ $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceScale.moc \ diff --git a/vcl/Library_vclplug_qt5.mk b/vcl/Library_vclplug_qt5.mk index 30c2fa8bf45a..c5012310b9aa 100644 --- a/vcl/Library_vclplug_qt5.mk +++ b/vcl/Library_vclplug_qt5.mk @@ -119,6 +119,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_qt5,\ vcl/qt5/QtInstanceMenuButton \ vcl/qt5/QtInstanceMessageDialog \ vcl/qt5/QtInstanceNotebook \ + vcl/qt5/QtInstancePopover \ vcl/qt5/QtInstanceProgressBar \ vcl/qt5/QtInstanceRadioButton \ vcl/qt5/QtInstanceScale \ diff --git a/vcl/Library_vclplug_qt6.mk b/vcl/Library_vclplug_qt6.mk index 43100fa3d585..f533bc8a597c 100644 --- a/vcl/Library_vclplug_qt6.mk +++ b/vcl/Library_vclplug_qt6.mk @@ -118,6 +118,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_qt6,\ vcl/qt6/QtInstanceMenuButton \ vcl/qt6/QtInstanceMessageDialog \ vcl/qt6/QtInstanceNotebook \ + vcl/qt6/QtInstancePopover \ vcl/qt6/QtInstanceProgressBar \ vcl/qt6/QtInstanceRadioButton \ vcl/qt6/QtInstanceScale \ diff --git a/vcl/inc/qt5/QtInstanceBuilder.hxx b/vcl/inc/qt5/QtInstanceBuilder.hxx index 484df49bc50b..4f75711edb5f 100644 --- a/vcl/inc/qt5/QtInstanceBuilder.hxx +++ b/vcl/inc/qt5/QtInstanceBuilder.hxx @@ -75,7 +75,7 @@ public: FactoryFunction pUITestFactoryFunction = nullptr, void* pUserData = nullptr) override; virtual std::unique_ptr<weld::Menu> weld_menu(const OUString& rId) override; - virtual std::unique_ptr<weld::Popover> weld_popover(const OUString&) override; + virtual std::unique_ptr<weld::Popover> weld_popover(const OUString& rId) override; virtual std::unique_ptr<weld::Toolbar> weld_toolbar(const OUString&) override; virtual std::unique_ptr<weld::Scrollbar> weld_scrollbar(const OUString&) override; virtual std::unique_ptr<weld::SizeGroup> create_size_group() override; diff --git a/vcl/inc/qt5/QtInstancePopover.hxx b/vcl/inc/qt5/QtInstancePopover.hxx new file mode 100644 index 000000000000..db928aa4a600 --- /dev/null +++ b/vcl/inc/qt5/QtInstancePopover.hxx @@ -0,0 +1,28 @@ +/* -*- 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 QtInstancePopover : public QtInstanceContainer, public virtual weld::Popover +{ + Q_OBJECT + +public: + explicit QtInstancePopover(QWidget* pWidget); + + virtual void popup_at_rect(weld::Widget* pParent, const tools::Rectangle& rRect, + weld::Placement ePlace = weld::Placement::Under) override; + virtual void popdown() override; + + virtual void resize_to_request() override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/inc/qt6/QtInstancePopover.hxx b/vcl/inc/qt6/QtInstancePopover.hxx new file mode 100644 index 000000000000..48ab41a853b1 --- /dev/null +++ b/vcl/inc/qt6/QtInstancePopover.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/QtInstancePopover.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/qt5/QtBuilder.cxx b/vcl/qt5/QtBuilder.cxx index 9e8985d04d60..253049625844 100644 --- a/vcl/qt5/QtBuilder.cxx +++ b/vcl/qt5/QtBuilder.cxx @@ -298,6 +298,12 @@ QObject* QtBuilder::makeObject(QObject* pParent, std::u16string_view sName, std: { pObject = new QSplitter(pParentWidget); } + else if (sName == u"GtkPopover") + { + QWidget* pWidget = new QWidget(pParentWidget, Qt::Popup); + pWidget->setLayout(new QVBoxLayout); + pObject = pWidget; + } else if (sName == u"GtkRadioButton") { pObject = new QRadioButton(pParentWidget); diff --git a/vcl/qt5/QtInstanceBuilder.cxx b/vcl/qt5/QtInstanceBuilder.cxx index fffe30e94d04..3294a7ec141f 100644 --- a/vcl/qt5/QtInstanceBuilder.cxx +++ b/vcl/qt5/QtInstanceBuilder.cxx @@ -28,6 +28,7 @@ #include <QtInstanceMenuButton.hxx> #include <QtInstanceMessageDialog.hxx> #include <QtInstanceNotebook.hxx> +#include <QtInstancePopover.hxx> #include <QtInstanceProgressBar.hxx> #include <QtInstanceRadioButton.hxx> #include <QtInstanceScale.hxx> @@ -395,10 +396,12 @@ std::unique_ptr<weld::Menu> QtInstanceBuilder::weld_menu(const OUString& rId) return xRet; } -std::unique_ptr<weld::Popover> QtInstanceBuilder::weld_popover(const OUString&) +std::unique_ptr<weld::Popover> QtInstanceBuilder::weld_popover(const OUString& rId) { - assert(false && "Not implemented yet"); - return nullptr; + QWidget* pWidget = m_xBuilder->get<QWidget>(rId); + std::unique_ptr<weld::Popover> xRet(pWidget ? std::make_unique<QtInstancePopover>(pWidget) + : nullptr); + return xRet; } std::unique_ptr<weld::Toolbar> QtInstanceBuilder::weld_toolbar(const OUString&) diff --git a/vcl/qt5/QtInstancePopover.cxx b/vcl/qt5/QtInstancePopover.cxx new file mode 100644 index 000000000000..e35665e8289c --- /dev/null +++ b/vcl/qt5/QtInstancePopover.cxx @@ -0,0 +1,27 @@ +/* -*- 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 <QtInstancePopover.hxx> +#include <QtInstancePopover.moc> + +QtInstancePopover::QtInstancePopover(QWidget* pWidget) + : QtInstanceContainer(pWidget) +{ +} + +void QtInstancePopover::popup_at_rect(weld::Widget*, const tools::Rectangle&, weld::Placement) +{ + assert(false && "Not implemented yet"); +} + +void QtInstancePopover::popdown() { assert(false && "Not implemented yet"); } + +void QtInstancePopover::resize_to_request() { assert(false && "Not implemented yet"); } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/qt6/QtInstancePopover.cxx b/vcl/qt6/QtInstancePopover.cxx new file mode 100644 index 000000000000..c8452932ac0b --- /dev/null +++ b/vcl/qt6/QtInstancePopover.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/QtInstancePopover.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
