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)
{
// Unlike the mpCertPathDlg, we *don't* keep the same dialog object around between
// invocations. Seems clearer to my little brain that way.
ScopedVclPtrInstance<TSAURLsDialog> pTSAURLsDlg(this);
pTSAURLsDlg->Execute();
TSAURLsDialog aTSAURLsDlg(GetDialogFrameWeld());
aTSAURLsDlg.run();
}
IMPL_STATIC_LINK_NOARG(SvxSecurityTabPage, MacroSecPBHdl, Button*, void)
......
......@@ -19,22 +19,22 @@
using namespace ::com::sun::star;
TSAURLsDialog::TSAURLsDialog(vcl::Window* pParent)
: ModalDialog(pParent, "TSAURLDialog", "cui/ui/tsaurldialog.ui")
TSAURLsDialog::TSAURLsDialog(weld::Window* pParent)
: 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");
get(m_pDeleteBtn, "delete");
get(m_pOKBtn, "ok");
get(m_pURLListBox, "urls");
m_xURLListBox->set_size_request(m_xURLListBox->get_approximate_digit_width() * 28,
m_xURLListBox->get_height_rows(8));
m_xOKBtn->set_sensitive(false);
m_pURLListBox->SetDropDownLineCount(8);
m_pURLListBox->set_width_request(m_pURLListBox->approximate_char_width() * 32);
m_pOKBtn->Disable();
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 ) );
m_xAddBtn->connect_clicked( LINK( this, TSAURLsDialog, AddHdl_Impl ) );
m_xDeleteBtn->connect_clicked( LINK( this, TSAURLsDialog, DeleteHdl_Impl ) );
m_xOKBtn->connect_clicked( LINK( this, TSAURLsDialog, OKHdl_Impl ) );
m_xURLListBox->connect_changed( LINK( this, TSAURLsDialog, SelectHdl ) );
try
{
......@@ -53,88 +53,77 @@ TSAURLsDialog::TSAURLsDialog(vcl::Window* pParent)
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());
officecfg::Office::Common::Security::Scripting::TSAURLs::set(comphelper::containerToSequence(m_aURLs), batch);
batch->commit();
EndDialog(RET_OK);
m_xDialog->response(RET_OK);
}
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)
{
m_aURLs.insert(rURL);
m_pURLListBox->SetUpdateMode(false);
m_pURLListBox->Clear();
m_xURLListBox->freeze();
m_xURLListBox->clear();
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 aDesc( get<FixedText>("enteraurl")->GetText() );
OUString aDesc(m_xEnterAUrl->get_label());
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);
m_pOKBtn->Enable();
m_xOKBtn->set_sensitive(true);
}
m_xURLListBox->unselect_all();
// 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();
if (nSel == LISTBOX_ENTRY_NOTFOUND)
int nSel = m_xURLListBox->get_selected_index();
if (nSel == -1)
return;
m_aURLs.erase(m_pURLListBox->GetEntry(nSel));
m_pURLListBox->RemoveEntry(nSel);
m_aURLs.erase(m_xURLListBox->get_text(nSel));
m_xURLListBox->remove(nSel);
m_xURLListBox->unselect_all();
// After operations in a ListBox we have nothing selected
m_pDeleteBtn->Disable();
m_pOKBtn->Enable();
m_xDeleteBtn->set_sensitive(false);
m_xOKBtn->set_sensitive(true);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -10,32 +10,31 @@
#ifndef INCLUDED_CUI_SOURCE_OPTIONS_TSAURLS_HXX
#define INCLUDED_CUI_SOURCE_OPTIONS_TSAURLS_HXX
#include <vcl/lstbox.hxx>
#include <vcl/button.hxx>
#include <vcl/weld.hxx>
class TSAURLsDialog : public ModalDialog
class TSAURLsDialog : public weld::GenericDialogController
{
private:
VclPtr<ListBox> m_pURLListBox;
VclPtr<PushButton> m_pAddBtn;
VclPtr<PushButton> m_pDeleteBtn;
VclPtr<OKButton> m_pOKBtn;
DECL_LINK(AddHdl_Impl, Button*, void);
DECL_LINK(DeleteHdl_Impl, Button*, void);
DECL_LINK(OKHdl_Impl, Button*, void);
// After operations in a ListBox we have nothing selected
// Is Selected element handler for the ListBox
DECL_LINK(SelectHdl, ListBox&, void);
std::unique_ptr<weld::Button> m_xAddBtn;
std::unique_ptr<weld::Button> m_xDeleteBtn;
std::unique_ptr<weld::Button> m_xOKBtn;
std::unique_ptr<weld::TreeView> m_xURLListBox;
std::unique_ptr<weld::Label> m_xEnterAUrl;
DECL_LINK(AddHdl_Impl, weld::Button&, void);
DECL_LINK(DeleteHdl_Impl, weld::Button&, void);
DECL_LINK(OKHdl_Impl, weld::Button&, void);
// After operations in a TreeView we have nothing selected
// Is Selected element handler for the TreeView
DECL_LINK(SelectHdl, weld::TreeView&, void);
std::set<OUString> m_aURLs;
void AddTSAURL(const OUString &rURL);
public:
explicit TSAURLsDialog(vcl::Window* pParent);
explicit TSAURLsDialog(weld::Window* pParent);
virtual ~TSAURLsDialog() override;
virtual void dispose() override;
};
#endif
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface domain="cui">
<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">
<property name="can_focus">False</property>
<property name="border_width">6</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>
<child>
<placeholder/>
</child>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
......@@ -32,13 +47,14 @@
</child>
<child>
<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="can_focus">True</property>
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="receives_default">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
......@@ -126,12 +142,12 @@
<property name="visible">True</property>
<property name="can_focus">False</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="use_underline">True</property>
<property name="wrap">True</property>
<property name="max_width_chars">60</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
</object>
<packing>
<property name="expand">False</property>
......@@ -140,14 +156,37 @@
</packing>
</child>
<child>
<object class="GtkTreeView" id="urls:border">
<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="show_expanders">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection3"/>
<property name="shadow_type">in</property>
<child>
<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>
</object>
<packing>
......@@ -170,8 +209,6 @@
<packing>
<property name="left_attach">2</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
......@@ -212,8 +249,8 @@
</child>
<action-widgets>
<action-widget response="-11">help</action-widget>
<action-widget response="0">delete</action-widget>
<action-widget response="0">add</action-widget>
<action-widget response="101">delete</action-widget>
<action-widget response="102">add</action-widget>
<action-widget response="-5">ok</action-widget>
<action-widget response="-6">cancel</action-widget>
</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