cui/source/options/personalization.cxx | 76 +++++++++++++++++++++---------- cui/source/options/personalization.hxx | 13 ++--- cui/uiconfig/ui/select_persona_dialog.ui | 18 +++---- 3 files changed, 69 insertions(+), 38 deletions(-)
New commits: commit 8cd23b0862cf9de31babd1859b8968c6801d6272 Author: Rachit Gupta <rachitgupta1...@gmail.com> Date: Fri Jun 13 22:54:45 2014 +0530 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 diff --git a/cui/source/options/personalization.cxx b/cui/source/options/personalization.cxx index ffc1d8b..dadb88f 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 212a4e5..89238b6 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 commit 92d33c56ea851ef8dff14b87ce245e5241574fe0 Author: Rachit Gupta <rachitgupta1...@gmail.com> Date: Fri Jun 13 19:27:45 2014 +0530 Fixed Bug: Small buttons are not visible initially. Small ugly buttons were visible before searching. Their default visibility is set to false. Change-Id: I54baf50e4ffd7749391fbc0a48a07d7a1ffd5433 diff --git a/cui/uiconfig/ui/select_persona_dialog.ui b/cui/uiconfig/ui/select_persona_dialog.ui index 2c9f5a1..4ebd36d 100644 --- a/cui/uiconfig/ui/select_persona_dialog.ui +++ b/cui/uiconfig/ui/select_persona_dialog.ui @@ -136,7 +136,7 @@ <property name="column_spacing">6</property> <child> <object class="GtkButton" id="result1"> - <property name="visible">True</property> + <property name="visible">False</property> <property name="can_focus">True</property> <property name="receives_default">True</property> <child> @@ -152,7 +152,7 @@ </child> <child> <object class="GtkButton" id="result2"> - <property name="visible">True</property> + <property name="visible">False</property> <property name="can_focus">True</property> <property name="receives_default">True</property> <child> @@ -168,7 +168,7 @@ </child> <child> <object class="GtkButton" id="result3"> - <property name="visible">True</property> + <property name="visible">False</property> <property name="can_focus">True</property> <property name="receives_default">True</property> <child> @@ -184,7 +184,7 @@ </child> <child> <object class="GtkButton" id="result4"> - <property name="visible">True</property> + <property name="visible">False</property> <property name="can_focus">True</property> <property name="receives_default">True</property> <child> @@ -200,7 +200,7 @@ </child> <child> <object class="GtkButton" id="result5"> - <property name="visible">True</property> + <property name="visible">False</property> <property name="can_focus">True</property> <property name="receives_default">True</property> <child> @@ -216,7 +216,7 @@ </child> <child> <object class="GtkButton" id="result6"> - <property name="visible">True</property> + <property name="visible">False</property> <property name="can_focus">True</property> <property name="receives_default">True</property> <child> @@ -232,7 +232,7 @@ </child> <child> <object class="GtkButton" id="result7"> - <property name="visible">True</property> + <property name="visible">False</property> <property name="can_focus">True</property> <property name="receives_default">True</property> <child> @@ -248,7 +248,7 @@ </child> <child> <object class="GtkButton" id="result8"> - <property name="visible">True</property> + <property name="visible">False</property> <property name="can_focus">True</property> <property name="receives_default">True</property> <child> @@ -264,7 +264,7 @@ </child> <child> <object class="GtkButton" id="result9"> - <property name="visible">True</property> + <property name="visible">False</property> <property name="can_focus">True</property> <property name="receives_default">True</property> <child> _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits