[Libreoffice-commits] core.git: Branch 'feature/qt5+kde5' - 3 commits - vcl/unx

Katarina Behrens Katarina.Behrens at cib.de
Thu Jun 7 12:42:35 UTC 2018


 vcl/unx/kde5/KDE5FilePicker.cxx  |    4 ---
 vcl/unx/kde5/KDE5FilePicker.hxx  |   19 ++++++++++++++++--
 vcl/unx/kde5/KDE5FilePicker2.cxx |   40 +++++++++++++++++++++++++++++++++------
 vcl/unx/kde5/KDE5SalInstance.cxx |   10 +++++++--
 vcl/unx/kde5/KDE5SalInstance.hxx |    3 ++
 5 files changed, 62 insertions(+), 14 deletions(-)

New commits:
commit 9cec4e710b11eff5e258d2a4c631c6a9989ddb6d
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date:   Thu Jun 7 14:20:07 2018 +0200

    Basic native folder picker
    
    Change-Id: I1b77d7a1c8a4a3581554fb5c481b7d9039497ced

diff --git a/vcl/unx/kde5/KDE5FilePicker.hxx b/vcl/unx/kde5/KDE5FilePicker.hxx
index 3a02c770eda6..d303ba30a6ac 100644
--- a/vcl/unx/kde5/KDE5FilePicker.hxx
+++ b/vcl/unx/kde5/KDE5FilePicker.hxx
@@ -25,6 +25,7 @@
 #include <com/sun/star/lang/XInitialization.hpp>
 #include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
+#include <com/sun/star/ui/dialogs/XFolderPicker2.hpp>
 #include <com/sun/star/uno/XComponentContext.hpp>
 
 #include <osl/conditn.hxx>
@@ -37,13 +38,15 @@
 #include <QtCore/QString>
 #include <QtCore/QStringList>
 #include <QtCore/QHash>
+#include <QtWidgets/QFileDialog>
 
 class QFileDialog;
 class QGridLayout;
 class QWidget;
 
 typedef ::cppu::WeakComponentImplHelper<css::ui::dialogs::XFilePicker3,
-                                        css::ui::dialogs::XFilePickerControlAccess
+                                        css::ui::dialogs::XFilePickerControlAccess,
+                                        css::ui::dialogs::XFolderPicker2
                                         // TODO css::ui::dialogs::XFilePreview
                                         ,
                                         css::lang::XInitialization, css::lang::XServiceInfo>
@@ -80,7 +83,7 @@ protected:
     bool allowRemoteUrls;
 
 public:
-    explicit KDE5FilePicker(const css::uno::Reference<css::uno::XComponentContext>&);
+    explicit KDE5FilePicker(QFileDialog::FileMode);
     virtual ~KDE5FilePicker() override;
 
     void enableFolderMode();
@@ -121,6 +124,10 @@ public:
     virtual void SAL_CALL setLabel(sal_Int16 nControlId, const OUString& rLabel) override;
     virtual OUString SAL_CALL getLabel(sal_Int16 nControlId) override;
 
+    // XFolderPicker stuff
+    virtual OUString SAL_CALL getDirectory() override;
+    virtual void SAL_CALL setDescription(const OUString& rDescription) override;
+
     /* TODO XFilePreview
 
     virtual css::uno::Sequence< sal_Int16 > SAL_CALL getSupportedImageFormats(  );
diff --git a/vcl/unx/kde5/KDE5FilePicker2.cxx b/vcl/unx/kde5/KDE5FilePicker2.cxx
index 93e6d503d32b..759b2fccf790 100644
--- a/vcl/unx/kde5/KDE5FilePicker2.cxx
+++ b/vcl/unx/kde5/KDE5FilePicker2.cxx
@@ -77,7 +77,7 @@ uno::Sequence<OUString> FilePicker_getSupportedServiceNames()
 
 // KDE5FilePicker
 
-KDE5FilePicker::KDE5FilePicker(const uno::Reference<uno::XComponentContext>&)
+KDE5FilePicker::KDE5FilePicker(QFileDialog::FileMode eMode)
     : KDE5FilePicker_Base(_helperMutex)
     , _dialog(new QFileDialog(nullptr, {}, QDir::homePath()))
     , _extraControls(new QWidget)
@@ -94,6 +94,7 @@ KDE5FilePicker::KDE5FilePicker(const uno::Reference<uno::XComponentContext>&)
         QStringLiteral("webdavs"),
         QStringLiteral("smb"),
     });
+    _dialog->setFileMode(eMode);
 
     setMultiSelectionMode(false);
 
@@ -231,6 +232,10 @@ OUString SAL_CALL KDE5FilePicker::getLabel(sal_Int16 controlId)
     return label;
 }
 
+OUString SAL_CALL KDE5FilePicker::getDirectory() { return OUString(); }
+
+void SAL_CALL KDE5FilePicker::setDescription(const OUString&) {}
+
 void KDE5FilePicker::addCustomControl(sal_Int16 controlId)
 {
     const char* resId = nullptr;
diff --git a/vcl/unx/kde5/KDE5SalInstance.cxx b/vcl/unx/kde5/KDE5SalInstance.cxx
index ac6173e13550..37021cbe9315 100644
--- a/vcl/unx/kde5/KDE5SalInstance.cxx
+++ b/vcl/unx/kde5/KDE5SalInstance.cxx
@@ -49,9 +49,15 @@ 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*/)
 {
-    return uno::Reference<ui::dialogs::XFilePicker2>(new KDE5FilePicker(xMSF));
+    return uno::Reference<ui::dialogs::XFilePicker2>(new KDE5FilePicker(QFileDialog::ExistingFile));
+}
+
+uno::Reference<ui::dialogs::XFolderPicker2>
+KDE5SalInstance::createFolderPicker(const uno::Reference<uno::XComponentContext>& /*xMSF*/)
+{
+    return uno::Reference<ui::dialogs::XFolderPicker2>(new KDE5FilePicker(QFileDialog::Directory));
 }
 
 bool KDE5SalInstance::IsMainThread() const { return qApp->thread() == QThread::currentThread(); }
