sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx |   34 ++++++++++++++++++++--
 sw/source/uibase/sidebar/A11yCheckIssuesPanel.hxx |    6 +++
 sw/uiconfig/swriter/ui/a11ycheckissuespanel.ui    |   26 ++++++++++++++++
 3 files changed, 64 insertions(+), 2 deletions(-)

New commits:
commit d6bcc816f0729c2ea1004a6ee8b692efde87a1a9
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Mon May 20 15:45:51 2024 +0900
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon Jun 17 10:39:39 2024 +0200

    sw: add update button to a11y check sidebar when using LOKit
    
    Running the a11y check when the sidebar gets enable takes some
    time, because populating the widgets is quite expensive. Instead
    of running the check right away, add a "update" button to the
    sidebar, that needs to be clicked first to start running the
    accessibility check. This does not check the behavior of the
    sidebar in desktop LibreOffice.
    
    Also change the populate call to be async, which helps a bit to
    make the UI interaction more fluent, but doesn't fix the issue.
    
    Change-Id: Ia04f4a5fbae952035c1b8d4d7c56211e061d8251
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167855
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    (cherry picked from commit 5e6d7927e27551aa63a2b22134b1a9ee6408d39a)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168784
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    (cherry picked from commit efd665b931fdc46f226964ac838fb72a73782b98)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168882
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx 
b/sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx
index bf5333ac6456..8bcaa97b7174 100644
--- a/sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx
+++ b/sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx
@@ -23,6 +23,7 @@
 #include <unotools/configmgr.hxx>
 #include <vcl/svapp.hxx>
 #include <o3tl/enumrange.hxx>
+#include <comphelper/lok.hxx>
 
 #include "A11yCheckIssuesPanel.hxx"
 
