Kaydet (Commit) e436a61a authored tarafından Caolán McNamara's avatar Caolán McNamara

weld TSAURLsDialog

Change-Id: Iae3f4f1acfca02daa66726da3434ffb4406ff71d
Reviewed-on: https://gerrit.libreoffice.org/67380
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 5408f073
...@@ -813,10 +813,8 @@ IMPL_LINK_NOARG(SvxSecurityTabPage, TSAURLsPBHdl, Button*, void) ...@@ -813,10 +813,8 @@ IMPL_LINK_NOARG(SvxSecurityTabPage, TSAURLsPBHdl, Button*, void)
{ {
// Unlike the mpCertPathDlg, we *don't* keep the same dialog object around between // Unlike the mpCertPathDlg, we *don't* keep the same dialog object around between
// invocations. Seems clearer to my little brain that way. // invocations. Seems clearer to my little brain that way.
TSAURLsDialog aTSAURLsDlg(GetDialogFrameWeld());
ScopedVclPtrInstance<TSAURLsDialog> pTSAURLsDlg(this); aTSAURLsDlg.run();
pTSAURLsDlg->Execute();
} }
IMPL_STATIC_LINK_NOARG(SvxSecurityTabPage, MacroSecPBHdl, Button*, void) IMPL_STATIC_LINK_NOARG(SvxSecurityTabPage, MacroSecPBHdl, Button*, void)
......
...@@ -19,22 +19,22 @@ ...@@ -19,22 +19,22 @@
using namespace ::com::sun::star; using namespace ::com::sun::star;
TSAURLsDialog::TSAURLsDialog(vcl::Window* pParent) TSAURLsDialog::TSAURLsDialog(weld::Window* pParent)
: ModalDialog(pParent, "TSAURLDialog", "cui/ui/tsaurldialog.ui") : GenericDialogController(pParent, "cui/ui/tsaurldialog.ui", "TSAURLDialog")
, m_xAddBtn(m_xBuilder->weld_button("add"))
, m_xDeleteBtn(m_xBuilder->weld_button("delete"))
, m_xOKBtn(m_xBuilder->weld_button("ok"))
, m_xURLListBox(m_xBuilder->weld_tree_view("urls"))
, m_xEnterAUrl(m_xBuilder->weld_label("enteraurl"))
{ {
get(m_pAddBtn, "add"); m_xURLListBox->set_size_request(m_xURLListBox->get_approximate_digit_width() * 28,
get(m_pDeleteBtn, "delete"); m_xURLListBox->get_height_rows(8));
get(m_pOKBtn, "ok"); m_xOKBtn->set_sensitive(false);
get(m_pURLListBox, "urls");
m_pURLListBox->SetDropDownLineCount(8); m_xAddBtn->connect_clicked( LINK( this, TSAURLsDialog, AddHdl_Impl ) );
m_pURLListBox->set_width_request(m_pURLListBox->approximate_char_width() * 32); m_xDeleteBtn->connect_clicked( LINK( this, TSAURLsDialog, DeleteHdl_Impl ) );
m_pOKBtn->Disable(); m_xOKBtn->connect_clicked( LINK( this, TSAURLsDialog, OKHdl_Impl ) );
m_xURLListBox->connect_changed( LINK( this, TSAURLsDialog, SelectHdl ) );
m_pAddBtn->SetClickHdl( LINK( this, TSAURLsDialog, AddHdl_Impl ) );
m_pDeleteBtn->SetClickHdl( LINK( this, TSAURLsDialog, DeleteHdl_Impl ) );
m_pOKBtn->SetClickHdl( LINK( this, TSAURLsDialog, OKHdl_Impl ) );
m_pURLListBox->SetSelectHdl( LINK( this, TSAURLsDialog, SelectHdl ) );
try try
{ {
...@@ -53,88 +53,77 @@ TSAURLsDialog::TSAURLsDialog(vcl::Window* pParent) ...@@ -53,88 +53,77 @@ TSAURLsDialog::TSAURLsDialog(vcl::Window* pParent)
SAL_WARN("cui.options", "TSAURLsDialog::TSAURLsDialog(): " << e); SAL_WARN("cui.options", "TSAURLsDialog::TSAURLsDialog(): " << e);
} }
if ( m_pURLListBox->GetSelectedEntryCount() == 0 ) if (m_xURLListBox->get_selected_index() == -1)
{ {
m_pDeleteBtn->Disable(); m_xDeleteBtn->set_sensitive(false);
} }
} }
IMPL_LINK_NOARG(TSAURLsDialog, OKHdl_Impl, Button*, void) IMPL_LINK_NOARG(TSAURLsDialog, OKHdl_Impl, weld::Button&, void)
{ {
std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create()); std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
officecfg::Office::Common::Security::Scripting::TSAURLs::set(comphelper::containerToSequence(m_aURLs), batch); officecfg::Office::Common::Security::Scripting::TSAURLs::set(comphelper::containerToSequence(m_aURLs), batch);
batch->commit(); batch->commit();
EndDialog(RET_OK); m_xDialog->response(RET_OK);
} }
TSAURLsDialog::~TSAURLsDialog() TSAURLsDialog::~TSAURLsDialog()
{ {
disposeOnce();
}
void TSAURLsDialog::dispose()
{
m_pAddBtn.clear();
m_pDeleteBtn.clear();
m_pOKBtn.clear();
m_pURLListBox.clear();
ModalDialog::dispose();
} }
void TSAURLsDialog::AddTSAURL(const OUString& rURL) void TSAURLsDialog::AddTSAURL(const OUString& rURL)
{ {
m_aURLs.insert(rURL); m_aURLs.insert(rURL);
m_pURLListBox->SetUpdateMode(false); m_xURLListBox->freeze();
m_pURLListBox->Clear(); m_xURLListBox->clear();
for (auto const& url : m_aURLs) for (auto const& url : m_aURLs)
{ {
m_pURLListBox->InsertEntry(url); m_xURLListBox->append_text(url);
} }
m_pURLListBox->SetUpdateMode(true); m_xURLListBox->thaw();
} }
IMPL_LINK_NOARG(TSAURLsDialog, AddHdl_Impl, Button*, void) IMPL_LINK_NOARG(TSAURLsDialog, AddHdl_Impl, weld::Button&, void)
{ {
OUString aURL; OUString aURL;
OUString aDesc( get<FixedText>("enteraurl")->GetText() ); OUString aDesc(m_xEnterAUrl->get_label());
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
ScopedVclPtr<AbstractSvxNameDialog> pDlg(pFact->CreateSvxNameDialog(m_pAddBtn->GetFrameWeld(), aURL, aDesc)); ScopedVclPtr<AbstractSvxNameDialog> pDlg(pFact->CreateSvxNameDialog(m_xDialog.get(), aURL, aDesc));
if ( pDlg->Execute() == RET_OK ) if (pDlg->Execute() == RET_OK)
{ {
pDlg->GetName( aURL ); pDlg->GetName(aURL);
AddTSAURL(aURL); AddTSAURL(aURL);
m_pOKBtn->Enable(); m_xOKBtn->set_sensitive(true);
} }
m_xURLListBox->unselect_all();
// After operations in a ListBox we have nothing selected // After operations in a ListBox we have nothing selected
m_pDeleteBtn->Disable(); m_xDeleteBtn->set_sensitive(false);
} }
IMPL_LINK_NOARG(TSAURLsDialog, SelectHdl, ListBox&, void) IMPL_LINK_NOARG(TSAURLsDialog, SelectHdl, weld::TreeView&, void)
{ {
m_pDeleteBtn->Enable(); m_xDeleteBtn->set_sensitive(true);
} }
IMPL_LINK_NOARG(TSAURLsDialog, DeleteHdl_Impl, Button*, void) IMPL_LINK_NOARG(TSAURLsDialog, DeleteHdl_Impl, weld::Button&, void)
{ {
sal_Int32 nSel = m_pURLListBox->GetSelectedEntryPos(); int nSel = m_xURLListBox->get_selected_index();
if (nSel == -1)
if (nSel == LISTBOX_ENTRY_NOTFOUND)
return; return;
m_aURLs.erase(m_pURLListBox->GetEntry(nSel)); m_aURLs.erase(m_xURLListBox->get_text(nSel));
m_pURLListBox->RemoveEntry(nSel); m_xURLListBox->remove(nSel);
m_xURLListBox->unselect_all();
// After operations in a ListBox we have nothing selected // After operations in a ListBox we have nothing selected
m_pDeleteBtn->Disable(); m_xDeleteBtn->set_sensitive(false);
m_pOKBtn->Enable(); m_xOKBtn->set_sensitive(true);
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -10,32 +10,31 @@ ...@@ -10,32 +10,31 @@
#ifndef INCLUDED_CUI_SOURCE_OPTIONS_TSAURLS_HXX #ifndef INCLUDED_CUI_SOURCE_OPTIONS_TSAURLS_HXX
#define INCLUDED_CUI_SOURCE_OPTIONS_TSAURLS_HXX #define INCLUDED_CUI_SOURCE_OPTIONS_TSAURLS_HXX
#include <vcl/lstbox.hxx> #include <vcl/weld.hxx>
#include <vcl/button.hxx>
class TSAURLsDialog : public ModalDialog class TSAURLsDialog : public weld::GenericDialogController
{ {
private: private:
VclPtr<ListBox> m_pURLListBox; std::unique_ptr<weld::Button> m_xAddBtn;
VclPtr<PushButton> m_pAddBtn; std::unique_ptr<weld::Button> m_xDeleteBtn;
VclPtr<PushButton> m_pDeleteBtn; std::unique_ptr<weld::Button> m_xOKBtn;
VclPtr<OKButton> m_pOKBtn; std::unique_ptr<weld::TreeView> m_xURLListBox;
std::unique_ptr<weld::Label> m_xEnterAUrl;
DECL_LINK(AddHdl_Impl, Button*, void);
DECL_LINK(DeleteHdl_Impl, Button*, void); DECL_LINK(AddHdl_Impl, weld::Button&, void);
DECL_LINK(OKHdl_Impl, Button*, void); DECL_LINK(DeleteHdl_Impl, weld::Button&, void);
// After operations in a ListBox we have nothing selected DECL_LINK(OKHdl_Impl, weld::Button&, void);
// Is Selected element handler for the ListBox // After operations in a TreeView we have nothing selected
DECL_LINK(SelectHdl, ListBox&, void); // Is Selected element handler for the TreeView
DECL_LINK(SelectHdl, weld::TreeView&, void);
std::set<OUString> m_aURLs; std::set<OUString> m_aURLs;
void AddTSAURL(const OUString &rURL); void AddTSAURL(const OUString &rURL);
public: public:
explicit TSAURLsDialog(vcl::Window* pParent); explicit TSAURLsDialog(weld::Window* pParent);
virtual ~TSAURLsDialog() override; virtual ~TSAURLsDialog() override;
virtual void dispose() override;
}; };
#endif #endif
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface domain="cui"> <interface domain="cui">
<requires lib="gtk+" version="3.18"/> <requires lib="gtk+" version="3.18"/>
<object class="GtkTreeStore" id="liststore1">
<columns>
<!-- column-name text -->
<column type="gchararray"/>
<!-- column-name id -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkDialog" id="TSAURLDialog"> <object class="GtkDialog" id="TSAURLDialog">
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="border_width">6</property> <property name="border_width">6</property>
<property name="title" translatable="yes" context="tsaurldialog|TSAURLDialog">Time Stamping Authority URLs</property> <property name="title" translatable="yes" context="tsaurldialog|TSAURLDialog">Time Stamping Authority URLs</property>
<property name="modal">True</property>
<property name="default_width">0</property>
<property name="default_height">0</property>
<property name="type_hint">normal</property> <property name="type_hint">normal</property>
<child>
<placeholder/>
</child>
<child internal-child="vbox"> <child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1"> <object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property> <property name="can_focus">False</property>
...@@ -32,13 +47,14 @@ ...@@ -32,13 +47,14 @@
</child> </child>
<child> <child>
<object class="GtkButton" id="delete"> <object class="GtkButton" id="delete">
<property name="label" translatable="yes" context="tsaurldialog|delete">_Delete...</property> <property name="label" context="tsaurldialog|delete">gtk-delete</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="can_default">True</property> <property name="can_default">True</property>
<property name="has_default">True</property> <property name="has_default">True</property>
<property name="receives_default">True</property> <property name="receives_default">True</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="use_stock">True</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
...@@ -126,12 +142,12 @@ ...@@ -126,12 +142,12 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="margin_bottom">6</property> <property name="margin_bottom">6</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="label" translatable="yes" context="tsaurldialog|label2">Add or delete Time Stamp Authority URLs</property> <property name="label" translatable="yes" context="tsaurldialog|label2">Add or delete Time Stamp Authority URLs</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="wrap">True</property> <property name="wrap">True</property>
<property name="max_width_chars">60</property> <property name="max_width_chars">60</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
...@@ -140,14 +156,37 @@ ...@@ -140,14 +156,37 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkTreeView" id="urls:border"> <object class="GtkScrolledWindow">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="vexpand">True</property> <property name="vexpand">True</property>
<property name="show_expanders">False</property> <property name="shadow_type">in</property>
<child internal-child="selection"> <child>
<object class="GtkTreeSelection" id="treeview-selection3"/> <object class="GtkTreeView" id="urls">
<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-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> </child>
</object> </object>
<packing> <packing>
...@@ -170,8 +209,6 @@ ...@@ -170,8 +209,6 @@
<packing> <packing>
<property name="left_attach">2</property> <property name="left_attach">2</property>
<property name="top_attach">0</property> <property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing> </packing>
</child> </child>
<child> <child>
...@@ -212,8 +249,8 @@ ...@@ -212,8 +249,8 @@
</child> </child>
<action-widgets> <action-widgets>
<action-widget response="-11">help</action-widget> <action-widget response="-11">help</action-widget>
<action-widget response="0">delete</action-widget> <action-widget response="101">delete</action-widget>
<action-widget response="0">add</action-widget> <action-widget response="102">add</action-widget>
<action-widget response="-5">ok</action-widget> <action-widget response="-5">ok</action-widget>
<action-widget response="-6">cancel</action-widget> <action-widget response="-6">cancel</action-widget>
</action-widgets> </action-widgets>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment