diff options
author | Katarina Behrens <Katarina.Behrens@cib.de> | 2018-10-24 13:03:17 +0200 |
---|---|---|
committer | Katarina Behrens <Katarina.Behrens@cib.de> | 2018-10-25 10:35:13 +0200 |
commit | 8f71eb5182f7fe6d3e19705ed233f5f84a0a6208 (patch) | |
tree | 6a2eed6aff0acc17041b7e16530668f460f82c3a | |
parent | 54f06c0004d51db5a3ab5e339bd5b5822cdb59f6 (diff) |
tdf#119856 related: opening kde5 filepicker from extensions now possible
certain things have to be done exclusively in main thread
Change-Id: Ib9f5a3187080cd986977e323a38a1e6c2ed57366
Reviewed-on: https://gerrit.libreoffice.org/62281
Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
Tested-by: Katarina Behrens <Katarina.Behrens@cib.de>
-rw-r--r-- | vcl/CustomTarget_kde5_moc.mk | 1 | ||||
-rw-r--r-- | vcl/unx/kde5/KDE5FilePicker.hxx | 1 | ||||
-rw-r--r-- | vcl/unx/kde5/KDE5FilePicker2.cxx | 6 | ||||
-rw-r--r-- | vcl/unx/kde5/KDE5SalInstance.cxx | 10 | ||||
-rw-r--r-- | vcl/unx/kde5/KDE5SalInstance.hxx | 14 |
5 files changed, 27 insertions, 5 deletions
diff --git a/vcl/CustomTarget_kde5_moc.mk b/vcl/CustomTarget_kde5_moc.mk index 5c7fea94428b..7d68658fc279 100644 --- a/vcl/CustomTarget_kde5_moc.mk +++ b/vcl/CustomTarget_kde5_moc.mk @@ -10,6 +10,7 @@ $(eval $(call gb_CustomTarget_CustomTarget,vcl/unx/kde5)) $(call gb_CustomTarget_get_target,vcl/unx/kde5) : \ + $(call gb_CustomTarget_get_workdir,vcl/unx/kde5)/KDE5SalInstance.moc \ $(call gb_CustomTarget_get_workdir,vcl/unx/kde5)/KDE5FilePicker.moc \ $(call gb_CustomTarget_get_workdir,vcl/unx/kde5)/tst_exclude_socket_notifiers.moc \ $(call gb_CustomTarget_get_workdir,vcl/unx/kde5)/tst_exclude_posted_events.moc diff --git a/vcl/unx/kde5/KDE5FilePicker.hxx b/vcl/unx/kde5/KDE5FilePicker.hxx index d1a300be014c..df7d8499ecae 100644 --- a/vcl/unx/kde5/KDE5FilePicker.hxx +++ b/vcl/unx/kde5/KDE5FilePicker.hxx @@ -168,6 +168,7 @@ protected: bool eventFilter(QObject* watched, QEvent* event) override; Q_SIGNALS: + sal_Int16 executeSignal(); void setTitleSignal(const OUString& rTitle); void setDefaultNameSignal(const OUString& rName); void setDisplayDirectorySignal(const OUString& rDir); diff --git a/vcl/unx/kde5/KDE5FilePicker2.cxx b/vcl/unx/kde5/KDE5FilePicker2.cxx index 5de295453bd8..4327d0d36256 100644 --- a/vcl/unx/kde5/KDE5FilePicker2.cxx +++ b/vcl/unx/kde5/KDE5FilePicker2.cxx @@ -106,6 +106,7 @@ KDE5FilePicker::KDE5FilePicker(QFileDialog::FileMode eMode) connect(_dialog, &QFileDialog::filterSelected, this, &KDE5FilePicker::filterChanged); connect(_dialog, &QFileDialog::fileSelected, this, &KDE5FilePicker::selectionChanged); + connect(this, &KDE5FilePicker::executeSignal, this, &KDE5FilePicker::execute); // XExecutableDialog connect(this, &KDE5FilePicker::setTitleSignal, this, &KDE5FilePicker::setTitleSlot, @@ -183,6 +184,11 @@ void SAL_CALL KDE5FilePicker::setTitle(const OUString& title) sal_Int16 SAL_CALL KDE5FilePicker::execute() { + if (qApp->thread() != QThread::currentThread()) + { + return Q_EMIT executeSignal(); + } + if (!_filters.isEmpty()) _dialog->setNameFilters(_filters); if (!_currentFilter.isEmpty()) diff --git a/vcl/unx/kde5/KDE5SalInstance.cxx b/vcl/unx/kde5/KDE5SalInstance.cxx index f190714e02da..7c8f27802147 100644 --- a/vcl/unx/kde5/KDE5SalInstance.cxx +++ b/vcl/unx/kde5/KDE5SalInstance.cxx @@ -46,6 +46,8 @@ KDE5SalInstance::KDE5SalInstance() pSVData->maAppData.mxToolkitName = OUString("kde5"); KDE5SalData::initNWF(); + connect(this, &KDE5SalInstance::createFilePickerSignal, this, + &KDE5SalInstance::createFilePicker, Qt::BlockingQueuedConnection); } SalFrame* KDE5SalInstance::CreateFrame(SalFrame* pParent, SalFrameStyleFlags nState) @@ -54,8 +56,13 @@ SalFrame* KDE5SalInstance::CreateFrame(SalFrame* pParent, SalFrameStyleFlags nSt } uno::Reference<ui::dialogs::XFilePicker2> -KDE5SalInstance::createFilePicker(const uno::Reference<uno::XComponentContext>& /*xMSF*/) +KDE5SalInstance::createFilePicker(const uno::Reference<uno::XComponentContext>& xMSF) { + if (!IsMainThread()) + { + return Q_EMIT createFilePickerSignal(xMSF); + } + return uno::Reference<ui::dialogs::XFilePicker2>(new KDE5FilePicker(QFileDialog::ExistingFile)); } @@ -148,4 +155,5 @@ VCLPLUG_KDE5_PUBLIC SalInstance* create_SalInstance() } } +#include <KDE5SalInstance.moc> /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/kde5/KDE5SalInstance.hxx b/vcl/unx/kde5/KDE5SalInstance.hxx index a148f6cd8073..bfc24debfe7c 100644 --- a/vcl/unx/kde5/KDE5SalInstance.hxx +++ b/vcl/unx/kde5/KDE5SalInstance.hxx @@ -20,9 +20,9 @@ #pragma once #include <sal/config.h> - #include <memory> +#include <QtCore/QObject> #include <qt5/Qt5Instance.hxx> #include "KDE5SalFrame.hxx" @@ -31,19 +31,25 @@ class SalFrame; class KDE5SalInstance : public Qt5Instance { + Q_OBJECT public: explicit KDE5SalInstance(); virtual SalFrame* CreateFrame(SalFrame* pParent, SalFrameStyleFlags nStyle) override; virtual bool hasNativeFileSelection() const override { return true; } - virtual css::uno::Reference<css::ui::dialogs::XFilePicker2> - createFilePicker(const css::uno::Reference<css::uno::XComponentContext>&) override; - virtual css::uno::Reference<css::ui::dialogs::XFolderPicker2> createFolderPicker(const css::uno::Reference<css::uno::XComponentContext>&) override; virtual bool IsMainThread() const override; + +Q_SIGNALS: + css::uno::Reference<css::ui::dialogs::XFilePicker2> + createFilePickerSignal(const css::uno::Reference<css::uno::XComponentContext>&); + +private Q_SLOTS: + virtual css::uno::Reference<css::ui::dialogs::XFilePicker2> + createFilePicker(const css::uno::Reference<css::uno::XComponentContext>&) override; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |