From 4760c44c80e6dece5fe1a2e170b0f69c500a9681 Mon Sep 17 00:00:00 2001 From: Szymon Kłos Date: Thu, 16 Jun 2016 12:33:39 +0200 Subject: 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 Reviewed-by: Samuel Mehrbrodt --- cui/source/options/optgdlg.cxx | 23 ++++++++ cui/source/options/optgdlg.hxx | 2 + cui/uiconfig/ui/optviewpage.ui | 39 ++++++++++++-- include/sfx2/sidebar/SidebarToolBox.hxx | 1 + include/svtools/miscopt.hxx | 2 + .../schema/org/openoffice/Office/Common.xcs | 24 +++++++++ sfx2/source/sidebar/SidebarToolBox.cxx | 61 +++++++++++++++++++++- svtools/source/config/miscopt.cxx | 55 ++++++++++++++++++- 8 files changed, 200 insertions(+), 7 deletions(-) diff --git a/cui/source/options/optgdlg.cxx b/cui/source/options/optgdlg.cxx index c8b07afff987..bba62a3cf18f 100644 --- a/cui/source/options/optgdlg.cxx +++ b/cui/source/options/optgdlg.cxx @@ -612,6 +612,7 @@ void CanvasSettings::EnabledHardwareAcceleration( bool _bEnabled ) const OfaViewTabPage::OfaViewTabPage(vcl::Window* pParent, const SfxItemSet& rSet) : SfxTabPage(pParent, "OptViewPage", "cui/ui/optviewpage.ui", &rSet) , nSizeLB_InitialSelection(0) + , nSidebarSizeLB_InitialSelection(0) , nStyleLB_InitialSelection(0) , pAppearanceCfg(new SvtTabAppearanceCfg) , pCanvasSettings(new CanvasSettings) @@ -620,6 +621,7 @@ OfaViewTabPage::OfaViewTabPage(vcl::Window* pParent, const SfxItemSet& rSet) { get(m_pWindowSizeMF, "windowsize"); get(m_pIconSizeLB, "iconsize"); + get(m_pSidebarIconSizeLB, "sidebariconsize"); get(m_pIconStyleLB, "iconstyle"); get(m_pFontAntiAliasing, "aafont"); @@ -701,6 +703,7 @@ void OfaViewTabPage::dispose() pAppearanceCfg = nullptr; m_pWindowSizeMF.clear(); m_pIconSizeLB.clear(); + m_pSidebarIconSizeLB.clear(); m_pIconStyleLB.clear(); m_pFontAntiAliasing.clear(); m_pAAPointLimitLabel.clear(); @@ -759,6 +762,22 @@ bool OfaViewTabPage::FillItemSet( SfxItemSet* ) aMiscOptions.SetSymbolsSize( eSet ); } + const sal_Int32 nSidebarSizeLB_NewSelection = m_pSidebarIconSizeLB->GetSelectEntryPos(); + if( nSidebarSizeLB_InitialSelection != nSidebarSizeLB_NewSelection ) + { + // from now on it's modified, even if via auto setting the same size was set as now selected in the LB + sal_Int16 eSet = TOOLBOX_BUTTONSIZE_DONTCARE; + switch( nSidebarSizeLB_NewSelection ) + { + case 0: eSet = TOOLBOX_BUTTONSIZE_DONTCARE; break; + case 1: eSet = TOOLBOX_BUTTONSIZE_SMALL; break; + case 2: eSet = TOOLBOX_BUTTONSIZE_LARGE; break; + default: + OSL_FAIL( "OfaViewTabPage::FillItemSet(): This state of m_pSidebarIconSizeLB should not be possible!" ); + } + aMiscOptions.SetSidebarIconSize( eSet ); + } + const sal_Int32 nStyleLB_NewSelection = m_pIconStyleLB->GetSelectEntryPos(); if( nStyleLB_InitialSelection != nStyleLB_NewSelection ) { @@ -904,6 +923,10 @@ void OfaViewTabPage::Reset( const SfxItemSet* ) nSizeLB_InitialSelection = ( aMiscOptions.AreCurrentSymbolsLarge() )? 2 : 1; m_pIconSizeLB->SelectEntryPos( nSizeLB_InitialSelection ); m_pIconSizeLB->SaveValue(); + if( aMiscOptions.GetSidebarIconSize() != TOOLBOX_BUTTONSIZE_DONTCARE ) + nSidebarSizeLB_InitialSelection = aMiscOptions.GetSidebarIconSize(); + m_pSidebarIconSizeLB->SelectEntryPos( nSidebarSizeLB_InitialSelection ); + m_pSidebarIconSizeLB->SaveValue(); if (aMiscOptions.IconThemeWasSetAutomatically()) { nStyleLB_InitialSelection = 0; diff --git a/cui/source/options/optgdlg.hxx b/cui/source/options/optgdlg.hxx index e6d99e67ad67..60df261b5de9 100644 --- a/cui/source/options/optgdlg.hxx +++ b/cui/source/options/optgdlg.hxx @@ -81,6 +81,7 @@ class OfaViewTabPage : public SfxTabPage private: VclPtr m_pWindowSizeMF; VclPtr m_pIconSizeLB; + VclPtr m_pSidebarIconSizeLB; VclPtr m_pIconStyleLB; VclPtr m_pFontAntiAliasing; @@ -103,6 +104,7 @@ private: VclPtr m_pMouseMiddleLB; sal_Int32 nSizeLB_InitialSelection; + sal_Int32 nSidebarSizeLB_InitialSelection; sal_Int32 nStyleLB_InitialSelection; SvtTabAppearanceCfg* pAppearanceCfg; diff --git a/cui/uiconfig/ui/optviewpage.ui b/cui/uiconfig/ui/optviewpage.ui index c6b899af4d81..5b9e03ccbb39 100644 --- a/cui/uiconfig/ui/optviewpage.ui +++ b/cui/uiconfig/ui/optviewpage.ui @@ -367,7 +367,7 @@ 1 - 2 + 3 @@ -396,7 +396,7 @@ 0 - 2 + 3 @@ -411,7 +411,7 @@ 0 - 3 + 4 2 @@ -426,7 +426,7 @@ 0 - 4 + 5 @@ -439,7 +439,36 @@ 1 - 4 + 5 + + + + + True + False + end + Sidebar _icon size: + True + iconsize + + + 0 + 2 + + + + + True + False + + Automatic + Small + Large + + + + 1 + 2 diff --git a/include/sfx2/sidebar/SidebarToolBox.hxx b/include/sfx2/sidebar/SidebarToolBox.hxx index 6e2d053a31db..d56a81b833ec 100644 --- a/include/sfx2/sidebar/SidebarToolBox.hxx +++ b/include/sfx2/sidebar/SidebarToolBox.hxx @@ -66,6 +66,7 @@ private: DECL_LINK_TYPED(ClickHandler, ToolBox*, void); DECL_LINK_TYPED(DoubleClickHandler, ToolBox*, void); DECL_LINK_TYPED(SelectHandler, ToolBox*, void); + DECL_LINK_TYPED(ChangedIconSizeHandler, LinkParamNone*, void ); css::uno::Reference GetControllerForItemId(const sal_uInt16 nItemId) const; diff --git a/include/svtools/miscopt.hxx b/include/svtools/miscopt.hxx index 80835a9058e7..1ec74ce1d57d 100644 --- a/include/svtools/miscopt.hxx +++ b/include/svtools/miscopt.hxx @@ -62,6 +62,8 @@ class SVT_DLLPUBLIC SvtMiscOptions: public utl::detail::Options sal_Int16 GetSymbolsSize() const; void SetSymbolsSize( sal_Int16 eSet ); + sal_Int16 GetSidebarIconSize() const; + void SetSidebarIconSize( sal_Int16 eSet ); sal_Int16 GetCurrentSymbolsSize() const; bool AreCurrentSymbolsLarge() const; diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs index a9097caa0b40..ca23bd80be2d 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -5695,6 +5695,30 @@ 2 + + + + Specifies which size of the icons is used for the + sidebar. + + + + + will let the toolbox decide about its size + + + + + small icons + + + + + large icons + + + + 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 #include #include +#include #include +#include #include #include +#include #include #include #include +#include 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(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(nSize); + + bool bBigImages(eSize == TOOLBOX_BUTTONSIZE_LARGE); + SetToolboxButtonSize(eSize); + + for (auto const& it : maControllers) + { + Reference 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 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: */ diff --git a/svtools/source/config/miscopt.cxx b/svtools/source/config/miscopt.cxx index 2d30403096a3..67939398b89c 100644 --- a/svtools/source/config/miscopt.cxx +++ b/svtools/source/config/miscopt.cxx @@ -62,6 +62,8 @@ using namespace ::com::sun::star; #define PROPERTYHANDLE_EXPERIMENTALMODE 8 #define PROPERTYNAME_MACRORECORDERMODE "MacroRecorderMode" #define PROPERTYHANDLE_MACRORECORDERMODE 9 +#define PROPERTYNAME_SIDEBARICONSIZE "SidebarIconSize" +#define PROPERTYHANDLE_SIDEBARICONSIZE 10 #define VCL_TOOLBOX_STYLE_FLAT ((sal_uInt16)0x0004) // from @@ -75,6 +77,8 @@ private: bool m_bIsPluginsEnabledRO; sal_Int16 m_nSymbolsSize; bool m_bIsSymbolsSizeRO; + sal_Int16 m_nSidebarIconSize; + bool m_bIsSidebarIconSizeRO; bool m_bIsSymbolsStyleRO; sal_Int16 m_nToolboxStyle; bool m_bIsToolboxStyleRO; @@ -146,8 +150,13 @@ public: inline sal_Int16 GetSymbolsSize() { return m_nSymbolsSize; } + inline sal_Int16 GetSidebarIconSize() + { return m_nSidebarIconSize; } + void SetSymbolsSize( sal_Int16 nSet ); + void SetSidebarIconSize( sal_Int16 nSet ); + static OUString GetIconTheme(); enum SetModifiedFlag { SET_MODIFIED, DONT_SET_MODIFIED }; @@ -225,6 +234,8 @@ SvtMiscOptions_Impl::SvtMiscOptions_Impl() , m_bIsPluginsEnabledRO( false ) , m_nSymbolsSize( 0 ) , m_bIsSymbolsSizeRO( false ) + , m_nSidebarIconSize( 0 ) + , m_bIsSidebarIconSizeRO( false ) , m_bIsSymbolsStyleRO( false ) , m_nToolboxStyle( 1 ) , m_bIsToolboxStyleRO( false ) @@ -275,6 +286,16 @@ SvtMiscOptions_Impl::SvtMiscOptions_Impl() break; } + case PROPERTYHANDLE_SIDEBARICONSIZE : + { + if( !(seqValues[nProperty] >>= m_nSidebarIconSize) ) + { + OSL_FAIL("Wrong type of \"Misc\\SidebarIconSize\"!" ); + } + m_bIsSidebarIconSizeRO = seqRO[nProperty]; + break; + } + case PROPERTYHANDLE_TOOLBOXSTYLE : { if( !(seqValues[nProperty] >>= m_nToolboxStyle) ) @@ -404,6 +425,13 @@ void SvtMiscOptions_Impl::Load( const Sequence< OUString >& rPropertyNames ) } } break; + case PROPERTYHANDLE_SIDEBARICONSIZE : { + if( !(seqValues[nProperty] >>= m_nSidebarIconSize) ) + { + OSL_FAIL("Wrong type of \"Misc\\SidebarIconSize\"!" ); + } + } + break; case PROPERTYHANDLE_TOOLBOXSTYLE : { if( !(seqValues[nProperty] >>= m_nToolboxStyle) ) { @@ -486,6 +514,13 @@ void SvtMiscOptions_Impl::SetSymbolsSize( sal_Int16 nSet ) CallListeners(); } +void SvtMiscOptions_Impl::SetSidebarIconSize( sal_Int16 nSet ) +{ + m_nSidebarIconSize = nSet; + SetModified(); + CallListeners(); +} + OUString SvtMiscOptions_Impl::GetIconTheme() { return Application::GetSettings().GetStyleSettings().DetermineIconTheme(); @@ -553,6 +588,13 @@ void SvtMiscOptions_Impl::ImplCommit() break; } + case PROPERTYHANDLE_SIDEBARICONSIZE : + { + if ( !m_bIsSidebarIconSizeRO ) + seqValues[nProperty] <<= m_nSidebarIconSize; + break; + } + case PROPERTYHANDLE_TOOLBOXSTYLE : { if ( !m_bIsToolboxStyleRO ) @@ -634,7 +676,8 @@ Sequence< OUString > SvtMiscOptions_Impl::GetPropertyNames() OUString(PROPERTYNAME_SHOWLINKWARNINGDIALOG), OUString(PROPERTYNAME_DISABLEUICUSTOMIZATION), OUString(PROPERTYNAME_EXPERIMENTALMODE), - OUString(PROPERTYNAME_MACRORECORDERMODE) + OUString(PROPERTYNAME_MACRORECORDERMODE), + OUString(PROPERTYNAME_SIDEBARICONSIZE) }; // Initialize return sequence with these list ... @@ -701,6 +744,16 @@ void SvtMiscOptions::SetSymbolsSize( sal_Int16 nSet ) m_pImpl->SetSymbolsSize( nSet ); } +sal_Int16 SvtMiscOptions::GetSidebarIconSize() const +{ + return m_pDataContainer->GetSidebarIconSize(); +} + +void SvtMiscOptions::SetSidebarIconSize( sal_Int16 nSet ) +{ + m_pDataContainer->SetSidebarIconSize( nSet ); +} + sal_Int16 SvtMiscOptions::GetCurrentSymbolsSize() const { sal_Int16 eOptSymbolsSize = m_pImpl->GetSymbolsSize(); -- cgit v1.2.3