[Libreoffice-commits] core.git: vcl/inc vcl/jsdialog

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Thu Nov 26 17:13:01 UTC 2020


 vcl/inc/jsdialog/jsdialogbuilder.hxx |   11 +++++++++++
 vcl/jsdialog/executor.cxx            |   12 ++++++++++++
 vcl/jsdialog/jsdialogbuilder.cxx     |   28 ++++++++++++++++++++++++++++
 3 files changed, 51 insertions(+)

New commits:
commit f424bed38ce34a3f73dafb6de20632ed8275cf18
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Tue Nov 17 14:32:04 2020 +0100
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Thu Nov 26 18:12:10 2020 +0100

    jsdialog: implemented Expander widget
    
    Change-Id: Ib0aee0e01c662a4d6a9231d9a1a951c9fa68eff4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106693
    Tested-by: Jenkins
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx
index 5d7df8086ae4..4b9e042960f4 100644
--- a/vcl/inc/jsdialog/jsdialogbuilder.hxx
+++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx
@@ -113,6 +113,7 @@ public:
     virtual std::unique_ptr<weld::Toolbar> weld_toolbar(const OString& id) override;
     virtual std::unique_ptr<weld::TextView> weld_text_view(const OString& id) override;
     virtual std::unique_ptr<weld::TreeView> weld_tree_view(const OString& id) override;
+    virtual std::unique_ptr<weld::Expander> weld_expander(const OString& id) override;
 
     static weld::MessageDialog* CreateMessageDialog(weld::Widget* pParent,
                                                     VclMessageType eMessageType,
@@ -310,4 +311,14 @@ public:
     virtual void select(int pos) override;
 };
 
+class JSExpander : public JSWidget<SalInstanceExpander, ::VclExpander>
+{
+public:
+    JSExpander(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
+               ::VclExpander* pExpander, SalInstanceBuilder* pBuilder, bool bTakeOwnership,
+               std::string sTypeOfJSON);
+
+    virtual void set_expanded(bool bExpand) override;
+};
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/vcl/jsdialog/executor.cxx b/vcl/jsdialog/executor.cxx
index 6ded26055270..24e3eb1f14d3 100644
--- a/vcl/jsdialog/executor.cxx
+++ b/vcl/jsdialog/executor.cxx
@@ -209,6 +209,18 @@ bool ExecuteAction(sal_uInt64 nWindowId, const OString& rWidget, StringMap& rDat
                 }
             }
         }
+        else if (sControlType == "expander")
+        {
+            auto pExpander = dynamic_cast<weld::Expander*>(pWidget);
+            if (pExpander)
+            {
+                if (sAction == "toggle")
+                {
+                    pExpander->set_expanded(!pExpander->get_expanded());
+                    return true;
+                }
+            }
+        }
     }
 
     return false;
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index b72dae272500..4fb351b5439f 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -452,6 +452,20 @@ std::unique_ptr<weld::TreeView> JSInstanceBuilder::weld_tree_view(const OString&
     return pWeldWidget;
 }
 
+std::unique_ptr<weld::Expander> JSInstanceBuilder::weld_expander(const OString& id)
+{
+    VclExpander* pExpander = m_xBuilder->get<VclExpander>(id);
+    auto pWeldWidget = pExpander
+                           ? std::make_unique<JSExpander>(GetNotifierWindow(), GetContentWindow(),
+                                                          pExpander, this, false, m_sTypeOfJSON)
+                           : nullptr;
+
+    if (pWeldWidget)
+        RememberWidget(id, pWeldWidget.get());
+
+    return pWeldWidget;
+}
+
 weld::MessageDialog* JSInstanceBuilder::CreateMessageDialog(weld::Widget* pParent,
                                                             VclMessageType eMessageType,
                                                             VclButtonsType eButtonType,
@@ -779,4 +793,18 @@ void JSTreeView::select(int pos)
     enable_notify_events();
 }
 
+JSExpander::JSExpander(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
+                       ::VclExpander* pExpander, SalInstanceBuilder* pBuilder, bool bTakeOwnership,
+                       std::string sTypeOfJSON)
+    : JSWidget<SalInstanceExpander, ::VclExpander>(aNotifierWindow, aContentWindow, pExpander,
+                                                   pBuilder, bTakeOwnership, sTypeOfJSON)
+{
+}
+
+void JSExpander::set_expanded(bool bExpand)
+{
+    SalInstanceExpander::set_expanded(bExpand);
+    notifyDialogState();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */


More information about the Libreoffice-commits mailing list