vcl/Library_vclplug_qt5.mk | 1 vcl/Library_vclplug_qt6.mk | 1 vcl/inc/qt5/QtInstanceButton.hxx | 32 ++++++++++++++++++ vcl/inc/qt5/QtInstanceMessageDialog.hxx | 3 + vcl/inc/qt6/QtInstanceButton.hxx | 12 ++++++ vcl/qt5/QtInstanceButton.cxx | 56 ++++++++++++++++++++++++++++++++ vcl/qt5/QtInstanceMessageDialog.cxx | 31 +++++++++++------ vcl/qt6/QtInstanceButton.cxx | 12 ++++++ 8 files changed, 137 insertions(+), 11 deletions(-)
New commits: commit 97fa00148f4fdb1e5451c23d50c8c8f65080caec Author: Michael Weghorn <[email protected]> AuthorDate: Tue Aug 6 15:04:57 2024 +0200 Commit: Adolfo Jayme Barrientos <[email protected]> CommitDate: Fri Aug 9 02:59:48 2024 +0200 tdf#162351 tdf#130857 qt weld: Extract helper function to get button ... for response code. The new helper method `QtInstanceMessageDialog::buttonForResponseCode` will be reused elsewhere in an upcoming commit. Change-Id: Ie7ee065fb68f936b79ac96ba70dc85ffa18c9859 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171550 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> (cherry picked from commit 877075e3abe5378b359cf7f069a859b91eb2d6d7) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171533 Reviewed-by: Adolfo Jayme Barrientos <[email protected]> diff --git a/vcl/inc/qt5/QtInstanceMessageDialog.hxx b/vcl/inc/qt5/QtInstanceMessageDialog.hxx index c12243b5945c..bc6971210e06 100644 --- a/vcl/inc/qt5/QtInstanceMessageDialog.hxx +++ b/vcl/inc/qt5/QtInstanceMessageDialog.hxx @@ -50,6 +50,9 @@ public: const std::function<void(sal_Int32)>& func) override; virtual void response(int nResponse) override; +private: + virtual QPushButton* buttonForResponseCode(int nResponse); + private slots: void dialogFinished(int nResult); }; diff --git a/vcl/qt5/QtInstanceMessageDialog.cxx b/vcl/qt5/QtInstanceMessageDialog.cxx index cbda4c6ae0dd..ec5761bca75a 100644 --- a/vcl/qt5/QtInstanceMessageDialog.cxx +++ b/vcl/qt5/QtInstanceMessageDialog.cxx @@ -62,17 +62,9 @@ void QtInstanceMessageDialog::set_default_response(int nResponse) { assert(m_pMessageDialog); - const QList<QAbstractButton*> aButtons = m_pMessageDialog->buttons(); - for (QAbstractButton* pAbstractButton : aButtons) - { - if (pAbstractButton->property(PROPERTY_VCL_RESPONSE_CODE).toInt() == nResponse) - { - QPushButton* pButton = dynamic_cast<QPushButton*>(pAbstractButton); - assert(pButton); - m_pMessageDialog->setDefaultButton(pButton); - return; - } - } + QPushButton* pButton = buttonForResponseCode(nResponse); + if (pButton) + m_pMessageDialog->setDefaultButton(pButton); } int QtInstanceMessageDialog::run() @@ -144,4 +136,21 @@ void QtInstanceMessageDialog::dialogFinished(int nResult) xRunAsyncDialog.reset(); } +QPushButton* QtInstanceMessageDialog::buttonForResponseCode(int nResponse) +{ + assert(m_pMessageDialog); + + const QList<QAbstractButton*> aButtons = m_pMessageDialog->buttons(); + for (QAbstractButton* pAbstractButton : aButtons) + { + if (pAbstractButton->property(PROPERTY_VCL_RESPONSE_CODE).toInt() == nResponse) + { + QPushButton* pButton = dynamic_cast<QPushButton*>(pAbstractButton); + assert(pButton); + return pButton; + } + } + return nullptr; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit c336d044357d14f40644b0db321e66132203e959 Author: Michael Weghorn <[email protected]> AuthorDate: Tue Aug 6 14:58:12 2024 +0200 Commit: Adolfo Jayme Barrientos <[email protected]> CommitDate: Fri Aug 9 02:59:33 2024 +0200 tdf#162351 tdf#130857 qt weld: Add basic QtInstanceButton Add a very basic native Qt implementation for `weld::Button`. It currently doesn't really implement many methods and just triggers an assert when they get called. Change-Id: I7a15266e978ca3bb030c847822a82d8d58c4c189 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171549 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> (cherry picked from commit f0ad3a95c1e841281048a784bd96e8d34e090c5b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171532 Reviewed-by: Adolfo Jayme Barrientos <[email protected]> diff --git a/vcl/Library_vclplug_qt5.mk b/vcl/Library_vclplug_qt5.mk index f29090d9dd9d..4d844da518f4 100644 --- a/vcl/Library_vclplug_qt5.mk +++ b/vcl/Library_vclplug_qt5.mk @@ -92,6 +92,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_qt5,\ vcl/qt5/QtGraphics_Text \ vcl/qt5/QtInstance \ vcl/qt5/QtInstance_Print \ + vcl/qt5/QtInstanceButton \ vcl/qt5/QtInstanceContainer \ vcl/qt5/QtInstanceDialog \ vcl/qt5/QtInstanceMessageDialog \ diff --git a/vcl/Library_vclplug_qt6.mk b/vcl/Library_vclplug_qt6.mk index f8a2c38bb836..0e8d769ebd13 100644 --- a/vcl/Library_vclplug_qt6.mk +++ b/vcl/Library_vclplug_qt6.mk @@ -91,6 +91,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_qt6,\ vcl/qt6/QtGraphics_Text \ vcl/qt6/QtInstance \ vcl/qt6/QtInstance_Print \ + vcl/qt6/QtInstanceButton \ vcl/qt6/QtInstanceContainer \ vcl/qt6/QtInstanceDialog \ vcl/qt6/QtInstanceMessageDialog \ diff --git a/vcl/inc/qt5/QtInstanceButton.hxx b/vcl/inc/qt5/QtInstanceButton.hxx new file mode 100644 index 000000000000..cd55ddd470be --- /dev/null +++ b/vcl/inc/qt5/QtInstanceButton.hxx @@ -0,0 +1,32 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 <QtWidgets/QPushButton> + +class QtInstanceButton : public QtInstanceWidget, public virtual weld::Button +{ + QPushButton* m_pButton; + +public: + QtInstanceButton(QPushButton* pButton); + + virtual void set_label(const OUString& rText) override; + virtual void set_image(VirtualDevice* pDevice) override; + virtual void set_image(const css::uno::Reference<css::graphic::XGraphic>& rImage) override; + virtual void set_from_icon_name(const OUString& rIconName) override; + virtual OUString get_label() const override; + virtual void set_font(const vcl::Font& rFont) override; + virtual void set_custom_button(VirtualDevice* pDevice) override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/qt6/QtInstanceButton.hxx b/vcl/inc/qt6/QtInstanceButton.hxx new file mode 100644 index 000000000000..d20c299f1157 --- /dev/null +++ b/vcl/inc/qt6/QtInstanceButton.hxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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/QtInstanceButton.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/qt5/QtInstanceButton.cxx b/vcl/qt5/QtInstanceButton.cxx new file mode 100644 index 000000000000..841e4906c34f --- /dev/null +++ b/vcl/qt5/QtInstanceButton.cxx @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 <QtInstanceButton.hxx> + +QtInstanceButton::QtInstanceButton(QPushButton* pButton) + : QtInstanceWidget(pButton) + , m_pButton(pButton) +{ + assert(m_pButton); +} + +void QtInstanceButton::set_label(const OUString& rText) +{ + assert(m_pButton); + m_pButton->setText(toQString(rText)); +} + +void QtInstanceButton::set_image(VirtualDevice* /*pDevice*/) +{ + assert(false && "Not implemented yet"); +} + +void QtInstanceButton::set_image(const css::uno::Reference<css::graphic::XGraphic>& /*rImage*/) +{ + assert(false && "Not implemented yet"); +} + +void QtInstanceButton::set_from_icon_name(const OUString& /*rIconName*/) +{ + assert(false && "Not implemented yet"); +} + +OUString QtInstanceButton::get_label() const +{ + assert(m_pButton); + return toOUString(m_pButton->text()); +} + +void QtInstanceButton::set_font(const vcl::Font& /*rFont*/) +{ + assert(false && "Not implemented yet"); +} + +void QtInstanceButton::set_custom_button(VirtualDevice* /*pDevice*/) +{ + assert(false && "Not implemented yet"); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/qt6/QtInstanceButton.cxx b/vcl/qt6/QtInstanceButton.cxx new file mode 100644 index 000000000000..a51e0ff58196 --- /dev/null +++ b/vcl/qt6/QtInstanceButton.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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/QtInstanceButton.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
