diff options
author | Szymon Kłos <eszkadev@gmail.com> | 2016-06-16 12:33:39 +0200 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2016-07-01 13:31:46 +0000 |
commit | 4760c44c80e6dece5fe1a2e170b0f69c500a9681 (patch) | |
tree | a32b987b0a8821498dc00d3ee92eb0908270fbf1 /sfx2 | |
parent | 663b7aec30703c8479c9dec2f8955bdc28bdca5e (diff) |
GSoC possibility to change icon size in the SidebarToolBox
+ Added registy entry to store icon size
+ Added UI to change settings: Tools -> Options... -> View
+ Loading last settings in the SidebarToolBox
+ Settings update listener
Update icon code from: framework/source/uielement/toolbarmanager.cxx
Change-Id: I1d713c50fccfc19e1c8ea82eba68556ddb76cd3c
Reviewed-on: https://gerrit.libreoffice.org/26362
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/sidebar/SidebarToolBox.cxx | 61 |
1 files changed, 60 insertions, 1 deletions
diff --git a/sfx2/source/sidebar/SidebarToolBox.cxx b/sfx2/source/sidebar/SidebarToolBox.cxx index ab4f89d92b55..986cd33a11cb 100644 --- a/sfx2/source/sidebar/SidebarToolBox.cxx +++ b/sfx2/source/sidebar/SidebarToolBox.cxx @@ -21,13 +21,17 @@ #include <sfx2/sidebar/ControllerFactory.hxx> #include <sfx2/sidebar/Theme.hxx> #include <sfx2/sidebar/Tools.hxx> +#include <sfx2/viewfrm.hxx> #include <vcl/builderfactory.hxx> +#include <vcl/commandinfoprovider.hxx> #include <vcl/gradient.hxx> #include <vcl/settings.hxx> +#include <vcl/svapp.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <svtools/miscopt.hxx> #include <com/sun/star/frame/XSubToolbarController.hpp> +#include <framework/addonsoptions.hxx> using namespace css; using namespace css::uno; @@ -59,7 +63,17 @@ SidebarToolBox::SidebarToolBox (vcl::Window* pParentWindow) { SetBackground(Wallpaper()); SetPaintTransparent(true); - SetToolboxButtonSize( TOOLBOX_BUTTONSIZE_SMALL ); + + ToolBoxButtonSize eSize = TOOLBOX_BUTTONSIZE_SMALL; + + SvtMiscOptions aMiscOptions; + aMiscOptions.AddListenerLink(LINK(this, SidebarToolBox, ChangedIconSizeHandler)); + + sal_uInt16 nSize = aMiscOptions.GetSidebarIconSize(); + if (nSize <= TOOLBOX_BUTTONSIZE_LARGE) + eSize = static_cast<ToolBoxButtonSize>(nSize); + + SetToolboxButtonSize(eSize); #ifdef DEBUG SetText(OUString("SidebarToolBox")); @@ -75,6 +89,9 @@ SidebarToolBox::~SidebarToolBox() void SidebarToolBox::dispose() { + SvtMiscOptions aMiscOptions; + aMiscOptions.RemoveListenerLink(LINK(this, SidebarToolBox, ChangedIconSizeHandler)); + ControllerContainer aControllers; aControllers.swap(maControllers); for (ControllerContainer::iterator iController(aControllers.begin()), iEnd(aControllers.end()); @@ -241,6 +258,48 @@ IMPL_LINK_TYPED(SidebarToolBox, SelectHandler, ToolBox*, pToolBox, void) xController->execute((sal_Int16)pToolBox->GetModifier()); } +IMPL_LINK_NOARG_TYPED(SidebarToolBox, ChangedIconSizeHandler, LinkParamNone*, void) +{ + SolarMutexGuard g; + + ToolBoxButtonSize eSize = TOOLBOX_BUTTONSIZE_SMALL; + + SvtMiscOptions aMiscOptions; + sal_uInt16 nSize = aMiscOptions.GetSidebarIconSize(); + if(nSize <= TOOLBOX_BUTTONSIZE_LARGE) + eSize = static_cast<ToolBoxButtonSize>(nSize); + + bool bBigImages(eSize == TOOLBOX_BUTTONSIZE_LARGE); + SetToolboxButtonSize(eSize); + + for (auto const& it : maControllers) + { + Reference<frame::XSubToolbarController> xController(it.second, 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(); + } + else + { + OUString aCommandURL = GetItemCommand(it.first); + if(SfxViewFrame::Current()) + { + css::uno::Reference<frame::XFrame> xFrame = SfxViewFrame::Current()->GetFrame().GetFrameInterface(); + Image aImage = vcl::CommandInfoProvider::Instance().GetImageForCommand(aCommandURL, bBigImages, xFrame); + // Try also to query for add-on images before giving up and use an + // empty image. + if (!aImage) + aImage = framework::AddonsOptions().GetImageFromURL(aCommandURL, bBigImages); + SetItemImage(it.first, aImage); + } + } + } + + queue_resize(); +} + } } // end of namespace sfx2::sidebar /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |