[Libreoffice-commits] core.git: 9 commits - vcl/headless vcl/inc vcl/qt5 vcl/unx

Katarina Behrens Katarina.Behrens at cib.de
Tue Jul 3 12:18:32 UTC 2018


 vcl/headless/svpgdi.cxx          |   29 +++++++++----
 vcl/inc/headless/svpgdi.hxx      |    6 ++
 vcl/inc/qt5/Qt5Frame.hxx         |    1 
 vcl/qt5/Qt5Frame.cxx             |   12 +++++
 vcl/qt5/Qt5Widget.cxx            |   17 +++++++-
 vcl/unx/kde5/KDE5FilePicker.hxx  |    6 ++
 vcl/unx/kde5/KDE5FilePicker2.cxx |   81 ++++++++++++++++++++++++++++-----------
 vcl/unx/kde5/KDE5SalGraphics.cxx |   38 +++++++++++++-----
 vcl/unx/kde5/KDE5SalGraphics.hxx |    6 ++
 9 files changed, 150 insertions(+), 46 deletions(-)

New commits:
commit 63f0dbdd61df0bf390d201b4ea4215b0077a2f9d
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date:   Mon Jul 2 11:41:10 2018 +0200

    Draw button focus so that it doesn't obscure the actual button
    
    Change-Id: I0df51b8dfd75dd966639d0893c379f2038c949ff

diff --git a/vcl/unx/kde5/KDE5SalGraphics.cxx b/vcl/unx/kde5/KDE5SalGraphics.cxx
index 75e7c8664ab4..9377a134fdc4 100644
--- a/vcl/unx/kde5/KDE5SalGraphics.cxx
+++ b/vcl/unx/kde5/KDE5SalGraphics.cxx
@@ -81,6 +81,7 @@ void QImage2BitmapBuffer(QImage* pImg, BitmapBuffer* pBuf)
 KDE5SalGraphics::KDE5SalGraphics()
     : SvpSalGraphics()
 {
+    initStyles();
 }
 
 bool KDE5SalGraphics::IsNativeControlSupported(ControlType type, ControlPart part)
