vcl/Library_vclplug_qt5.mk        |    1 +
 vcl/Library_vclplug_qt6.mk        |    1 +
 vcl/inc/qt5/QtInstanceBuilder.hxx |    2 +-
 vcl/inc/qt5/QtInstanceImage.hxx   |   28 ++++++++++++++++++++++++++++
 vcl/inc/qt6/QtInstanceImage.hxx   |   12 ++++++++++++
 vcl/qt5/QtBuilder.cxx             |    4 ++++
 vcl/qt5/QtInstanceBuilder.cxx     |    8 +++++---
 vcl/qt5/QtInstanceImage.cxx       |   33 +++++++++++++++++++++++++++++++++
 vcl/qt6/QtInstanceImage.cxx       |   12 ++++++++++++
 9 files changed, 97 insertions(+), 4 deletions(-)

New commits:
commit c5f68d9862ff0cf55b449bd2f638a4cd22d28501
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Fri Oct 25 20:26:15 2024 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Sat Oct 26 13:10:53 2024 +0200

    tdf#130857 qt weld: Add QtInstanceImage skeleton
    
    Add a new class QtInstanceImage as a weld::Image
    implementation using native Qt widgets.
    
    It uses a QLabel that holds the Image, which can
    be set using QLabel::setPixmap [1].
    
    This commit adds the new class, lets
    QtInstanceBuilder::weld_image return an instance
    of the new class, and extends QtBuilder to create
    a QLabel when it encounters a "GtkImage" object.
    
    The logic to actually set the image when either
    processing the .ui file or when one of the
    weld::Image::set_from_icon_name or one of the
    weld::Image::set_image variants gets called
    still needs to be implemented in subsequent
    commits for the label to actually display
    an image.
    
    [1] https://doc.qt.io/qt-6/qlabel.html#pixmap-prop
    
    Change-Id: I3aa526b89487a5301dabd108723d7b68ca85ea66
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175655
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/vcl/Library_vclplug_qt5.mk b/vcl/Library_vclplug_qt5.mk
index 2cbd00943dc0..2a60b474b2d1 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/QtInstanceDialog \
     vcl/qt5/QtInstanceEntry \
     vcl/qt5/QtInstanceFrame \
+    vcl/qt5/QtInstanceImage \
     vcl/qt5/QtInstanceMessageDialog \
     vcl/qt5/QtInstanceLabel \
     vcl/qt5/QtInstanceRadioButton \
diff --git a/vcl/Library_vclplug_qt6.mk b/vcl/Library_vclplug_qt6.mk
index 89f3b7eefb47..485db0a19768 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/QtInstanceDialog \
     vcl/qt6/QtInstanceEntry \
     vcl/qt6/QtInstanceFrame \
+    vcl/qt6/QtInstanceImage \
     vcl/qt6/QtInstanceLabel \
     vcl/qt6/QtInstanceMessageDialog \
     vcl/qt6/QtInstanceRadioButton \
diff --git a/vcl/inc/qt5/QtInstanceBuilder.hxx 
b/vcl/inc/qt5/QtInstanceBuilder.hxx
index 33e33c9f08ed..cc02e6ce3b21 100644
--- a/vcl/inc/qt5/QtInstanceBuilder.hxx
+++ b/vcl/inc/qt5/QtInstanceBuilder.hxx
@@ -53,7 +53,7 @@ public:
     virtual std::unique_ptr<weld::ProgressBar> weld_progress_bar(const 
OUString&) override;
     virtual std::unique_ptr<weld::LevelBar> weld_level_bar(const OUString&) 
override;
     virtual std::unique_ptr<weld::Spinner> weld_spinner(const OUString&) 
override;
-    virtual std::unique_ptr<weld::Image> weld_image(const OUString&) override;
+    virtual std::unique_ptr<weld::Image> weld_image(const OUString& rId) 
override;
     virtual std::unique_ptr<weld::Calendar> weld_calendar(const OUString&) 
override;
     virtual std::unique_ptr<weld::Entry> weld_entry(const OUString& rId) 
