summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-02-04 16:53:38 +0000
committerCaolán McNamara <caolanm@redhat.com>2019-02-04 20:45:49 +0100
commitad5493c3fcbec7dfa41e57ca2f98acbbce739b85 (patch)
tree31289ed755e1f5868ceb17cb576590c4b6e9923e /cui
parent930d691d88a33cea32ad08971b034f03e2086b77 (diff)
weld SelectPersonaDialog
Change-Id: Ice5e59bb8c26f007b71ba7844872ce825a5549f8 Reviewed-on: https://gerrit.libreoffice.org/67371 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'cui')
-rw-r--r--cui/source/options/personalization.cxx139
-rw-r--r--cui/source/options/personalization.hxx37
-rw-r--r--cui/uiconfig/ui/select_persona_dialog.ui8
3 files changed, 87 insertions, 97 deletions
diff --git a/cui/source/options/personalization.cxx b/cui/source/options/personalization.cxx
index f5d6e9f232a3..e748baf8ac60 100644
--- a/cui/source/options/personalization.cxx
+++ b/cui/source/options/personalization.cxx
@@ -29,6 +29,7 @@
#include <vcl/settings.hxx>
#include <vcl/graphicfilter.hxx>
#include <vcl/mnemonic.hxx>
+#include <vcl/virdev.hxx>
#include <dialmgr.hxx>
#include <strings.hrc>
@@ -162,52 +163,41 @@ void curlDownload(const OString& rURL, const OUString& sFileURL)
}
} //End of anonymous namespace
-
-SelectPersonaDialog::SelectPersonaDialog( vcl::Window *pParent )
- : ModalDialog( pParent, "SelectPersonaDialog", "cui/ui/select_persona_dialog.ui" )
+SelectPersonaDialog::SelectPersonaDialog(weld::Window *pParent)
+ : GenericDialogController(pParent, "cui/ui/select_persona_dialog.ui", "SelectPersonaDialog")
+ , m_xEdit(m_xBuilder->weld_entry("search_term"))
+ , m_xSearchButton(m_xBuilder->weld_button("search_personas"))
+ , m_xProgressLabel(m_xBuilder->weld_label("progress_label"))
+ , m_xCategories(m_xBuilder->weld_combo_box("categoriesCB"))
+ , m_xOkButton(m_xBuilder->weld_button("ok"))
+ , m_xCancelButton(m_xBuilder->weld_button("cancel"))
+ , m_vResultList{ m_xBuilder->weld_button("result1"),
+ m_xBuilder->weld_button("result2"),
+ m_xBuilder->weld_button("result3"),
+ m_xBuilder->weld_button("result4"),
+ m_xBuilder->weld_button("result5"),
+ m_xBuilder->weld_button("result6"),
+ m_xBuilder->weld_button("result7"),
+ m_xBuilder->weld_button("result8"),
+ m_xBuilder->weld_button("result9") }
{
- get( m_pSearchButton, "search_personas" );
- m_pSearchButton->SetClickHdl( LINK( this, SelectPersonaDialog, SearchPersonas ) );
-
- get( m_pEdit, "search_term" );
-
- get( m_pCategories, "categoriesCB" );
- m_pCategories->SetSelectHdl( LINK( this, SelectPersonaDialog, SelectCategory ) );
-
- get( m_pProgressLabel, "progress_label" );
+ m_xSearchButton->connect_clicked( LINK( this, SelectPersonaDialog, SearchPersonas ) );
+ m_xCategories->connect_changed( LINK( this, SelectPersonaDialog, SelectCategory ) );
+ m_xOkButton->connect_clicked( LINK( this, SelectPersonaDialog, ActionOK ) );
+ m_xCancelButton->connect_clicked( LINK( this, SelectPersonaDialog, ActionCancel ) );
- 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" );
- get( m_vResultList[1], "result2" );
- get( m_vResultList[2], "result3" );
- get( m_vResultList[3], "result4" );
- get( m_vResultList[4], "result5" );
- get( m_vResultList[5], "result6" );
- get( m_vResultList[6], "result7" );
- get( m_vResultList[7], "result8" );
- get( m_vResultList[8], "result9" );
-
- for (VclPtr<PushButton> & nIndex : m_vResultList)
+ for (auto & nIndex : m_vResultList)
{
- nIndex->SetClickHdl( LINK( this, SelectPersonaDialog, SelectPersona ) );
- nIndex->Disable();
+ nIndex->connect_clicked( LINK( this, SelectPersonaDialog, SelectPersona ) );
+ nIndex->set_sensitive(false);
}
- m_pCategories->SelectEntry("Featured");
- m_pCategories->GetSelectHdl().Call(*m_pCategories);
+ m_xCategories->set_active_text("Featured");
+ SelectCategory(*m_xCategories);
}
SelectPersonaDialog::~SelectPersonaDialog()
{
- disposeOnce();
-}
-
-void SelectPersonaDialog::dispose()
-{
if (m_pSearchThread.is())
{
// Release the solar mutex, so the thread is not affected by the race
@@ -216,16 +206,6 @@ void SelectPersonaDialog::dispose()
SolarMutexReleaser aReleaser;
m_pSearchThread->join();
}
-
- m_pCategories.clear();
- m_pEdit.clear();
- m_pSearchButton.clear();
- m_pProgressLabel.clear();
- for (VclPtr<PushButton>& vp : m_vResultList)
- vp.clear();
- m_pOkButton.clear();
- m_pCancelButton.clear();
- ModalDialog::dispose();
}
OUString SelectPersonaDialog::GetSelectedPersona() const
@@ -236,9 +216,9 @@ OUString SelectPersonaDialog::GetSelectedPersona() const
return OUString();
}
-IMPL_LINK_NOARG( SelectPersonaDialog, SearchPersonas, Button*, void )
+IMPL_LINK_NOARG( SelectPersonaDialog, SearchPersonas, weld::Button&, void )
{
- OUString searchTerm = m_pEdit->GetText();
+ OUString searchTerm = m_xEdit->get_text();
if( searchTerm.isEmpty( ) )
return;
@@ -284,7 +264,7 @@ IMPL_LINK_NOARG( SelectPersonaDialog, SearchPersonas, Button*, void )
m_pSearchThread->launch();
}
-IMPL_LINK_NOARG( SelectPersonaDialog, ActionOK, Button*, void )
+IMPL_LINK_NOARG( SelectPersonaDialog, ActionOK, weld::Button&, void )
{
OUString aSelectedPersona = GetSelectedPersona();
@@ -299,23 +279,23 @@ IMPL_LINK_NOARG( SelectPersonaDialog, ActionOK, Button*, void )
if ( m_pSearchThread.is() )
m_pSearchThread->StopExecution();
- EndDialog( RET_OK );
+ m_xDialog->response(RET_OK);
}
}
-IMPL_LINK_NOARG( SelectPersonaDialog, ActionCancel, Button*, void )
+IMPL_LINK_NOARG( SelectPersonaDialog, ActionCancel, weld::Button&, void )
{
if( m_pSearchThread.is() )
m_pSearchThread->StopExecution();
if( m_pGetPersonaThread.is() )
m_pGetPersonaThread->StopExecution();
- EndDialog();
+ m_xDialog->response(RET_CANCEL);
}
-IMPL_LINK_NOARG( SelectPersonaDialog, SelectCategory, ListBox&, void )
+IMPL_LINK_NOARG( SelectPersonaDialog, SelectCategory, weld::ComboBox&, void )
{
- OUString searchTerm = *static_cast<OUString*>(m_pCategories->GetSelectedEntryData());
+ OUString searchTerm = m_xCategories->get_active_id();
OUString rSearchURL;
if (searchTerm.isEmpty())
@@ -335,7 +315,7 @@ IMPL_LINK_NOARG( SelectPersonaDialog, SelectCategory, ListBox&, void )
m_pSearchThread->launch();
}
-IMPL_LINK( SelectPersonaDialog, SelectPersona, Button*, pButton, void )
+IMPL_LINK( SelectPersonaDialog, SelectPersona, weld::Button&, rButton, void )
{
if( m_pSearchThread.is() )
m_pSearchThread->StopExecution();
@@ -344,7 +324,7 @@ IMPL_LINK( SelectPersonaDialog, SelectPersona, Button*, pButton, void )
for( sal_Int32 index = 0; index < MAX_RESULTS; index++ )
{
- if( pButton == m_vResultList[index] )
+ if( &rButton == m_vResultList[index].get() )
{
if( !m_vPersonaSettings[index].isEmpty() )
{
@@ -374,21 +354,21 @@ const OUString& SelectPersonaDialog::GetAppliedPersonaSetting() const
void SelectPersonaDialog::SetProgress( const OUString& rProgress )
{
if(rProgress.isEmpty())
- m_pProgressLabel->Hide();
+ m_xProgressLabel->hide();
else
{
SolarMutexGuard aGuard;
- m_pProgressLabel->Show();
- m_pProgressLabel->SetText( rProgress );
- setOptimalLayoutSize();
+ m_xProgressLabel->show();
+ m_xProgressLabel->set_label( rProgress );
+ m_xDialog->resize_to_request(); //TODO
}
}
-void SelectPersonaDialog::SetImages( const Image& aImage, const OUString& sName, const sal_Int32& nIndex )
+void SelectPersonaDialog::SetImages( VirtualDevice& rImage, const OUString& sName, const sal_Int32& nIndex )
{
- m_vResultList[nIndex]->Enable();
- m_vResultList[nIndex]->SetModeImage( aImage );
- m_vResultList[nIndex]->SetQuickHelpText( sName );
+ m_vResultList[nIndex]->set_sensitive(true);
+ m_vResultList[nIndex]->set_image(&rImage);
+ m_vResultList[nIndex]->set_tooltip_text( sName );
}
void SelectPersonaDialog::AddPersonaSetting( OUString const & rPersonaSetting )
@@ -402,10 +382,10 @@ void SelectPersonaDialog::ClearSearchResults()
SolarMutexGuard aGuard;
m_vPersonaSettings.clear();
m_aSelectedPersona.clear();
- for(VclPtr<PushButton> & nIndex : m_vResultList)
+ for(auto & nIndex : m_vResultList)
{
- nIndex->Disable();
- nIndex->SetModeImage(Image());
+ nIndex->set_sensitive(false);
+ nIndex->set_image(nullptr);
}
}
@@ -655,11 +635,11 @@ void SvxPersonalizationTabPage::LoadExtensionThemes()
IMPL_LINK_NOARG( SvxPersonalizationTabPage, SelectPersona, Button*, void )
{
m_pOwnPersona->Check();
- ScopedVclPtrInstance< SelectPersonaDialog > aDialog(nullptr);
+ SelectPersonaDialog aDialog(GetDialogFrameWeld());
- if ( aDialog->Execute() == RET_OK )
+ if (aDialog.run() == RET_OK)
{
- OUString aPersonaSetting( aDialog->GetAppliedPersonaSetting() );
+ OUString aPersonaSetting(aDialog.GetAppliedPersonaSetting());
if ( !aPersonaSetting.isEmpty() )
{
SetPersonaSettings( aPersonaSetting );
@@ -908,8 +888,11 @@ void SearchAndParseThread::execute()
aFilter.ImportGraphic( aGraphic, aURLObj );
BitmapEx aBmp = aGraphic.GetBitmapEx();
- m_pPersonaDialog->SetImages( Image( aBmp ), personaInfo.sName, nIndex );
- m_pPersonaDialog->setOptimalLayoutSize();
+ ScopedVclPtr<VirtualDevice> xVirDev(VclPtr<VirtualDevice>::Create());
+ xVirDev->SetOutputSizePixel(aBmp.GetSizePixel());
+ xVirDev->DrawBitmapEx(Point(0, 0), aBmp);
+
+ m_pPersonaDialog->SetImages(*xVirDev, personaInfo.sName, nIndex );
if (++nIndex >= MAX_RESULTS)
break;
@@ -971,8 +954,11 @@ void SearchAndParseThread::execute()
aFilter.ImportGraphic( aGraphic, aURLObj );
BitmapEx aBmp = aGraphic.GetBitmapEx();
- m_pPersonaDialog->SetImages( Image( aBmp ), aPersonaInfo.sName, 0 );
- m_pPersonaDialog->setOptimalLayoutSize();
+ ScopedVclPtr<VirtualDevice> xVirDev(VclPtr<VirtualDevice>::Create());
+ xVirDev->SetOutputSizePixel(aBmp.GetSizePixel());
+ xVirDev->DrawBitmapEx(Point(0, 0), aBmp);
+
+ m_pPersonaDialog->SetImages( *xVirDev, aPersonaInfo.sName, 0 );
}
}
@@ -983,7 +969,6 @@ void SearchAndParseThread::execute()
SolarMutexGuard aGuard;
sProgress.clear();
m_pPersonaDialog->SetProgress( sProgress );
- m_pPersonaDialog->setOptimalLayoutSize();
}
GetPersonaThread::GetPersonaThread( SelectPersonaDialog* pDialog,
@@ -1062,7 +1047,7 @@ void GetPersonaThread::execute()
+ ";" + aTextColor;
m_pPersonaDialog->SetAppliedPersonaSetting( aPersonaSetting );
- m_pPersonaDialog->EndDialog( RET_OK );
+ m_pPersonaDialog->response( RET_OK );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/options/personalization.hxx b/cui/source/options/personalization.hxx
index 8cd7fd89bcb1..1e0638024cff 100644
--- a/cui/source/options/personalization.hxx
+++ b/cui/source/options/personalization.hxx
@@ -94,25 +94,24 @@ private:
};
/** Dialog that will allow the user to choose a Persona to use. */
-class SelectPersonaDialog : public ModalDialog
+class SelectPersonaDialog : public weld::GenericDialogController
{
private:
- VclPtr<Edit> m_pEdit; ///< The input line for the search term
- VclPtr<PushButton> m_pSearchButton; ///< The search button
- VclPtr<FixedText> m_pProgressLabel; ///< The label for showing progress of search
- VclPtr<PushButton> m_vResultList[MAX_RESULTS]; ///< List of buttons to show search results
- VclPtr<ListBox> m_pCategories; ///< The list of categories
- VclPtr<PushButton> m_pOkButton; ///< The OK button
- VclPtr<PushButton> m_pCancelButton; ///< The Cancel button
-
std::vector<OUString> m_vPersonaSettings;
OUString m_aSelectedPersona;
OUString m_aAppliedPersona;
+ std::unique_ptr<weld::Entry> m_xEdit; ///< The input line for the search term
+ std::unique_ptr<weld::Button> m_xSearchButton; ///< The search button
+ std::unique_ptr<weld::Label> m_xProgressLabel; ///< The label for showing progress of search
+ std::unique_ptr<weld::ComboBox> m_xCategories; ///< The list of categories
+ std::unique_ptr<weld::Button> m_xOkButton; ///< The OK button
+ std::unique_ptr<weld::Button> m_xCancelButton; ///< The Cancel button
+ std::unique_ptr<weld::Button> m_vResultList[MAX_RESULTS]; ///< List of buttons to show search results
+
public:
- explicit SelectPersonaDialog( vcl::Window *pParent );
+ explicit SelectPersonaDialog(weld::Window *pParent);
virtual ~SelectPersonaDialog() override;
- virtual void dispose() override;
::rtl::Reference< SearchAndParseThread > m_pSearchThread;
::rtl::Reference< GetPersonaThread > m_pGetPersonaThread;
@@ -124,7 +123,7 @@ public:
* @param sName Name of the persona
* @param nIndex Index number of the result button
*/
- void SetImages(const Image& aPreviewImage, const OUString& sName, const sal_Int32& nIndex );
+ void SetImages( VirtualDevice& rPreviewImage, const OUString& sName, const sal_Int32& nIndex );
void AddPersonaSetting( OUString const & );
void ClearSearchResults();
void SetAppliedPersonaSetting( OUString const & );
@@ -132,19 +131,19 @@ public:
private:
/// Handle the Search button
- DECL_LINK( SearchPersonas, Button*, void );
+ DECL_LINK( SearchPersonas, weld::Button&, void );
/// Handle persona categories list box
- DECL_LINK( SelectCategory, ListBox&, void );
- DECL_LINK( SelectPersona, Button*, void );
- DECL_LINK( ActionOK, Button*, void );
- DECL_LINK( ActionCancel, Button*, void );
+ DECL_LINK( SelectCategory, weld::ComboBox&, void );
+ DECL_LINK( SelectPersona, weld::Button&, void );
+ DECL_LINK( ActionOK, weld::Button&, void );
+ DECL_LINK( ActionCancel, weld::Button&, void );
};
class SearchAndParseThread: public salhelper::Thread
{
private:
- VclPtr<SelectPersonaDialog> m_pPersonaDialog;
+ SelectPersonaDialog* m_pPersonaDialog;
OUString m_aURL;
std::atomic<bool> m_bExecute;
bool m_bDirectURL;
@@ -164,7 +163,7 @@ class GetPersonaThread: public salhelper::Thread
{
private:
- VclPtr<SelectPersonaDialog> m_pPersonaDialog;
+ SelectPersonaDialog* m_pPersonaDialog;
OUString m_aSelectedPersona;
std::atomic<bool> m_bExecute;
diff --git a/cui/uiconfig/ui/select_persona_dialog.ui b/cui/uiconfig/ui/select_persona_dialog.ui
index 36d80658a5d2..9c17e485fa24 100644
--- a/cui/uiconfig/ui/select_persona_dialog.ui
+++ b/cui/uiconfig/ui/select_persona_dialog.ui
@@ -6,6 +6,9 @@
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="select_persona_dialog|SelectPersonaDialog">Select Firefox Theme</property>
+ <property name="modal">True</property>
+ <property name="default_width">0</property>
+ <property name="default_height">0</property>
<property name="type_hint">dialog</property>
<child>
<placeholder/>
@@ -68,7 +71,9 @@
<object class="GtkLabel" id="progress_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="hexpand">True</property>
<property name="ellipsize">end</property>
+ <property name="width_chars">45</property>
<property name="max_width_chars">45</property>
<property name="xalign">0</property>
</object>
@@ -98,6 +103,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
+ <property name="activates_default">True</property>
<property name="primary_icon_activatable">False</property>
<property name="secondary_icon_activatable">False</property>
<property name="placeholder_text" translatable="yes" context="select_persona_dialog|search_term">Search term or address</property>
@@ -142,7 +148,7 @@
<object class="GtkLabel" id="categories_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" context="select_persona_dialog|categories_label" translatable="yes">Ca_tegory:</property>
+ <property name="label" translatable="yes" context="select_persona_dialog|categories_label">Ca_tegory:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">categoriesCB</property>
</object>