vcl/inc/qt5/QtInstanceWidget.hxx |    2 
 vcl/inc/qt5/QtInstanceWindow.hxx |    4 -
 vcl/qt5/QtInstanceWidget.cxx     |    8 +++
 vcl/qt5/QtInstanceWindow.cxx     |   79 +++++++++++++++++++++++++++++++++++----
 4 files changed, 81 insertions(+), 12 deletions(-)

New commits:
commit 4aa9b7a0bbcca4352a838962838c3311c44d7442
Author:     Michael Weghorn <[email protected]>
AuthorDate: Wed Dec 4 21:52:51 2024 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Thu Dec 5 09:27:14 2024 +0100

    tdf#130857 qt weld: Implement QtInstanceWindow::{g,s}et_window_state
    
    Map to/from what looks like the corresponding QWidget
    equivalents.
    No explicit testing done.
    
    Change-Id: I47152c8789223372c49ea60f774d0a04a64db2b7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177828
    Reviewed-by: Michael Weghorn <[email protected]>
    Tested-by: Jenkins

diff --git a/vcl/inc/qt5/QtInstanceWindow.hxx b/vcl/inc/qt5/QtInstanceWindow.hxx
index b92b830c7b9b..151e6d47e6ad 100644
--- a/vcl/inc/qt5/QtInstanceWindow.hxx
+++ b/vcl/inc/qt5/QtInstanceWindow.hxx
@@ -32,8 +32,8 @@ public:
     virtual void change_default_widget(weld::Widget*, weld::Widget*) override;
     virtual bool is_default_widget(const weld::Widget*) const override;
 
-    virtual void set_window_state(const OUString&) override;
-    virtual OUString get_window_state(vcl::WindowDataMask) const override;
+    virtual void set_window_state(const OUString& rStr) override;
+    virtual OUString get_window_state(vcl::WindowDataMask eMask) const 
override;
 
     virtual css::uno::Reference<css::awt::XWindow> GetXWindow() override;
 
diff --git a/vcl/qt5/QtInstanceWindow.cxx b/vcl/qt5/QtInstanceWindow.cxx
index b911ac590de8..4d1cde125cfb 100644
--- a/vcl/qt5/QtInstanceWindow.cxx
+++ b/vcl/qt5/QtInstanceWindow.cxx
@@ -115,12 +115,68 @@ bool QtInstanceWindow::is_default_widget(const 
weld::Widget*) const
     return true;
 }
 
-void QtInstanceWindow::set_window_state(const OUString&) { assert(false && 
"Not implemented yet"); }
+void QtInstanceWindow::set_window_state(const OUString& rStr)
+{
+    SolarMutexGuard g;
+
+    const vcl::WindowData aData(rStr);
+    const vcl::WindowDataMask eMask = aData.mask();
+
+    GetQtInstance().RunInMainThread([&] {
+        QRect aGeometry = getQWidget()->geometry();
+        if (eMask & vcl::WindowDataMask::X)
+            aGeometry.setX(aData.x());
+        if (eMask & vcl::WindowDataMask::Y)
+            aGeometry.setY(aData.y());
+        if (eMask & vcl::WindowDataMask::Width)
+            aGeometry.setWidth(aData.width());
+        if (eMask & vcl::WindowDataMask::Height)
+            aGeometry.setHeight(aData.height());
+
+        getQWidget()->setGeometry(aGeometry);
+
+        if (eMask & vcl::WindowDataMask::State)
+        {
+            const vcl::WindowState eState = aData.state();
+            if (eState & vcl::WindowState::Normal)
+                getQWidget()->showNormal();
+            else if (eState & vcl::WindowState::Maximized)
+                getQWidget()->showMaximized();
+            else if (eState & vcl::WindowState::Minimized)
+                getQWidget()->showMinimized();
+        }
+    });
+}
 
-OUString QtInstanceWindow::get_window_state(vcl::WindowDataMask) const
+OUString QtInstanceWindow::get_window_state(vcl::WindowDataMask eMask) const
 {
-    assert(false && "Not implemented yet");
-    return OUString();
+    SolarMutexGuard g;
+
+    vcl::WindowData aData;
+    GetQtInstance().RunInMainThread([&] {
+        QRect aGeometry = getQWidget()->geometry();
+        if (eMask & vcl::WindowDataMask::X)
+            aData.setX(aGeometry.x());
+        if (eMask & vcl::WindowDataMask::Y)
+            aData.setY(aGeometry.y());
+        if (eMask & vcl::WindowDataMask::Width)
+            aData.setWidth(aGeometry.width());
+        if (eMask & vcl::WindowDataMask::Height)
+            aData.setHeight(aGeometry.height());
+        if (eMask & vcl::WindowDataMask::State)
+        {
+            vcl::WindowState nState = vcl::WindowState::NONE;
+            if (getQWidget()->isMaximized())
+                nState |= vcl::WindowState::Maximized;
+            else if (getQWidget()->isMinimized())
+                nState |= vcl::WindowState::Minimized;
+            else
+                nState |= vcl::WindowState::Normal;
+            aData.setState(nState);
+        }
+    });
+
+    return aData.toStr();
 }
 
 css::uno::Reference<css::awt::XWindow> QtInstanceWindow::GetXWindow()