override;
     virtual std::unique_ptr<weld::SpinButton> weld_spin_button(const 
OUString&) override;
diff --git a/vcl/inc/qt5/QtInstanceImage.hxx b/vcl/inc/qt5/QtInstanceImage.hxx
new file mode 100644
index 000000000000..9afd20a2f16a
--- /dev/null
+++ b/vcl/inc/qt5/QtInstanceImage.hxx
@@ -0,0 +1,28 @@
+/* -*- 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 QtInstanceImage : public QtInstanceWidget, public virtual weld::Image
+{
+    QLabel* m_pLabel;
+
+public:
+    QtInstanceImage(QLabel* pLabel);
+
+    virtual void set_from_icon_name(const OUString& rIconName) override;
+    virtual void set_image(VirtualDevice* pDevice) override;
+    virtual void set_image(const css::uno::Reference<css::graphic::XGraphic>& 
rImage) override;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/qt6/QtInstanceImage.hxx b/vcl/inc/qt6/QtInstanceImage.hxx
new file mode 100644
index 000000000000..01f647222fc8
--- /dev/null
+++ b/vcl/inc/qt6/QtInstanceImage.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/QtInstanceImage.hxx"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/QtBuilder.cxx b/vcl/qt5/QtBuilder.cxx
index 8510967533d9..2bf4f12dc662 100644
--- a/vcl/qt5/QtBuilder.cxx
+++ b/vcl/qt5/QtBuilder.cxx
@@ -184,6 +184,10 @@ QObject* QtBuilder::makeObject(QObject* pParent, 
std::u16string_view sName, cons
     {
         pObject = new QGridLayout(pParentWidget);
     }
+    else if (sName == u"GtkImage")
+    {
+        pObject = new QLabel(pParentWidget);
+    }
     else if (sName == u"GtkLabel")
     {
         extractMnemonicWidget(sID, rMap);
diff --git a/vcl/qt5/QtInstanceBuilder.cxx b/vcl/qt5/QtInstanceBuilder.cxx
index a2cac7f825bd..6001128760d6 100644
--- a/vcl/qt5/QtInstanceBuilder.cxx
+++ b/vcl/qt5/QtInstanceBuilder.cxx
@@ -16,6 +16,7 @@
 #include <QtInstanceComboBox.hxx>
 #include <QtInstanceEntry.hxx>
 #include <QtInstanceFrame.hxx>
+#include <QtInstanceImage.hxx>
 #include <QtInstanceLabel.hxx>
 #include <QtInstanceMessageDialog.hxx>
 #include <QtInstanceRadioButton.hxx>
@@ -202,10 +203,11 @@ std::unique_ptr<weld::Spinner> 
QtInstanceBuilder::weld_spinner(const OUString&)
     return nullptr;
 }
 
-std::unique_ptr<weld::Image> QtInstanceBuilder::weld_image(const OUString&)
+std::unique_ptr<weld::Image> QtInstanceBuilder::weld_image(const OUString& rId)
 {
-    assert(false && "Not implemented yet");
-    return nullptr;
+    QLabel* pLabel = m_xBuilder->get<QLabel>(rId);
+    std::unique_ptr<weld::Image> xRet(pLabel ? 
std::make_unique<QtInstanceImage>(pLabel) : nullptr);
+    return xRet;
 }
 
 std::unique_ptr<weld::Calendar> QtInstanceBuilder::weld_calendar(const 
OUString&)
diff --git a/vcl/qt5/QtInstanceImage.cxx b/vcl/qt5/QtInstanceImage.cxx
new file mode 100644
index 000000000000..d41fa077e4c2
--- /dev/null
+++ b/vcl/qt5/QtInstanceImage.cxx
@@ -0,0 +1,33 @@
+/* -*- 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 <QtInstanceImage.hxx>
+
+#include <vcl/qt/QtUtils.hxx>
+
+QtInstanceImage::QtInstanceImage(QLabel* pLabel)
+    : QtInstanceWidget(pLabel)
+    , m_pLabel(pLabel)
+{
+    assert(m_pLabel);
+}
+
+void QtInstanceImage::set_from_icon_name(const OUString&)
+{
+    assert(false && "Not implemented yet");
+}
+
+void QtInstanceImage::set_image(VirtualDevice*) { assert(false && "Not 
implemented yet"); }
+
+void QtInstanceImage::set_image(const 
css::uno::Reference<css::graphic::XGraphic>&)
+{
+    assert(false && "Not implemented yet");
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt6/QtInstanceImage.cxx b/vcl/qt6/QtInstanceImage.cxx
new file mode 100644
index 000000000000..4f3779f4ab86
--- /dev/null
+++ b/vcl/qt6/QtInstanceImage.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/QtInstanceImage.cxx"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to