[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - vcl/inc vcl/jsdialog

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Wed May 13 15:49:19 UTC 2020


 vcl/inc/jsdialog/jsdialogbuilder.hxx |   32 ++++++++++++++++++++++++++++----
 vcl/jsdialog/jsdialogbuilder.cxx     |   14 ++++++--------
 2 files changed, 34 insertions(+), 12 deletions(-)

New commits:
commit bccb6b744378fc4f5f1dbab143c8da59fc5dc7aa
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Fri Feb 28 13:47:22 2020 +0100
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Wed May 13 17:48:47 2020 +0200

    jsdialog: Common weld::Widget implementation
    
    Change-Id: Iab21652c6abaf143fb421d6030f6acc394733bcb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94073
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    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 a82732d05f5a..98126bfcc12f 100644
--- a/vcl/inc/jsdialog/jsdialogbuilder.hxx
+++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx
@@ -36,7 +36,31 @@ public:
                                                            bool bTakeOwnership = false) override;
 };
 
-class VCL_DLLPUBLIC JSLabel : public SalInstanceLabel, public JSDialogSender
+template <class BaseInstanceClass, class VclClass>
+class JSWidget : public BaseInstanceClass, public JSDialogSender
+{
+public:
+    JSWidget(VclPtr<vcl::Window> aOwnedToplevel, VclClass* pObject, SalInstanceBuilder* pBuilder,
+             bool bTakeOwnership)
+        : BaseInstanceClass(pObject, pBuilder, bTakeOwnership)
+        , JSDialogSender(aOwnedToplevel)
+    {
+    }
+
+    virtual void show() override
+    {
+        BaseInstanceClass::show();
+        notifyDialogState();
+    }
+
+    virtual void hide() override
+    {
+        BaseInstanceClass::hide();
+        notifyDialogState();
+    }
+};
+
+class VCL_DLLPUBLIC JSLabel : public JSWidget<SalInstanceLabel, FixedText>
 {
 public:
     JSLabel(VclPtr<vcl::Window> aOwnedToplevel, FixedText* pLabel, SalInstanceBuilder* pBuilder,
@@ -44,7 +68,7 @@ public:
     virtual void set_label(const OUString& rText) override;
 };
 
-class VCL_DLLPUBLIC JSEntry : public SalInstanceEntry, public JSDialogSender
+class VCL_DLLPUBLIC JSEntry : public JSWidget<SalInstanceEntry, ::Edit>
 {
 public:
     JSEntry(VclPtr<vcl::Window> aOwnedToplevel, ::Edit* pEntry, SalInstanceBuilder* pBuilder,
@@ -52,7 +76,7 @@ public:
     virtual void set_text(const OUString& rText) override;
 };
 
-class VCL_DLLPUBLIC JSListBox : public SalInstanceComboBoxWithoutEdit, public JSDialogSender
+class VCL_DLLPUBLIC JSListBox : public JSWidget<SalInstanceComboBoxWithoutEdit, ::ListBox>
 {
 public:
     JSListBox(VclPtr<vcl::Window> aOwnedToplevel, ::ListBox* pListBox, SalInstanceBuilder* pBuilder,
@@ -62,7 +86,7 @@ public:
     virtual void remove(int pos) override;
 };
 
-class VCL_DLLPUBLIC JSComboBox : public SalInstanceComboBoxWithEdit, public JSDialogSender
+class VCL_DLLPUBLIC JSComboBox : public JSWidget<SalInstanceComboBoxWithEdit, ::ComboBox>
 {
 public:
     JSComboBox(VclPtr<vcl::Window> aOwnedToplevel, ::ComboBox* pComboBox,
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index 62fd9e16b24a..52fa6a19a8e1 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -86,8 +86,7 @@ std::unique_ptr<weld::ComboBox> JSInstanceBuilder::weld_combo_box(const OString&
 
 JSLabel::JSLabel(VclPtr<vcl::Window> aOwnedToplevel, FixedText* pLabel,
                  SalInstanceBuilder* pBuilder, bool bTakeOwnership)
-    : SalInstanceLabel(pLabel, pBuilder, bTakeOwnership)
-    , JSDialogSender(aOwnedToplevel)
+    : JSWidget<SalInstanceLabel, FixedText>(aOwnedToplevel, pLabel, pBuilder, bTakeOwnership)
 {
 }
 
@@ -99,8 +98,7 @@ void JSLabel::set_label(const OUString& rText)
 
 JSEntry::JSEntry(VclPtr<vcl::Window> aOwnedToplevel, ::Edit* pEntry, SalInstanceBuilder* pBuilder,
                  bool bTakeOwnership)
-    : SalInstanceEntry(pEntry, pBuilder, bTakeOwnership)
-    , JSDialogSender(aOwnedToplevel)
+    : JSWidget<SalInstanceEntry, ::Edit>(aOwnedToplevel, pEntry, pBuilder, bTakeOwnership)
 {
 }
 
@@ -112,8 +110,8 @@ void JSEntry::set_text(const OUString& rText)
 
 JSListBox::JSListBox(VclPtr<vcl::Window> aOwnedToplevel, ::ListBox* pListBox,
                      SalInstanceBuilder* pBuilder, bool bTakeOwnership)
-    : SalInstanceComboBoxWithoutEdit(pListBox, pBuilder, bTakeOwnership)
-    , JSDialogSender(aOwnedToplevel)
+    : JSWidget<SalInstanceComboBoxWithoutEdit, ::ListBox>(aOwnedToplevel, pListBox, pBuilder,
+                                                          bTakeOwnership)
 {
 }
 
@@ -132,8 +130,8 @@ void JSListBox::remove(int pos)
 
 JSComboBox::JSComboBox(VclPtr<vcl::Window> aOwnedToplevel, ::ComboBox* pComboBox,
                        SalInstanceBuilder* pBuilder, bool bTakeOwnership)
-    : SalInstanceComboBoxWithEdit(pComboBox, pBuilder, bTakeOwnership)
-    , JSDialogSender(aOwnedToplevel)
+    : JSWidget<SalInstanceComboBoxWithEdit, ::ComboBox>(aOwnedToplevel, pComboBox, pBuilder,
+                                                        bTakeOwnership)
 {
 }
 


More information about the Libreoffice-commits mailing list