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/QtInstanceBuilder.hxx  |    2 
 vcl/inc/qt5/QtInstanceNotebook.hxx |   40 +++++++++++++++++
 vcl/inc/qt6/QtInstanceNotebook.hxx |   12 +++++
 vcl/qt5/QtBuilder.cxx              |    4 +
 vcl/qt5/QtInstanceBuilder.cxx      |    9 ++--
 vcl/qt5/QtInstanceNotebook.cxx     |   83 +++++++++++++++++++++++++++++++++++++
 vcl/qt6/QtInstanceNotebook.cxx     |   12 +++++
 11 files changed, 162 insertions(+), 4 deletions(-)

New commits:
commit 6c957f1b4978d89149da3b379f85a5a526428a8a
Author:     Michael Weghorn <[email protected]>
AuthorDate: Sat Nov 9 22:03:16 2024 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Sun Nov 10 12:28:51 2024 +0100

    tdf#130857 qt weld: Add QtInstanceNotebook skeleton
    
    Add a new QtInstanceNotebook class that is the
    weld::Notebook implementation using a native
    Qt widget. It uses a QTabWidget.
    
    Initially, all methods trigger an assert;
    the actual logic still needs to be implemented
    in future commits.
    
    Let QtBuilder handle "GtkNotebook" objects by
    creating a QTabWidget and let
    QtInstanceBuilder::weld_notebook return
    an instance of the new class.
    
    Change-Id: I5a0671a1ba98bea3e0659e4f280706179bfb4d47
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176322
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/vcl/CustomTarget_qt5_moc.mk b/vcl/CustomTarget_qt5_moc.mk
index ace904832882..efa4fd9e16fd 100644
--- a/vcl/CustomTarget_qt5_moc.mk
+++ b/vcl/CustomTarget_qt5_moc.mk
@@ -22,6 +22,7 @@ $(call gb_CustomTarget_get_target,vcl/qt5) : \
        $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceLevelBar.moc \
        $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceLinkButton.moc \
        $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceMessageDialog.moc \
+       $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceNotebook.moc \
        $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceProgressBar.moc \
        $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceRadioButton.moc \
        $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceTreeView.moc \
diff --git a/vcl/CustomTarget_qt6_moc.mk b/vcl/CustomTarget_qt6_moc.mk
index bc961a273404..69fc48db7ae5 100644
--- a/vcl/CustomTarget_qt6_moc.mk
+++ b/vcl/CustomTarget_qt6_moc.mk
@@ -22,6 +22,7 @@ $(call gb_CustomTarget_get_target,vcl/qt6) : \
        $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceLevelBar.moc \
        $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceLinkButton.moc \
        $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceMessageDialog.moc \
+       $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceNotebook.moc \
        $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceProgressBar.moc \
        $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceRadioButton.moc \
        $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceTreeView.moc \
diff --git a/vcl/Library_vclplug_qt5.mk b/vcl/Library_vclplug_qt5.mk
index 6a61cd334c35..29dd1de6fba9 100644
--- a/vcl/Library_vclplug_qt5.mk
+++ b/vcl/Library_vclplug_qt5.mk
@@ -111,6 +111,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_qt5,\
     vcl/qt5/QtInstanceLevelBar \
     vcl/qt5/QtInstanceLinkButton \
     vcl/qt5/QtInstanceMessageDialog \
+    vcl/qt5/QtInstanceNotebook \
     vcl/qt5/QtInstanceProgressBar \
     vcl/qt5/QtInstanceRadioButton \
     vcl/qt5/QtInstanceSpinButton \
diff --git a/vcl/Library_vclplug_qt6.mk b/vcl/Library_vclplug_qt6.mk
index 188c5e71fd66..a1c28756220b 100644
--- a/vcl/Library_vclplug_qt6.mk
+++ b/vcl/Library_vclplug_qt6.mk
@@ -110,6 +110,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_qt6,\
     vcl/qt6/QtInstanceLevelBar \
     vcl/qt6/QtInstanceLinkButton \
     vcl/qt6/QtInstanceMessageDialog \
