[Libreoffice-commits] core.git: Branch 'libreoffice-6-4' - 2 commits - vcl/inc vcl/qt5 vcl/unx

Jan-Marek Glogowski (via logerrit) logerrit at kemper.freedesktop.org
Fri Dec 6 15:23:02 UTC 2019


 vcl/inc/qt5/Qt5FilePicker.hxx |    7 +++----
 vcl/inc/qt5/Qt5MainWindow.hxx |    3 +--
 vcl/qt5/Qt5Frame.cxx          |   10 ++++++----
 vcl/qt5/Qt5MainWindow.cxx     |    4 ++--
 vcl/unx/kf5/KF5FilePicker.cxx |   22 ----------------------
 vcl/unx/kf5/KF5FilePicker.hxx |    7 ++++---
 6 files changed, 16 insertions(+), 37 deletions(-)

New commits:
commit 61cd5e13368bf7511fef519d7cefaa43d6094cb6
Author:     Jan-Marek Glogowski <jan-marek.glogowski at extern.cib.de>
AuthorDate: Tue Dec 3 08:20:21 2019 +0100
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Fri Dec 6 16:21:28 2019 +0100

    tdf#129071 Qt5 handle windows with parents as dialogs
    
    This is the main fix for this bug. Qt Xcb is a little picky here.
    It won't tell the window manager about the transient state, using
    WM_TRANSIENT_FOR, for all Qt::WindowTypes. The QPA internal list
    (see isTransient function) doesn't include the Qt::Window, which
    is qt5 VCL's primary used window type.
    
    This has two consequences:
    1. LO dialogs show up in the plasma task manager as seperate
       windows.
    2. LO has to handle the transient state itself, instead of relying
       on the window manager. This results in flickering, because LO
       can just push a transient window to the top again, after the
       parent window was activated and therefore drawn in front.
    
    So this just declares all windows with parents to be dialogs.
    Almost everything else should be a top-level window anyway. If
    not, there is SalFrameStyleFlags::DIALOG to create a parent-less
    dialog window.
    
    Change-Id: I89a6d46fd09e4f1d1d2904e152a26733eb266079
    Reviewed-on: https://gerrit.libreoffice.org/84298
    Tested-by: Jenkins
    Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>
    (cherry picked from commit d8e3a08f06dcfea02c3f2f2a8578486381d77df7)
    Reviewed-on: https://gerrit.libreoffice.org/84619

diff --git a/vcl/inc/qt5/Qt5MainWindow.hxx b/vcl/inc/qt5/Qt5MainWindow.hxx
index a0836170f644..f1e91b489532 100644
--- a/vcl/inc/qt5/Qt5MainWindow.hxx
+++ b/vcl/inc/qt5/Qt5MainWindow.hxx
@@ -34,8 +34,7 @@ class Qt5MainWindow : public QMainWindow
     void moveEvent(QMoveEvent*) override;
 
 public:
-    Qt5MainWindow(Qt5Frame& rFrame, QWidget* parent = Q_NULLPTR,
-                  Qt::WindowFlags f = Qt::WindowFlags());
+    Qt5MainWindow(Qt5Frame& rFrame, Qt::WindowFlags f = Qt::WindowFlags());
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index 2ca319ee515c..0a89b53c111a 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -139,18 +139,20 @@ Qt5Frame::Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags nStyle, bool bUseCairo)
         else if ((nStyle & SalFrameStyleFlags::FLOAT)
                  && !(nStyle & SalFrameStyleFlags::OWNERDRAWDECORATION))
             aWinFlags |= Qt::Popup;
-        else if (nStyle & SalFrameStyleFlags::DIALOG && pParent)
-            aWinFlags |= Qt::Dialog;
         else if (nStyle & SalFrameStyleFlags::TOOLWINDOW)
             aWinFlags |= Qt::Tool;
