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

weld SwNewUserIdxDlg

Change-Id: I49502af0b045116fba32259d8ada80b1e53a79a8
Reviewed-on: https://gerrit.libreoffice.org/52332Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 96300e32
...@@ -564,49 +564,40 @@ void SwIndexMarkPane::UpdateKeyBoxes() ...@@ -564,49 +564,40 @@ void SwIndexMarkPane::UpdateKeyBoxes()
} }
} }
class SwNewUserIdxDlg : public ModalDialog class SwNewUserIdxDlg : public weld::GenericDialogController
{ {
VclPtr<OKButton> m_pOKPB;
VclPtr<Edit> m_pNameED;
SwIndexMarkPane* m_pDlg; SwIndexMarkPane* m_pDlg;
DECL_LINK( ModifyHdl, Edit&, void); std::unique_ptr<weld::Button> m_xOKPB;
std::unique_ptr<weld::Entry> m_xNameED;
public: DECL_LINK(ModifyHdl, weld::Entry&, void);
explicit SwNewUserIdxDlg(SwIndexMarkPane* pPane)
: ModalDialog(&(pPane->GetDialog()), "NewUserIndexDialog", public:
"modules/swriter/ui/newuserindexdialog.ui") explicit SwNewUserIdxDlg(SwIndexMarkPane* pPane)
, m_pDlg(pPane) : GenericDialogController(pPane->GetFrameWeld(), "modules/swriter/ui/newuserindexdialog.ui", "NewUserIndexDialog")
{ , m_pDlg(pPane)
get(m_pOKPB, "ok"); , m_xOKPB(m_xBuilder->weld_button("ok"))
get(m_pNameED, "entry"); , m_xNameED(m_xBuilder->weld_entry("entry"))
m_pNameED->SetModifyHdl(LINK(this, SwNewUserIdxDlg, ModifyHdl));
m_pOKPB->Enable(false);
m_pNameED->GrabFocus();
}
virtual ~SwNewUserIdxDlg() override { disposeOnce(); }
virtual void dispose() override
{ {
m_pOKPB.clear(); m_xNameED->connect_changed(LINK(this, SwNewUserIdxDlg, ModifyHdl));
m_pNameED.clear(); m_xOKPB->set_sensitive(false);
ModalDialog::dispose(); m_xNameED->grab_focus();
} }
OUString GetName() const { return m_xNameED->get_text(); }
OUString GetName(){return m_pNameED->GetText();}
}; };
IMPL_LINK( SwNewUserIdxDlg, ModifyHdl, Edit&, rEdit, void) IMPL_LINK( SwNewUserIdxDlg, ModifyHdl, weld::Entry&, rEdit, void)
{ {
m_pOKPB->Enable(!rEdit.GetText().isEmpty() && !m_pDlg->IsTOXType(rEdit.GetText())); m_xOKPB->set_sensitive(!rEdit.get_text().isEmpty() && !m_pDlg->IsTOXType(rEdit.get_text()));
} }
IMPL_LINK_NOARG(SwIndexMarkPane, NewUserIdxHdl, Button*, void) IMPL_LINK_NOARG(SwIndexMarkPane, NewUserIdxHdl, Button*, void)
{ {
ScopedVclPtrInstance< SwNewUserIdxDlg > pDlg(this); SwNewUserIdxDlg aDlg(this);
if(RET_OK == pDlg->Execute()) if (aDlg.run() == RET_OK)
{ {
OUString sNewName(pDlg->GetName()); OUString sNewName(aDlg.GetName());
m_pTypeDCB->InsertEntry(sNewName); m_pTypeDCB->InsertEntry(sNewName);
m_pTypeDCB->SelectEntry(sNewName); m_pTypeDCB->SelectEntry(sNewName);
} }
......
...@@ -144,7 +144,7 @@ public: ...@@ -144,7 +144,7 @@ public:
bool bNewDlg, bool bNewDlg,
SwWrtShell& rWrtShell); SwWrtShell& rWrtShell);
Dialog &GetDialog() { return m_rDialog; } weld::Window* GetFrameWeld() { return m_rDialog.GetFrameWeld(); }
~SwIndexMarkPane(); ~SwIndexMarkPane();
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.4 -->
<interface domain="sw"> <interface domain="sw">
<!-- interface-requires gtk+ 3.0 --> <requires lib="gtk+" version="3.18"/>
<!-- interface-requires LibreOffice 1.0 -->
<object class="GtkDialog" id="NewUserIndexDialog"> <object class="GtkDialog" id="NewUserIndexDialog">
<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="newuserindexdialog|NewUserIndexDialog">Create New User-defined Index</property> <property name="title" translatable="yes" context="newuserindexdialog|NewUserIndexDialog">Create New User-defined Index</property>
<property name="modal">True</property>
<property name="default_width">0</property>
<property name="default_height">0</property>
<property name="type_hint">dialog</property> <property name="type_hint">dialog</property>
<child internal-child="vbox"> <child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1"> <object class="GtkBox" id="dialog-vbox1">
...@@ -58,6 +61,7 @@ ...@@ -58,6 +61,7 @@
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">2</property> <property name="position">2</property>
<property name="secondary">True</property>
</packing> </packing>
</child> </child>
</object> </object>
...@@ -96,16 +100,14 @@ ...@@ -96,16 +100,14 @@
<object class="GtkLabel" id="label2"> <object class="GtkLabel" id="label2">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="newuserindexdialog|label2">_Name</property> <property name="label" translatable="yes" context="newuserindexdialog|label2">_Name</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">entry</property> <property name="mnemonic_widget">entry</property>
<property name="xalign">0</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</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>
...@@ -113,12 +115,11 @@ ...@@ -113,12 +115,11 @@
<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="activates_default">True</property>
</object> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</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>
</object> </object>
...@@ -149,5 +150,8 @@ ...@@ -149,5 +150,8 @@
<action-widget response="-6">cancel</action-widget> <action-widget response="-6">cancel</action-widget>
<action-widget response="-11">help</action-widget> <action-widget response="-11">help</action-widget>
</action-widgets> </action-widgets>
<child>
<placeholder/>
</child>
</object> </object>
</interface> </interface>
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