@@ -218,12 +219,6 @@ bool KDE5SalGraphics::drawNativeControl(ControlType type, ControlPart part,
         case ControlType::Tooltip:
             m_image->fill(QApplication::palette().color(QPalette::ToolTipBase).rgb());
             break;
-        case ControlType::Pushbutton:
-            if (nControlState & ControlState::FOCUSED)
-                m_image->fill(QApplication::palette().color(QPalette::Highlight).rgb());
-            else
-                m_image->fill(QApplication::palette().color(QPalette::Button).rgb());
-            break;
         case ControlType::Scrollbar:
             if ((part == ControlPart::DrawBackgroundVert)
                 || (part == ControlPart::DrawBackgroundHorz))
@@ -241,9 +236,21 @@ bool KDE5SalGraphics::drawNativeControl(ControlType type, ControlPart part,
 
     if (type == ControlType::Pushbutton)
     {
-        QStyleOptionButton option;
-        draw(QStyle::CE_PushButton, &option, m_image.get(),
-             vclStateValue2StateFlag(nControlState, value));
+        if (part == ControlPart::Entire)
+        {
+            QStyleOptionButton option;
+            draw(QStyle::CE_PushButton, &option, m_image.get(),
+                 vclStateValue2StateFlag(nControlState, value));
+        }
+        else if (part == ControlPart::Focus)
+        {
+            QStyleOptionButton option;
+            option.state = QStyle::State_HasFocus;
+            option.rect = m_image->rect();
+            QPainter painter(m_image.get());
+            m_focusedButton->style()->drawControl(QStyle::CE_PushButton, &option, &painter,
+                                                  m_focusedButton.get());
+        }
     }
     else if (type == ControlType::Menubar)
     {
@@ -991,4 +998,15 @@ bool KDE5SalGraphics::hitTestNativeControl(ControlType nType, ControlPart nPart,
     return false;
 }
 
+void KDE5SalGraphics::initStyles()
+{
+    // button focus
+    m_focusedButton.reset(new QPushButton());
+    QString aHighlightColor = QApplication::palette().color(QPalette::Highlight).name();
+    QString focusStyleSheet("background-color: rgb(0,0,0,0%); border: 1px; border-radius: 2px; "
+                            "border-color: %1; border-style:solid;");
+    focusStyleSheet.replace("%1", aHighlightColor);
+    m_focusedButton->setStyleSheet(focusStyleSheet);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde5/KDE5SalGraphics.hxx b/vcl/unx/kde5/KDE5SalGraphics.hxx
index 77121459e8be..e70159ba9568 100644
--- a/vcl/unx/kde5/KDE5SalGraphics.hxx
+++ b/vcl/unx/kde5/KDE5SalGraphics.hxx
@@ -25,6 +25,7 @@
 #include <headless/svpgdi.hxx>
 
 #include <QtGui/QImage>
+#include <QtWidgets/QPushButton>
 
 class KDE5SalFrame;
 
@@ -49,6 +50,11 @@ public:
 
     std::unique_ptr<QImage> m_image;
     QRect lastPopupRect;
+
+private:
+    void initStyles();
+
+    std::unique_ptr<QPushButton> m_focusedButton;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit dc8f347f5fed638f07ef88246950460e3ed284d1
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date:   Thu Jun 28 13:42:00 2018 +0200

    Use cairo's OVER operator to preserve transparency
    
    Change-Id: I1afae266a5308fa0dbf2488777ddb963e99199c7

diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index 9163d8cf8133..de1145a6cc7c 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -35,8 +35,6 @@
 #include <basegfx/polygon/b2dpolygon.hxx>
 #include <basegfx/polygon/b2dpolygontools.hxx>
 
-#include <cairo.h>
-
 #if ENABLE_CAIRO_CANVAS
 #   if defined CAIRO_VERSION && CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 10, 0)
 #      define CAIRO_OPERATOR_DIFFERENCE (static_cast<cairo_operator_t>(23))
@@ -1134,8 +1132,8 @@ void SvpSalGraphics::copyArea( long nDestX,
     copyBits(aTR, this);
 }
 
-static basegfx::B2DRange renderSource(cairo_t* cr, const SalTwoRect& rTR,
-                                          cairo_surface_t* source)
+static basegfx::B2DRange renderWithOperator(cairo_t* cr, const SalTwoRect& rTR,
+                                          cairo_surface_t* source, cairo_operator_t eOperator = CAIRO_OPERATOR_SOURCE)
 {
     cairo_rectangle(cr, rTR.mnDestX, rTR.mnDestY, rTR.mnDestWidth, rTR.mnDestHeight);
 
@@ -1160,24 +1158,35 @@ static basegfx::B2DRange renderSource(cairo_t* cr, const SalTwoRect& rTR,
         cairo_pattern_set_extend(sourcepattern, CAIRO_EXTEND_REPEAT);
         cairo_pattern_set_filter(sourcepattern, CAIRO_FILTER_NEAREST);
     }
-    cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
+    cairo_set_operator(cr, eOperator);
     cairo_paint(cr);
     cairo_restore(cr);
 
     return extents;
 }
 
-void SvpSalGraphics::copySource( const SalTwoRect& rTR,
-                                 cairo_surface_t* source )
+static basegfx::B2DRange renderSource(cairo_t* cr, const SalTwoRect& rTR,
+                                          cairo_surface_t* source)
+{
+    return renderWithOperator(cr, rTR, source, CAIRO_OPERATOR_SOURCE);
+}
+
+void SvpSalGraphics::copyWithOperator( const SalTwoRect& rTR, cairo_surface_t* source,
+                                 cairo_operator_t eOp )
 {
     cairo_t* cr = getCairoContext(false);
     clipRegion(cr);
 
-    basegfx::B2DRange extents = renderSource(cr, rTR, source);
+    basegfx::B2DRange extents = renderWithOperator(cr, rTR, source, eOp);
 
     releaseCairoContext(cr, false, extents);
 }
 
+void SvpSalGraphics::copySource( const SalTwoRect& rTR, cairo_surface_t* source )
+{
+   copyWithOperator(rTR, source, CAIRO_OPERATOR_SOURCE);
+}
+
 void SvpSalGraphics::copyBits( const SalTwoRect& rTR,
                                SalGraphics*      pSrcGraphics )
 {
@@ -1224,10 +1233,10 @@ void SvpSalGraphics::drawBitmap(const SalTwoRect& rTR, const SalBitmap& rSourceB
     copySource(rTR, source);
 }
 
-void SvpSalGraphics::drawBitmap(const SalTwoRect& rTR, BitmapBuffer* pBuffer)
+void SvpSalGraphics::drawBitmap(const SalTwoRect& rTR, BitmapBuffer* pBuffer, cairo_operator_t eOp)
 {
     cairo_surface_t* source = createCairoSurface( pBuffer );
-    copySource(rTR, source);
+    copyWithOperator(rTR, source, eOp);
 }
 
 void SvpSalGraphics::drawBitmap( const SalTwoRect& rTR,
diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx
index 860eacec7cbf..6571d21cf89d 100644
--- a/vcl/inc/headless/svpgdi.hxx
+++ b/vcl/inc/headless/svpgdi.hxx
@@ -24,6 +24,7 @@
 #include <vcl/sysdata.hxx>
 #include <vcl/metric.hxx>
 #include <config_cairo_canvas.h>
+#include <cairo.h>
 
 #include <salgdi.hxx>
 #include <sallayout.hxx>
@@ -111,6 +112,8 @@ public:
 private:
     void invert(const basegfx::B2DPolygon &rPoly, SalInvert nFlags);
     void copySource(const SalTwoRect& rTR, cairo_surface_t* source);
+    void copyWithOperator(const SalTwoRect& rTR, cairo_surface_t* source,
+                          cairo_operator_t eOp = CAIRO_OPERATOR_SOURCE);
     void setupPolyPolygon(cairo_t* cr, const basegfx::B2DPolyPolygon& rPolyPoly);
     void applyColor(cairo_t *cr, Color rColor);
     void drawPolyPolygon(const basegfx::B2DPolyPolygon& rPolyPoly);
@@ -225,7 +228,8 @@ public:
     virtual void            drawBitmap( const SalTwoRect& rPosAry,
                                         const SalBitmap& rSalBitmap ) override;
     void                    drawBitmap( const SalTwoRect& rPosAry,
-                                        BitmapBuffer* pBuffer );
+                                        BitmapBuffer* pBuffer,
+                                        cairo_operator_t eOp );
     virtual void            drawBitmap( const SalTwoRect& rPosAry,
                                         const SalBitmap& rSalBitmap,
                                         const SalBitmap& rTransparentBitmap ) override;
diff --git a/vcl/unx/kde5/KDE5SalGraphics.cxx b/vcl/unx/kde5/KDE5SalGraphics.cxx
index 6ec1e6e385ea..75e7c8664ab4 100644
--- a/vcl/unx/kde5/KDE5SalGraphics.cxx
+++ b/vcl/unx/kde5/KDE5SalGraphics.cxx
@@ -622,7 +622,7 @@ bool KDE5SalGraphics::drawNativeControl(ControlType type, ControlPart part,
     QImage2BitmapBuffer(m_image.get(), pBuffer);
     SalTwoRect aTR(0, 0, m_image.get()->width(), m_image.get()->height(), rControlRegion.getX(),
                    rControlRegion.getY(), rControlRegion.GetWidth(), rControlRegion.GetHeight());
-    drawBitmap(aTR, pBuffer);
+    drawBitmap(aTR, pBuffer, CAIRO_OPERATOR_OVER);
 
     delete localClipRegion;
     return returnVal;
commit c4a06289ca549290bfd2ba9e16236e430b4c53fe
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date:   Wed Jun 27 10:41:03 2018 +0200

    Implement native modality for modal dialogs
    
    instead of hack with hiding the window and showing it again (otherwise
    modality change has no effect and worse yet, weird things happen)
    it would be much easier to use QDialog
    
    Change-Id: Ie7029ca66380495c4aad246d02f4b96cb55eb01e

diff --git a/vcl/inc/qt5/Qt5Frame.hxx b/vcl/inc/qt5/Qt5Frame.hxx
index 268441ea688a..96446c28a358 100644
--- a/vcl/inc/qt5/Qt5Frame.hxx
+++ b/vcl/inc/qt5/Qt5Frame.hxx
@@ -107,6 +107,7 @@ public:
     virtual void GetClientSize(long& rWidth, long& rHeight) override;
     virtual void GetWorkArea(tools::Rectangle& rRect) override;
     virtual SalFrame* GetParent() const override;
+    virtual void SetModal(bool bModal) override;
     virtual void SetWindowState(const SalFrameState* pState) override;
     virtual bool GetWindowState(SalFrameState* pState) override;
     virtual void ShowFullScreen(bool bFullScreen, sal_Int32 nDisplay) override;
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index 9c5b8edbc5be..b47b64ab1cb8 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -345,6 +345,18 @@ void Qt5Frame::GetWorkArea(tools::Rectangle& rRect)
 
 SalFrame* Qt5Frame::GetParent() const { return m_pParent; }
 
+void Qt5Frame::SetModal(bool bModal)
+{
+    if (m_pQWidget->isWindow())
+    {
+        // modality change is only effective if the window is hidden
+        m_pQWidget->windowHandle()->hide();
+        m_pQWidget->windowHandle()->setModality(bModal ? Qt::WindowModal : Qt::NonModal);
+        // and shown again
+        m_pQWidget->windowHandle()->show();
+    }
+}
+
 void Qt5Frame::SetWindowState(const SalFrameState* pState)
 {
     if (!m_pQWidget->isWindow() || !pState || isChild(true, false))
commit b1a5ce7d1db7b654ad49b8865ecdf482ef05e2b7
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date:   Tue Jun 26 11:48:52 2018 +0200

    Traversing dialog controls backwards (Shift-Tab) works now
    
    Change-Id: If0e8d7307dd37436751e524d7ed24e89d5b72db3

diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx
index 3e3448381946..c4d38264782c 100644
--- a/vcl/qt5/Qt5Widget.cxx
+++ b/vcl/qt5/Qt5Widget.cxx
@@ -257,6 +257,10 @@ static sal_uInt16 GetKeyCode(int keyval)
                 nCode = KEY_ESCAPE;
                 break;
             case Qt::Key_Tab:
+            // oddly enough, Qt doesn't send Shift-Tab event as 'Tab key pressed with Shift
+            // modifier' but as 'Backtab key pressed' (while its modifier bits are still
+            // set to Shift) -- so let's map both Key_Tab and Key_Backtab to VCL's KEY_TAB
+            case Qt::Key_Backtab:
                 nCode = KEY_TAB;
                 break;
             case Qt::Key_Backspace:
commit e3ac0b04324b32a58c6ce94b413de3c3ea2fa9e0
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date:   Fri Jun 22 15:53:51 2018 +0200

    Ignore closeEvent if user has vetoed closing the frame
    
    Change-Id: Ib86ec0d297e23c02ad50ce1044859e029eae2ba9

diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx
index 8c62280d3f99..3e3448381946 100644
--- a/vcl/qt5/Qt5Widget.cxx
+++ b/vcl/qt5/Qt5Widget.cxx
@@ -199,9 +199,18 @@ void VclQtMixinBase::mixinShowEvent(QShowEvent*)
     m_pFrame->CallCallback(SalEvent::Paint, &aPaintEvt);
 }
 
-void VclQtMixinBase::mixinCloseEvent(QCloseEvent* /*pEvent*/)
+void VclQtMixinBase::mixinCloseEvent(QCloseEvent* pEvent)
 {
-    m_pFrame->CallCallback(SalEvent::Close, nullptr);
+    bool bRet = false;
+    bRet = m_pFrame->CallCallback(SalEvent::Close, nullptr);
+
+    if (bRet)
+        pEvent->accept();
+    // SalEvent::Close returning false may mean that user has vetoed
+    // closing the frame ("you have unsaved changes" dialog for example)
+    // We should't process the event in such case
+    else
+        pEvent->ignore();
 }
 
 static sal_uInt16 GetKeyCode(int keyval)
commit af74bf268f3cdcd86931d033eaae9ee5ee521c8c
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date:   Fri Jun 22 15:20:34 2018 +0200

    Rearrange and annotate funcs by XInterface
    
    Change-Id: Ie429074fdbe8fb4e28b1af47486bc70c5f8070e8

diff --git a/vcl/unx/kde5/KDE5FilePicker2.cxx b/vcl/unx/kde5/KDE5FilePicker2.cxx
index d4e6d507dd79..123df3a09118 100644
--- a/vcl/unx/kde5/KDE5FilePicker2.cxx
+++ b/vcl/unx/kde5/KDE5FilePicker2.cxx
@@ -105,17 +105,33 @@ KDE5FilePicker::KDE5FilePicker(QFileDialog::FileMode eMode)
 
     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);
-    connect(this, &KDE5FilePicker::setDefaultNameSignal, this, &KDE5FilePicker::setDefaultNameSlot,
+
+    // XExecutableDialog
+    connect(this, &KDE5FilePicker::setTitleSignal, this, &KDE5FilePicker::setTitleSlot,
             Qt::BlockingQueuedConnection);
-    connect(this, &KDE5FilePicker::setDisplayDirectorySignal /*(const OUString&)*/, this,
-            &KDE5FilePicker::setDisplayDirectorySlot /*(const OUString&)*/,
+    // XFilePicker
+    connect(this, &KDE5FilePicker::setMultiSelectionSignal, this,
+            &KDE5FilePicker::setMultiSelectionSlot, Qt::BlockingQueuedConnection);
+    connect(this, &KDE5FilePicker::setDefaultNameSignal, this, &KDE5FilePicker::setDefaultNameSlot,
             Qt::BlockingQueuedConnection);
+    connect(this, &KDE5FilePicker::setDisplayDirectorySignal, this,
+            &KDE5FilePicker::setDisplayDirectorySlot, Qt::BlockingQueuedConnection);
     connect(this, &KDE5FilePicker::getDisplayDirectorySignal, this,
             &KDE5FilePicker::getDisplayDirectorySlot, Qt::BlockingQueuedConnection);
-    connect(this, &KDE5FilePicker::setMultiSelectionSignal, this,
-            &KDE5FilePicker::setMultiSelectionSlot, Qt::BlockingQueuedConnection);
+    // XFolderPicker
+    connect(this, &KDE5FilePicker::getDirectorySignal, this, &KDE5FilePicker::getDirectorySlot,
+            Qt::BlockingQueuedConnection);
+    // XFilterManager
+    connect(this, &KDE5FilePicker::appendFilterSignal, this, &KDE5FilePicker::appendFilterSlot,
+            Qt::BlockingQueuedConnection);
+    connect(this, &KDE5FilePicker::setCurrentFilterSignal, this,
+            &KDE5FilePicker::setCurrentFilterSlot, Qt::BlockingQueuedConnection);
+    connect(this, &KDE5FilePicker::getCurrentFilterSignal, this,
+            &KDE5FilePicker::getCurrentFilterSlot, Qt::BlockingQueuedConnection);
+    // XFilterGroupManager
+    connect(this, &KDE5FilePicker::appendFilterGroupSignal, this,
+            &KDE5FilePicker::appendFilterGroupSlot, Qt::BlockingQueuedConnection);
+    // XFilePickerControlAccess
     connect(this, &KDE5FilePicker::setValueSignal, this, &KDE5FilePicker::setValueSlot,
             Qt::BlockingQueuedConnection);
     connect(this, &KDE5FilePicker::getValueSignal, this, &KDE5FilePicker::getValueSlot,
@@ -126,18 +142,9 @@ KDE5FilePicker::KDE5FilePicker(QFileDialog::FileMode eMode)
             Qt::BlockingQueuedConnection);
     connect(this, &KDE5FilePicker::enableControlSignal, this, &KDE5FilePicker::enableControlSlot,
             Qt::BlockingQueuedConnection);
-    connect(this, &KDE5FilePicker::appendFilterSignal, this, &KDE5FilePicker::appendFilterSlot,
-            Qt::BlockingQueuedConnection);
-    connect(this, &KDE5FilePicker::appendFilterGroupSignal, this,
-            &KDE5FilePicker::appendFilterGroupSlot, Qt::BlockingQueuedConnection);
-    connect(this, &KDE5FilePicker::setCurrentFilterSignal, this,
-            &KDE5FilePicker::setCurrentFilterSlot, Qt::BlockingQueuedConnection);
-    connect(this, &KDE5FilePicker::getCurrentFilterSignal, this,
-            &KDE5FilePicker::getCurrentFilterSlot, Qt::BlockingQueuedConnection);
+    // XFilePicker2
     connect(this, &KDE5FilePicker::getSelectedFilesSignal, this,
             &KDE5FilePicker::getSelectedFilesSlot, Qt::BlockingQueuedConnection);
-    connect(this, &KDE5FilePicker::getDirectorySignal, this,
-            &KDE5FilePicker::getDirectorySlot, Qt::BlockingQueuedConnection);
 
     qApp->installEventFilter(this);
 }
@@ -161,6 +168,7 @@ void SAL_CALL KDE5FilePicker::removeFilePickerListener(const uno::Reference<XFil
     m_xListener.clear();
 }
 
+// XExecutableDialog
 void SAL_CALL KDE5FilePicker::setTitle(const OUString& title)
 {
     if (qApp->thread() != QThread::currentThread())
@@ -184,6 +192,7 @@ sal_Int16 SAL_CALL KDE5FilePicker::execute()
     return _dialog->exec() == QFileDialog::Accepted ? 1 : 0;
 }
 
+// XFilePicker
 void SAL_CALL KDE5FilePicker::setMultiSelectionMode(sal_Bool multiSelect)
 {
     if (qApp->thread() != QThread::currentThread())
@@ -240,6 +249,7 @@ uno::Sequence<OUString> SAL_CALL KDE5FilePicker::getFiles()
     return seq;
 }
 
+// XFilePicker2
 uno::Sequence<OUString> SAL_CALL KDE5FilePicker::getSelectedFiles()
 {
     if (qApp->thread() != QThread::currentThread())
@@ -260,6 +270,7 @@ uno::Sequence<OUString> SAL_CALL KDE5FilePicker::getSelectedFiles()
     return seq;
 }
 
+// XFilterManager
 void SAL_CALL KDE5FilePicker::appendFilter(const OUString& title, const OUString& filter)
 {
     if (qApp->thread() != QThread::currentThread())
@@ -312,6 +323,7 @@ OUString SAL_CALL KDE5FilePicker::getCurrentFilter()
     return filter;
 }
 
+// XFilterGroupManager
 void SAL_CALL KDE5FilePicker::appendFilterGroup(const OUString& rGroupTitle,
                                                 const uno::Sequence<beans::StringPair>& filters)
 {
@@ -329,6 +341,7 @@ void SAL_CALL KDE5FilePicker::appendFilterGroup(const OUString& rGroupTitle,
     }
 }
 
+// XFilePickerControlAccess
 void SAL_CALL KDE5FilePicker::setValue(sal_Int16 controlId, sal_Int16 nControlAction,
                                        const uno::Any& value)
 {
@@ -433,6 +446,7 @@ OUString SAL_CALL KDE5FilePicker::getLabel(sal_Int16 controlId)
     return label;
 }
 
+// XFolderPicker
 OUString SAL_CALL KDE5FilePicker::getDirectory()
 {
     if (qApp->thread() != QThread::currentThread())
@@ -546,6 +560,7 @@ OUString KDE5FilePicker::implGetDirectory()
     return dir;
 }
 
+// XInitialization
 void SAL_CALL KDE5FilePicker::initialize(const uno::Sequence<uno::Any>& args)
 {
     // parameter checking
@@ -665,11 +680,13 @@ void SAL_CALL KDE5FilePicker::initialize(const uno::Sequence<uno::Any>& args)
     setTitle(VclResId(saveDialog ? STR_FPICKER_SAVE : STR_FPICKER_OPEN));
 }
 
+// XCancellable
 void SAL_CALL KDE5FilePicker::cancel()
 {
     // TODO
 }
 
+// XEventListener
 void KDE5FilePicker::disposing(const lang::EventObject& rEvent)
 {
     uno::Reference<XFilePickerListener> xFilePickerListener(rEvent.Source, uno::UNO_QUERY);
@@ -680,6 +697,7 @@ void KDE5FilePicker::disposing(const lang::EventObject& rEvent)
     }
 }
 
+// XServiceInfo
 OUString SAL_CALL KDE5FilePicker::getImplementationName()
 {
     return OUString("com.sun.star.ui.dialogs.KDE5FilePicker");
commit aeda1e0ff96007ffc69c34485cea35952fd0a222
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date:   Wed Jun 20 11:51:35 2018 +0200

    Implement getDirectory, signal+slot
    
    also factor some shared code out into separate func
    
    Change-Id: I49d25eeb4eb647b72dae78c42301091d198eeff4

diff --git a/vcl/unx/kde5/KDE5FilePicker.hxx b/vcl/unx/kde5/KDE5FilePicker.hxx
index 6f175cc375cf..d1a300be014c 100644
--- a/vcl/unx/kde5/KDE5FilePicker.hxx
+++ b/vcl/unx/kde5/KDE5FilePicker.hxx
@@ -157,6 +157,7 @@ public:
 private:
     //add a custom control widget to the file dialog
     void addCustomControl(sal_Int16 controlId);
+    OUString implGetDirectory();
 
     // emit XFilePickerListener controlStateChanged event
     void filterChanged();
@@ -171,6 +172,7 @@ Q_SIGNALS:
     void setDefaultNameSignal(const OUString& rName);
     void setDisplayDirectorySignal(const OUString& rDir);
     OUString getDisplayDirectorySignal();
+    OUString getDirectorySignal();
     void setValueSignal(sal_Int16 nControlId, sal_Int16 nControlAction,
                         const css::uno::Any& rValue);
     css::uno::Any getValueSignal(sal_Int16 nControlId, sal_Int16 nControlAction);
@@ -189,7 +191,8 @@ private Q_SLOTS:
     void setTitleSlot(const OUString& rTitle) { return setTitle(rTitle); }
     void setDefaultNameSlot(const OUString& rName) { return setDefaultName(rName); }
     void setDisplayDirectorySlot(const OUString& rDir) { return setDisplayDirectory(rDir); }
-    OUString getDisplayDirectorySlot() { return getDisplayDirectory(); }
+    OUString getDisplayDirectorySlot() { return implGetDirectory(); }
+    OUString getDirectorySlot() { return implGetDirectory(); }
     void setValueSlot(sal_Int16 nControlId, sal_Int16 nControlAction, const css::uno::Any& rValue)
     {
         return setValue(nControlId, nControlAction, rValue);
diff --git a/vcl/unx/kde5/KDE5FilePicker2.cxx b/vcl/unx/kde5/KDE5FilePicker2.cxx
index 56734b4d36e9..d4e6d507dd79 100644
--- a/vcl/unx/kde5/KDE5FilePicker2.cxx
+++ b/vcl/unx/kde5/KDE5FilePicker2.cxx
@@ -136,6 +136,8 @@ KDE5FilePicker::KDE5FilePicker(QFileDialog::FileMode eMode)
             &KDE5FilePicker::getCurrentFilterSlot, Qt::BlockingQueuedConnection);
     connect(this, &KDE5FilePicker::getSelectedFilesSignal, this,
             &KDE5FilePicker::getSelectedFilesSlot, Qt::BlockingQueuedConnection);
+    connect(this, &KDE5FilePicker::getDirectorySignal, this,
+            &KDE5FilePicker::getDirectorySlot, Qt::BlockingQueuedConnection);
 
     qApp->installEventFilter(this);
 }
@@ -227,8 +229,7 @@ OUString SAL_CALL KDE5FilePicker::getDisplayDirectory()
         return Q_EMIT getDisplayDirectorySignal();
     }
 
-    OUString dir = toOUString(_dialog->directoryUrl().url());
-    return dir;
+    return implGetDirectory();
 }
 
 uno::Sequence<OUString> SAL_CALL KDE5FilePicker::getFiles()
@@ -432,7 +433,16 @@ OUString SAL_CALL KDE5FilePicker::getLabel(sal_Int16 controlId)
     return label;
 }
 
-OUString SAL_CALL KDE5FilePicker::getDirectory() { return OUString(); }
+OUString SAL_CALL KDE5FilePicker::getDirectory()
+{
+    if (qApp->thread() != QThread::currentThread())
+    {
+        SolarMutexReleaser aReleaser;
+        return Q_EMIT getDirectorySignal();
+    }
+
+    return implGetDirectory();
+}
 
 void SAL_CALL KDE5FilePicker::setDescription(const OUString&) {}
 
@@ -530,6 +540,12 @@ void KDE5FilePicker::addCustomControl(sal_Int16 controlId)
     }
 }
 
+OUString KDE5FilePicker::implGetDirectory()
+{
+    OUString dir = toOUString(_dialog->directoryUrl().url());
+    return dir;
+}
+
 void SAL_CALL KDE5FilePicker::initialize(const uno::Sequence<uno::Any>& args)
 {
     // parameter checking
commit 998f08ee291a5dd8e8953dc463d3c8e176e80ff0
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date:   Tue Jun 19 15:59:50 2018 +0200

    Folder picker is now really a folder picker
    
    and not a regular file picker with wrong title
    
    Change-Id: I849e7bb3d0cad197880fadd865f4d39f13245e97

diff --git a/vcl/unx/kde5/KDE5FilePicker.hxx b/vcl/unx/kde5/KDE5FilePicker.hxx
index 4fbbc487394c..6f175cc375cf 100644
--- a/vcl/unx/kde5/KDE5FilePicker.hxx
+++ b/vcl/unx/kde5/KDE5FilePicker.hxx
@@ -79,6 +79,7 @@ protected:
     QGridLayout* _layout;
 
     bool allowRemoteUrls;
+    bool mbIsFolderPicker;
 
 public:
     explicit KDE5FilePicker(QFileDialog::FileMode);
diff --git a/vcl/unx/kde5/KDE5FilePicker2.cxx b/vcl/unx/kde5/KDE5FilePicker2.cxx
index 46bcccf4bd24..56734b4d36e9 100644
--- a/vcl/unx/kde5/KDE5FilePicker2.cxx
+++ b/vcl/unx/kde5/KDE5FilePicker2.cxx
@@ -83,6 +83,7 @@ KDE5FilePicker::KDE5FilePicker(QFileDialog::FileMode eMode)
     , _extraControls(new QWidget)
     , _layout(new QGridLayout(_extraControls))
     , allowRemoteUrls(false)
+    , mbIsFolderPicker(eMode == QFileDialog::Directory)
 {
     _dialog->setSupportedSchemes({
         QStringLiteral("file"),
@@ -96,14 +97,12 @@ KDE5FilePicker::KDE5FilePicker(QFileDialog::FileMode eMode)
 
     _dialog->setFileMode(eMode);
 
-    if (eMode == QFileDialog::Directory)
+    if (mbIsFolderPicker)
     {
         _dialog->setOption(QFileDialog::ShowDirsOnly, true);
         _dialog->setWindowTitle(toQString(VclResId(STR_FPICKER_FOLDER_DEFAULT_TITLE)));
     }
 
-    setMultiSelectionMode(false);
-
     connect(_dialog, &QFileDialog::filterSelected, this, &KDE5FilePicker::filterChanged);
     connect(_dialog, &QFileDialog::fileSelected, this, &KDE5FilePicker::selectionChanged);
     connect(this, &KDE5FilePicker::setTitleSignal /*(const OUString&)*/, this,
@@ -191,6 +190,9 @@ void SAL_CALL KDE5FilePicker::setMultiSelectionMode(sal_Bool multiSelect)
         return Q_EMIT setMultiSelectionSignal(multiSelect);
     }
 
+    if (mbIsFolderPicker)
+        return;
+
     _dialog->setFileMode(multiSelect ? QFileDialog::ExistingFiles : QFileDialog::ExistingFile);
 }
 
commit 1af4ab72e2488515fcaedeb4a377ee070d68a495
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date:   Tue Jun 19 13:01:43 2018 +0200

    Fix initial switch to folder in fileopen dlg
    
    the argument passed is an URL, so using setDirectory wouldn't do
    the trick, setDirectoryUrl would
    
    Change-Id: I312f6e2a06b46777dc126f95f63ec0dbcb1f5799

diff --git a/vcl/unx/kde5/KDE5FilePicker2.cxx b/vcl/unx/kde5/KDE5FilePicker2.cxx
index 3d1491eab5cc..46bcccf4bd24 100644
--- a/vcl/unx/kde5/KDE5FilePicker2.cxx
+++ b/vcl/unx/kde5/KDE5FilePicker2.cxx
@@ -213,7 +213,8 @@ void SAL_CALL KDE5FilePicker::setDisplayDirectory(const OUString& dir)
         return Q_EMIT setDisplayDirectorySignal(dir);
     }
 
-    _dialog->setDirectory(toQString(dir));
+    QString qDir(toQString(dir));
+    _dialog->setDirectoryUrl(QUrl(qDir));
 }
 
 OUString SAL_CALL KDE5FilePicker::getDisplayDirectory()


More information about the Libreoffice-commits mailing list