summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vcl/inc/qt5/QtInstanceDialog.hxx16
-rw-r--r--vcl/inc/qt5/QtInstanceMessageDialog.hxx13
-rw-r--r--vcl/qt5/QtInstanceDialog.cxx70
-rw-r--r--vcl/qt5/QtInstanceMessageDialog.cxx68
4 files changed, 83 insertions, 84 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: */
diff --git a/vcl/qt5/QtInstanceDialog.cxx b/vcl/qt5/QtInstanceDialog.cxx
index 7e905aff980c..6a8040cfbf2c 100644
--- a/vcl/qt5/QtInstanceDialog.cxx
+++ b/vcl/qt5/QtInstanceDialog.cxx
@@ -15,6 +15,7 @@ const char* const QtInstanceDialog::PROPERTY_VCL_RESPONSE_CODE = "response-code"
QtInstanceDialog::QtInstanceDialog(QDialog* pDialog)
: QtInstanceWindow(pDialog)
, m_pDialog(pDialog)
+ , m_aRunAsyncFunc(nullptr)
{
}
@@ -24,15 +25,48 @@ QtInstanceDialog::~QtInstanceDialog()
GetQtInstance().RunInMainThread([&] { m_pDialog.reset(); });
}
-bool QtInstanceDialog::runAsync(std::shared_ptr<Dialog> const&,
- const std::function<void(sal_Int32)>&)
+bool QtInstanceDialog::runAsync(const std::shared_ptr<weld::DialogController>& rxOwner,
+ const std::function<void(sal_Int32)>& func)
{
+ SolarMutexGuard g;
+ QtInstance& rQtInstance = GetQtInstance();
+ if (!rQtInstance.IsMainThread())
+ {
+ bool bRet = false;
+ rQtInstance.RunInMainThread([&] { bRet = runAsync(rxOwner, func); });
+ return bRet;
+ }
+
+ assert(m_pDialog);
+
+ m_xRunAsyncDialogController = rxOwner;
+ m_aRunAsyncFunc = func;
+ connect(m_pDialog.get(), &QDialog::finished, this, &QtInstanceDialog::dialogFinished);
+ m_pDialog->open();
+
return true;
}
-bool QtInstanceDialog::runAsync(const std::shared_ptr<weld::DialogController>&,
- const std::function<void(sal_Int32)>&)
+bool QtInstanceDialog::runAsync(std::shared_ptr<Dialog> const& rxSelf,
+ const std::function<void(sal_Int32)>& func)
{
+ SolarMutexGuard g;
+ QtInstance& rQtInstance = GetQtInstance();
+ if (!rQtInstance.IsMainThread())
+ {
+ bool bRet;
+ rQtInstance.RunInMainThread([&] { bRet = runAsync(rxSelf, func); });
+ return bRet;
+ }
+
+ assert(m_pDialog);
+ assert(rxSelf.get() == this);
+
+ m_xRunAsyncDialog = rxSelf;
+ m_aRunAsyncFunc = func;
+ connect(m_pDialog.get(), &QDialog::finished, this, &QtInstanceDialog::dialogFinished);
+ m_pDialog->open();
+
return true;
}
@@ -95,4 +129,32 @@ void QtInstanceDialog::set_default_response(int) {}
weld::Container* QtInstanceDialog::weld_content_area() { return nullptr; }
+void QtInstanceDialog::dialogFinished(int nResult)
+{
+ SolarMutexGuard g;
+ QtInstance& rQtInstance = GetQtInstance();
+ if (!rQtInstance.IsMainThread())
+ {
+ rQtInstance.RunInMainThread([&] { dialogFinished(nResult); });
+ return;
+ }
+
+ assert(m_aRunAsyncFunc);
+
+ disconnect(m_pDialog.get(), &QDialog::finished, this, &QtInstanceDialog::dialogFinished);
+
+ // use local variables for these, as members might have got de-allocated by the time they're reset
+ std::shared_ptr<weld::Dialog> xRunAsyncDialog = m_xRunAsyncDialog;
+ std::shared_ptr<weld::DialogController> xRunAsyncDialogController = m_xRunAsyncDialogController;
+ std::function<void(sal_Int32)> aFunc = m_aRunAsyncFunc;
+ m_aRunAsyncFunc = nullptr;
+ m_xRunAsyncDialogController.reset();
+ m_xRunAsyncDialog.reset();
+
+ aFunc(nResult);
+
+ xRunAsyncDialogController.reset();
+ xRunAsyncDialog.reset();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/QtInstanceMessageDialog.cxx b/vcl/qt5/QtInstanceMessageDialog.cxx
index a907f6740960..906c17bc3aec 100644
--- a/vcl/qt5/QtInstanceMessageDialog.cxx
+++ b/vcl/qt5/QtInstanceMessageDialog.cxx
@@ -15,7 +15,6 @@
QtInstanceMessageDialog::QtInstanceMessageDialog(QMessageBox* pMessageDialog)
: QtInstanceDialog(pMessageDialog)
, m_pMessageDialog(pMessageDialog)
- , m_aRunAsyncFunc(nullptr)
{
assert(m_pMessageDialog);
}
@@ -146,51 +145,6 @@ int QtInstanceMessageDialog::run()
return pClickedButton->property(PROPERTY_VCL_RESPONSE_CODE).toInt();
}
-bool QtInstanceMessageDialog::runAsync(const std::shared_ptr<weld::DialogController>& rxOwner,
- const std::function<void(sal_Int32)>& func)
-{
- SolarMutexGuard g;
- QtInstance& rQtInstance = GetQtInstance();
- if (!rQtInstance.IsMainThread())
- {
- bool bRet = false;
- rQtInstance.RunInMainThread([&] { bRet = runAsync(rxOwner, func); });
- return bRet;
- }
-
- assert(m_pMessageDialog);
-
- m_xRunAsyncDialogController = rxOwner;
- m_aRunAsyncFunc = func;
- connect(m_pMessageDialog, &QDialog::finished, this, &QtInstanceMessageDialog::dialogFinished);
- m_pMessageDialog->open();
-
- return true;
-}
-
-bool QtInstanceMessageDialog::runAsync(std::shared_ptr<Dialog> const& rxSelf,
- const std::function<void(sal_Int32)>& func)
-{
- SolarMutexGuard g;
- QtInstance& rQtInstance = GetQtInstance();
- if (!rQtInstance.IsMainThread())
- {
- bool bRet;
- rQtInstance.RunInMainThread([&] { bRet = runAsync(rxSelf, func); });
- return bRet;
- }
-
- assert(m_pMessageDialog);
- assert(rxSelf.get() == this);
-
- m_xRunAsyncDialog = rxSelf;
- m_aRunAsyncFunc = func;
- connect(m_pMessageDialog, &QDialog::finished, this, &QtInstanceMessageDialog::dialogFinished);
- m_pMessageDialog->open();
-
- return true;
-}
-
void QtInstanceMessageDialog::response(int nResponse)
{
SolarMutexGuard g;
@@ -215,28 +169,12 @@ void QtInstanceMessageDialog::dialogFinished(int nResult)
return;
}
- assert(m_aRunAsyncFunc);
-
- disconnect(m_pMessageDialog, &QDialog::finished, this,
- &QtInstanceMessageDialog::dialogFinished);
-
- // use local variables for these, as members might have got de-allocated by the time they're reset
- std::shared_ptr<weld::Dialog> xRunAsyncDialog = m_xRunAsyncDialog;
- std::shared_ptr<weld::DialogController> xRunAsyncDialogController = m_xRunAsyncDialogController;
- std::function<void(sal_Int32)> aFunc = m_aRunAsyncFunc;
- m_aRunAsyncFunc = nullptr;
- m_xRunAsyncDialogController.reset();
- m_xRunAsyncDialog.reset();
-
// if a button was clicked, use its response code, otherwise the passed one
- int nRet = nResult;
+ int nResponseCode = nResult;
if (QAbstractButton* pClickedButton = m_pMessageDialog->clickedButton())
- nRet = pClickedButton->property(PROPERTY_VCL_RESPONSE_CODE).toInt();
-
- aFunc(nRet);
+ nResponseCode = pClickedButton->property(PROPERTY_VCL_RESPONSE_CODE).toInt();
- xRunAsyncDialogController.reset();
- xRunAsyncDialog.reset();
+ QtInstanceDialog::dialogFinished(nResponseCode);
}
QPushButton* QtInstanceMessageDialog::buttonForResponseCode(int nResponse)