+    vcl/qt6/QtInstanceNotebook \
     vcl/qt6/QtInstanceProgressBar \
     vcl/qt6/QtInstanceRadioButton \
     vcl/qt6/QtInstanceSpinButton \
diff --git a/vcl/inc/qt5/QtInstanceBuilder.hxx 
b/vcl/inc/qt5/QtInstanceBuilder.hxx
index c1d562940777..dff208adfcda 100644
--- a/vcl/inc/qt5/QtInstanceBuilder.hxx
+++ b/vcl/inc/qt5/QtInstanceBuilder.hxx
@@ -40,7 +40,7 @@ public:
     virtual std::unique_ptr<weld::Frame> weld_frame(const OUString& rId) 
override;
     virtual std::unique_ptr<weld::ScrolledWindow>
     weld_scrolled_window(const OUString&, bool bUserManagedScrolling = false) 
override;
-    virtual std::unique_ptr<weld::Notebook> weld_notebook(const OUString&) 
override;
+    virtual std::unique_ptr<weld::Notebook> weld_notebook(const OUString& rId) 
override;
     virtual std::unique_ptr<weld::Button> weld_button(const OUString& rId) 
override;
     virtual std::unique_ptr<weld::MenuButton> weld_menu_button(const 
OUString&) override;
     virtual std::unique_ptr<weld::MenuToggleButton>
