diff options
author | Rachit Gupta <rachitgupta1792@gmail.com> | 2014-07-01 18:27:42 +0530 |
---|---|---|
committer | Rachit Gupta <rachitgupta1792@gmail.com> | 2014-07-01 18:27:42 +0530 |
commit | 7b6d0027af81b406014226bc0172d0646be545c5 (patch) | |
tree | 89877dda76fdd6255b879c2fd6fc572f059455dd | |
parent | e23bd6a56c5f9868d042ee79c4810ac47d41745b (diff) |
Changed Personas installed through extensions procedure.
The UI now consists of a TreeView that lists all the personas that were
installed through extensions. When the user selects any name from the
list, the preview is shown in a button besides the list.
If there are no extensions installed, the list stays hidden.
Change-Id: I030d99549fd5b15d1104224116257ad62cdd1891
-rw-r--r-- | cui/source/options/personalization.cxx | 63 | ||||
-rw-r--r-- | cui/source/options/personalization.hxx | 19 | ||||
-rw-r--r-- | cui/uiconfig/ui/personalization_tab.ui | 29 |
3 files changed, 46 insertions, 65 deletions
diff --git a/cui/source/options/personalization.cxx b/cui/source/options/personalization.cxx index 616fd1431690..0bc8fb5b12c5 100644 --- a/cui/source/options/personalization.cxx +++ b/cui/source/options/personalization.cxx @@ -21,6 +21,7 @@ #include <tools/urlobj.hxx> #include <vcl/edit.hxx> #include <vcl/msgbox.hxx> +#include <vcl/lstbox.hxx> #include <vcl/svapp.hxx> #include <vcl/settings.hxx> #include <vcl/graphicfilter.hxx> @@ -244,17 +245,13 @@ SvxPersonalizationTabPage::SvxPersonalizationTabPage( Window *pParent, const Sfx get( m_vDefaultPersonaImages[2], "default3" ); m_vDefaultPersonaImages[2]->SetClickHdl( LINK( this, SvxPersonalizationTabPage, DefaultPersona ) ); - get( m_vExtensionPersonas[0], "extension1" ); - m_vExtensionPersonas[0]->SetClickHdl( LINK( this, SvxPersonalizationTabPage, InstalledPersona ) ); + get( m_pPersonaList, "installed_personas" ); + m_pPersonaList->SetSelectHdl( LINK( this, SvxPersonalizationTabPage, SelectInstalledPersona ) ); - get( m_vExtensionPersonas[1], "extension2" ); - m_vExtensionPersonas[1]->SetClickHdl( LINK( this, SvxPersonalizationTabPage, InstalledPersona ) ); - - get( m_vExtensionPersonas[2], "extension3" ); - m_vExtensionPersonas[2]->SetClickHdl( LINK( this, SvxPersonalizationTabPage, InstalledPersona ) ); + get( m_pExtensionPersonaPreview, "persona_preview" ); LoadDefaultImages(); - LoadExtensionImages(); + LoadExtensionThemes(); } SvxPersonalizationTabPage::~SvxPersonalizationTabPage() @@ -363,37 +360,28 @@ void SvxPersonalizationTabPage::LoadDefaultImages() } } -void SvxPersonalizationTabPage::LoadExtensionImages() +void SvxPersonalizationTabPage::LoadExtensionThemes() { // See if any extensions are used to install personas. If yes, load them. - GraphicFilter aFilter; - Graphic aGraphic; - sal_Int32 nIndex = 0; css::uno::Sequence<OUString> installedPersonas( officecfg::Office::Common::Misc::PersonasList::get()->getElementNames() ); sal_Int32 nLength = installedPersonas.getLength(); - sal_Int32 nCount = 0; if( nLength == 0 ) return; - if( nLength > 3 ) - nIndex = nLength - 3; + m_pPersonaList->Show(); - for( ; nIndex < nLength; nIndex++ ) + for( sal_Int32 nIndex = 0; nIndex < nLength; nIndex++ ) { Reference< XPropertySet > xPropertySet( officecfg::Office::Common::Misc::PersonasList::get()->getByName( installedPersonas[nIndex] ), UNO_QUERY_THROW ); OUString aPersonaName, aPreviewFile, aHeaderFile, aFooterFile, aTextColor, aAccentColor, aPersonaSettings; - Any aValue = xPropertySet->getPropertyValue( "Preview" ); - aValue >>= aPreviewFile; - INetURLObject aURLObj( aPreviewFile ); - aFilter.ImportGraphic( aGraphic, aURLObj ); - Bitmap aBmp = aGraphic.GetBitmap(); - m_vExtensionPersonas[nCount]->Show(); - m_vExtensionPersonas[nCount++]->SetModeImage( Image( aBmp ) ); - - aValue = xPropertySet->getPropertyValue( "Name" ); + Any aValue = xPropertySet->getPropertyValue( "Name" ); aValue >>= aPersonaName; + m_pPersonaList->InsertEntry( aPersonaName ); + + aValue = xPropertySet->getPropertyValue( "Preview" ); + aValue >>= aPreviewFile; aValue = xPropertySet->getPropertyValue( "Header" ); aValue >>= aHeaderFile; @@ -407,7 +395,7 @@ void SvxPersonalizationTabPage::LoadExtensionImages() aValue = xPropertySet->getPropertyValue( "AccentColor" ); aValue >>= aAccentColor; - aPersonaSettings = aHeaderFile + ";" + aFooterFile + ";" + aTextColor + ";" + aAccentColor; + aPersonaSettings = aPreviewFile + ";" + aHeaderFile + ";" + aFooterFile + ";" + aTextColor + ";" + aAccentColor; rtl::Bootstrap::expandMacros( aPersonaSettings ); m_vExtensionPersonaSettings.push_back( aPersonaSettings ); } @@ -451,14 +439,23 @@ IMPL_LINK( SvxPersonalizationTabPage, DefaultPersona, PushButton*, pButton ) return 0; } -IMPL_LINK( SvxPersonalizationTabPage, InstalledPersona, PushButton*, pButton ) +IMPL_LINK( SvxPersonalizationTabPage, SelectInstalledPersona, ListBox*, ) { - m_pOwnPersona->Check(); - for( sal_Int32 nIndex = 0; nIndex < 3; nIndex++ ) - { - if( pButton == m_vExtensionPersonas[nIndex] ) - m_aPersonaSettings = m_vExtensionPersonaSettings[nIndex]; - } + // Get the details of the selected theme. + m_pExtensionPersonaPreview->Show(); + sal_Int32 nSelectedPos = m_pPersonaList->GetSelectEntryPos(); + OUString aSettings = m_vExtensionPersonaSettings[nSelectedPos]; + sal_Int32 nIndex = aSettings.indexOf( ';', 0 ); + OUString aPreviewFile = aSettings.copy( 0, nIndex ); + m_aPersonaSettings = aSettings.copy( nIndex + 1 ); + + // Show the preview file in the button. + GraphicFilter aFilter; + Graphic aGraphic; + INetURLObject aURLObj( aPreviewFile ); + aFilter.ImportGraphic( aGraphic, aURLObj ); + Bitmap aBmp = aGraphic.GetBitmap(); + m_pExtensionPersonaPreview->SetModeImage( Image( aBmp ) ); return 0; } diff --git a/cui/source/options/personalization.hxx b/cui/source/options/personalization.hxx index d5e4bcf5c026..e3f40c6dd0aa 100644 --- a/cui/source/options/personalization.hxx +++ b/cui/source/options/personalization.hxx @@ -25,13 +25,14 @@ class SvxPersonalizationTabPage : public SfxTabPage using SfxTabPage::DeactivatePage; private: - RadioButton *m_pNoPersona; ///< Just the default look, without any bitmap - RadioButton *m_pDefaultPersona; ///< Use the built-in bitmap - RadioButton *m_pOwnPersona; ///< Use the user-defined bitmap - PushButton *m_pSelectPersona; ///< Let the user select in the 'own' case - PushButton *m_vDefaultPersonaImages[3]; ///< Buttons to show the default persona images - PushButton *m_vExtensionPersonas[3]; ///< Buttons to show the last 3 personas installed via extensions - OUString m_aPersonaSettings; ///< Header and footer images + color to be set in the settings. + RadioButton *m_pNoPersona; ///< Just the default look, without any bitmap + RadioButton *m_pDefaultPersona; ///< Use the built-in bitmap + RadioButton *m_pOwnPersona; ///< Use the user-defined bitmap + PushButton *m_pSelectPersona; ///< Let the user select in the 'own' case + PushButton *m_vDefaultPersonaImages[3]; ///< Buttons to show the default persona images + PushButton *m_pExtensionPersonaPreview; ///< Buttons to show the last 3 personas installed via extensions + ListBox* m_pPersonaList; ///< The ListBox to show the list of installed personas + OUString m_aPersonaSettings; ///< Header and footer images + color to be set in the settings. std::vector<OUString> m_vDefaultPersonaSettings; std::vector<OUString> m_vExtensionPersonaSettings; @@ -52,7 +53,7 @@ public: void SetPersonaSettings( const OUString ); void LoadDefaultImages(); - void LoadExtensionImages(); + void LoadExtensionThemes(); private: /// Handle the Persona selection @@ -65,7 +66,7 @@ private: DECL_LINK( DefaultPersona, PushButton* ); /// Handle the Personas installed through extensions selection - DECL_LINK( InstalledPersona, PushButton* ); + DECL_LINK( SelectInstalledPersona, ListBox* ); }; /** Dialog that will allow the user to choose a Persona to use. diff --git a/cui/uiconfig/ui/personalization_tab.ui b/cui/uiconfig/ui/personalization_tab.ui index 2b53e029bc29..f19e1dbbc55b 100644 --- a/cui/uiconfig/ui/personalization_tab.ui +++ b/cui/uiconfig/ui/personalization_tab.ui @@ -168,26 +168,23 @@ <property name="can_focus">False</property> <property name="spacing">6</property> <child> - <object class="GtkButton" id="extension1"> + <object class="GtkTreeView" id="installed_personas:border"> + <property name="visible">False</property> <property name="can_focus">True</property> - <property name="receives_default">True</property> - <child> - <placeholder/> + <child internal-child="selection"> + <object class="GtkTreeSelection" id="treeview-selection2"/> </child> </object> <packing> - <property name="expand">False</property> + <property name="expand">True</property> <property name="fill">True</property> <property name="position">0</property> </packing> </child> <child> - <object class="GtkButton" id="extension2"> + <object class="GtkButton" id="persona_preview"> <property name="can_focus">True</property> <property name="receives_default">True</property> - <child> - <placeholder/> - </child> </object> <packing> <property name="expand">False</property> @@ -195,20 +192,6 @@ <property name="position">1</property> </packing> </child> - <child> - <object class="GtkButton" id="extension3"> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">2</property> - </packing> - </child> </object> <packing> <property name="expand">True</property> |