summaryrefslogtreecommitdiff
path: root/vcl/qt5
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2021-10-31 11:03:36 +0100
committerJan-Marek Glogowski <glogow@fbihome.de>2021-11-01 12:18:58 +0100
commitfa9b28c781d4d3e97f7dcf150a0e22e70289c228 (patch)
tree251c7bef97ef4449d699ef2b1ffb9c39e585a984 /vcl/qt5
parenta2bc467b4c0c0da71a8c213ac61477cd7697cdc0 (diff)
Qt picker: implement XAsynchronousExecutableDialog
FWIW: most places still call FileDialogHelper::Execute instead of StartExecuteModal. I tested with "Insert >> Text from File...". Change-Id: I303cc89c97c8fc17015ab7831e6a324ef16a6a0b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124512 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl/qt5')
-rw-r--r--vcl/qt5/QtFilePicker.cxx57
1 files changed, 45 insertions, 12 deletions
diff --git a/vcl/qt5/QtFilePicker.cxx b/vcl/qt5/QtFilePicker.cxx
index ca80b61ef101..3fae63fca74f 100644
--- a/vcl/qt5/QtFilePicker.cxx
+++ b/vcl/qt5/QtFilePicker.cxx
@@ -116,6 +116,8 @@ QtFilePicker::QtFilePicker(css::uno::Reference<css::uno::XComponentContext> cons
// update automatic file extension when filter is changed
connect(m_pFileDialog.get(), SIGNAL(filterSelected(const QString&)), this,
SLOT(updateAutomaticFileExtension()));
+
+ connect(m_pFileDialog.get(), SIGNAL(finished(int)), this, SLOT(finished(int)));
}
QtFilePicker::~QtFilePicker()
@@ -152,18 +154,8 @@ void SAL_CALL QtFilePicker::setTitle(const OUString& title)
[this, &title]() { m_pFileDialog->setWindowTitle(toQString(title)); });
}
-sal_Int16 SAL_CALL QtFilePicker::execute()
+void QtFilePicker::prepareExecute()
{
- SolarMutexGuard g;
- auto* pSalInst(static_cast<QtInstance*>(GetSalData()->m_pInstance));
- assert(pSalInst);
- if (!pSalInst->IsMainThread())
- {
- sal_uInt16 ret;
- pSalInst->RunInMainThread([&ret, this]() { ret = execute(); });
- return ret;
- }
-
QWidget* pTransientParent = m_pParentWidget;
if (!pTransientParent)
{
@@ -191,15 +183,56 @@ sal_Int16 SAL_CALL QtFilePicker::execute()
m_pFileDialog->setParent(pTransientParent, m_pFileDialog->windowFlags());
m_pFileDialog->show();
xDesktop->addTerminateListener(this);
- int result = m_pFileDialog->exec();
+}
+
+void QtFilePicker::finished(int nResult)
+{
+ uno::Reference<css::frame::XDesktop> xDesktop(css::frame::Desktop::create(m_context),
+ UNO_QUERY_THROW);
xDesktop->removeTerminateListener(this);
m_pFileDialog->setParent(nullptr, m_pFileDialog->windowFlags());
+ if (m_xClosedListener.is())
+ {
+ const sal_Int16 nRet = (QFileDialog::Rejected == nResult) ? ExecutableDialogResults::CANCEL
+ : ExecutableDialogResults::OK;
+ css::ui::dialogs::DialogClosedEvent aEvent(*this, nRet);
+ m_xClosedListener->dialogClosed(aEvent);
+ m_xClosedListener.clear();
+ }
+}
+
+sal_Int16 SAL_CALL QtFilePicker::execute()
+{
+ SolarMutexGuard g;
+ auto* pSalInst(static_cast<QtInstance*>(GetSalData()->m_pInstance));
+ assert(pSalInst);
+ if (!pSalInst->IsMainThread())
+ {
+ sal_uInt16 ret;
+ pSalInst->RunInMainThread([&ret, this]() { ret = execute(); });
+ return ret;
+ }
+
+ prepareExecute();
+ int result = m_pFileDialog->exec();
+
if (QFileDialog::Rejected == result)
return ExecutableDialogResults::CANCEL;
return ExecutableDialogResults::OK;
}
+// XAsynchronousExecutableDialog functions
+void SAL_CALL QtFilePicker::setDialogTitle(const OUString& _rTitle) { setTitle(_rTitle); }
+
+void SAL_CALL
+QtFilePicker::startExecuteModal(const Reference<css::ui::dialogs::XDialogClosedListener>& xListener)
+{
+ m_xClosedListener = xListener;
+ prepareExecute();
+ m_pFileDialog->show();
+}
+
void SAL_CALL QtFilePicker::setMultiSelectionMode(sal_Bool multiSelect)
{
SolarMutexGuard g;