diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-04-04 08:57:10 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-04-04 11:02:48 +0200 |
commit | 8166d76b371c42f40f1d9b7d0c6617da7814c39e (patch) | |
tree | aa9664c3f68b5ab1fb30ab66fab37349a0d70017 | |
parent | f4bcba6074f394cc0ce3b660308b3ee8e4714978 (diff) |
weld SvxPathSelectDialog
Change-Id: Ie79d45e6c2e0da0fad45b4e1ae7ec7ac6222d5f9
Reviewed-on: https://gerrit.libreoffice.org/52360
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | cui/source/dialogs/multipat.cxx | 86 | ||||
-rw-r--r-- | cui/source/factory/dlgfact.cxx | 18 | ||||
-rw-r--r-- | cui/source/factory/dlgfact.hxx | 11 | ||||
-rw-r--r-- | cui/source/inc/multipat.hxx | 19 | ||||
-rw-r--r-- | cui/uiconfig/ui/selectpathdialog.ui | 40 | ||||
-rw-r--r-- | include/svx/svxdlg.hxx | 2 | ||||
-rw-r--r-- | sw/source/ui/misc/glossary.cxx | 4 |
7 files changed, 99 insertions, 81 deletions
diff --git a/cui/source/dialogs/multipat.cxx b/cui/source/dialogs/multipat.cxx index eccc81553ebd..ca431ff2ffcc 100644 --- a/cui/source/dialogs/multipat.cxx +++ b/cui/source/dialogs/multipat.cxx @@ -49,12 +49,12 @@ IMPL_LINK_NOARG(SvxMultiPathDialog, SelectHdl_Impl, SvTreeListBox*, void) m_pDelBtn->Enable(bEnable && bIsSelected); } -IMPL_LINK_NOARG(SvxPathSelectDialog, SelectHdl_Impl, ListBox&, void) +IMPL_LINK_NOARG(SvxPathSelectDialog, SelectHdl_Impl, weld::TreeView&, void) { - sal_uLong nCount = m_pPathLB->GetEntryCount(); - bool bIsSelected = m_pPathLB->GetSelectedEntryPos() != LISTBOX_ENTRY_NOTFOUND; + sal_uLong nCount = m_xPathLB->n_children(); + bool bIsSelected = m_xPathLB->get_selected_index() != -1; bool bEnable = nCount > 1; - m_pDelBtn->Enable(bEnable && bIsSelected); + m_xDelBtn->set_sensitive(bEnable && bIsSelected); } IMPL_LINK( SvxMultiPathDialog, CheckHdl_Impl, SvTreeListBox*, pBox, void ) @@ -102,7 +102,7 @@ IMPL_LINK_NOARG(SvxMultiPathDialog, AddHdl_Impl, Button*, void) } } -IMPL_LINK_NOARG(SvxPathSelectDialog, AddHdl_Impl, Button*, void) +IMPL_LINK_NOARG(SvxPathSelectDialog, AddHdl_Impl, weld::Button&, void) { Reference < XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); Reference < XFolderPicker2 > xFolderPicker = FolderPicker::create(xContext); @@ -115,21 +115,20 @@ IMPL_LINK_NOARG(SvxPathSelectDialog, AddHdl_Impl, Button*, void) OUString sInsPath; osl::FileBase::getSystemPathFromFileURL(aURL, sInsPath); - if ( LISTBOX_ENTRY_NOTFOUND != m_pPathLB->GetEntryPos( sInsPath ) ) + if (m_xPathLB->find(sInsPath) != -1) { OUString sMsg( CuiResId( RID_MULTIPATH_DBL_ERR ) ); sMsg = sMsg.replaceFirst( "%1", sInsPath ); - std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Info, VclButtonsType::Ok, sMsg)); xInfoBox->run(); } else { - const sal_Int32 nPos = m_pPathLB->InsertEntry( sInsPath ); - m_pPathLB->SetEntryData( nPos, new OUString( aURL ) ); + m_xPathLB->append(aURL, sInsPath, ""); } - SelectHdl_Impl( *m_pPathLB ); + SelectHdl_Impl(*m_xPathLB); } } @@ -159,22 +158,22 @@ IMPL_LINK_NOARG(SvxMultiPathDialog, DelHdl_Impl, Button*, void) SelectHdl_Impl( nullptr ); } -IMPL_LINK_NOARG(SvxPathSelectDialog, DelHdl_Impl, Button*, void) +IMPL_LINK_NOARG(SvxPathSelectDialog, DelHdl_Impl, weld::Button&, void) { - sal_Int32 nPos = m_pPathLB->GetSelectedEntryPos(); - m_pPathLB->RemoveEntry( nPos ); - sal_Int32 nCnt = m_pPathLB->GetEntryCount(); + int nPos = m_xPathLB->get_selected_index(); + m_xPathLB->remove(nPos); + int nCnt = m_xPathLB->n_children(); - if ( nCnt ) + if (nCnt) { - nCnt--; + --nCnt; if ( nPos > nCnt ) nPos = nCnt; - m_pPathLB->SelectEntryPos( nPos ); + m_xPathLB->select(nPos); } - SelectHdl_Impl( *m_pPathLB ); + SelectHdl_Impl(*m_xPathLB); } SvxMultiPathDialog::SvxMultiPathDialog(vcl::Window* pParent) @@ -206,21 +205,20 @@ SvxMultiPathDialog::SvxMultiPathDialog(vcl::Window* pParent) m_pRadioLB->ShowTable(); } -SvxPathSelectDialog::SvxPathSelectDialog(vcl::Window* pParent) - : ModalDialog(pParent, "SelectPathDialog", "cui/ui/selectpathdialog.ui") +SvxPathSelectDialog::SvxPathSelectDialog(weld::Window* pParent) + : GenericDialogController(pParent, "cui/ui/selectpathdialog.ui", "SelectPathDialog") + , m_xPathLB(m_xBuilder->weld_tree_view("paths")) + , m_xAddBtn(m_xBuilder->weld_button("add")) + , m_xDelBtn(m_xBuilder->weld_button("delete")) { - get(m_pAddBtn, "add"); - get(m_pDelBtn, "delete"); - get(m_pPathLB, "paths"); - Size aSize(LogicToPixel(Size(189, 80), MapMode(MapUnit::MapAppFont))); - m_pPathLB->set_width_request(aSize.Width()); - m_pPathLB->set_height_request(aSize.Height()); + m_xPathLB->set_size_request(m_xPathLB->get_approximate_digit_width() * 60, + m_xPathLB->get_text_height() * 10); - m_pPathLB->SetSelectHdl( LINK( this, SvxPathSelectDialog, SelectHdl_Impl ) ); - m_pAddBtn->SetClickHdl( LINK( this, SvxPathSelectDialog, AddHdl_Impl ) ); - m_pDelBtn->SetClickHdl( LINK( this, SvxPathSelectDialog, DelHdl_Impl ) ); + m_xPathLB->connect_changed(LINK(this, SvxPathSelectDialog, SelectHdl_Impl)); + m_xAddBtn->connect_clicked(LINK(this, SvxPathSelectDialog, AddHdl_Impl)); + m_xDelBtn->connect_clicked(LINK(this, SvxPathSelectDialog, DelHdl_Impl)); - SelectHdl_Impl( *m_pPathLB ); + SelectHdl_Impl(*m_xPathLB); } SvxMultiPathDialog::~SvxMultiPathDialog() @@ -246,25 +244,6 @@ void SvxMultiPathDialog::dispose() ModalDialog::dispose(); } -SvxPathSelectDialog::~SvxPathSelectDialog() -{ - disposeOnce(); -} - -void SvxPathSelectDialog::dispose() -{ - if (m_pPathLB) - { - sal_Int32 nPos = m_pPathLB->GetEntryCount(); - while ( nPos-- ) - delete static_cast<OUString*>(m_pPathLB->GetEntryData(nPos)); - } - m_pPathLB.clear(); - m_pAddBtn.clear(); - m_pDelBtn.clear(); - ModalDialog::dispose(); -} - OUString SvxMultiPathDialog::GetPath() const { OUString sNewPath; @@ -294,11 +273,11 @@ OUString SvxPathSelectDialog::GetPath() const { OUString sNewPath; - for ( sal_Int32 i = 0; i < m_pPathLB->GetEntryCount(); ++i ) + for (int i = 0; i < m_xPathLB->n_children(); ++i) { if ( !sNewPath.isEmpty() ) sNewPath += OUStringLiteral1(SVT_SEARCHPATH_DELIMITER); - sNewPath += *static_cast<OUString*>(m_pPathLB->GetEntryData(i)); + sNewPath += m_xPathLB->get_id(i); } return sNewPath; @@ -349,13 +328,12 @@ void SvxPathSelectDialog::SetPath(const OUString& rPath) bool bIsSystemPath = osl::FileBase::getSystemPathFromFileURL(sPath, sSystemPath) == osl::FileBase::E_None; - const sal_Int32 nPos = m_pPathLB->InsertEntry( bIsSystemPath ? sSystemPath : sPath ); - m_pPathLB->SetEntryData( nPos, new OUString( sPath ) ); + m_xPathLB->append(sPath, bIsSystemPath ? sSystemPath : sPath, ""); } while (nIndex >= 0); } - SelectHdl_Impl( *m_pPathLB ); + SelectHdl_Impl(*m_xPathLB); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx index bf07b49fc5d5..644326aa7c5a 100644 --- a/cui/source/factory/dlgfact.cxx +++ b/cui/source/factory/dlgfact.cxx @@ -142,7 +142,12 @@ short AbstractSvxObjectTitleDescDialog_Impl::Execute() } IMPL_ABSTDLG_BASE(AbstractSvxMultiPathDialog_Impl); -IMPL_ABSTDLG_BASE(AbstractSvxPathSelectDialog_Impl); + +short AbstractSvxPathSelectDialog_Impl::Execute() +{ + return m_xDlg->run(); +} + IMPL_ABSTDLG_BASE(AbstractSvxHpLinkDlg_Impl); IMPL_ABSTDLG_BASE(AbstractFmSearchDialog_Impl); IMPL_ABSTDLG_BASE(AbstractGraphicFilterDialog_Impl); @@ -683,17 +688,17 @@ void AbstractSvxMultiPathDialog_Impl::SetTitle( const OUString& rNewTitle ) OUString AbstractSvxPathSelectDialog_Impl::GetPath() const { - return pDlg->GetPath(); + return m_xDlg->GetPath(); } void AbstractSvxPathSelectDialog_Impl::SetPath( const OUString& rPath ) { - pDlg->SetPath( rPath ); + m_xDlg->SetPath( rPath ); } void AbstractSvxPathSelectDialog_Impl::SetTitle( const OUString& rNewTitle ) { - pDlg->SetText( rNewTitle ); + m_xDlg->SetTitle(rNewTitle); } vcl::Window * AbstractSvxHpLinkDlg_Impl::GetWindow() @@ -1159,10 +1164,9 @@ VclPtr<AbstractSvxMultiPathDialog> AbstractDialogFactory_Impl::CreateSvxMultiPat return VclPtr<AbstractSvxMultiPathDialog_Impl>::Create( pDlg ); } -VclPtr<AbstractSvxMultiPathDialog> AbstractDialogFactory_Impl::CreateSvxPathSelectDialog(vcl::Window* pParent) +VclPtr<AbstractSvxMultiPathDialog> AbstractDialogFactory_Impl::CreateSvxPathSelectDialog(weld::Window* pParent) { - VclPtrInstance<SvxPathSelectDialog> pDlg(pParent); - return VclPtr<AbstractSvxPathSelectDialog_Impl>::Create( pDlg ); + return VclPtr<AbstractSvxPathSelectDialog_Impl>::Create(new SvxPathSelectDialog(pParent)); } VclPtr<AbstractSvxHpLinkDlg> AbstractDialogFactory_Impl::CreateSvxHpLinkDlg (vcl::Window* pParent, diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx index ddea72e2c206..771f6eafd611 100644 --- a/cui/source/factory/dlgfact.hxx +++ b/cui/source/factory/dlgfact.hxx @@ -380,7 +380,14 @@ class AbstractSvxMultiPathDialog_Impl : public AbstractSvxMultiPathDialog class SvxPathSelectDialog; class AbstractSvxPathSelectDialog_Impl : public AbstractSvxMultiPathDialog { - DECL_ABSTDLG_BASE(AbstractSvxPathSelectDialog_Impl,SvxPathSelectDialog) +protected: + std::unique_ptr<SvxPathSelectDialog> m_xDlg; +public: + explicit AbstractSvxPathSelectDialog_Impl(SvxPathSelectDialog* p) + : m_xDlg(p) + { + } + virtual short Execute() override; virtual OUString GetPath() const override; virtual void SetPath( const OUString& rPath ) override; virtual void SetTitle( const OUString& rNewTitle ) override; @@ -622,7 +629,7 @@ public: virtual VclPtr<AbstractSvxObjectTitleDescDialog> CreateSvxObjectTitleDescDialog(weld::Window* pParent, const OUString& rTitle, const OUString& rDescription) override; virtual VclPtr<AbstractSvxMultiPathDialog> CreateSvxMultiPathDialog(vcl::Window* pParent) override; - virtual VclPtr<AbstractSvxMultiPathDialog> CreateSvxPathSelectDialog(vcl::Window* pParent) override; + virtual VclPtr<AbstractSvxMultiPathDialog> CreateSvxPathSelectDialog(weld::Window* pParent) override; virtual VclPtr<AbstractSvxHpLinkDlg> CreateSvxHpLinkDlg(vcl::Window* pParent, SfxBindings* pBindings) override; virtual VclPtr<AbstractFmSearchDialog> CreateFmSearchDialog(vcl::Window* pParent, const OUString& strInitialText, diff --git a/cui/source/inc/multipat.hxx b/cui/source/inc/multipat.hxx index f059a55bcca1..ea9ade6ac059 100644 --- a/cui/source/inc/multipat.hxx +++ b/cui/source/inc/multipat.hxx @@ -57,24 +57,23 @@ public: void SetPath( const OUString& rPath ); }; -class SvxPathSelectDialog : public ModalDialog +class SvxPathSelectDialog : public weld::GenericDialogController { private: - VclPtr<ListBox> m_pPathLB; - VclPtr<PushButton> m_pAddBtn; - VclPtr<PushButton> m_pDelBtn; + std::unique_ptr<weld::TreeView> m_xPathLB; + std::unique_ptr<weld::Button> m_xAddBtn; + std::unique_ptr<weld::Button> m_xDelBtn; - DECL_LINK(AddHdl_Impl, Button*, void); - DECL_LINK(DelHdl_Impl, Button*, void); - DECL_LINK(SelectHdl_Impl, ListBox&, void); + DECL_LINK(AddHdl_Impl, weld::Button&, void); + DECL_LINK(DelHdl_Impl, weld::Button&, void); + DECL_LINK(SelectHdl_Impl, weld::TreeView&, void); public: - SvxPathSelectDialog(vcl::Window* pParent); - virtual ~SvxPathSelectDialog() override; - virtual void dispose() override; + SvxPathSelectDialog(weld::Window* pParent); OUString GetPath() const; void SetPath( const OUString& rPath ); + void SetTitle(const OUString& rTitle) { m_xDialog->set_title(rTitle); } }; #endif // INCLUDED_CUI_SOURCE_INC_MULTIPAT_HXX diff --git a/cui/uiconfig/ui/selectpathdialog.ui b/cui/uiconfig/ui/selectpathdialog.ui index 956c44e314f5..c8ac090ab7d6 100644 --- a/cui/uiconfig/ui/selectpathdialog.ui +++ b/cui/uiconfig/ui/selectpathdialog.ui @@ -1,12 +1,23 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.20.4 --> <interface domain="cui"> <requires lib="gtk+" version="3.18"/> + <object class="GtkListStore" id="liststore1"> + <columns> + <!-- column-name text --> + <column type="gchararray"/> + <!-- column-name id --> + <column type="gchararray"/> + </columns> + </object> <object class="GtkDialog" id="SelectPathDialog"> <property name="can_focus">False</property> <property name="border_width">6</property> <property name="title" translatable="yes" context="selectpathdialog|SelectPathDialog">Select Paths</property> <property name="resizable">False</property> + <property name="modal">True</property> + <property name="default_width">0</property> + <property name="default_height">0</property> <property name="type_hint">normal</property> <child internal-child="vbox"> <object class="GtkBox" id="dialog-vbox1"> @@ -136,18 +147,34 @@ </packing> </child> <child> - <object class="GtkScrolledWindow" id="scrolledwindow2"> + <object class="GtkScrolledWindow"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> <property name="shadow_type">in</property> <child> - <object class="GtkTreeView" id="paths:border"> + <object class="GtkTreeView" id="paths"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="hexpand">True</property> <property name="vexpand">True</property> + <property name="model">liststore1</property> + <property name="headers_visible">False</property> + <property name="headers_clickable">False</property> + <property name="search_column">0</property> + <property name="show_expanders">False</property> <child internal-child="selection"> - <object class="GtkTreeSelection" id="treeview-selection"/> + <object class="GtkTreeSelection" id="treeview-selection1"/> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn1"> + <child> + <object class="GtkCellRendererText" id="cellrenderertext1"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> </child> </object> </child> @@ -185,5 +212,8 @@ <action-widget response="-6">cancel</action-widget> <action-widget response="-11">help</action-widget> </action-widgets> + <child> + <placeholder/> + </child> </object> </interface> diff --git a/include/svx/svxdlg.hxx b/include/svx/svxdlg.hxx index 6f3b7097a4e5..77f4437f8ae9 100644 --- a/include/svx/svxdlg.hxx +++ b/include/svx/svxdlg.hxx @@ -405,7 +405,7 @@ public: virtual VclPtr<AbstractSvxObjectTitleDescDialog> CreateSvxObjectTitleDescDialog(weld::Window* pParent, const OUString& rTitle, const OUString& rDescription) = 0; virtual VclPtr<AbstractSvxMultiPathDialog> CreateSvxMultiPathDialog(vcl::Window* pParent) = 0 ; - virtual VclPtr<AbstractSvxMultiPathDialog> CreateSvxPathSelectDialog(vcl::Window* pParent) = 0 ; + virtual VclPtr<AbstractSvxMultiPathDialog> CreateSvxPathSelectDialog(weld::Window* pParent) = 0 ; virtual VclPtr<AbstractSvxHpLinkDlg> CreateSvxHpLinkDlg(vcl::Window* pParent, SfxBindings* pBindings)=0; virtual VclPtr<AbstractFmSearchDialog> CreateFmSearchDialog(vcl::Window* pParent, const OUString& strInitialText, diff --git a/sw/source/ui/misc/glossary.cxx b/sw/source/ui/misc/glossary.cxx index 6479ad71b3c5..2d8dcf52cd42 100644 --- a/sw/source/ui/misc/glossary.cxx +++ b/sw/source/ui/misc/glossary.cxx @@ -1044,12 +1044,12 @@ OUString SwGlossaryDlg::GetCurrGrpName() const return OUString(); } -IMPL_LINK( SwGlossaryDlg, PathHdl, Button *, pBtn, void ) +IMPL_LINK_NOARG( SwGlossaryDlg, PathHdl, Button *, void ) { SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); if(pFact) { - ScopedVclPtr<AbstractSvxMultiPathDialog> pDlg(pFact->CreateSvxPathSelectDialog(pBtn)); + ScopedVclPtr<AbstractSvxMultiPathDialog> pDlg(pFact->CreateSvxPathSelectDialog(GetFrameWeld())); OSL_ENSURE(pDlg, "Dialog creation failed!"); SvtPathOptions aPathOpt; const OUString sGlosPath( aPathOpt.GetAutoTextPath() ); |