diff --git a/vcl/inc/qt5/QtInstanceNotebook.hxx 
b/vcl/inc/qt5/QtInstanceNotebook.hxx
new file mode 100644
index 000000000000..d8e83fe90ac3
--- /dev/null
+++ b/vcl/inc/qt5/QtInstanceNotebook.hxx
@@ -0,0 +1,40 @@
+/* -*- 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/QTabWidget>
+
+class QtInstanceNotebook : public QObject, public QtInstanceWidget, public 
virtual weld::Notebook
+{
+    Q_OBJECT
+
+    QTabWidget* m_pTabWidget;
+
+public:
+    QtInstanceNotebook(QTabWidget* pTabWidget);
+
+    virtual int get_current_page() const override;
+    virtual int get_page_index(const OUString& rIdent) const override;
+    virtual OUString get_page_ident(int nPage) const override;
+    virtual OUString get_current_page_ident() const override;
+    virtual void set_current_page(int nPage) override;
+    virtual void set_current_page(const OUString& rIdent) override;
+    virtual void remove_page(const OUString& rIdent) override;
+    virtual void insert_page(const OUString& rIdent, const OUString& rLabel, 
int nPos) override;
+    virtual void set_tab_label_text(const OUString& rIdent, const OUString& 
rLabel) override;
+    virtual OUString get_tab_label_text(const OUString& rIdent) const override;
+    virtual void set_show_tabs(bool bShow) override;
+    virtual int get_n_pages() const override;
+    virtual weld::Container* get_page(const OUString& rIdent) const override;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/qt6/QtInstanceNotebook.hxx 
b/vcl/inc/qt6/QtInstanceNotebook.hxx
new file mode 100644
index 000000000000..06cc26235db9
--- /dev/null
+++ b/vcl/inc/qt6/QtInstanceNotebook.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/QtInstanceNotebook.hxx"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/QtBuilder.cxx b/vcl/qt5/QtBuilder.cxx
index 68ecf56c4126..38c6ad278c34 100644
--- a/vcl/qt5/QtBuilder.cxx
+++ b/vcl/qt5/QtBuilder.cxx
@@ -245,6 +245,10 @@ QObject* QtBuilder::makeObject(QObject* pParent, 
std::u16string_view sName, cons
 
         pObject = pLabel;
     }
+    else if (sName == u"GtkNotebook")
+    {
+        pObject = new QTabWidget(pParentWidget);
+    }
     else if (sName == u"GtkRadioButton")
     {
         pObject = new QRadioButton(pParentWidget);
diff --git a/vcl/qt5/QtInstanceBuilder.cxx b/vcl/qt5/QtInstanceBuilder.cxx
index 84ac30fcbb6d..dc7632b78ec8 100644
--- a/vcl/qt5/QtInstanceBuilder.cxx
+++ b/vcl/qt5/QtInstanceBuilder.cxx
@@ -22,6 +22,7 @@
 #include <QtInstanceLevelBar.hxx>
 #include <QtInstanceLinkButton.hxx>
 #include <QtInstanceMessageDialog.hxx>
+#include <QtInstanceNotebook.hxx>
 #include <QtInstanceProgressBar.hxx>
 #include <QtInstanceRadioButton.hxx>
 #include <QtInstanceSpinButton.hxx>
@@ -150,10 +151,12 @@ std::unique_ptr<weld::ScrolledWindow> 
QtInstanceBuilder::weld_scrolled_window(co
     return nullptr;
 }
 
-std::unique_ptr<weld::Notebook> QtInstanceBuilder::weld_notebook(const 
OUString&)
+std::unique_ptr<weld::Notebook> QtInstanceBuilder::weld_notebook(const 
OUString& rId)
 {
-    assert(false && "Not implemented yet");
-    return nullptr;
+    QTabWidget* pTabWidget = m_xBuilder->get<QTabWidget>(rId);
+    std::unique_ptr<weld::Notebook> xRet(
+        pTabWidget ? std::make_unique<QtInstanceNotebook>(pTabWidget) : 
nullptr);
+    return xRet;
 }
 
 std::unique_ptr<weld::Button> QtInstanceBuilder::weld_button(const OUString& 
rId)
diff --git a/vcl/qt5/QtInstanceNotebook.cxx b/vcl/qt5/QtInstanceNotebook.cxx
new file mode 100644
index 000000000000..b6487fe79582
--- /dev/null
+++ b/vcl/qt5/QtInstanceNotebook.cxx
@@ -0,0 +1,83 @@
+/* -*- 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 <QtInstanceNotebook.hxx>
+#include <QtInstanceNotebook.moc>
+
+QtInstanceNotebook::QtInstanceNotebook(QTabWidget* pTabWidget)
+    : QtInstanceWidget(pTabWidget)
+    , m_pTabWidget(pTabWidget)
+{
+    assert(m_pTabWidget);
+}
+
+int QtInstanceNotebook::get_current_page() const
+{
+    assert(false && "Not implemented yet");
+    return -1;
+}
+
+int QtInstanceNotebook::get_page_index(const OUString&) const
+{
+    assert(false && "Not implemented yet");
+    return -1;
+}
+
+OUString QtInstanceNotebook::get_page_ident(int) const
+{
+    assert(false && "Not implemented yet");
+    return OUString();
+}
+
+OUString QtInstanceNotebook::get_current_page_ident() const
+{
+    assert(false && "Not implemented yet");
+    return OUString();
+}
+
+void QtInstanceNotebook::set_current_page(int) { assert(false && "Not 
implemented yet"); }
+
+void QtInstanceNotebook::set_current_page(const OUString&)
+{
+    assert(false && "Not implemented yet");
+}
+
+void QtInstanceNotebook::remove_page(const OUString&) { assert(false && "Not 
implemented yet"); }
+
+void QtInstanceNotebook::insert_page(const OUString&, const OUString&, int)
+{
+    assert(false && "Not implemented yet");
+}
+
+void QtInstanceNotebook::set_tab_label_text(const OUString&, const OUString&)
+{
+    assert(false && "Not implemented yet");
+}
+
+OUString QtInstanceNotebook::get_tab_label_text(const OUString&) const
+{
+    assert(false && "Not implemented yet");
+    return OUString();
+}
+
+void QtInstanceNotebook::set_show_tabs(bool) { assert(false && "Not 
implemented yet"); }
+
+int QtInstanceNotebook::get_n_pages() const
+{
+    assert(false && "Not implemented yet");
+    return 0;
+}
+
+weld::Container* QtInstanceNotebook::get_page(const OUString&) const
+{
+    assert(false && "Not implemented yet");
+    return nullptr;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt6/QtInstanceNotebook.cxx b/vcl/qt6/QtInstanceNotebook.cxx
new file mode 100644
index 000000000000..f374c183e265
--- /dev/null
+++ b/vcl/qt6/QtInstanceNotebook.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/QtInstanceNotebook.cxx"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to