summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2019-06-02 20:17:49 +0000
committerJan-Marek Glogowski <glogow@fbihome.de>2019-06-05 13:21:36 +0200
commitca69a1e17782d88580f2449e0252be52c26cae42 (patch)
tree49fcf3067b414fe940ee04e6b35f75a3bb115042 /vcl
parentb1a17c2d3f35ed801d745785fdeb7cf1ea2e1c60 (diff)
Qt5/KDE5 always use either Qt5 or KDE5 pickers
And use RunInMain for both SalInstances and for both picker types, as there is no reason to assume just the file and not the folder picker can be called from the non-GUI thread. Little drawback is the inclusion of Qt5FilePicker header in the Qt5Instance header, as Qt's enums aren't forward-declarable. Change-Id: Ie170d247a76134df9aff835393c71c9d6e907d32 Reviewed-on: https://gerrit.libreoffice.org/73416 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/qt5/Qt5Instance.hxx5
-rw-r--r--vcl/qt5/Qt5Instance.cxx18
-rw-r--r--vcl/unx/kde5/KDE5SalInstance.cxx25
-rw-r--r--vcl/unx/kde5/KDE5SalInstance.hxx20
4 files changed, 34 insertions, 34 deletions
diff --git a/vcl/inc/qt5/Qt5Instance.hxx b/vcl/inc/qt5/Qt5Instance.hxx
index 52b45b12d2b8..c87f3c93c1ac 100644
--- a/vcl/inc/qt5/Qt5Instance.hxx
+++ b/vcl/inc/qt5/Qt5Instance.hxx
@@ -33,6 +33,8 @@
#include <memory>
#include <vector>
+#include "Qt5FilePicker.hxx"
+
class QApplication;
class SalYieldMutex;
class SalFrame;
@@ -74,6 +76,9 @@ Q_SIGNALS:
void ImplRunInMainSignal();
void deleteObjectLaterSignal(QObject* pObject);
+protected:
+ virtual Qt5FilePicker* createPicker(QFileDialog::FileMode);
+
public:
explicit Qt5Instance(std::unique_ptr<QApplication>& pQApp, bool bUseCairo = false);
virtual ~Qt5Instance() override;
diff --git a/vcl/qt5/Qt5Instance.cxx b/vcl/qt5/Qt5Instance.cxx
index 0358ecd548a6..52eab795682e 100644
--- a/vcl/qt5/Qt5Instance.cxx
+++ b/vcl/qt5/Qt5Instance.cxx
@@ -394,18 +394,32 @@ void Qt5Instance::ProcessEvent(SalUserEvent aEvent)
aEvent.m_pFrame->CallCallback(aEvent.m_nEvent, aEvent.m_pData);
}
+Qt5FilePicker* Qt5Instance::createPicker(QFileDialog::FileMode eMode)
+{
+ if (!IsMainThread())
+ {
+ SolarMutexGuard g;
+ Qt5FilePicker* pPicker;
+ RunInMainThread(std::function([&, this]() { pPicker = createPicker(eMode); }));
+ assert(pPicker);
+ return pPicker;
+ }
+
+ return new Qt5FilePicker(eMode);
+}
+
css::uno::Reference<css::ui::dialogs::XFilePicker2>
Qt5Instance::createFilePicker(const css::uno::Reference<css::uno::XComponentContext>&)
{
return css::uno::Reference<css::ui::dialogs::XFilePicker2>(
- new Qt5FilePicker(QFileDialog::ExistingFile));
+ createPicker(QFileDialog::ExistingFile));
}
css::uno::Reference<css::ui::dialogs::XFolderPicker2>
Qt5Instance::createFolderPicker(const css::uno::Reference<css::uno::XComponentContext>&)
{
return css::uno::Reference<css::ui::dialogs::XFolderPicker2>(
- new Qt5FilePicker(QFileDialog::Directory));
+ createPicker(QFileDialog::Directory));
}
css::uno::Reference<css::uno::XInterface>
diff --git a/vcl/unx/kde5/KDE5SalInstance.cxx b/vcl/unx/kde5/KDE5SalInstance.cxx
index 63ce689518f5..e2bd75277d23 100644
--- a/vcl/unx/kde5/KDE5SalInstance.cxx
+++ b/vcl/unx/kde5/KDE5SalInstance.cxx
@@ -50,34 +50,23 @@ SalFrame* KDE5SalInstance::CreateFrame(SalFrame* pParent, SalFrameStyleFlags nSt
return pRet;
}
-uno::Reference<ui::dialogs::XFilePicker2>
-KDE5SalInstance::createFilePicker(const uno::Reference<uno::XComponentContext>& xMSF)
+Qt5FilePicker* KDE5SalInstance::createPicker(QFileDialog::FileMode eMode)
{
if (!IsMainThread())
{
SolarMutexGuard g;
- uno::Reference<ui::dialogs::XFilePicker2> xRet;
- RunInMainThread(
- std::function([&xRet, this, xMSF]() { xRet = this->createFilePicker(xMSF); }));
- assert(xRet);
- return xRet;
+ Qt5FilePicker* pPicker;
+ RunInMainThread(std::function([&, this]() { pPicker = createPicker(eMode); }));
+ assert(pPicker);
+ return pPicker;
}
// In order to insert custom controls, KDE5FilePicker currently relies on KFileWidget
// being used in the native file picker, which is only the case for KDE Plasma.
// Therefore, return the plain qt5 one in order to not lose custom controls.
if (Application::GetDesktopEnvironment() == "KDE5")
- {
- return uno::Reference<ui::dialogs::XFilePicker2>(
- new KDE5FilePicker(QFileDialog::ExistingFile));
- }
- return Qt5Instance::createFilePicker(xMSF);
-}
-
-uno::Reference<ui::dialogs::XFolderPicker2>
-KDE5SalInstance::createFolderPicker(const uno::Reference<uno::XComponentContext>& /*xMSF*/)
-{
- return uno::Reference<ui::dialogs::XFolderPicker2>(new KDE5FilePicker(QFileDialog::Directory));
+ return new KDE5FilePicker(eMode);
+ return Qt5Instance::createPicker(eMode);
}
extern "C" {
diff --git a/vcl/unx/kde5/KDE5SalInstance.hxx b/vcl/unx/kde5/KDE5SalInstance.hxx
index 11276be3f4ec..53993a5ecc34 100644
--- a/vcl/unx/kde5/KDE5SalInstance.hxx
+++ b/vcl/unx/kde5/KDE5SalInstance.hxx
@@ -21,23 +21,15 @@
#include <qt5/Qt5Instance.hxx>
-class QApplication;
-
-class KDE5SalInstance : public Qt5Instance
+class KDE5SalInstance final : public Qt5Instance
{
-public:
- explicit KDE5SalInstance(std::unique_ptr<QApplication>& pQApp);
-
- virtual bool hasNativeFileSelection() const override { return true; }
+ Qt5FilePicker* createPicker(QFileDialog::FileMode) override;
- virtual css::uno::Reference<css::ui::dialogs::XFolderPicker2>
- createFolderPicker(const css::uno::Reference<css::uno::XComponentContext>&) override;
+ SalFrame* CreateFrame(SalFrame* pParent, SalFrameStyleFlags nStyle) override;
+ bool hasNativeFileSelection() const override { return true; }
-private:
- virtual SalFrame* CreateFrame(SalFrame* pParent, SalFrameStyleFlags nStyle) override;
-
- virtual css::uno::Reference<css::ui::dialogs::XFilePicker2>
- createFilePicker(const css::uno::Reference<css::uno::XComponentContext>&) override;
+public:
+ explicit KDE5SalInstance(std::unique_ptr<QApplication>& pQApp);
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */