diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2024-10-02 09:33:08 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2024-10-02 13:15:38 +0200 |
commit | cb7e14bf370647a3fe618492ff79d0202c64c71f (patch) | |
tree | 2fec54fdee17fcd68f48d3e65c1a53c185366b57 /vcl/inc | |
parent | 169c56518e1213ea29b7ccbe746f75e5f13825a3 (diff) |
tdf#130857 qt weld: Move runAsync logic to QtInstanceDialog
Refactor the handling for running a QtInstanceMessageDialog
asynchronously, and reuse the logic for the QtInstanceDialog
base class:
Move implementations for both QtInstanceMessageDialog::runAsync
methods and the involved class members from QtInstanceMessageDialog
to QtInstanceDialog.
Split the previous logic from
QtInstanceMessageDialog::dialogFinished into two methods:
* move most of the logic as is to a new virtual slot
in the base class, QtInstanceDialog::dialogFinished
* override the base class implementation to get the
response code from the actually clicked button
via the PROPERTY_VCL_RESPONSE_CODE property
set on that button, and call the base class
method with that one.
For QtInstanceDialog, there's no QDialog::clickedButton
method that could be used to retrieve the clicked button,
but it's also not needed there, because there a slot
connected to the QAbstractButton::clicked signal that triggers
closing the dialog, and passes the proper response code of the
corresponding button already, see
commit 08b55df5c9e42c1ccb78a156261811875629342a
Author: Michael Weghorn <m.weghorn@posteo.de>
Date: Sat Sep 28 00:32:15 2024 +0200
tdf#130857 qt weld: Close dialog on button click
With this commit in place, QtInstanceDialog can now
also be run asynchronously, instead of the
QtInstanceDialog::runAsync methods
just returning true without doing anything.
This will be needed e.g. when adding support for the
"Tools" -> "Word Count" dialog in Writer.
Change-Id: I4edb9443cb11d1dc831a18f708cdbdd67c239aa6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174374
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
Diffstat (limited to 'vcl/inc')
-rw-r--r-- | vcl/inc/qt5/QtInstanceDialog.hxx | 16 | ||||
-rw-r--r-- | vcl/inc/qt5/QtInstanceMessageDialog.hxx | 13 |
2 files changed, 14 insertions, 15 deletions
diff --git a/vcl/inc/qt5/QtInstanceDialog.hxx b/vcl/inc/qt5/QtInstanceDialog.hxx index 6c00df7181fb..16db9acd1d1e 100644 --- a/vcl/inc/qt5/QtInstanceDialog.hxx +++ b/vcl/inc/qt5/QtInstanceDialog.hxx @@ -17,15 +17,20 @@ class QtInstanceDialog : public QObject, public QtInstanceWindow, public virtual std::unique_ptr<QDialog> m_pDialog; + // the DialogController/Dialog/function passed to the runAsync variants + std::shared_ptr<weld::DialogController> m_xRunAsyncDialogController; + std::shared_ptr<weld::Dialog> m_xRunAsyncDialog; + std::function<void(sal_Int32)> m_aRunAsyncFunc; + public: QtInstanceDialog(QDialog* pDialog); ~QtInstanceDialog(); - virtual bool runAsync(std::shared_ptr<Dialog> const&, - const std::function<void(sal_Int32)>&) override; + virtual bool runAsync(const std::shared_ptr<weld::DialogController>& rxOwner, + const std::function<void(sal_Int32)>& func) override; - virtual bool runAsync(const std::shared_ptr<weld::DialogController>&, - const std::function<void(sal_Int32)>&) override; + virtual bool runAsync(std::shared_ptr<Dialog> const& rxSelf, + const std::function<void(sal_Int32)>& func) override; virtual void collapse(weld::Widget*, weld::Widget*) override; @@ -55,6 +60,9 @@ public: * int VCL response code of that button. */ static const char* const PROPERTY_VCL_RESPONSE_CODE; + +protected slots: + virtual void dialogFinished(int nResult); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/qt5/QtInstanceMessageDialog.hxx b/vcl/inc/qt5/QtInstanceMessageDialog.hxx index ea532a6eabb2..a410a8fd5dfc 100644 --- a/vcl/inc/qt5/QtInstanceMessageDialog.hxx +++ b/vcl/inc/qt5/QtInstanceMessageDialog.hxx @@ -20,11 +20,6 @@ class QtInstanceMessageDialog : public QtInstanceDialog, public virtual weld::Me private: QMessageBox* m_pMessageDialog; - // the DialogController/Dialog/function passed to the runAsync variants - std::shared_ptr<weld::DialogController> m_xRunAsyncDialogController; - std::shared_ptr<weld::Dialog> m_xRunAsyncDialog; - std::function<void(sal_Int32)> m_aRunAsyncFunc; - public: QtInstanceMessageDialog(QMessageBox* pMessageDialog); @@ -44,17 +39,13 @@ public: virtual void set_default_response(int nResponse) override; QtInstanceButton* weld_widget_for_response(int nResponse) override; virtual int run() override; - virtual bool runAsync(std::shared_ptr<weld::DialogController> const& rxOwner, - const std::function<void(sal_Int32)>& func) override; - virtual bool runAsync(std::shared_ptr<Dialog> const& rxSelf, - 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); +protected slots: + virtual void dialogFinished(int nResult) override; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |