summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRachit Gupta <rachitgupta1792@gmail.com>2014-06-13 22:54:45 +0530
committerRachit Gupta <rachitgupta1792@gmail.com>2014-06-13 22:54:45 +0530
commit8cd23b0862cf9de31babd1859b8968c6801d6272 (patch)
treee4cd8d32fe60468df3e615ff3ed03c7409f0cc02
parentFixed Bug: Small buttons are not visible initially. (diff)
downloadcore-8cd23b0862cf9de31babd1859b8968c6801d6272.tar.gz
core-8cd23b0862cf9de31babd1859b8968c6801d6272.zip
Moved the application of persona process to SelectPersonaDialog.
The theme is downloaded now when the user clicks OK on SelectPersonaDialog instead of SvxPersonalizationTabPage. The task is done in a separate thread. Change-Id: I93173cce2ae9030ee8e271bd53b40e713c560731
-rw-r--r--cui/source/options/personalization.cxx76
-rw-r--r--cui/source/options/personalization.hxx13
2 files changed, 60 insertions, 29 deletions
diff --git a/cui/source/options/personalization.cxx b/cui/source/options/personalization.cxx
index ffc1d8bdf952..dadb88f6fe17 100644
--- a/cui/source/options/personalization.cxx
+++ b/cui/source/options/personalization.cxx
@@ -43,6 +43,12 @@ SelectPersonaDialog::SelectPersonaDialog( Window *pParent )
get( m_pProgressLabel, "progress_label" );
+ get( m_pOkButton, "ok" );
+ m_pOkButton->SetClickHdl( LINK( this, SelectPersonaDialog, ActionOK ) );
+
+ get( m_pCancelButton, "cancel" );
+ m_pCancelButton->SetClickHdl( LINK( this, SelectPersonaDialog, ActionCancel ) );
+
get(m_vResultList[0], "result1");
m_vResultList[0]->SetClickHdl( LINK( this, SelectPersonaDialog, SelectPersona ) );
@@ -91,6 +97,30 @@ IMPL_LINK( SelectPersonaDialog, SearchPersonas, PushButton*, /*pButton*/ )
return 0;
}
+IMPL_LINK( SelectPersonaDialog, ActionOK, PushButton*, /* pButton */ )
+{
+ OUString aSelectedPersona = GetSelectedPersona();
+
+ if( !aSelectedPersona.isEmpty() )
+ {
+ m_rSearchThread = new SearchAndParseThread( this, aSelectedPersona );
+ m_rSearchThread->launch();
+ }
+
+ else
+ EndDialog( RET_OK );
+ return 0;
+}
+
+IMPL_LINK( SelectPersonaDialog, ActionCancel, PushButton*, /* pButton */ )
+{
+ if( m_rSearchThread.is() )
+ m_rSearchThread->terminate();
+
+ EndDialog( RET_CANCEL );
+ return 0;
+}
+
IMPL_LINK( SelectPersonaDialog, SelectPersona, PushButton*, pButton )
{
if( pButton == m_vResultList[0] )
@@ -150,6 +180,16 @@ IMPL_LINK( SelectPersonaDialog, SelectPersona, PushButton*, pButton )
return 0;
}
+void SelectPersonaDialog::SetAppliedPersonaSetting( OUString& rPersonaSetting )
+{
+ m_aAppliedPersona = rPersonaSetting;
+}
+
+OUString SelectPersonaDialog::GetAppliedPersonaSetting() const
+{
+ return m_aAppliedPersona;
+}
+
void SelectPersonaDialog::SetProgress( OUString& rProgress )
{
if(rProgress.isEmpty())
@@ -269,10 +309,10 @@ IMPL_LINK( SvxPersonalizationTabPage, SelectPersona, PushButton*, /*pButton*/ )
while ( aDialog.Execute() == RET_OK )
{
- OUString aURL( aDialog.GetSelectedPersona() );
- if ( !aURL.isEmpty() )
+ OUString aPersonaSetting( aDialog.GetAppliedPersonaSetting() );
+ if ( !aPersonaSetting.isEmpty() )
{
- CopyPersonaToGallery( aURL );
+ m_aPersonaSettings = aPersonaSetting;
break;
}
}
@@ -345,12 +385,6 @@ static bool parsePersonaInfo( const OString &rBuffer, OUString *pHeaderURL, OUSt
return true;
}
-void SvxPersonalizationTabPage::CopyPersonaToGallery( const OUString &rURL )
-{
- m_rApplyThread = new SearchAndParseThread( this, rURL );
- m_rApplyThread->launch();
-}
-
void SvxPersonalizationTabPage::setPersonaSettings( const OUString aPersonaSettings )
{
m_aPersonaSettings = aPersonaSettings;
@@ -361,16 +395,6 @@ SearchAndParseThread::SearchAndParseThread( SelectPersonaDialog* pDialog,
const OUString& rURL ) :
Thread( "cuiPersonasSearchThread" ),
m_pPersonaDialog( pDialog ),
- m_pPersonalizationTabPage( NULL ),
- m_aURL( rURL )
-{
-}
-
-SearchAndParseThread::SearchAndParseThread( SvxPersonalizationTabPage* pDialog,
- const OUString& rURL ) :
- Thread( "cuiPersonasSearchThread" ),
- m_pPersonaDialog( NULL ),
- m_pPersonalizationTabPage( pDialog ),
m_aURL( rURL )
{
}
@@ -381,7 +405,7 @@ SearchAndParseThread::~SearchAndParseThread()
void SearchAndParseThread::execute()
{
- if(m_pPersonaDialog)
+ if( m_aURL.startsWith( "https://" ) )
{
m_pPersonaDialog->ClearSearchResults();
OUString sProgress( "Searching.. Please Wait.." );
@@ -437,12 +461,15 @@ void SearchAndParseThread::execute()
else
{
+ OUString sProgress( "Applying persona.." );
+ m_pPersonaDialog->SetProgress( sProgress );
+
uno::Reference< ucb::XSimpleFileAccess3 > xFileAccess( ucb::SimpleFileAccess::create( comphelper::getProcessComponentContext() ), uno::UNO_QUERY );
if ( !xFileAccess.is() )
return;
OUString aName, aHeaderURL, aFooterURL, aTextColor, aAccentColor;
- OUString m_aPersonaSettings;
+ OUString aPersonaSetting;
// get the required fields from m_aURL
sal_Int32 nOldIndex = 0;
@@ -486,8 +513,11 @@ void SearchAndParseThread::execute()
return;
}
- m_aPersonaSettings = aHeaderFile + ";" + aFooterFile + ";" + aTextColor + ";" + aAccentColor;
- m_pPersonalizationTabPage->setPersonaSettings( m_aPersonaSettings );
+ SolarMutexGuard aGuard;
+
+ aPersonaSetting = aHeaderFile + ";" + aFooterFile + ";" + aTextColor + ";" + aAccentColor;
+ m_pPersonaDialog->SetAppliedPersonaSetting( aPersonaSetting );
+ m_pPersonaDialog->EndDialog( RET_OK );
}
}
diff --git a/cui/source/options/personalization.hxx b/cui/source/options/personalization.hxx
index 212a4e5cb8fc..89238b6919a7 100644
--- a/cui/source/options/personalization.hxx
+++ b/cui/source/options/personalization.hxx
@@ -52,9 +52,6 @@ private:
/// When 'own' is chosen, but the Persona is not chosen yet.
DECL_LINK( ForceSelect, RadioButton* );
-
- /// Download the bitmaps + color settings, and copy them to user's profile.
- void CopyPersonaToGallery( const OUString &rURL );
};
/** Dialog that will allow the user to choose a Persona to use.
@@ -69,9 +66,12 @@ private:
PushButton *m_pSearchButton; ///< The search button
FixedText *m_pProgressLabel; ///< The label for showing progress of search
PushButton *m_vResultList[9]; ///< List of buttons to show search results
+ PushButton *m_pOkButton; ///< The OK button
+ PushButton *m_pCancelButton; ///< The Cancel button
std::vector<OUString> m_vPersonaSettings;
OUString m_aSelectedPersona;
+ OUString m_aAppliedPersona;
public:
SelectPersonaDialog( Window *pParent );
@@ -82,11 +82,15 @@ public:
void SetImages( std::vector<Image>&);
void AddPersonaSetting( OUString& );
void ClearSearchResults();
+ void SetAppliedPersonaSetting( OUString& );
+ OUString GetAppliedPersonaSetting() const;
private:
/// Handle the Search button
DECL_LINK( SearchPersonas, PushButton* );
DECL_LINK( SelectPersona, PushButton* );
+ DECL_LINK( ActionOK, PushButton* );
+ DECL_LINK( ActionCancel, PushButton* );
};
class SearchAndParseThread: public salhelper::Thread
@@ -94,7 +98,6 @@ class SearchAndParseThread: public salhelper::Thread
private:
SelectPersonaDialog *m_pPersonaDialog;
- SvxPersonalizationTabPage *m_pPersonalizationTabPage;
OUString m_aURL;
virtual ~SearchAndParseThread();
@@ -105,8 +108,6 @@ public:
SearchAndParseThread( SelectPersonaDialog* pDialog,
const OUString& rURL );
- SearchAndParseThread( SvxPersonalizationTabPage *pTabPage,
- const OUString& rURL );
};
#endif // INCLUDED_CUI_SOURCE_OPTIONS_PERSONALIZATION_HXX