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

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Tue Jul 7 11:49:47 UTC 2020


 vcl/inc/jsdialog/jsdialogbuilder.hxx |    4 +++-
 vcl/jsdialog/jsdialogbuilder.cxx     |   27 +++++++++++++++++++++++----
 2 files changed, 26 insertions(+), 5 deletions(-)

New commits:
commit aff12153caab1abd5ab576cf5ff36b49c25310d4
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Tue Jul 7 13:15:31 2020 +0200
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Tue Jul 7 13:49:15 2020 +0200

    jsdialog: force update if tab is selected again
    
    This will allow to add additional tabs in the view
    (not existing in the JSON) and switching tabs still
    will work properly.
    
    Change-Id: Ia6901da3157b391502d5170f599410bfd6ea2c61
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98253
    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 ffc67e98ac5e..3118d3b65894 100644
--- a/vcl/inc/jsdialog/jsdialogbuilder.hxx
+++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx
@@ -30,11 +30,13 @@ class JSDialogNotifyIdle : public Idle
 {
     VclPtr<vcl::Window> m_aWindow;
     std::string m_LastNotificationMessage;
+    bool m_bForce;
 
 public:
     JSDialogNotifyIdle(VclPtr<vcl::Window> aWindow);
 
     void Invoke() override;
+    void ForceUpdate();
 };
 
 class VCL_DLLPUBLIC JSDialogSender
@@ -47,7 +49,7 @@ public:
     {
     }
 
-    void notifyDialogState();
+    void notifyDialogState(bool bForce = false);
 };
 
 class JSInstanceBuilder : public SalInstanceBuilder
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index 4601a26d4cd1..d9fcf3032081 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -22,10 +22,13 @@ JSDialogNotifyIdle::JSDialogNotifyIdle(VclPtr<vcl::Window> aWindow)
     : Idle("JSDialog notify")
     , m_aWindow(aWindow)
     , m_LastNotificationMessage()
+    , m_bForce(false)
 {
     SetPriority(TaskPriority::POST_PAINT);
 }
 
+void JSDialogNotifyIdle::ForceUpdate() { m_bForce = true; }
+
 void JSDialogNotifyIdle::Invoke()
 {
     try
@@ -41,8 +44,9 @@ void JSDialogNotifyIdle::Invoke()
             aTree.put("id", m_aWindow->GetLOKWindowId());
             boost::property_tree::write_json(aStream, aTree);
             const std::string message = aStream.str();
-            if (message != m_LastNotificationMessage)
+            if (m_bForce || message != m_LastNotificationMessage)
             {
+                m_bForce = false;
                 m_LastNotificationMessage = message;
                 pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, message.c_str());
             }
@@ -54,7 +58,12 @@ void JSDialogNotifyIdle::Invoke()
     }
 }
 
-void JSDialogSender::notifyDialogState() { mpIdleNotify->Start(); }
+void JSDialogSender::notifyDialogState(bool bForce)
+{
+    if (bForce)
+        mpIdleNotify->ForceUpdate();
+    mpIdleNotify->Start();
+}
 
 JSInstanceBuilder::JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIRoot,
                                      const OUString& rUIFile)
@@ -479,14 +488,24 @@ JSNotebook::JSNotebook(VclPtr<vcl::Window> aOwnedToplevel, ::TabControl* pContro
 
 void JSNotebook::set_current_page(int nPage)
 {
+    bool bForce = false;
+    int nCurrent = get_current_page();
+    if (nCurrent == nPage)
+        bForce = true;
+
     SalInstanceNotebook::set_current_page(nPage);
-    notifyDialogState();
+    notifyDialogState(bForce);
 }
 
 void JSNotebook::set_current_page(const OString& rIdent)
 {
+    bool bForce = false;
+    OString sCurrent = get_current_page_ident();
+    if (sCurrent == rIdent)
+        bForce = true;
+
     SalInstanceNotebook::set_current_page(rIdent);
-    notifyDialogState();
+    notifyDialogState(bForce);
 }
 
 void JSNotebook::remove_page(const OString& rIdent)


More information about the Libreoffice-commits mailing list