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@fbihome.de>
diff --git a/vcl/inc/qt5/Qt5MainWindow.hxx b/vcl/inc/qt5/Qt5MainWindow.hxx
index a083617..f1e91b4 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 070e17a..ed5f306 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 a78097f..a2a0d6c 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);