diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2021-12-14 18:21:39 +0100 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2022-02-21 05:31:53 +0100 |
commit | 522bde9470bbb321813fa5f1ca8e3c2ebb1bb5cc (patch) | |
tree | c9e766fa594245b6b01b6c7e3af4feba693c8c52 /svx/source/tbxctrls/StylesPreviewWindow.cxx | |
parent | 3ab1a849ba54410d14e2c988ae010f2c31dd4dce (diff) |
Update styles previews in Idle
This helps with performance when we do series of actions
updating styles. In that case we will only request update.
When we will reach idle state we will do it only one time.
What removes unnecessary updates in the meantime.
Change-Id: I9fc59992833a6cf98c42571c1189b3c5d49ba5a0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126840
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130232
Tested-by: Jenkins
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'svx/source/tbxctrls/StylesPreviewWindow.cxx')
-rw-r--r-- | svx/source/tbxctrls/StylesPreviewWindow.cxx | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/svx/source/tbxctrls/StylesPreviewWindow.cxx b/svx/source/tbxctrls/StylesPreviewWindow.cxx index 228e322be50a..2c27c2fb834f 100644 --- a/svx/source/tbxctrls/StylesPreviewWindow.cxx +++ b/svx/source/tbxctrls/StylesPreviewWindow.cxx @@ -100,7 +100,7 @@ StylePoolChangeListener::~StylePoolChangeListener() void StylePoolChangeListener::Notify(SfxBroadcaster& /*rBC*/, const SfxHint& /*rHint*/) { - m_pPreviewControl->UpdateStylesList(); + m_pPreviewControl->RequestStylesListUpdate(); } StyleItemController::StyleItemController(const std::pair<OUString, OUString>& aStyleName) @@ -358,6 +358,7 @@ StylesPreviewWindow_Base::StylesPreviewWindow_Base( const css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider) : m_xDispatchProvider(xDispatchProvider) , m_xStylesView(xBuilder.weld_icon_view("stylesview")) + , m_aUpdateTask(*this) , m_aDefaultStyles(std::move(aDefaultStyles)) { m_xStylesView->connect_selection_changed(LINK(this, StylesPreviewWindow_Base, Selected)); @@ -368,8 +369,7 @@ StylesPreviewWindow_Base::StylesPreviewWindow_Base( m_pStylePoolChangeListener.reset(new StylePoolChangeListener(this)); - UpdateStylesList(); - Update(); + RequestStylesListUpdate(); } IMPL_LINK(StylesPreviewWindow_Base, Selected, weld::IconView&, rIconView, void) @@ -405,6 +405,8 @@ StylesPreviewWindow_Base::~StylesPreviewWindow_Base() { m_xStatusListener->UnBind(); + m_aUpdateTask.Stop(); + try { m_xStatusListener->dispose(); @@ -420,10 +422,10 @@ void StylesPreviewWindow_Base::Select(const OUString& rStyleName) { m_sSelectedStyle = rStyleName; - Update(); + UpdateSelection(); } -void StylesPreviewWindow_Base::Update() +void StylesPreviewWindow_Base::UpdateSelection() { for (std::vector<std::pair<OUString, OUString>>::size_type i = 0; i < m_aAllStyles.size(); ++i) { @@ -435,6 +437,14 @@ void StylesPreviewWindow_Base::Update() } } +void StylesPreviewWindow_Base::RequestStylesListUpdate() { m_aUpdateTask.Start(); } + +void StylesListUpdateTask::Invoke() +{ + m_rStylesList.UpdateStylesList(); + m_rStylesList.UpdateSelection(); +} + void StylesPreviewWindow_Base::UpdateStylesList() { m_aAllStyles = m_aDefaultStyles; |