commit d1243097a39375e98ef2fbc8a87be549e16275ff
Author:     Michael Weghorn <[email protected]>
AuthorDate: Wed Dec 4 21:19:02 2024 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Thu Dec 5 09:27:07 2024 +0100

    tdf#130857 qt weld: Implement QtInstanceWindow::get_{size,position}
    
    These are needed e.g. for the "Find and Replace" dialog.
    Use the QWidget::geometry property [1] for now.
    An alternative to consider might be QWidget::frameGeometry [2].
    
    At least on Wayland, screen positions are not available
    anyway, however.
    
    [1] https://doc.qt.io/qt-6/qwidget.html#geometry-prop
    [2] https://doc.qt.io/qt-6/qwidget.html#frameGeometry-prop
    
    Change-Id: I2449d8be688c17a4abb58ba424c966dde0e30e26
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177827
    Reviewed-by: Michael Weghorn <[email protected]>
    Tested-by: Jenkins

diff --git a/vcl/qt5/QtInstanceWindow.cxx b/vcl/qt5/QtInstanceWindow.cxx
index 262fe299a0c9..b911ac590de8 100644
--- a/vcl/qt5/QtInstanceWindow.cxx
+++ b/vcl/qt5/QtInstanceWindow.cxx
@@ -64,14 +64,21 @@ bool QtInstanceWindow::get_resizable() const
 
 Size QtInstanceWindow::get_size() const
 {
-    assert(false && "Not implemented yet");
-    return Size();
+    SolarMutexGuard g;
+
+    Size aSize;
+    GetQtInstance().RunInMainThread([&] { aSize = 
toSize(getQWidget()->size()); });
+    return aSize;
 }
 
 Point QtInstanceWindow::get_position() const
 {
-    assert(false && "Not implemented yet");
-    return Point();
+    SolarMutexGuard g;
+
+    Point aPosition;
+    GetQtInstance().RunInMainThread(
+        [&] { aPosition = toPoint(getQWidget()->geometry().topLeft()); });
+    return aPosition;
 }
 
 AbsoluteScreenPixelRectangle QtInstanceWindow::get_monitor_workarea() const
commit 33c7d3a3e16c2c8db31e30d9daf302263449ed0d
Author:     Michael Weghorn <[email protected]>
AuthorDate: Wed Dec 4 21:03:50 2024 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Thu Dec 5 09:27:01 2024 +0100

    tdf#130857 qt weld: Implement QtInstanceWidget::set_background
    
    Used e.g. by the "Find and Replace" dialog (Ctrl+H).
    
    Change-Id: Ie181eea1600616ddb6a8044864df221ac4bb108d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177826
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/vcl/inc/qt5/QtInstanceWidget.hxx b/vcl/inc/qt5/QtInstanceWidget.hxx
index b63376208200..a98288908084 100644
--- a/vcl/inc/qt5/QtInstanceWidget.hxx
+++ b/vcl/inc/qt5/QtInstanceWidget.hxx
@@ -173,7 +173,7 @@ public:
 
     virtual void set_highlight_background() override;
 
-    virtual void set_background(const Color&) override;
+    virtual void set_background(const Color& rBackColor) override;
 
     virtual void draw(OutputDevice&, const Point&, const Size&) override;
 
diff --git a/vcl/qt5/QtInstanceWidget.cxx b/vcl/qt5/QtInstanceWidget.cxx
index 6636e3f1c956..da0c0112dab0 100644
--- a/vcl/qt5/QtInstanceWidget.cxx
+++ b/vcl/qt5/QtInstanceWidget.cxx
@@ -545,7 +545,13 @@ void QtInstanceWidget::set_toolbar_background() { 
assert(false && "Not implement
 
 void QtInstanceWidget::set_highlight_background() { assert(false && "Not 
implemented yet"); }
 
-void QtInstanceWidget::set_background(const Color&) { assert(false && "Not 
implemented yet"); }
+void QtInstanceWidget::set_background(const Color& rBackColor)
+{
+    QPalette aPalette = getQWidget()->palette();
+    aPalette.setColor(QPalette::Base, toQColor(rBackColor));
+    getQWidget()->setPalette(aPalette);
+    getQWidget()->setBackgroundRole(QPalette::Base);
+}
 
 void QtInstanceWidget::draw(OutputDevice&, const Point&, const Size&)
 {

Reply via email to