cui/source/options/personalization.cxx | 189 ++++++++++--- cui/source/options/personalization.hxx | 10 officecfg/registry/schema/org/openoffice/Office/Common.xcs | 62 ++++ vcl/inc/vcl/msgbox.hxx | 4 4 files changed, 230 insertions(+), 35 deletions(-)
New commits: commit ad0e96c2ec27ed6266715c724464809e6d86979f Author: Jan Holesovsky <[email protected]> Date: Tue Dec 4 08:49:50 2012 +0100 Personas: Allow to paste Persona to the selection dialog. Change-Id: Ife095eb27fac135c0c2285259dd1008e9b7cefc5 diff --git a/cui/source/options/personalization.cxx b/cui/source/options/personalization.cxx index 3f0330a..4fe2b1b 100644 --- a/cui/source/options/personalization.cxx +++ b/cui/source/options/personalization.cxx @@ -11,6 +11,7 @@ #include <comphelper/processfactory.hxx> #include <officecfg/Office/Common.hxx> +#include <vcl/edit.hxx> #include <vcl/msgbox.hxx> #include <com/sun/star/lang/XMultiServiceFactory.hpp> @@ -31,9 +32,15 @@ http://www.getpersona.com ... */ class SelectPersonaDialog : public ModalDialog { +private: + Edit *m_pEdit; ///< The input line for the Persona URL + public: SelectPersonaDialog( Window *pParent ); + /// Get the URL from the Edit field. + OUString GetPersonaURL() const; + private: /// Handle the [Visit Firefox Personas] button DECL_LINK( VisitPersonas, PushButton* ); @@ -45,6 +52,19 @@ SelectPersonaDialog::SelectPersonaDialog( Window *pParent ) PushButton *pButton; get( pButton, "visit_personas" ); pButton->SetClickHdl( LINK( this, SelectPersonaDialog, VisitPersonas ) ); + + get( m_pEdit, "persona_url" ); + m_pEdit->SetPlaceholderText( "http://www.getpersonas.com/persona/" ); +} + +OUString SelectPersonaDialog::GetPersonaURL() const +{ + OUString aText( m_pEdit->GetText() ); + + if ( !aText.startsWith( "http://www.getpersonas.com/" ) ) + return OUString(); + + return aText; } IMPL_LINK( SelectPersonaDialog, VisitPersonas, PushButton*, /*pButton*/ ) @@ -198,10 +218,16 @@ IMPL_LINK( SvxPersonalizationTabPage, SelectPersona, PushButton*, /*pButton*/ ) { SelectPersonaDialog aDialog( NULL ); - if ( aDialog.Execute() == RET_OK ) + while ( aDialog.Execute() == RET_OK ) { - m_pOwnPersona->Check(); - // TODO parse the results + OUString aURL( aDialog.GetPersonaURL() ); + if ( aURL != "" ) + { + // TODO parse the results + m_pOwnPersona->Check(); + break; + } + // else TODO msgbox that the URL did not match } return 0; commit 23c3f4a72cfbcc59d39be7b9832ef6439f440d29 Author: Jan Holesovsky <[email protected]> Date: Tue Dec 4 00:33:12 2012 +0100 Personas: Make the [Visit Firefox Personas] button work. Change-Id: I024bcd527b643076642a233d8e71003c006b5c15 diff --git a/cui/source/options/personalization.cxx b/cui/source/options/personalization.cxx index 25cc8d0..3f0330a 100644 --- a/cui/source/options/personalization.cxx +++ b/cui/source/options/personalization.cxx @@ -14,6 +14,8 @@ #include <vcl/msgbox.hxx> #include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/system/SystemShellExecute.hpp> +#include <com/sun/star/system/SystemShellExecuteFlags.hpp> #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> #include <com/sun/star/ui/dialogs/XFilePicker.hpp> @@ -31,11 +33,27 @@ class SelectPersonaDialog : public ModalDialog { public: SelectPersonaDialog( Window *pParent ); + +private: + /// Handle the [Visit Firefox Personas] button + DECL_LINK( VisitPersonas, PushButton* ); }; SelectPersonaDialog::SelectPersonaDialog( Window *pParent ) : ModalDialog( pParent, "SelectPersonaDialog", "cui/ui/select_persona_dialog.ui" ) { + PushButton *pButton; + get( pButton, "visit_personas" ); + pButton->SetClickHdl( LINK( this, SelectPersonaDialog, VisitPersonas ) ); +} + +IMPL_LINK( SelectPersonaDialog, VisitPersonas, PushButton*, /*pButton*/ ) +{ + uno::Reference< system::XSystemShellExecute > xSystemShell( system::SystemShellExecute::create( ::comphelper::getProcessComponentContext() ) ); + + xSystemShell->execute( "http://www.getpersonas.com", OUString(), system::SystemShellExecuteFlags::URIS_ONLY ); + + return 0; } SvxPersonalizationTabPage::SvxPersonalizationTabPage( Window *pParent, const SfxItemSet &rSet ) commit 03f04a9ee298ad968d00910f0f96a0a834ec7cda Author: Jan Holesovsky <[email protected]> Date: Tue Dec 4 00:16:18 2012 +0100 Personas: File dialog for the selection of the background image. Change-Id: Iafb5c62f310a6fd1658a7fa80346fa3510fc38e7 diff --git a/cui/source/options/personalization.cxx b/cui/source/options/personalization.cxx index 1bfe549..25cc8d0 100644 --- a/cui/source/options/personalization.cxx +++ b/cui/source/options/personalization.cxx @@ -13,6 +13,13 @@ #include <officecfg/Office/Common.hxx> #include <vcl/msgbox.hxx> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> +#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> +#include <com/sun/star/ui/dialogs/XFilePicker.hpp> +#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp> +#include <com/sun/star/ui/dialogs/XFilterManager.hpp> + using namespace com::sun::star; /** Dialog that will allow the user to choose a Persona to use. @@ -134,8 +141,37 @@ void SvxPersonalizationTabPage::Reset( const SfxItemSet & ) IMPL_LINK( SvxPersonalizationTabPage, SelectBackground, PushButton*, /*pButton*/ ) { - // TODO m_pOwnBackground->Check(); if something selected - // TODO parse the results + uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); + if ( !xFactory.is() ) + return 0; + + uno::Reference< ui::dialogs::XFilePicker > xFilePicker( xFactory->createInstance( "com.sun.star.ui.dialogs.FilePicker" ), uno::UNO_QUERY ); + if ( !xFilePicker.is() ) + return 0; + + xFilePicker->setMultiSelectionMode( false ); + + uno::Reference< ui::dialogs::XFilePickerControlAccess > xController( xFilePicker, uno::UNO_QUERY ); + if ( xController.is() ) + xController->setValue( ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, 0, uno::makeAny( sal_True ) ); + + uno::Reference< ui::dialogs::XFilterManager > xFilterMgr( xFilePicker, uno::UNO_QUERY ); + if ( xFilterMgr.is() ) + xFilterMgr->appendFilter( "Background images (*.jpg;*.png)", "*.jpg;*.png" ); // TODO localize + + while ( xFilePicker->execute() == ui::dialogs::ExecutableDialogResults::OK ) + { + OUString aFile( xFilePicker->getFiles()[0] ); + + if ( aFile.startsWith( "file:///" ) && ( aFile.endsWith( ".png" ) || aFile.endsWith( ".jpg" ) ) ) + { + m_aBackgroundURL = aFile; + m_pOwnBackground->Check(); + break; + } + + // TODO display what is wrong (not a file:// or not .png / .jpg) + } return 0; } commit 2437cf972a9dbf7ab11e18e7fd8b43ef5f6a63e0 Author: Jan Holesovsky <[email protected]> Date: Mon Dec 3 14:43:43 2012 +0100 Personas: Configuration entries for Personas and BacgroundImage. Change-Id: I47b1a5bacaeb5bd54f11630e5d3f2652be2bdfb4 diff --git a/cui/source/options/personalization.cxx b/cui/source/options/personalization.cxx index e6d6a39..1bfe549 100644 --- a/cui/source/options/personalization.cxx +++ b/cui/source/options/personalization.cxx @@ -9,6 +9,12 @@ #include "personalization.hxx" +#include <comphelper/processfactory.hxx> +#include <officecfg/Office/Common.hxx> +#include <vcl/msgbox.hxx> + +using namespace com::sun::star; + /** Dialog that will allow the user to choose a Persona to use. So far there is no better possibility than just to paste the URL from @@ -26,24 +32,21 @@ SelectPersonaDialog::SelectPersonaDialog( Window *pParent ) } SvxPersonalizationTabPage::SvxPersonalizationTabPage( Window *pParent, const SfxItemSet &rSet ) - : SfxTabPage( pParent, "PersonalizationTabPage", "cui/ui/personalization_tab.ui", rSet ) + : SfxTabPage( pParent, "PersonalizationTabPage", "cui/ui/personalization_tab.ui", rSet ), + m_aBackgroundURL() { + // background image get( m_pNoBackground, "no_background" ); get( m_pDefaultBackground, "default_background" ); get( m_pOwnBackground, "own_background" ); - m_pNoBackground->SetClickHdl( LINK( this, SvxPersonalizationTabPage, EnableDisableSelectionButtons ) ); - m_pDefaultBackground->SetClickHdl( LINK( this, SvxPersonalizationTabPage, EnableDisableSelectionButtons ) ); - m_pOwnBackground->SetClickHdl( LINK( this, SvxPersonalizationTabPage, EnableDisableSelectionButtons ) ); get( m_pSelectBackground, "select_background" ); m_pSelectBackground->SetClickHdl( LINK( this, SvxPersonalizationTabPage, SelectBackground ) ); + // persona get( m_pNoPersona, "no_persona" ); get( m_pDefaultPersona, "default_persona" ); get( m_pOwnPersona, "own_persona" ); - m_pNoPersona->SetClickHdl( LINK( this, SvxPersonalizationTabPage, EnableDisableSelectionButtons ) ); - m_pDefaultPersona->SetClickHdl( LINK( this, SvxPersonalizationTabPage, EnableDisableSelectionButtons ) ); - m_pOwnPersona->SetClickHdl( LINK( this, SvxPersonalizationTabPage, EnableDisableSelectionButtons ) ); get( m_pSelectPersona, "select_persona" ); LINK( this, SvxPersonalizationTabPage, SelectPersona ); @@ -59,47 +62,93 @@ SfxTabPage* SvxPersonalizationTabPage::Create( Window *pParent, const SfxItemSet return new SvxPersonalizationTabPage( pParent, rSet ); } -IMPL_LINK( SvxPersonalizationTabPage, EnableDisableSelectionButtons, RadioButton*, pButton ) +sal_Bool SvxPersonalizationTabPage::FillItemSet( SfxItemSet & ) { - PushButton *pPushButton = NULL; - RadioButton *pRadioButton = NULL; - - if ( pButton == m_pNoBackground || pButton == m_pDefaultBackground || pButton == m_pOwnBackground ) + // background image + OUString aBackground( "default" ); + if ( m_pNoBackground->IsChecked() ) + aBackground = "no"; + else if ( m_pOwnBackground->IsChecked() ) + aBackground = "own"; + + // persona + OUString aPersona( "default" ); + if ( m_pNoPersona->IsChecked() ) + aPersona = "no"; + else if ( m_pOwnPersona->IsChecked() ) + aPersona = "own"; + + bool bModified = false; + uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext(); + if ( xContext.is() && + ( aBackground != officecfg::Office::Common::Misc::BackgroundImage::get( xContext ) || + m_aBackgroundURL != officecfg::Office::Common::Misc::BackgroundImageURL::get( xContext ) || + aPersona != officecfg::Office::Common::Misc::Persona::get( xContext ) ) ) { - pPushButton = m_pSelectBackground; - pRadioButton = m_pOwnBackground; + bModified = true; } - else if ( pButton == m_pNoPersona || pButton == m_pDefaultPersona || pButton == m_pOwnPersona ) + + // write + boost::shared_ptr< comphelper::ConfigurationChanges > batch( comphelper::ConfigurationChanges::create() ); + + officecfg::Office::Common::Misc::BackgroundImage::set( aBackground, batch ); + officecfg::Office::Common::Misc::BackgroundImageURL::set( m_aBackgroundURL, batch ); + officecfg::Office::Common::Misc::Persona::set( aPersona, batch ); + + batch->commit(); + + return bModified; +} + +void SvxPersonalizationTabPage::Reset( const SfxItemSet & ) +{ + uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext(); + + // background image + OUString aBackground( "default" ); + if ( xContext.is() ) { - pPushButton = m_pSelectPersona; - pRadioButton = m_pOwnPersona; + aBackground = officecfg::Office::Common::Misc::BackgroundImage::get( xContext ); + m_aBackgroundURL = officecfg::Office::Common::Misc::BackgroundImageURL::get( xContext ); } + + if ( aBackground == "no" ) + m_pNoBackground->Check(); + else if ( aBackground == "own" ) + m_pOwnBackground->Check(); else - return 0; + m_pDefaultBackground->Check(); - if ( pRadioButton->IsChecked() && !pPushButton->IsEnabled() ) - { - pPushButton->Enable(); - pPushButton->Invalidate(); - } - else if ( !pRadioButton->IsChecked() && pPushButton->IsEnabled() ) - { - pPushButton->Disable(); - pPushButton->Invalidate(); - } + // persona + OUString aPersona( "default" ); + if ( xContext.is() ) + aPersona = officecfg::Office::Common::Misc::Persona::get( xContext ); - return 0; + if ( aPersona == "no" ) + m_pNoPersona->Check(); + else if ( aPersona == "own" ) + m_pOwnPersona->Check(); + else + m_pDefaultPersona->Check(); } IMPL_LINK( SvxPersonalizationTabPage, SelectBackground, PushButton*, /*pButton*/ ) { + // TODO m_pOwnBackground->Check(); if something selected + // TODO parse the results + return 0; } IMPL_LINK( SvxPersonalizationTabPage, SelectPersona, PushButton*, /*pButton*/ ) { SelectPersonaDialog aDialog( NULL ); - /* TODO handle the ret val sal_Int16 nReturn =*/ aDialog.Execute(); + + if ( aDialog.Execute() == RET_OK ) + { + m_pOwnPersona->Check(); + // TODO parse the results + } return 0; } diff --git a/cui/source/options/personalization.hxx b/cui/source/options/personalization.hxx index 89fc3fd..bb70b33 100644 --- a/cui/source/options/personalization.hxx +++ b/cui/source/options/personalization.hxx @@ -23,6 +23,7 @@ private: RadioButton *m_pDefaultBackground; ///< Use the built-in bitmap for Writer background RadioButton *m_pOwnBackground; ///< Use the user-defined bitmap PushButton *m_pSelectBackground; ///< Let the user select in the 'own' case + OUString m_aBackgroundURL; ///< URL of the the background image in the 'own' case RadioButton *m_pNoPersona; ///< Just the default look, without any bitmap RadioButton *m_pDefaultPersona; ///< Use the built-in bitmap @@ -35,10 +36,13 @@ public: static SfxTabPage* Create( Window *pParent, const SfxItemSet &rSet ); -private: - /// Maintain sane behavior of the m_pSelect(Background|Persona) buttons - DECL_LINK( EnableDisableSelectionButtons, RadioButton* ); + /// Apply the settings ([OK] button). + virtual sal_Bool FillItemSet( SfxItemSet &rSet ); + + /// Reset to default settings ([Revert] button). + virtual void Reset( const SfxItemSet &rSet ); +private: /// Handle the bacground selection DECL_LINK( SelectBackground, PushButton* ); diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs index cc11bb6..f847e0e 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -6685,6 +6685,68 @@ </constraints> <value>auto</value> </prop> + <prop oor:name="BackgroundImage" oor:type="xs:string" oor:nillable="false"> + <!-- UIHints: Tools Options General Personalization --> + <info> + <author>kendy</author> + <desc>Specifies whether we should use background image in the + workplace.</desc> + </info> + <constraints> + <enumeration oor:value="no"> + <info> + <desc>No - the user wants only solid bacground.</desc> + </info> + </enumeration> + <enumeration oor:value="default"> + <info> + <desc>Default - the LibreOffice default background image.</desc> + </info> + </enumeration> + <enumeration oor:value="own"> + <info> + <desc>The user installed an own background image, and wants to + use that. It's URL is in BackgroundImageURL.</desc> + </info> + </enumeration> + </constraints> + <value>default</value> + </prop> + <prop oor:name="BackgroundImageURL" oor:type="xs:string" oor:nillable="false"> + <!-- UIHints: Tools Options General Personalization --> + <info> + <author>kendy</author> + <desc>URL of the image the user wants to use; it is used only when + BackgroundImage is 'own'.</desc> + </info> + <value></value> + </prop> + <prop oor:name="Persona" oor:type="xs:string" oor:nillable="false"> + <!-- UIHints: Tools Options General Personalization --> + <info> + <author>kendy</author> + <desc>Specifies whether we should use a Firefox Persona, ie. a + picture under the menu, toolbar, and status bar.</desc> + </info> + <constraints> + <enumeration oor:value="no"> + <info> + <desc>No - the user wants just the themed look, no Persona.</desc> + </info> + </enumeration> + <enumeration oor:value="default"> + <info> + <desc>Default - the LibreOffice default Persona.</desc> + </info> + </enumeration> + <enumeration oor:value="own"> + <info> + <desc>The user installed an own Persona, and wants to use that.</desc> + </info> + </enumeration> + </constraints> + <value>default</value> + </prop> <prop oor:name="ToolboxStyle" oor:type="xs:short" oor:nillable="false"> <!-- UIHints: Tools Options General View --> <info> commit 14005c28404028a1fda3c9240f3f69bb90764378 Author: Jan Holesovsky <[email protected]> Date: Mon Dec 3 22:01:25 2012 +0100 Who wants RET_OK / RET_CANCEL to be sal_Bool? Change-Id: Ibda7e501b8f116f231a012a0ddee82674bfb5cc0 diff --git a/vcl/inc/vcl/msgbox.hxx b/vcl/inc/vcl/msgbox.hxx index d93c875..cd9e860 100644 --- a/vcl/inc/vcl/msgbox.hxx +++ b/vcl/inc/vcl/msgbox.hxx @@ -36,8 +36,8 @@ class CheckBox; // Return-Werte von Execute //!!! bei Aenderungen \basic\source\runtime\methods.cxx msgbox anpassen -#define RET_OK sal_True -#define RET_CANCEL sal_False +#define RET_CANCEL 0 +#define RET_OK 1 #define RET_YES 2 #define RET_NO 3 #define RET_RETRY 4 _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
