vcl/inc/qt5/QtInstanceMessageDialog.hxx | 2 +- vcl/qt5/QtInstanceMessageDialog.cxx | 20 ++++++++------------ 2 files changed, 9 insertions(+), 13 deletions(-)
New commits: commit 84dd10614a15eb3655871681f3468c0cd9aba67c Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Sat Jul 26 08:52:52 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Tue Jul 29 05:58:23 2025 +0200 tdf#130857 qt weld: Adjust MessageDialog override to set default button Change-Id: I4da34ee14436eb2025781947309cecb397ace4c5 Author: Michael Weghorn <m.wegh...@posteo.de> Date: Sat Jul 26 08:06:56 2025 +0200 tdf#130857 qt weld: Implement QtInstanceDialog::set_default_response implemented set_default_response in the base class now. Rely on that implementation, and override change_default_button instead. Change-Id: Id0759aef5c635427dbb1c07a6196b62ca409689a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188388 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/inc/qt5/QtInstanceMessageDialog.hxx b/vcl/inc/qt5/QtInstanceMessageDialog.hxx index ee996032949b..16fb4d284b0d 100644 --- a/vcl/inc/qt5/QtInstanceMessageDialog.hxx +++ b/vcl/inc/qt5/QtInstanceMessageDialog.hxx @@ -37,7 +37,7 @@ public: // weld::Dialog overrides virtual void add_button(const OUString& rText, int nResponse, const OUString& rHelpId = {}) override; - virtual void set_default_response(int nResponse) override; + virtual void change_default_button(weld::Button* pOld, weld::Button* pNew) override; std::unique_ptr<weld::Button> weld_button_for_response(int nResponse) override; virtual int run() override; diff --git a/vcl/qt5/QtInstanceMessageDialog.cxx b/vcl/qt5/QtInstanceMessageDialog.cxx index 4b4e57716b82..6b909874a4de 100644 --- a/vcl/qt5/QtInstanceMessageDialog.cxx +++ b/vcl/qt5/QtInstanceMessageDialog.cxx @@ -102,21 +102,17 @@ void QtInstanceMessageDialog::add_button(const OUString& rText, int nResponse, c addButton(*m_pMessageDialog, rText, nResponse); } -void QtInstanceMessageDialog::set_default_response(int nResponse) +void QtInstanceMessageDialog::change_default_button(weld::Button*, weld::Button* pNew) { SolarMutexGuard g; - QtInstance& rQtInstance = GetQtInstance(); - if (!rQtInstance.IsMainThread()) - { - rQtInstance.RunInMainThread([&] { set_default_response(nResponse); }); - return; - } - assert(m_pMessageDialog); - - QPushButton* pButton = buttonForResponseCode(nResponse); - if (pButton) - m_pMessageDialog->setDefaultButton(pButton); + GetQtInstance().RunInMainThread([&] { + if (QtInstanceButton* pButton = dynamic_cast<QtInstanceButton*>(pNew)) + { + if (QPushButton* pPushButton = qobject_cast<QPushButton*>(&pButton->getButton())) + m_pMessageDialog->setDefaultButton(pPushButton); + } + }); } std::unique_ptr<weld::Button> QtInstanceMessageDialog::weld_button_for_response(int nResponse)