vcl/inc/qt5/QtInstanceButton.hxx |    1 
 vcl/inc/qt5/QtInstanceDialog.hxx |    2 -
 vcl/qt5/QtInstanceDialog.cxx     |   40 +++++++++++++++++++++++++++++++++------
 3 files changed, 35 insertions(+), 8 deletions(-)

New commits:
commit 0ab3440533dcc7d15d6f30287675788b550770ff
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Sat Jul 26 08:06:56 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue Jul 29 05:58:13 2025 +0200

    tdf#130857 qt weld: Implement QtInstanceDialog::set_default_response
    
    Use existing logic. This isn't event specific to the
    Qt implementation.
    
    Change-Id: I4da34ee14436eb2025781947309cecb397ace4c5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188386
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/vcl/inc/qt5/QtInstanceDialog.hxx b/vcl/inc/qt5/QtInstanceDialog.hxx
index cbae80b675d1..0ac82cf8fb3a 100644
--- a/vcl/inc/qt5/QtInstanceDialog.hxx
+++ b/vcl/inc/qt5/QtInstanceDialog.hxx
@@ -58,7 +58,7 @@ public:
 
     virtual std::unique_ptr<weld::Button> weld_button_for_response(int 
nResponse) override;
 
-    virtual void set_default_response(int) override;
+    virtual void set_default_response(int nResponse) override;
 
     virtual std::unique_ptr<weld::Container> weld_content_area() override;
 
diff --git a/vcl/qt5/QtInstanceDialog.cxx b/vcl/qt5/QtInstanceDialog.cxx
index 9ecb1b4f9487..13c8bbdcc678 100644
--- a/vcl/qt5/QtInstanceDialog.cxx
+++ b/vcl/qt5/QtInstanceDialog.cxx
@@ -168,7 +168,11 @@ std::unique_ptr<weld::Button> 
QtInstanceDialog::weld_button_for_response(int nRe
     return nullptr;
 }
 
-void QtInstanceDialog::set_default_response(int) { assert(false && "Not 
implemented yet"); }
+void QtInstanceDialog::set_default_response(int nResponse)
+{
+    std::unique_ptr<weld::Button> pButton = 
weld_button_for_response(nResponse);
+    change_default_button(nullptr, pButton.get());
+}
 
 std::unique_ptr<weld::Container> QtInstanceDialog::weld_content_area()
 {
commit 01724fd8c2c69af36022b3e1efd0b2d20d7b6d61
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Sat Jul 26 07:58:48 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue Jul 29 05:58:05 2025 +0200

    tdf#130857 qt weld: Implement QtInstanceDialog::{is,change}_default_button
    
    Qt doc: https://doc.qt.io/qt-6/qdialog.html#default-button
    
    Change-Id: Iccfbcac2558eb821ae101aa1350ee1f8eb0cf229
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188385
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/inc/qt5/QtInstanceButton.hxx b/vcl/inc/qt5/QtInstanceButton.hxx
index 09c797d557fd..0bcb75782b62 100644
--- a/vcl/inc/qt5/QtInstanceButton.hxx
+++ b/vcl/inc/qt5/QtInstanceButton.hxx
@@ -36,7 +36,6 @@ public:
     // same result if called on the corresponding QtInstanceButton)
     static bool hasCustomClickHandler(const QAbstractButton& rButton);
 
-protected:
     QAbstractButton& getButton() const;
 
 private slots:
diff --git a/vcl/qt5/QtInstanceDialog.cxx b/vcl/qt5/QtInstanceDialog.cxx
index 9ddcb9cda1b1..9ecb1b4f9487 100644
--- a/vcl/qt5/QtInstanceDialog.cxx
+++ b/vcl/qt5/QtInstanceDialog.cxx
@@ -190,15 +190,39 @@ std::unique_ptr<weld::Container> 
QtInstanceDialog::weld_content_area()
     return std::make_unique<QtInstanceContainer>(m_pContentArea);
 }
 
-void QtInstanceDialog::change_default_button(weld::Button*, weld::Button*)
+void QtInstanceDialog::change_default_button(weld::Button* pOld, weld::Button* 
pNew)
 {
-    assert(false && "Not implemented yet");
+    SolarMutexGuard g;
+
+    GetQtInstance().RunInMainThread([&] {
+        if (QtInstanceButton* pOldButton = 
dynamic_cast<QtInstanceButton*>(pOld))
+        {
+            if (QPushButton* pPushButton = 
qobject_cast<QPushButton*>(&pOldButton->getButton()))
+                pPushButton->setDefault(false);
+        }
+
+        if (QtInstanceButton* pNewButton = 
dynamic_cast<QtInstanceButton*>(pNew))
+        {
+            if (QPushButton* pPushButton = 
qobject_cast<QPushButton*>(&pNewButton->getButton()))
+                pPushButton->setDefault(true);
+        }
+    });
 }
 
-bool QtInstanceDialog::is_default_button(const weld::Button*) const
+bool QtInstanceDialog::is_default_button(const weld::Button* pCandidate) const
 {
-    assert(false && "Not implemented yet");
-    return true;
+    SolarMutexGuard g;
+
+    bool bDefault = false;
+    GetQtInstance().RunInMainThread([&] {
+        if (const QtInstanceButton* pButton = dynamic_cast<const 
QtInstanceButton*>(pCandidate))
+        {
+            if (QPushButton* pPushButton = 
qobject_cast<QPushButton*>(&pButton->getButton()))
+                bDefault = pPushButton->isDefault();
+        }
+    });
+
+    return bDefault;
 }
 
 void QtInstanceDialog::dialogFinished(int nResult)

Reply via email to