summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorTobias Lippert <drtl@fastmail.fm>2014-02-09 00:53:28 +0100
committerCaolán McNamara <caolanm@redhat.com>2014-02-21 17:23:50 +0000
commit076a7eacca48f203f0a8b9aa537e88fea9a88409 (patch)
treecd95446ac0b80b29658fa2a44030dacb5304a63d /cui
parent1ec263e25d8606c70ac2089d5ceea22750d25daf (diff)
Bug #63962 Dynamically scan the config directory for icon themes
The hard-coded icon themes have been replaced by a dynamic list which is filled by scanning the config directory Conflicts: include/vcl/settings.hxx vcl/source/app/settings.cxx vcl/source/window/window.cxx Change-Id: Ie3680ffe27d06e375acf22753e036cb6ddabc4ed Reviewed-on: https://gerrit.libreoffice.org/7935 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'cui')
-rw-r--r--cui/source/options/optgdlg.cxx88
-rw-r--r--cui/source/options/optgdlg.hxx8
2 files changed, 41 insertions, 55 deletions
diff --git a/cui/source/options/optgdlg.cxx b/cui/source/options/optgdlg.cxx
index f93dc04f52f6..92fe1dfdcf08 100644
--- a/cui/source/options/optgdlg.cxx
+++ b/cui/source/options/optgdlg.cxx
@@ -85,6 +85,7 @@
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
+#include <vcl/IconThemeInfo.hxx>
#include "optgdlg.hxx"
#include <svx/ofaitem.hxx>
@@ -538,7 +539,6 @@ OfaViewTabPage::OfaViewTabPage(Window* pParent, const SfxItemSet& rSet)
: SfxTabPage(pParent, "OptViewPage", "cui/ui/optviewpage.ui", rSet)
, nSizeLB_InitialSelection(0)
, nStyleLB_InitialSelection(0)
- , aIconStyleItemId(STYLE_SYMBOLS_THEMES_MAX, 0)
, pAppearanceCfg(new SvtTabAppearanceCfg)
, pCanvasSettings(new CanvasSettings)
, mpDrawinglayerOpt(new SvtOptionsDrawinglayer)
@@ -593,50 +593,27 @@ OfaViewTabPage::OfaViewTabPage(Window* pParent, const SfxItemSet& rSet)
m_pSystemFont->Enable(false);
}
- const StyleSettings& aStyleSettings = Application::GetSettings().GetStyleSettings();
+ // Set known icon themes
+ m_pIconStyleLB->Clear();
+ StyleSettings aStyleSettings = Application::GetSettings().GetStyleSettings();
+ mInstalledIconThemes = aStyleSettings.GetInstalledIconThemes();
- // remove non-installed icon themes
- if( m_pIconStyleLB->GetEntryCount() == STYLE_SYMBOLS_THEMES_MAX )
- {
- // do not check 0th item == auto; it is not a real theme
- aIconStyleItemId[0] = 0;
- sal_uLong nItem = 1;
- for ( sal_uLong n=0; ++n < STYLE_SYMBOLS_THEMES_MAX; )
- {
- if ( aStyleSettings.CheckSymbolStyle( n ) )
- {
- // existing style => save the item id
- aIconStyleItemId[n] = nItem++;
- }
- else
- {
- // non-existing style => remove item;
- m_pIconStyleLB->RemoveEntry( nItem );
- aIconStyleItemId[n] = 0;
- }
- }
- }
+ // Start with the automatically chosen icon theme
+ OUString autoThemeId = aStyleSettings.GetAutomaticallyChosenIconTheme();
+ const vcl::IconThemeInfo& autoIconTheme = vcl::IconThemeInfo::FindIconThemeById(mInstalledIconThemes, autoThemeId);
- // add real theme name to 'auto' theme, e.g. 'auto' => 'auto (classic)'
- if( m_pIconStyleLB->GetEntryCount() > 1 )
- {
- OUString aAutoStr( m_pIconStyleLB->GetEntry( 0 ) );
+ OUString entryForAuto = OUString("Auto (") +
+ autoIconTheme.GetDisplayName() +
+ OUString(")");
+ m_pIconStyleLB->InsertEntry(entryForAuto);
- aAutoStr += " (";
-
- // prefer the icon style set by the desktop native widgets modules
- sal_uLong nAutoStyle = aStyleSettings.GetPreferredSymbolsStyle();
- // fallback to the statically defined values
- if ( nAutoStyle == STYLE_SYMBOLS_AUTO || !aIconStyleItemId.at(nAutoStyle) )
- nAutoStyle = aStyleSettings.GetAutoSymbolsStyle();
- if ( aIconStyleItemId.at(nAutoStyle) )
- aAutoStr += m_pIconStyleLB->GetEntry( aIconStyleItemId.at(nAutoStyle) );
-
- m_pIconStyleLB->RemoveEntry( 0 );
- m_pIconStyleLB->InsertEntry( aAutoStr += ")", 0 );
- // separate auto and other icon themes
- m_pIconStyleLB->SetSeparatorPos( 0 );
+ for (const vcl::IconThemeInfo& i : mInstalledIconThemes) {
+ m_pIconStyleLB->InsertEntry(i.GetDisplayName());
}
+
+ // separate auto and other icon themes
+ m_pIconStyleLB->SetSeparatorPos( 0 );
+ m_pIconStyleLB->SelectEntryPos(0);
}
OfaViewTabPage::~OfaViewTabPage()
@@ -703,16 +680,16 @@ sal_Bool OfaViewTabPage::FillItemSet( SfxItemSet& )
sal_uInt16 nStyleLB_NewSelection = m_pIconStyleLB->GetSelectEntryPos();
if( nStyleLB_InitialSelection != nStyleLB_NewSelection )
{
- // find the style name in the aIconStyleItemId table
- // items from the non-installed icon themes were removed
- for ( sal_uLong n=0; n < STYLE_SYMBOLS_THEMES_MAX; n++ )
- {
- if ( aIconStyleItemId[n] == nStyleLB_NewSelection )
- {
- aMiscOptions.SetSymbolsStyle( n );
- n = STYLE_SYMBOLS_THEMES_MAX;
- }
+ // 0 means choose style automatically
+ if (nStyleLB_NewSelection == 0) {
+ aMiscOptions.SetIconThemeAutomatically();
+ }
+ else {
+ sal_uInt16 pos = m_pIconStyleLB->GetSelectEntryPos();
+ const vcl::IconThemeInfo& iconThemeId = mInstalledIconThemes.at(pos-1);
+ aMiscOptions.SetIconTheme(iconThemeId.GetThemeId());
}
+ nStyleLB_InitialSelection = nStyleLB_NewSelection;
}
sal_Bool bAppearanceChanged = sal_False;
@@ -880,8 +857,15 @@ void OfaViewTabPage::Reset( const SfxItemSet& )
m_pIconSizeLB->SelectEntryPos( nSizeLB_InitialSelection );
m_pIconSizeLB->SaveValue();
- if( aMiscOptions.GetSymbolsStyle() != STYLE_SYMBOLS_AUTO )
- nStyleLB_InitialSelection = aIconStyleItemId.at(aMiscOptions.GetCurrentSymbolsStyle());
+ if (aMiscOptions.IconThemeWasSetAutomatically()) {
+ nStyleLB_InitialSelection = 0;
+ }
+ else {
+ const OUString& selected = aMiscOptions.GetIconTheme();
+ const vcl::IconThemeInfo& selectedInfo =
+ vcl::IconThemeInfo::FindIconThemeById(mInstalledIconThemes, selected);
+ nStyleLB_InitialSelection = m_pIconStyleLB->GetEntryPos(selectedInfo.GetDisplayName());
+ }
m_pIconStyleLB->SelectEntryPos( nStyleLB_InitialSelection );
m_pIconStyleLB->SaveValue();
diff --git a/cui/source/options/optgdlg.hxx b/cui/source/options/optgdlg.hxx
index 6f2f7c80fc99..79aaeaed8c8a 100644
--- a/cui/source/options/optgdlg.hxx
+++ b/cui/source/options/optgdlg.hxx
@@ -28,6 +28,9 @@
// predeclarations
class CanvasSettings;
class SvtOptionsDrawinglayer;
+namespace vcl {
+class IconThemeInfo;
+}
// class OfaMiscTabPage --------------------------------------------------
@@ -104,13 +107,12 @@ private:
sal_uInt16 nSizeLB_InitialSelection;
sal_uInt16 nStyleLB_InitialSelection;
- // item ID for the given icon theme
- // might be zero when the theme is not installed and the item is removed
- std::vector<unsigned> aIconStyleItemId;
SvtTabAppearanceCfg* pAppearanceCfg;
CanvasSettings* pCanvasSettings;
SvtOptionsDrawinglayer* mpDrawinglayerOpt;
+ std::vector<vcl::IconThemeInfo> mInstalledIconThemes;
+
#if defined( UNX )
DECL_LINK( OnAntialiasingToggled, void* );
#endif