diff --git a/vcl/unx/kde5/KDE5SalInstance.hxx b/vcl/unx/kde5/KDE5SalInstance.hxx
index cc7d7ad7cbce..0bf30ab8b235 100644
--- a/vcl/unx/kde5/KDE5SalInstance.hxx
+++ b/vcl/unx/kde5/KDE5SalInstance.hxx
@@ -36,6 +36,9 @@ public:
     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;
 };
 
commit d9e66bd17cbb6f377cfe9994c1ac2c9e4c18f928
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date:   Thu Jun 7 13:26:59 2018 +0200

    Implement setDisplayDirectory, signal+slot
    
    Change-Id: Ieb3fb6bb9afa8cddbfd7f14ddfb36faebd524701

diff --git a/vcl/unx/kde5/KDE5FilePicker.cxx b/vcl/unx/kde5/KDE5FilePicker.cxx
index 3968a0f686a6..9891439ae0ee 100644
--- a/vcl/unx/kde5/KDE5FilePicker.cxx
+++ b/vcl/unx/kde5/KDE5FilePicker.cxx
@@ -53,8 +53,6 @@ KDE5FilePicker::~KDE5FilePicker()
 
 void KDE5FilePicker::setDefaultName(const QString& name) { _dialog->selectUrl(QUrl(name)); }
 
-void KDE5FilePicker::setDisplayDirectory(const QString& dir) { _dialog->selectUrl(QUrl(dir)); }
-
 QString KDE5FilePicker::getDisplayDirectory() const { return _dialog->directoryUrl().url(); }
 
 QList<QUrl> KDE5FilePicker::getSelectedFiles() const { return _dialog->selectedUrls(); }
diff --git a/vcl/unx/kde5/KDE5FilePicker.hxx b/vcl/unx/kde5/KDE5FilePicker.hxx
index 6078a53b0f98..3a02c770eda6 100644
--- a/vcl/unx/kde5/KDE5FilePicker.hxx
+++ b/vcl/unx/kde5/KDE5FilePicker.hxx
@@ -166,9 +166,11 @@ protected:
 
 Q_SIGNALS:
     void setTitleSignal(const OUString& rTitle);
+    void setDisplayDirectorySignal(const OUString& rDir);
 
 private Q_SLOTS:
     void setTitleSlot(const OUString& rTitle) { return setTitle(rTitle); }
+    void setDisplayDirectorySlot(const OUString& rDir) { return setDisplayDirectory(rDir); }
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde5/KDE5FilePicker2.cxx b/vcl/unx/kde5/KDE5FilePicker2.cxx
index 8df045b3aa59..93e6d503d32b 100644
--- a/vcl/unx/kde5/KDE5FilePicker2.cxx
+++ b/vcl/unx/kde5/KDE5FilePicker2.cxx
@@ -101,6 +101,9 @@ KDE5FilePicker::KDE5FilePicker(const uno::Reference<uno::XComponentContext>&)
     connect(_dialog, &QFileDialog::fileSelected, this, &KDE5FilePicker::selectionChanged);
     connect(this, &KDE5FilePicker::setTitleSignal /*(const OUString&)*/, this,
             &KDE5FilePicker::setTitleSlot /*(const OUString&)*/, Qt::BlockingQueuedConnection);
+    connect(this, &KDE5FilePicker::setDisplayDirectorySignal /*(const OUString&)*/, this,
+            &KDE5FilePicker::setDisplayDirectorySlot /*(const OUString&)*/,
+            Qt::BlockingQueuedConnection);
 
     qApp->installEventFilter(this);
     setMultiSelectionMode(false);
@@ -146,7 +149,16 @@ void SAL_CALL KDE5FilePicker::setMultiSelectionMode(sal_Bool multiSelect) {}
 
 void SAL_CALL KDE5FilePicker::setDefaultName(const OUString& name) {}
 
-void SAL_CALL KDE5FilePicker::setDisplayDirectory(const OUString& dir) {}
+void SAL_CALL KDE5FilePicker::setDisplayDirectory(const OUString& dir)
+{
+    if (qApp->thread() != QThread::currentThread())
+    {
+        SolarMutexReleaser aReleaser;
+        return Q_EMIT setDisplayDirectorySignal(dir);
+    }
+
+    _dialog->selectUrl(QUrl(toQString(dir)));
+}
 
 OUString SAL_CALL KDE5FilePicker::getDisplayDirectory()
 {
commit a1725517d644ba4bb9f91c74e1e54e8f3efe4d1b
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date:   Thu Jun 7 12:47:35 2018 +0200

    Add setTitle functionality, signal+slot
    
    Change-Id: Ib79837ff08cabf8a27b6d154529399a5965ab148

diff --git a/vcl/unx/kde5/KDE5FilePicker.cxx b/vcl/unx/kde5/KDE5FilePicker.cxx
index 3e1387da7fd2..3968a0f686a6 100644
--- a/vcl/unx/kde5/KDE5FilePicker.cxx
+++ b/vcl/unx/kde5/KDE5FilePicker.cxx
@@ -46,8 +46,6 @@ KDE5FilePicker::~KDE5FilePicker()
     delete _dialog;
 }
 
-//void KDE5FilePicker::setTitle(const QString& title) { _dialog->setWindowTitle(title); }
-
 /*void KDE5FilePicker::setMultiSelectionMode(bool multiSelect)
 {
     _dialog->setFileMode(multiSelect ? QFileDialog::ExistingFiles : QFileDialog::ExistingFile);
diff --git a/vcl/unx/kde5/KDE5FilePicker.hxx b/vcl/unx/kde5/KDE5FilePicker.hxx
index ea18b3298ed4..6078a53b0f98 100644
--- a/vcl/unx/kde5/KDE5FilePicker.hxx
+++ b/vcl/unx/kde5/KDE5FilePicker.hxx
@@ -163,6 +163,12 @@ private:
 
 protected:
     bool eventFilter(QObject* watched, QEvent* event) override;
+
+Q_SIGNALS:
+    void setTitleSignal(const OUString& rTitle);
+
+private Q_SLOTS:
+    void setTitleSlot(const OUString& rTitle) { return setTitle(rTitle); }
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde5/KDE5FilePicker2.cxx b/vcl/unx/kde5/KDE5FilePicker2.cxx
index e505791cad03..8df045b3aa59 100644
--- a/vcl/unx/kde5/KDE5FilePicker2.cxx
+++ b/vcl/unx/kde5/KDE5FilePicker2.cxx
@@ -31,16 +31,15 @@
 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
 
 #include <osl/mutex.hxx>
-
-#include <fpicker/strings.hrc>
-
 #include "FPServiceInfo.hxx"
 
 #undef Region
 
 #include <unx/geninst.h>
+#include <qt5/Qt5Tools.hxx>
 
 #include <QtCore/QDebug>
+#include <QtCore/QThread>
 #include <QtCore/QUrl>
 #include <QtGui/QClipboard>
 #include <QtGui/QWindow>
@@ -50,6 +49,7 @@
 #include <QtWidgets/QWidget>
 #include <QtWidgets/QApplication>
 
+#include <fpicker/strings.hrc>
 #include <strings.hrc>
 
 using namespace ::com::sun::star;
@@ -99,6 +99,8 @@ KDE5FilePicker::KDE5FilePicker(const uno::Reference<uno::XComponentContext>&)
 
     connect(_dialog, &QFileDialog::filterSelected, this, &KDE5FilePicker::filterChanged);
     connect(_dialog, &QFileDialog::fileSelected, this, &KDE5FilePicker::selectionChanged);
+    connect(this, &KDE5FilePicker::setTitleSignal /*(const OUString&)*/, this,
+            &KDE5FilePicker::setTitleSlot /*(const OUString&)*/, Qt::BlockingQueuedConnection);
 
     qApp->installEventFilter(this);
     setMultiSelectionMode(false);
@@ -117,7 +119,16 @@ void SAL_CALL KDE5FilePicker::removeFilePickerListener(const uno::Reference<XFil
     m_xListener.clear();
 }
 
-void SAL_CALL KDE5FilePicker::setTitle(const OUString& title) {}
+void SAL_CALL KDE5FilePicker::setTitle(const OUString& title)
+{
+    if (qApp->thread() != QThread::currentThread())
+    {
+        SolarMutexReleaser aReleaser;
+        return Q_EMIT setTitleSignal(title);
+    }
+
+    _dialog->setWindowTitle(toQString(title));
+}
 
 sal_Int16 SAL_CALL KDE5FilePicker::execute()
 {


More information about the Libreoffice-commits mailing list