+        // top level windows can't be transient in Qt, so make them dialogs, if they have a parent. At least
+        // the plasma shell relies on this setting to skip dialogs in the window list. And Qt Xcb will just
+        // set transient for the types Dialog, Sheet, Tool, SplashScreen, ToolTip, Drawer and Popup.
+        else if (nStyle & SalFrameStyleFlags::DIALOG || m_pParent)
+            aWinFlags |= Qt::Dialog;
         else
             aWinFlags |= Qt::Window;
     }
 
     if (aWinFlags == Qt::Window)
     {
-        QWidget* pParentWidget = m_pParent ? m_pParent->asChild() : nullptr;
-        m_pTopLevel = new Qt5MainWindow(*this, pParentWidget, aWinFlags);
+        m_pTopLevel = new Qt5MainWindow(*this, aWinFlags);
         m_pQWidget = new Qt5Widget(*this, aWinFlags);
         m_pTopLevel->setCentralWidget(m_pQWidget);
         m_pTopLevel->setFocusProxy(m_pQWidget);
diff --git a/vcl/qt5/Qt5MainWindow.cxx b/vcl/qt5/Qt5MainWindow.cxx
index a78097fb66c3..a2a0d6cea86f 100644
--- a/vcl/qt5/Qt5MainWindow.cxx
+++ b/vcl/qt5/Qt5MainWindow.cxx
@@ -15,8 +15,8 @@
 #include <QtGui/QAccessible>
 #include <QtGui/QCloseEvent>
 
-Qt5MainWindow::Qt5MainWindow(Qt5Frame& rFrame, QWidget* parent, Qt::WindowFlags f)
-    : QMainWindow(parent, f)
+Qt5MainWindow::Qt5MainWindow(Qt5Frame& rFrame, Qt::WindowFlags f)
+    : QMainWindow(nullptr, f)
     , m_rFrame(rFrame)
 {
     QAccessible::installFactory(Qt5AccessibleWidget::customFactory);
commit e536f28e9d7f640028461c5d02d3e50ef1102773
Author:     Jan-Marek Glogowski <jan-marek.glogowski at extern.cib.de>
AuthorDate: Tue Dec 3 06:54:14 2019 +0000
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Fri Dec 6 16:20:40 2019 +0100

    KF5 drop KF5FilePicker::execute
    
    To prevent calls to Qt5FilePicker::updateAutomaticFileExtension,
    it is simply made virtual with an empty override. This is needed,
    because the KF5 file picker has its own automatic extension
    handling.
    
    The main motivation is the fix for tdf#129071, which will result
    in some major changes to XExecutableDialog::execute, so this will
    prevent larger code duplication later.
    
    Change-Id: I5f747f0828cb8a65b4e7043f3ee68ebd31973e6a
    Reviewed-on: https://gerrit.libreoffice.org/84297
    Reviewed-by: Michael Weghorn <m.weghorn at posteo.de>
    Tested-by: Jenkins
    (cherry picked from commit c0cdb01ef33042be76251c4a353e0582a0838e0e)
    Reviewed-on: https://gerrit.libreoffice.org/84605
    Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>

diff --git a/vcl/inc/qt5/Qt5FilePicker.hxx b/vcl/inc/qt5/Qt5FilePicker.hxx
index 6fb116875dd4..f88395c6acce 100644
--- a/vcl/inc/qt5/Qt5FilePicker.hxx
+++ b/vcl/inc/qt5/Qt5FilePicker.hxx
@@ -64,9 +64,11 @@ private:
 
     osl::Mutex m_aHelperMutex; ///< mutex used by the WeakComponentImplHelper
 
+    QStringList m_aNamedFilterList; ///< to keep the original sequence
     QHash<QString, QString> m_aTitleToFilterMap;
     // to retrieve the filename extension for a given filter
     QHash<QString, QString> m_aNamedFilterToExtensionMap;
+    QString m_aCurrentFilter;
 
     QGridLayout* m_pLayout; ///< layout for extra custom controls
     QHash<sal_Int16, QWidget*> m_aCustomWidgetsMap; ///< map of SAL control ID's to widget
@@ -74,9 +76,6 @@ private:
     const bool m_bIsFolderPicker;
 
 protected:
-    QStringList m_aNamedFilterList; ///< to keep the original sequence
-    QString m_aCurrentFilter;
-
     std::unique_ptr<QFileDialog> m_pFileDialog; ///< the file picker dialog
     QWidget* m_pExtraControls; ///< widget to contain extra custom controls
 
@@ -165,7 +164,7 @@ private Q_SLOTS:
     // emit XFilePickerListener fileSelectionChanged event
     void currentChanged(const QString&);
     // (un)set automatic file extension
-    void updateAutomaticFileExtension();
+    virtual void updateAutomaticFileExtension();
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kf5/KF5FilePicker.cxx b/vcl/unx/kf5/KF5FilePicker.cxx
index a7ecd938ccca..0d95cd0be304 100644
--- a/vcl/unx/kf5/KF5FilePicker.cxx
+++ b/vcl/unx/kf5/KF5FilePicker.cxx
@@ -70,28 +70,6 @@ KF5FilePicker::KF5FilePicker(css::uno::Reference<css::uno::XComponentContext> co
     qApp->installEventFilter(this);
 }
 
-sal_Int16 SAL_CALL KF5FilePicker::execute()
-{
-    SolarMutexGuard g;
-    auto* pSalInst(static_cast<Qt5Instance*>(GetSalData()->m_pInstance));
-    assert(pSalInst);
-    if (!pSalInst->IsMainThread())
-    {
-        sal_Int16 ret;
-        pSalInst->RunInMainThread([&ret, this] { ret = execute(); });
-        return ret;
-    }
-
-    if (!m_aNamedFilterList.isEmpty())
-        m_pFileDialog->setNameFilters(m_aNamedFilterList);
-    if (!m_aCurrentFilter.isEmpty())
-        m_pFileDialog->selectNameFilter(m_aCurrentFilter);
-
-    m_pFileDialog->show();
-    //block and wait for user input
-    return m_pFileDialog->exec() == QFileDialog::Accepted ? 1 : 0;
-}
-
 // XFilePickerControlAccess
 void SAL_CALL KF5FilePicker::setValue(sal_Int16 controlId, sal_Int16 nControlAction,
                                       const uno::Any& value)
diff --git a/vcl/unx/kf5/KF5FilePicker.hxx b/vcl/unx/kf5/KF5FilePicker.hxx
index ee731a36a425..0886579cf459 100644
--- a/vcl/unx/kf5/KF5FilePicker.hxx
+++ b/vcl/unx/kf5/KF5FilePicker.hxx
@@ -35,9 +35,6 @@ public:
     explicit KF5FilePicker(css::uno::Reference<css::uno::XComponentContext> const& context,
                            QFileDialog::FileMode);
 
-    // XExecutableDialog functions
-    virtual sal_Int16 SAL_CALL execute() override;
-
     // XFilePickerControlAccess functions
     virtual void SAL_CALL setValue(sal_Int16 nControlId, sal_Int16 nControlAction,
                                    const css::uno::Any& rValue) override;
@@ -56,6 +53,10 @@ private:
     //add a custom control widget to the file dialog
     void addCustomControl(sal_Int16 controlId) override;
     bool eventFilter(QObject* watched, QEvent* event) override;
+
+private Q_SLOTS:
+    // the KF5 file picker has its own automatic extension handling
+    void updateAutomaticFileExtension() override {}
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list