vcl/CustomTarget_qt5_moc.mk           |    1 
 vcl/CustomTarget_qt6_moc.mk           |    1 
 vcl/Library_vclplug_qt5.mk            |    1 
 vcl/Library_vclplug_qt6.mk            |    1 
 vcl/inc/qt5/QtInstanceDrawingArea.hxx |   52 ++++++++++++++++++++++
 vcl/inc/qt5/QtInstanceWidget.hxx      |    2 
 vcl/inc/qt6/QtInstanceDrawingArea.hxx |   12 +++++
 vcl/qt5/QtBuilder.cxx                 |   11 ++++
 vcl/qt5/QtInstanceBuilder.cxx         |    9 ++-
 vcl/qt5/QtInstanceDrawingArea.cxx     |   77 ++++++++++++++++++++++++++++++++++
 vcl/qt5/QtInstanceWidget.cxx          |   15 +++++-
 vcl/qt6/QtInstanceDrawingArea.cxx     |   12 +++++
 12 files changed, 188 insertions(+), 6 deletions(-)

New commits:
commit 6e2dd3bed69355c028c2378bce81b98f390b50b2
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Wed Nov 6 22:03:42 2024 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Thu Nov 7 09:53:50 2024 +0100

    tdf#130857 qt weld: Implement QtInstanceWidget::{g,s}et_size_request
    
    As described at [1], gtk_widget_set_size_request sets the
    minimum size. Therefore, get/set the QWidget::minimumSize
    property [2] for the QtInstanceWidget implementation using
    a native QWidget.
    
    [1] https://docs.gtk.org/gtk3/method.Widget.set_size_request.html
    [2] https://doc.qt.io/qt-6/qwidget.html#minimumSize-prop
    
    Change-Id: I38b9d02b81ed209b2acc94c2b9b015f32c6eec79
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176172
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/inc/qt5/QtInstanceWidget.hxx b/vcl/inc/qt5/QtInstanceWidget.hxx
index a6fbfc06950d..bcff81bc6e90 100644
--- a/vcl/inc/qt5/QtInstanceWidget.hxx
+++ b/vcl/inc/qt5/QtInstanceWidget.hxx
@@ -50,7 +50,7 @@ public:
 
     virtual void hide() override;
 
-    virtual void set_size_request(int, int) override;
+    virtual void set_size_request(int nWidth, int nHeight) override;
 
     virtual Size get_size_request() const override;
 
diff --git a/vcl/qt5/QtInstanceWidget.cxx b/vcl/qt5/QtInstanceWidget.cxx
index 6764c83422d2..4f5a4e5f06d2 100644
--- a/vcl/qt5/QtInstanceWidget.cxx
+++ b/vcl/qt5/QtInstanceWidget.cxx
@@ -184,9 +184,20 @@ void QtInstanceWidget::hide()
     m_pWidget->hide();
 }
 
-void QtInstanceWidget::set_size_request(int, int) {}
+void QtInstanceWidget::set_size_request(int nWidth, int nHeight)
+{
+    SolarMutexGuard g;
+    GetQtInstance().RunInMainThread([&] { m_pWidget->setMinimumSize(nWidth, 
nHeight); });
+}
 
