summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRachit Gupta <rachitgupta1792@gmail.com>2014-06-19 18:49:36 +0530
committerRachit Gupta <rachitgupta1792@gmail.com>2014-06-19 18:49:36 +0530
commitdc7092fe6e48e5d50a438bf27332cf151d86b2ca (patch)
treeceb2c6765c3aebb4e3c71166d558c40d2e19c7d5
parentb3ed6f893c1b2839d176977cd82ad88a9c9d9905 (diff)
Added functionality to apply default themes.
* The themes are stored in the share folder under the personas directory in the gallery. The information is stored in a personas_list.txt which contains the info in the form headerFile;footerFile;textColor;AccentColor for the default themes. * Changed the personalization_tab.ui to include _three_ buttons to show the default images. * Changed the vcl/source/app/settings.cxx to read the persona information properly in the case of default personas. * Some variable name changes. Change-Id: Ib5f2167729a5fb7eb8061925679560accb934a44
-rw-r--r--cui/source/options/personalization.cxx81
-rw-r--r--cui/source/options/personalization.hxx10
-rw-r--r--cui/uiconfig/ui/personalization_tab.ui66
-rw-r--r--vcl/source/app/settings.cxx8
4 files changed, 142 insertions, 23 deletions
diff --git a/cui/source/options/personalization.cxx b/cui/source/options/personalization.cxx
index e6307f49fc00..e5921265eab4 100644
--- a/cui/source/options/personalization.cxx
+++ b/cui/source/options/personalization.cxx
@@ -202,6 +202,17 @@ SvxPersonalizationTabPage::SvxPersonalizationTabPage( Window *pParent, const Sfx
get( m_pSelectPersona, "select_persona" );
m_pSelectPersona->SetClickHdl( LINK( this, SvxPersonalizationTabPage, SelectPersona ) );
+
+ get( m_vDefaultPersonaImages[0], "default1" );
+ m_vDefaultPersonaImages[0]->SetClickHdl( LINK( this, SvxPersonalizationTabPage, DefaultPersona ) );
+
+ get( m_vDefaultPersonaImages[1], "default2" );
+ m_vDefaultPersonaImages[1]->SetClickHdl( LINK( this, SvxPersonalizationTabPage, DefaultPersona ) );
+
+ get( m_vDefaultPersonaImages[2], "default3" );
+ m_vDefaultPersonaImages[2]->SetClickHdl( LINK( this, SvxPersonalizationTabPage, DefaultPersona ) );
+
+ LoadDefaultImages();
}
SvxPersonalizationTabPage::~SvxPersonalizationTabPage()
@@ -268,6 +279,45 @@ void SvxPersonalizationTabPage::Reset( const SfxItemSet & )
m_pDefaultPersona->Check();
}
+void SvxPersonalizationTabPage::SetPersonaSettings( const OUString aPersonaSettings )
+{
+ m_aPersonaSettings = aPersonaSettings;
+ m_pOwnPersona->Check();
+}
+
+void SvxPersonalizationTabPage::LoadDefaultImages()
+{
+ OUString gallery( "" );
+ gallery = "$BRAND_BASE_DIR/" LIBO_SHARE_FOLDER;
+ gallery += "/gallery/personas/";
+ rtl::Bootstrap::expandMacros( gallery );
+ OUString aPersonasList = gallery + "personas_list.txt";
+ SvFileStream aStream( aPersonasList, STREAM_READ );
+ GraphicFilter aFilter;
+ Graphic aGraphic;
+ sal_Int32 nIndex = 0;
+
+ while( aStream.IsOpen() && !aStream.IsEof() )
+ {
+ OString aLine;
+ aStream.ReadLine( aLine );
+ OUString aPersonaSetting( OStringToOUString( aLine, RTL_TEXTENCODING_UTF8 ) );
+ OUString aPreviewFile;
+ sal_Int32 nNewIndex = aPersonaSetting.indexOf( ';', 0 );
+ if( nNewIndex < 0 )
+ break;
+ aPreviewFile = aPersonaSetting.copy( 0, nNewIndex );
+ aPersonaSetting = aPersonaSetting.copy( nNewIndex + 1 );
+ m_vDefaultPersonaSettings.push_back( aPersonaSetting );
+
+ INetURLObject aURLObj( gallery + aPreviewFile );
+ aFilter.ImportGraphic( aGraphic, aURLObj );
+ Bitmap aBmp = aGraphic.GetBitmap();
+ m_vDefaultPersonaImages[nIndex]->Show();
+ m_vDefaultPersonaImages[nIndex++]->SetModeImage( Image( aBmp ) );
+ }
+}
+
IMPL_LINK( SvxPersonalizationTabPage, SelectPersona, PushButton*, /*pButton*/ )
{
SelectPersonaDialog aDialog( NULL );
@@ -277,7 +327,7 @@ IMPL_LINK( SvxPersonalizationTabPage, SelectPersona, PushButton*, /*pButton*/ )
OUString aPersonaSetting( aDialog.GetAppliedPersonaSetting() );
if ( !aPersonaSetting.isEmpty() )
{
- setPersonaSettings( aPersonaSetting );
+ SetPersonaSettings( aPersonaSetting );
}
break;
@@ -294,6 +344,17 @@ IMPL_LINK( SvxPersonalizationTabPage, ForceSelect, RadioButton*, pButton )
return 0;
}
+IMPL_LINK( SvxPersonalizationTabPage, DefaultPersona, PushButton*, pButton )
+{
+ m_pDefaultPersona->Check();
+ for( sal_Int32 nIndex = 0; nIndex < 3; nIndex++ )
+ {
+ if( pButton == m_vDefaultPersonaImages[nIndex] )
+ m_aPersonaSettings = m_vDefaultPersonaSettings[nIndex];
+ }
+ return 0;
+}
+
/// Find the value on the Persona page, and convert it to a usable form.
static OUString searchValue( const OString &rBuffer, sal_Int32 from, const OString &rIdentifier )
{
@@ -351,12 +412,6 @@ static bool parsePersonaInfo( const OString &rBuffer, OUString *pHeaderURL, OUSt
return true;
}
-void SvxPersonalizationTabPage::setPersonaSettings( const OUString aPersonaSettings )
-{
- m_aPersonaSettings = aPersonaSettings;
- m_pOwnPersona->Check();
-}
-
SearchAndParseThread::SearchAndParseThread( SelectPersonaDialog* pDialog,
const OUString& rURL ) :
Thread( "cuiPersonasSearchThread" ),
@@ -416,13 +471,13 @@ void SearchAndParseThread::execute()
for( it = vLearnmoreURLs.begin(); it!=vLearnmoreURLs.end(); ++it )
{
- OUString sHeaderFile, aPersonaSetting;
- getPreviewFile( *it, &sHeaderFile, &aPersonaSetting );
- INetURLObject aURLObj( sHeaderFile );
+ OUString sPreviewFile, aPersonaSetting;
+ getPreviewFile( *it, &sPreviewFile, &aPersonaSetting );
+ INetURLObject aURLObj( sPreviewFile );
aFilter.ImportGraphic( aGraphic, aURLObj );
Bitmap aBmp = aGraphic.GetBitmap();
vResultList.push_back( Image( aBmp ) );
- m_pPersonaDialog->AddPersonaSetting(aPersonaSetting);
+ m_pPersonaDialog->AddPersonaSetting( aPersonaSetting );
}
// for VCL to be able to do visual changes in the thread
@@ -498,7 +553,7 @@ void SearchAndParseThread::execute()
}
}
-void SearchAndParseThread::getPreviewFile( const OUString& rURL, OUString *pHeaderFile, OUString *pPersonaSetting )
+void SearchAndParseThread::getPreviewFile( const OUString& rURL, OUString *pPreviewFile, OUString *pPersonaSetting )
{
uno::Reference< ucb::XSimpleFileAccess3 > xFileAccess( ucb::SimpleFileAccess::create( comphelper::getProcessComponentContext() ), uno::UNO_QUERY );
if ( !xFileAccess.is() )
@@ -555,7 +610,7 @@ void SearchAndParseThread::getPreviewFile( const OUString& rURL, OUString *pHead
{
return;
}
- *pHeaderFile = gallery + aPreviewFile;
+ *pPreviewFile = gallery + aPreviewFile;
*pPersonaSetting = aName + ";" + aHeaderURL + ";" + aFooterURL + ";" + aTextColor + ";" + aAccentColor;
}
diff --git a/cui/source/options/personalization.hxx b/cui/source/options/personalization.hxx
index 89238b6919a7..fb26c70ffe2d 100644
--- a/cui/source/options/personalization.hxx
+++ b/cui/source/options/personalization.hxx
@@ -29,8 +29,11 @@ private:
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
OUString m_aPersonaSettings; ///< Header and footer images + color to be set in the settings.
+ std::vector<OUString> m_vDefaultPersonaSettings;
+
public:
::rtl::Reference< SearchAndParseThread > m_rApplyThread;
SvxPersonalizationTabPage( Window *pParent, const SfxItemSet &rSet );
@@ -44,7 +47,9 @@ public:
/// Reset to default settings ([Revert] button).
virtual void Reset( const SfxItemSet &rSet ) SAL_OVERRIDE;
- void setPersonaSettings( const OUString );
+ void SetPersonaSettings( const OUString );
+
+ void LoadDefaultImages();
private:
/// Handle the Persona selection
@@ -52,6 +57,9 @@ private:
/// When 'own' is chosen, but the Persona is not chosen yet.
DECL_LINK( ForceSelect, RadioButton* );
+
+ /// Handle the default Persona selection
+ DECL_LINK( DefaultPersona, PushButton* );
};
/** 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 307891c2edda..677d5fc13298 100644
--- a/cui/uiconfig/ui/personalization_tab.ui
+++ b/cui/uiconfig/ui/personalization_tab.ui
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.16.1 -->
<interface>
- <!-- interface-requires gtk+ 3.0 -->
+ <requires lib="gtk+" version="3.0"/>
<object class="GtkVBox" id="PersonalizationTabPage">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -22,6 +23,7 @@
<object class="GtkVBox" id="vbox2">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="spacing">2</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkRadioButton" id="no_persona">
@@ -56,6 +58,66 @@
</packing>
</child>
<child>
+ <object class="GtkBox" id="box1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkButton" id="default1">
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="default2">
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="default3">
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">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">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -94,7 +156,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">2</property>
+ <property name="position">3</property>
</packing>
</child>
</object>
diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx
index 4174d5af59ae..ceab2f69f5c3 100644
--- a/vcl/source/app/settings.cxx
+++ b/vcl/source/app/settings.cxx
@@ -2095,7 +2095,6 @@ static BitmapEx readBitmapEx( const OUString& rPath )
Graphic aGraphic;
if ( GraphicFilter::LoadGraphic( aPath, OUString(), aGraphic ) != GRFILTER_OK )
return BitmapEx();
-
return aGraphic.GetBitmapEx();
}
@@ -2123,7 +2122,7 @@ static void setupPersonaHeaderFooter( WhichPersona eWhich, OUString& rHeaderFoot
// now read the new values and setup bitmaps
OUString aHeader, aFooter;
- if ( aPersona == "own" )
+ if ( aPersona == "own" || aPersona == "default" )
{
sal_Int32 nIndex = 0;
aHeader = aPersonaSettings.getToken( 0, ';', nIndex );
@@ -2137,11 +2136,6 @@ static void setupPersonaHeaderFooter( WhichPersona eWhich, OUString& rHeaderFoot
rMenuBarTextColor = Color( aColor.toUInt64( 16 ) );
}
}
- else if ( aPersona == "default" )
- {
- aHeader = "header.jpg";
- aFooter = "footer.jpg";
- }
OUString aName;
switch ( eWhich ) {