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/QtInstanceBox.hxx | 25 +++++++++++++++++++++++++ vcl/inc/qt5/QtInstanceBuilder.hxx | 2 +- vcl/inc/qt6/QtInstanceBox.hxx | 12 ++++++++++++ vcl/qt5/QtInstanceBox.cxx | 23 +++++++++++++++++++++++ vcl/qt5/QtInstanceBuilder.cxx | 11 ++++++++--- vcl/qt5/QtInstanceLinkButton.cxx | 7 ++++++- vcl/qt5/QtInstanceWidget.cxx | 12 ++++++++---- vcl/qt6/QtInstanceBox.cxx | 12 ++++++++++++ 12 files changed, 99 insertions(+), 9 deletions(-)
New commits: commit cfee53a71ecf0f4cf5788a7748352fe981d4cf3c Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Jan 22 22:41:31 2025 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Jan 23 08:29:34 2025 +0100 tdf#130857 qt weld: Actually paint custom bg color Call QWidget::setAutoFillBackground(true) [1] so that the color set for the widget background is actually automatically filled with the color that was set. Stop setting a custom role for the background role. Instead, set the custom color for the role that is already set as the background role. Make sure to run in the main thread. With this in place, the "warningmsg" label in the "Security Level" tab (xmlsecurity/uiconfig/ui/securitylevelpage.ui) of the macro security dialog now actually shows with the background color that gets set in MacroSecurityLevelTP::SetWarningLabel in a WIP branch where support for that dialog is declared in QtInstanceBuilder. [1] https://doc.qt.io/qt-6/qwidget.html#autoFillBackground-prop Change-Id: Ib09ef25ee8d7b84fb8287f9b7abb25459a708be7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180611 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/qt5/QtInstanceWidget.cxx b/vcl/qt5/QtInstanceWidget.cxx index 3c016ef91902..ab7782757cfd 100644 --- a/vcl/qt5/QtInstanceWidget.cxx +++ b/vcl/qt5/QtInstanceWidget.cxx @@ -592,10 +592,14 @@ void QtInstanceWidget::set_highlight_background() { assert(false && "Not impleme void QtInstanceWidget::set_background(const Color& rBackColor) { - QPalette aPalette = getQWidget()->palette(); - aPalette.setColor(QPalette::Base, toQColor(rBackColor)); - getQWidget()->setPalette(aPalette); - getQWidget()->setBackgroundRole(QPalette::Base); + SolarMutexGuard g; + + GetQtInstance().RunInMainThread([&] { + QPalette aPalette = getQWidget()->palette(); + aPalette.setColor(getQWidget()->backgroundRole(), toQColor(rBackColor)); + getQWidget()->setPalette(aPalette); + getQWidget()->setAutoFillBackground(true); + }); } void QtInstanceWidget::draw(OutputDevice&, const Point&, const Size&) commit f3ac98295b859e2664279bfb6966ce5caabf2cc4 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Jan 22 22:20:12 2025 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Jan 23 08:29:28 2025 +0100 tdf#130857 qt weld: Implement QtInstanceLinkButton::set_label_wrap Change-Id: I399ccf7f7949d51c3561e088afc4081823df4067 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180610 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/qt5/QtInstanceLinkButton.cxx b/vcl/qt5/QtInstanceLinkButton.cxx index 88c5f28e3ae5..2a7f18aef314 100644 --- a/vcl/qt5/QtInstanceLinkButton.cxx +++ b/vcl/qt5/QtInstanceLinkButton.cxx @@ -37,7 +37,12 @@ OUString QtInstanceLinkButton::get_label() const return sLabel; } -void QtInstanceLinkButton::set_label_wrap(bool) { assert(false && "Not implemented yet"); } +void QtInstanceLinkButton::set_label_wrap(bool bWrap) +{ + SolarMutexGuard g; + + GetQtInstance().RunInMainThread([&] { m_pLabel->setWordWrap(bWrap); }); +} void QtInstanceLinkButton::set_uri(const OUString& rUri) { commit d7fd4f2f84aba449dcd03b20ae4f295172164131 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Jan 22 21:54:37 2025 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Jan 23 08:29:22 2025 +0100 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.wegh...@posteo.de> 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: */