@@ -104,6 +105,10 @@ std::unique_ptr<PanelLayout> 
A11yCheckIssuesPanel::Create(weld::Widget* pParent,
 A11yCheckIssuesPanel::A11yCheckIssuesPanel(weld::Widget* pParent, SfxBindings* 
pBindings)
     : PanelLayout(pParent, u"A11yCheckIssuesPanel"_ustr,
                   u"modules/swriter/ui/a11ycheckissuespanel.ui"_ustr)
+    , mxAccessibilityBox(m_xBuilder->weld_box(u"accessibilityCheckBox"_ustr))
+    , mxUpdateBox(m_xBuilder->weld_box(u"updateBox"_ustr))
+    , 
mxUpdateLinkButton(m_xBuilder->weld_link_button(u"updateLinkButton"_ustr))
+
     , mpBindings(pBindings)
     , mpDoc(nullptr)
     , maA11yCheckController(FN_STAT_ACCESSIBILITY_CHECK, *pBindings, *this)
@@ -132,6 +137,9 @@ A11yCheckIssuesPanel::A11yCheckIssuesPanel(weld::Widget* 
pParent, SfxBindings* p
     m_xBoxes[8] = m_xBuilder->weld_box(u"box_numbering"_ustr);
     m_xBoxes[9] = m_xBuilder->weld_box(u"box_other"_ustr);
 
+    mxUpdateLinkButton->connect_activate_link(
+        LINK(this, A11yCheckIssuesPanel, UpdateLinkButtonClicked));
+
     SwDocShell* pDocSh = dynamic_cast<SwDocShell*>(SfxObjectShell::Current());
     if (!pDocSh)
         return;
@@ -150,9 +158,31 @@ A11yCheckIssuesPanel::A11yCheckIssuesPanel(weld::Widget* 
pParent, SfxBindings* p
 
     mpDoc = pDocSh->GetDoc();
 
-    populateIssues();
+    // If LOKit is enabled, then enable the update button and don't run the 
accessibility check.
+    // In desktop don't show the update button and schedule to run the 
accessibility check async
+    if (comphelper::LibreOfficeKit::isActive())
+    {
+        mxAccessibilityBox->hide();
+        mxUpdateBox->show();
+    }
+    else
+    {
+        mxAccessibilityBox->show();
+        mxUpdateBox->hide();
+        Application::PostUserEvent(LINK(this, A11yCheckIssuesPanel, 
PopulateIssuesHdl));
+    }
+}
+
+IMPL_LINK_NOARG(A11yCheckIssuesPanel, UpdateLinkButtonClicked, 
weld::LinkButton&, bool)
+{
+    mxAccessibilityBox->show();
+    mxUpdateBox->hide();
+    Application::PostUserEvent(LINK(this, A11yCheckIssuesPanel, 
PopulateIssuesHdl));
+    return true;
 }
 
+IMPL_LINK_NOARG(A11yCheckIssuesPanel, PopulateIssuesHdl, void*, void) { 
populateIssues(); }
+
 void A11yCheckIssuesPanel::ImplDestroy()
 {
     // Restore state when this panel is no longer used
@@ -196,7 +226,7 @@ void 
A11yCheckIssuesPanel::addEntryForGroup(AccessibilityCheckGroups eGroup,
 
 void A11yCheckIssuesPanel::populateIssues()
 {
-    if (!mpDoc)
+    if (!mpDoc || !mxAccessibilityBox->is_visible())
         return;
 
     sw::AccessibilityCheck aCheck(mpDoc);
diff --git a/sw/source/uibase/sidebar/A11yCheckIssuesPanel.hxx 
b/sw/source/uibase/sidebar/A11yCheckIssuesPanel.hxx
index 519cd6b244e8..ef8d4da0e186 100644
--- a/sw/source/uibase/sidebar/A11yCheckIssuesPanel.hxx
+++ b/sw/source/uibase/sidebar/A11yCheckIssuesPanel.hxx
@@ -78,11 +78,17 @@ private:
     std::array<std::vector<std::unique_ptr<AccessibilityCheckEntry>>, 10> 
m_aEntries;
     std::array<std::unique_ptr<weld::Expander>, 10> m_xExpanders;
     std::array<std::unique_ptr<weld::Box>, 10> m_xBoxes;
+    std::unique_ptr<weld::Box> mxAccessibilityBox;
+    std::unique_ptr<weld::Box> mxUpdateBox;
+    std::unique_ptr<weld::LinkButton> mxUpdateLinkButton;
 
     sfx::AccessibilityIssueCollection m_aIssueCollection;
     void removeAllEntries();
     void populateIssues();
 
+    DECL_LINK(UpdateLinkButtonClicked, weld::LinkButton&, bool);
+    DECL_LINK(PopulateIssuesHdl, void*, void);
+
     void addEntryForGroup(AccessibilityCheckGroups eGroup, 
std::vector<sal_Int32>& rIndices,
                           std::shared_ptr<sfx::AccessibilityIssue> const& 
pIssue);
 
diff --git a/sw/uiconfig/swriter/ui/a11ycheckissuespanel.ui 
b/sw/uiconfig/swriter/ui/a11ycheckissuespanel.ui
index 6657b8c80c4b..3918611f7590 100644
--- a/sw/uiconfig/swriter/ui/a11ycheckissuespanel.ui
+++ b/sw/uiconfig/swriter/ui/a11ycheckissuespanel.ui
@@ -318,5 +318,31 @@
         <property name="position">0</property>
       </packing>
     </child>
+    <child>
+      <object class="GtkBox" id="updateBox">
+        <property name="visible">True</property>
+        <property name="can-focus">False</property>
+        <property name="orientation">vertical</property>
+        <child>
+          <object class="GtkLinkButton" id="updateLinkButton">
+            <property name="label" translatable="yes" 
context="a11ycheckissuespanel|updateLinkButton">Click to update...</property>
+            <property name="visible">True</property>
+            <property name="can-focus">True</property>
+            <property name="receives-default">True</property>
+            <property name="relief">none</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">True</property>
+        <property name="position">1</property>
+      </packing>
+    </child>
   </object>
 </interface>

Reply via email to