include/sfx2/weldutils.hxx | 4 ++ include/vcl/weld.hxx | 1 sfx2/source/toolbox/weldutils.cxx | 52 +++++++++++++++++++++++++++++++++++++- vcl/source/app/salvtables.cxx | 22 ++++++++++++++++ vcl/unx/gtk3/gtk3gtkinst.cxx | 23 ++++++++++++++++ 5 files changed, 101 insertions(+), 1 deletion(-)
New commits: commit ac748be2f0a3d5ba965eb8a3ace0b526a65a48cb Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Thu Jan 16 10:47:37 2020 +0000 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Thu Jan 16 15:19:24 2020 +0100 use sidebar icon size setting for welded toolboxes in sidebars Change-Id: Ie582a76e87126effca9260b58d8a8bef51c147ae Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86908 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/include/sfx2/weldutils.hxx b/include/sfx2/weldutils.hxx index 2486ca97307e..8c577f9a1651 100644 --- a/include/sfx2/weldutils.hxx +++ b/include/sfx2/weldutils.hxx @@ -16,6 +16,7 @@ #include <com/sun/star/uno/Reference.hxx> #include <tools/link.hxx> #include <sfx2/dllapi.h> +#include <svtools/miscopt.hxx> #include <vcl/svapp.hxx> #include <vcl/weld.hxx> @@ -30,12 +31,15 @@ class SFX2_DLLPUBLIC ToolbarUnoDispatcher { private: css::uno::Reference<css::frame::XFrame> m_xFrame; + SvtMiscOptions m_aToolbarOptions; weld::Toolbar* m_pToolbar; DECL_LINK(SelectHdl, const OString&, void); DECL_LINK(ToggleMenuHdl, const OString&, void); + DECL_LINK(ChangedIconSizeHandler, LinkParamNone*, void); void CreateController(const OUString& rCommand); + vcl::ImageType GetIconSize() const; typedef std::map<OUString, css::uno::Reference<css::frame::XToolbarController>> ControllerContainer; diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx index 6d99c3516589..9890be5d4bc0 100644 --- a/include/vcl/weld.hxx +++ b/include/vcl/weld.hxx @@ -1995,6 +1995,7 @@ public: virtual void set_item_tooltip_text(int nIndex, const OUString& rTip) = 0; virtual vcl::ImageType get_icon_size() const = 0; + virtual void set_icon_size(vcl::ImageType eType) = 0; void connect_clicked(const Link<const OString&, void>& rLink) { m_aClickHdl = rLink; } void connect_menu_toggled(const Link<const OString&, void>& rLink) { m_aToggleMenuHdl = rLink; } diff --git a/sfx2/source/toolbox/weldutils.cxx b/sfx2/source/toolbox/weldutils.cxx index 112f285297c5..327373d45819 100644 --- a/sfx2/source/toolbox/weldutils.cxx +++ b/sfx2/source/toolbox/weldutils.cxx @@ -7,6 +7,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include <com/sun/star/frame/XSubToolbarController.hpp> #include <comphelper/dispatchcommand.hxx> #include <sfx2/sidebar/ControllerFactory.hxx> #include <sfx2/weldutils.hxx> @@ -52,6 +53,25 @@ bool lcl_RTLizeCommandURL(OUString& rCommandURL) } } +// for now all controllers are in the sidebar +vcl::ImageType ToolbarUnoDispatcher::GetIconSize() const +{ + vcl::ImageType eType = vcl::ImageType::Size16; + switch (m_aToolbarOptions.GetSidebarIconSize()) + { + case ToolBoxButtonSize::Large: + eType = vcl::ImageType::Size26; + break; + case ToolBoxButtonSize::Size32: + eType = vcl::ImageType::Size32; + break; + case ToolBoxButtonSize::DontCare: + case ToolBoxButtonSize::Small: + break; + } + return eType; +} + ToolbarUnoDispatcher::ToolbarUnoDispatcher(weld::Toolbar& rToolbar, const css::uno::Reference<css::frame::XFrame>& rFrame) : m_xFrame(rFrame) @@ -61,7 +81,8 @@ ToolbarUnoDispatcher::ToolbarUnoDispatcher(weld::Toolbar& rToolbar, rToolbar.connect_menu_toggled(LINK(this, ToolbarUnoDispatcher, ToggleMenuHdl)); OUString aModuleName(vcl::CommandInfoProvider::GetModuleIdentifier(rFrame)); - vcl::ImageType eSize = rToolbar.get_icon_size(); + vcl::ImageType eSize = GetIconSize(); + rToolbar.set_icon_size(eSize); bool bRTL = AllSettings::GetLayoutRTL(); @@ -82,6 +103,8 @@ ToolbarUnoDispatcher::ToolbarUnoDispatcher(weld::Toolbar& rToolbar, CreateController(sCommand); } + + m_aToolbarOptions.AddListenerLink(LINK(this, ToolbarUnoDispatcher, ChangedIconSizeHandler)); } void ToolbarUnoDispatcher::CreateController(const OUString& rCommand) @@ -121,11 +144,38 @@ IMPL_LINK(ToolbarUnoDispatcher, ToggleMenuHdl, const OString&, rCommand, void) xController->click(); } +IMPL_LINK_NOARG(ToolbarUnoDispatcher, ChangedIconSizeHandler, LinkParamNone*, void) +{ + vcl::ImageType eSize = GetIconSize(); + m_pToolbar->set_icon_size(eSize); + + for (int i = 0, nItems = m_pToolbar->get_n_items(); i < nItems; ++i) + { + OUString sCommand = OUString::fromUtf8(m_pToolbar->get_item_ident(i)); + auto xImage(vcl::CommandInfoProvider::GetXGraphicForCommand(sCommand, m_xFrame, eSize)); + m_pToolbar->set_item_image(i, xImage); + } + + for (auto const& it : maControllers) + { + css::uno::Reference<css::frame::XSubToolbarController> xController(it.second, + css::uno::UNO_QUERY); + if (xController.is() && xController->opensSubToolbar()) + { + // The button should show the last function that was selected from the + // dropdown. The controller should know better than us what it was. + xController->updateImage(); + } + } +} + void ToolbarUnoDispatcher::dispose() { if (!m_pToolbar) return; + m_aToolbarOptions.RemoveListenerLink(LINK(this, ToolbarUnoDispatcher, ChangedIconSizeHandler)); + ControllerContainer aControllers; aControllers.swap(maControllers); for (auto const& controller : aControllers) diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 7cb974d90635..248a62090f06 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -1164,6 +1164,28 @@ public: return m_xToolBox->GetImageSize(); } + virtual void set_icon_size(vcl::ImageType eType) override + { + ToolBoxButtonSize eButtonSize = ToolBoxButtonSize::DontCare; + switch (eType) + { + case vcl::ImageType::Size16: + eButtonSize = ToolBoxButtonSize::Small; + break; + case vcl::ImageType::Size26: + eButtonSize = ToolBoxButtonSize::Large; + break; + case vcl::ImageType::Size32: + eButtonSize = ToolBoxButtonSize::Size32; + break; + } + if (m_xToolBox->GetToolboxButtonSize() != eButtonSize) + { + m_xToolBox->SetToolboxButtonSize(eButtonSize); + m_xToolBox->queue_resize(); + } + } + virtual ~SalInstanceToolbar() override { m_xToolBox->SetDropdownClickHdl(Link<ToolBox*, void>()); diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 45b4c529f50b..f4424ac18e5c 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -7049,6 +7049,24 @@ public: } return eRet; } + + GtkIconSize VclToGtk(vcl::ImageType eSize) + { + GtkIconSize eRet; + switch (eSize) + { + case vcl::ImageType::Size16: + eRet = GTK_ICON_SIZE_SMALL_TOOLBAR; + break; + case vcl::ImageType::Size26: + eRet = GTK_ICON_SIZE_LARGE_TOOLBAR; + break; + case vcl::ImageType::Size32: + eRet = GTK_ICON_SIZE_DIALOG; + break; + } + return eRet; + } } void GtkInstanceMenuButton::set_menu(weld::Menu* pMenu) @@ -7410,6 +7428,11 @@ public: return GtkToVcl(gtk_toolbar_get_icon_size(m_pToolbar)); } + virtual void set_icon_size(vcl::ImageType eType) override + { + return gtk_toolbar_set_icon_size(m_pToolbar, VclToGtk(eType)); + } + virtual ~GtkInstanceToolbar() override { for (auto& a : m_aMap) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits