tdf#154381 qt weld: Implement QtInstanceWindow::{g,s}et_title

Implement methods to set and get the window title.

In order to do that, add a `m_pWidget` member to
`QtInstanceWindow`. For the `QtInstanceDialog` case, that widget
is a pointer to the same dialog that `QtInstanceDialog::m_pDialog`
points to, which is a unique_ptr and thus takes care of the memory
management.

The non-dialog case is not supported yet, s.a. this commit
adding support for simple welded message dialogs initially:

    commit 1ace888823443b85d4a81b94656844f1b27e2987
    Date:   Wed Dec 20 19:13:50 2023 +0530

        tdf#130857 Use native qt widgets - simple message dialog

With this in place, the qt6 welded message dialog that
shows up when opening a file that's already open in another
instance of LO has the correct title ("Document in Use"),
just as is the case for the non-welded one
(whose use can be forced by setting env var
`SAL_VCL_QT_NO_WELDED_WIDGETS=1`).

Change-Id: I35f323cdfa70fb953b6bc73aaf726fb1f3098c45
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162437
Tested-by: Jenkins
Reviewed-by: Omkar Acharekar  <omkaracharekar12@gmail.com>
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
diff --git a/vcl/inc/qt5/QtInstanceWindow.hxx b/vcl/inc/qt5/QtInstanceWindow.hxx
index be6aec6..c29863da 100644
--- a/vcl/inc/qt5/QtInstanceWindow.hxx
+++ b/vcl/inc/qt5/QtInstanceWindow.hxx
@@ -13,7 +13,12 @@

class QtInstanceWindow : public QtInstanceContainer, public virtual weld::Window
{
    virtual void set_title(const OUString&) override;
    QWidget* m_pWidget;

public:
    QtInstanceWindow(QWidget* pWidget);

    virtual void set_title(const OUString& rTitle) override;
    virtual OUString get_title() const override;
    virtual void window_move(int, int) override;
    virtual void set_modal(bool) override;
diff --git a/vcl/qt5/QtInstanceDialog.cxx b/vcl/qt5/QtInstanceDialog.cxx
index 8d88468..e65e4b7 100644
--- a/vcl/qt5/QtInstanceDialog.cxx
+++ b/vcl/qt5/QtInstanceDialog.cxx
@@ -10,7 +10,8 @@
#include <QtInstanceDialog.hxx>

QtInstanceDialog::QtInstanceDialog(QDialog* pDialog)
    : m_pDialog(pDialog)
    : QtInstanceWindow(pDialog)
    , m_pDialog(pDialog)
{
}

diff --git a/vcl/qt5/QtInstanceWindow.cxx b/vcl/qt5/QtInstanceWindow.cxx
index e0bf4bf..0e74c8d6f 100644
--- a/vcl/qt5/QtInstanceWindow.cxx
+++ b/vcl/qt5/QtInstanceWindow.cxx
@@ -9,9 +9,18 @@

#include <QtInstanceWindow.hxx>

void QtInstanceWindow::set_title(const OUString&) {}
QtInstanceWindow::QtInstanceWindow(QWidget* pWidget)
    : m_pWidget(pWidget)
{
    assert(m_pWidget);
}

OUString QtInstanceWindow::get_title() const { return OUString(); }
void QtInstanceWindow::set_title(const OUString& rTitle)
{
    m_pWidget->setWindowTitle(toQString(rTitle));
}

OUString QtInstanceWindow::get_title() const { return toOUString(m_pWidget->windowTitle()); }

void QtInstanceWindow::window_move(int, int) {}