summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2024-05-20 15:45:51 +0900
committerCaolán McNamara <caolan.mcnamara@collabora.com>2024-05-20 13:17:31 +0200
commit5e6d7927e27551aa63a2b22134b1a9ee6408d39a (patch)
tree7497d015814e4fd8557d6e6947761b636645f675
parent628f56a1802ad76cbe84a9a5590b04ed81a57a9e (diff)
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.mcnamara@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
-rw-r--r--sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx33
-rw-r--r--sw/source/uibase/sidebar/A11yCheckIssuesPanel.hxx6
-rw-r--r--sw/uiconfig/swriter/ui/a11ycheckissuespanel.ui26
3 files changed, 63 insertions, 2 deletions
diff --git a/sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx b/sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx
index 7bbbf130678c..c29574a84933 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"
@@ -103,6 +104,9 @@ std::unique_ptr<PanelLayout> A11yCheckIssuesPanel::Create(weld::Widget* pParent,
A11yCheckIssuesPanel::A11yCheckIssuesPanel(weld::Widget* pParent, SfxBindings* pBindings)
: PanelLayout(pParent, "A11yCheckIssuesPanel", "modules/swriter/ui/a11ycheckissuespanel.ui")
+ , mxAccessibilityBox(m_xBuilder->weld_box("accessibilityCheckBox"))
+ , mxUpdateBox(m_xBuilder->weld_box("updateBox"))
+ , mxUpdateLinkButton(m_xBuilder->weld_link_button("updateLinkButton"))
, mpBindings(pBindings)
, mpDoc(nullptr)
, maA11yCheckController(FN_STAT_ACCESSIBILITY_CHECK, *pBindings, *this)
@@ -131,6 +135,9 @@ A11yCheckIssuesPanel::A11yCheckIssuesPanel(weld::Widget* pParent, SfxBindings* p
m_xBoxes[8] = m_xBuilder->weld_box("box_numbering");
m_xBoxes[9] = m_xBuilder->weld_box("box_other");
+ mxUpdateLinkButton->connect_activate_link(
+ LINK(this, A11yCheckIssuesPanel, UpdateLinkButtonClicked));
+
SwDocShell* pDocSh = dynamic_cast<SwDocShell*>(SfxObjectShell::Current());
if (!pDocSh)
return;
@@ -149,9 +156,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
@@ -195,7 +224,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>