[Libreoffice-commits] core.git: Branch 'private/michaelweghorn/qt5_kde5_fpicker_deduplication' - vcl/inc vcl/qt5 vcl/unx

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Feb 7 16:07:34 UTC 2019


 vcl/inc/qt5/Qt5FilePicker.hxx    |    5 ++++-
 vcl/qt5/Qt5FilePicker.cxx        |    7 +++++--
 vcl/unx/kde5/KDE5FilePicker2.cxx |    2 +-
 3 files changed, 10 insertions(+), 4 deletions(-)

New commits:
commit c4e3924d2656944bf9c06a32f524563a0fb40903
Author:     Michael Weghorn <m.weghorn at posteo.de>
AuthorDate: Thu Feb 7 16:58:29 2019 +0100
Commit:     Michael Weghorn <m.weghorn at posteo.de>
CommitDate: Thu Feb 7 17:04:50 2019 +0100

    Make 'setDefaultName()' work again for kde5 fpicker
    
    Add an option to Qt5FilePicker constructor to
    say whether the QFileDialog should be a native one or not,
    since 'QFileDialog::selectFile' does not preselect the correct
    name in the native dialog any more if the
    'QFileDialog::DontUseNativeDialog' option has ever been set, i.e.
    
        QFileDialog fileDialog;
        fileDialog.setOption(QFileDialog::DontUseNativeDialog);
        fileDialog.setOption(QFileDialog::DontUseNativeDialog, false);
        fileDialog.selectFile("test.txt");
    
    will not properly set the name in the native file dialog, which
    broke 'setDefaultName' for the KDE5FilePicker.
    
    This makes it work again, even though I think that the underlying
    issue is a Qt bug
    (s. https://bugreports.qt.io/browse/QTBUG-73682 ).
    
    Change-Id: I99a1e7c97d594925d600fa8eaf3303f9013551c2

diff --git a/vcl/inc/qt5/Qt5FilePicker.hxx b/vcl/inc/qt5/Qt5FilePicker.hxx
index 8b8055efab9d..1bb6974ab83e 100644
--- a/vcl/inc/qt5/Qt5FilePicker.hxx
+++ b/vcl/inc/qt5/Qt5FilePicker.hxx
@@ -86,7 +86,10 @@ protected:
     bool m_bIsFolderPicker;
 
 public:
-    explicit Qt5FilePicker(QFileDialog::FileMode, bool bShowFileExtensionInFilterTitle = false);
+    // use non-native file dialog by default; there's no easy way to add custom widgets
+    // in a generic way in the native one
+    explicit Qt5FilePicker(QFileDialog::FileMode, bool bShowFileExtensionInFilterTitle = false,
+                           bool bUseNativeDialog = false);
     virtual ~Qt5FilePicker() override;
 
     // XFilePickerNotifier
diff --git a/vcl/qt5/Qt5FilePicker.cxx b/vcl/qt5/Qt5FilePicker.cxx
index 0d2025cec55b..dcfcc68f0888 100644
--- a/vcl/qt5/Qt5FilePicker.cxx
+++ b/vcl/qt5/Qt5FilePicker.cxx
@@ -76,13 +76,16 @@ uno::Sequence<OUString> FilePicker_getSupportedServiceNames()
 }
 }
 
-Qt5FilePicker::Qt5FilePicker(QFileDialog::FileMode eMode, bool bShowFileExtensionInFilterTitle)
+Qt5FilePicker::Qt5FilePicker(QFileDialog::FileMode eMode, bool bShowFileExtensionInFilterTitle,
+                             bool bUseNativeDialog)
     : Qt5FilePicker_Base(m_aHelperMutex)
     , m_bShowFileExtensionInFilterTitle(bShowFileExtensionInFilterTitle)
     , m_pFileDialog(new QFileDialog(nullptr, {}, QDir::homePath()))
     , m_bIsFolderPicker(eMode == QFileDialog::Directory)
 {
-    m_pFileDialog->setOption(QFileDialog::DontUseNativeDialog);
+    if (!bUseNativeDialog)
+        m_pFileDialog->setOption(QFileDialog::DontUseNativeDialog);
+
     m_pFileDialog->setFileMode(eMode);
     m_pFileDialog->setWindowModality(Qt::ApplicationModal);
 
diff --git a/vcl/unx/kde5/KDE5FilePicker2.cxx b/vcl/unx/kde5/KDE5FilePicker2.cxx
index 3f4f61575185..2e855bac7c6b 100644
--- a/vcl/unx/kde5/KDE5FilePicker2.cxx
+++ b/vcl/unx/kde5/KDE5FilePicker2.cxx
@@ -82,7 +82,7 @@ uno::Sequence<OUString> FilePicker_getSupportedServiceNames()
 
 KDE5FilePicker::KDE5FilePicker(QFileDialog::FileMode eMode)
     // Native kde5 filepicker does not add file extension automatically
-    : Qt5FilePicker(eMode, true)
+    : Qt5FilePicker(eMode, true, true)
     , _layout(new QGridLayout(m_pExtraControls))
     , allowRemoteUrls(false)
 {


More information about the Libreoffice-commits mailing list