-Size QtInstanceWidget::get_size_request() const { return Size(); }
+Size QtInstanceWidget::get_size_request() const
+{
+    SolarMutexGuard g;
+
+    Size aSize;
+    GetQtInstance().RunInMainThread([&] { aSize = 
toSize(m_pWidget->minimumSize()); });
+    return aSize;
+}
 
 Size QtInstanceWidget::get_preferred_size() const
 {
commit 5c85ef3df01daf7848753fe33f254aeb3d1dd8e6
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Wed Nov 6 21:51:46 2024 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Thu Nov 7 09:53:43 2024 +0100

    tdf#130857 qt weld: Add QtInstanceDrawingArea basics
    
    Add a new QtInstanceDrawingArea class as the weld::DrawingArea
    implementation using native Qt widgets.
    
    Initially only add the "basic structure" (most of the actual
    functionality of drawing will be added separately):
    
    * Add the QtInstanceDrawingArea class with most methods
      currently still unimplemented and triggering an assert
      when they get called.
    * Add a `ScopedVclPtrInstance<VirtualDevice> m_xDevice`
      member and return that in `QtInstanceDrawingArea::get_ref_device`,
      as the gtk3 implementation (GtkInstanceDrawingArea) does.
    * Let QtBuilder::makeObject create a QLabel for a
      "GtkDrawingArea" object for now. That label will hold
      a pixmap (which should be sufficient for simple cases
      at least).
    * Let QtInstanceBuilder::weld_drawing_area return an
      instance of the new class.
    
    Change-Id: I5d509ccd9f5a7a826a166958af4a92ff01cc0225
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176171
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/vcl/CustomTarget_qt5_moc.mk b/vcl/CustomTarget_qt5_moc.mk
index 0072fa3883ad..672398d4b03f 100644
--- a/vcl/CustomTarget_qt5_moc.mk
+++ b/vcl/CustomTarget_qt5_moc.mk
@@ -16,6 +16,7 @@ $(call gb_CustomTarget_get_target,vcl/qt5) : \
        $(gb_CustomTarget_workdir)/vcl/qt5/QtInstance.moc \
        $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceComboBox.moc \
        $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceDialog.moc \
+       $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceDrawingArea.moc \
        $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceEntry.moc \
        $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceLevelBar.moc \
        $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceLinkButton.moc \
diff --git a/vcl/CustomTarget_qt6_moc.mk b/vcl/CustomTarget_qt6_moc.mk
index 33e185e4c962..03d3c079771f 100644
--- a/vcl/CustomTarget_qt6_moc.mk
+++ b/vcl/CustomTarget_qt6_moc.mk
@@ -16,6 +16,7 @@ $(call gb_CustomTarget_get_target,vcl/qt6) : \
        $(gb_CustomTarget_workdir)/vcl/qt6/QtInstance.moc \
        $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceComboBox.moc \
        $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceDialog.moc \
+       $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceDrawingArea.moc \
        $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceEntry.moc \
        $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceLevelBar.moc \
        $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceLinkButton.moc \
diff --git a/vcl/Library_vclplug_qt5.mk b/vcl/Library_vclplug_qt5.mk
index 8870dfda6f2f..678f69a92088 100644
--- a/vcl/Library_vclplug_qt5.mk
+++ b/vcl/Library_vclplug_qt5.mk
@@ -103,6 +103,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_qt5,\
     vcl/qt5/QtInstanceContainer \
     vcl/qt5/QtInstanceComboBox \
     vcl/qt5/QtInstanceDialog \
+    vcl/qt5/QtInstanceDrawingArea \
     vcl/qt5/QtInstanceEntry \
     vcl/qt5/QtInstanceFrame \
     vcl/qt5/QtInstanceImage \
diff --git a/vcl/Library_vclplug_qt6.mk b/vcl/Library_vclplug_qt6.mk
index c31efc27a490..f57bcc307157 100644
--- a/vcl/Library_vclplug_qt6.mk
+++ b/vcl/Library_vclplug_qt6.mk
@@ -102,6 +102,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_qt6,\
     vcl/qt6/QtInstanceComboBox \
     vcl/qt6/QtInstanceContainer \
     vcl/qt6/QtInstanceDialog \
+    vcl/qt6/QtInstanceDrawingArea \
     vcl/qt6/QtInstanceEntry \
     vcl/qt6/QtInstanceFrame \
     vcl/qt6/QtInstanceImage \
diff --git a/vcl/inc/qt5/QtInstanceDrawingArea.hxx 
b/vcl/inc/qt5/QtInstanceDrawingArea.hxx
new file mode 100644
index 000000000000..757174330c13
--- /dev/null
+++ b/vcl/inc/qt5/QtInstanceDrawingArea.hxx
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#pragma once
+
+#include "QtInstanceWidget.hxx"
+
+#include <QtWidgets/QLabel>
+
+class QtInstanceDrawingArea : public QObject,
+                              public QtInstanceWidget,
+                              public virtual weld::DrawingArea
+{
+    Q_OBJECT
+
+    QLabel* m_pLabel;
+    ScopedVclPtrInstance<VirtualDevice> m_xDevice;
+
+public:
+    QtInstanceDrawingArea(QLabel* pLabel);
+
+    virtual void queue_draw() override;
+    virtual void queue_draw_area(int x, int y, int width, int height) override;
+
+    virtual void enable_drag_source(rtl::Reference<TransferDataContainer>& 
rTransferable,
+                                    sal_uInt8 eDNDConstants) override;
+
+    virtual void set_cursor(PointerStyle ePointerStyle) override;
+
+    virtual Point get_pointer_position() const override;
+
+    virtual void set_input_context(const InputContext& rInputContext) override;
+    virtual void im_context_set_cursor_location(const tools::Rectangle& 
rCursorRect,
+                                                int nExtTextInputWidth) 
override;
+
+    virtual OutputDevice& get_ref_device() override;
+
+    virtual a11yref get_accessible_parent() override;
+    virtual a11yrelationset get_accessible_relation_set() override;
+    virtual AbsoluteScreenPixelPoint get_accessible_location_on_screen() 
override;
+
+private:
+    virtual void click(const Point&) override;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/qt6/QtInstanceDrawingArea.hxx 
b/vcl/inc/qt6/QtInstanceDrawingArea.hxx
new file mode 100644
index 000000000000..00c19b649c0f
--- /dev/null
+++ b/vcl/inc/qt6/QtInstanceDrawingArea.hxx
@@ -0,0 +1,12 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "../qt5/QtInstanceDrawingArea.hxx"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/QtBuilder.cxx b/vcl/qt5/QtBuilder.cxx
index 6529ae653303..73ad72ec424b 100644
--- a/vcl/qt5/QtBuilder.cxx
+++ b/vcl/qt5/QtBuilder.cxx
@@ -186,6 +186,10 @@ QObject* QtBuilder::makeObject(QObject* pParent, 
std::u16string_view sName, cons
     {
         pObject = new QDialog(pParentWidget);
     }
+    else if (sName == u"GtkDrawingArea")
+    {
+        pObject = new QLabel(pParentWidget);
+    }
     else if (sName == u"GtkEntry")
     {
         QLineEdit* pLineEdit = new QLineEdit(pParentWidget);
diff --git a/vcl/qt5/QtInstanceBuilder.cxx b/vcl/qt5/QtInstanceBuilder.cxx
index 8db7c8cd9c6c..82036d43e1c0 100644
--- a/vcl/qt5/QtInstanceBuilder.cxx
+++ b/vcl/qt5/QtInstanceBuilder.cxx
@@ -14,6 +14,7 @@
 #include <QtBuilder.hxx>
 #include <QtInstanceCheckButton.hxx>
 #include <QtInstanceComboBox.hxx>
+#include <QtInstanceDrawingArea.hxx>
 #include <QtInstanceEntry.hxx>
 #include <QtInstanceFrame.hxx>
 #include <QtInstanceImage.hxx>
@@ -317,10 +318,12 @@ std::unique_ptr<weld::Expander> 
QtInstanceBuilder::weld_expander(const OUString&
 }
 
 std::unique_ptr<weld::DrawingArea>
-QtInstanceBuilder::weld_drawing_area(const OUString&, const a11yref&, 
FactoryFunction, void*)
+QtInstanceBuilder::weld_drawing_area(const OUString& rId, const a11yref&, 
FactoryFunction, void*)
 {
-    assert(false && "Not implemented yet");
-    return nullptr;
+    QLabel* pLabel = m_xBuilder->get<QLabel>(rId);
+    std::unique_ptr<weld::DrawingArea> xRet(pLabel ? 
std::make_unique<QtInstanceDrawingArea>(pLabel)
+                                                   : nullptr);
+    return xRet;
 }
 
 std::unique_ptr<weld::Menu> QtInstanceBuilder::weld_menu(const OUString&)
diff --git a/vcl/qt5/QtInstanceDrawingArea.cxx 
b/vcl/qt5/QtInstanceDrawingArea.cxx
new file mode 100644
index 000000000000..0ae6baa2b087
--- /dev/null
+++ b/vcl/qt5/QtInstanceDrawingArea.cxx
@@ -0,0 +1,77 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <QtInstanceDrawingArea.hxx>
+#include <QtInstanceDrawingArea.moc>
+
+QtInstanceDrawingArea::QtInstanceDrawingArea(QLabel* pLabel)
+    : QtInstanceWidget(pLabel)
+    , m_pLabel(pLabel)
+    , m_xDevice(DeviceFormat::WITHOUT_ALPHA)
+{
+    assert(m_pLabel);
+}
+
+void QtInstanceDrawingArea::queue_draw()
+{
+    SolarMutexGuard g;
+    GetQtInstance().RunInMainThread([&] { getQWidget()->update(); });
+}
+
+void QtInstanceDrawingArea::queue_draw_area(int, int, int, int)
+{
+    assert(false && "Not implemented yet");
+}
+
+void 
QtInstanceDrawingArea::enable_drag_source(rtl::Reference<TransferDataContainer>&,
 sal_uInt8)
+{
+    assert(false && "Not implemented yet");
+}
+
+void QtInstanceDrawingArea::set_cursor(PointerStyle) { assert(false && "Not 
implemented yet"); }
+
+Point QtInstanceDrawingArea::get_pointer_position() const
+{
+    assert(false && "Not implemented yet");
+    return Point();
+}
+
+void QtInstanceDrawingArea::set_input_context(const InputContext&)
+{
+    assert(false && "Not implemented yet");
+}
+
+void QtInstanceDrawingArea::im_context_set_cursor_location(const 
tools::Rectangle&, int)
+{
+    assert(false && "Not implemented yet");
+}
+
+OutputDevice& QtInstanceDrawingArea::get_ref_device() { return *m_xDevice; }
+
+a11yref QtInstanceDrawingArea::get_accessible_parent()
+{
+    assert(false && "Not implemented yet");
+    return nullptr;
+}
+
+a11yrelationset QtInstanceDrawingArea::get_accessible_relation_set()
+{
+    assert(false && "Not implemented yet");
+    return nullptr;
+}
+
+AbsoluteScreenPixelPoint 
QtInstanceDrawingArea::get_accessible_location_on_screen()
+{
+    assert(false && "Not implemented yet");
+    return AbsoluteScreenPixelPoint(0, 0);
+}
+
+void QtInstanceDrawingArea::click(const Point&) { assert(false && "Not 
implemented yet"); }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt6/QtInstanceDrawingArea.cxx 
b/vcl/qt6/QtInstanceDrawingArea.cxx
new file mode 100644
index 000000000000..78b40804dd01
--- /dev/null
+++ b/vcl/qt6/QtInstanceDrawingArea.cxx
@@ -0,0 +1,12 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "../qt5/QtInstanceDrawingArea.cxx"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 2d1de12ac8064dd3c73e4359b931fdccae3541fb
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Wed Nov 6 21:32:59 2024 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Thu Nov 7 09:53:37 2024 +0100

    tdf#130857 qt weld: Support "GtkSeparator"
    
    Handle "GtkSeparator" objects in .ui files:
    Create a QFrame and, depending on the orientation
    set a shape of either QFrame::HLine ("QFrame draws a
    horizontal line that frames nothing (useful as separator)")
    or QFrame::VLine ("QFrame draws a vertical line that frames
    nothing (useful as separator)") [1].
    
    This will be used e.g. in the "Help" -> "Show Tip of the Day"
    dialog.
    
    [1] https://doc.qt.io/qt-6/qframe.html#Shape-enum
    
    Change-Id: I41e69dd211cbb69cb7b23cc54640cd1fad655efc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176165
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/vcl/qt5/QtBuilder.cxx b/vcl/qt5/QtBuilder.cxx
index 91cd1839d055..6529ae653303 100644
--- a/vcl/qt5/QtBuilder.cxx
+++ b/vcl/qt5/QtBuilder.cxx
@@ -245,6 +245,13 @@ QObject* QtBuilder::makeObject(QObject* pParent, 
std::u16string_view sName, cons
     {
         pObject = new QScrollArea(pParentWidget);
     }
+    else if (sName == u"GtkSeparator")
+    {
+        const bool bVertical = hasOrientationVertical(rMap);
+        QFrame* pFrame = new QFrame(pParentWidget);
+        pFrame->setFrameShape(bVertical ? QFrame::VLine : QFrame::HLine);
+        pObject = pFrame;
+    }
     else if (sName == u"GtkTextView")
     {
         pObject = new QPlainTextEdit(pParentWidget);

Reply via email to