weld AddModelDialog

Change-Id: Ia12069f966c93ad7700b7a068dd7660284a40130
Reviewed-on: https://gerrit.libreoffice.org/54314
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara 2018-05-14 12:27:57 +01:00
parent 881bb00dc3
commit 2cc5db6244
3 changed files with 35 additions and 38 deletions

View file

@ -1485,15 +1485,15 @@ namespace svxform
OString sIdent(pBtn->GetCurItemIdent());
if (sIdent == "modelsadd")
{
ScopedVclPtrInstance< AddModelDialog > aDlg( this, false );
AddModelDialog aDlg(GetFrameWeld(), false);
bool bShowDialog = true;
while ( bShowDialog )
{
bShowDialog = false;
if ( aDlg->Execute() == RET_OK )
if (aDlg.run() == RET_OK)
{
OUString sNewName = aDlg->GetName();
bool bDocumentData = aDlg->GetModifyDoc();
OUString sNewName = aDlg.GetName();
bool bDocumentData = aDlg.GetModifyDoc();
if ( m_pModelsBox->GetEntryPos( sNewName ) != LISTBOX_ENTRY_NOTFOUND )
{
@ -1531,8 +1531,8 @@ namespace svxform
}
else if (sIdent == "modelsedit")
{
ScopedVclPtrInstance< AddModelDialog > aDlg( this, true );
aDlg->SetName( sSelectedModel );
AddModelDialog aDlg(GetFrameWeld(), true);
aDlg.SetName( sSelectedModel );
bool bDocumentData( false );
try
@ -1548,13 +1548,13 @@ namespace svxform
{
DBG_UNHANDLED_EXCEPTION("svx");
}
aDlg->SetModifyDoc( bDocumentData );
aDlg.SetModifyDoc( bDocumentData );
if ( aDlg->Execute() == RET_OK )
if (aDlg.run() == RET_OK)
{
if ( aDlg->GetModifyDoc() != bDocumentData )
if ( aDlg.GetModifyDoc() != bDocumentData )
{
bDocumentData = aDlg->GetModifyDoc();
bDocumentData = aDlg.GetModifyDoc();
try
{
Reference< css::xforms::XFormsSupplier > xFormsSupp( m_xFrameModel, UNO_QUERY_THROW );
@ -1569,7 +1569,7 @@ namespace svxform
}
}
OUString sNewName = aDlg->GetName();
OUString sNewName = aDlg.GetName();
if ( !sNewName.isEmpty() && ( sNewName != sSelectedModel ) )
{
try
@ -3317,26 +3317,18 @@ namespace svxform
m_pRefBtn->Enable( m_xTempBinding.is() );
}
AddModelDialog::AddModelDialog(vcl::Window* pParent, bool bIsEdit)
: ModalDialog(pParent, "AddModelDialog", "svx/ui/addmodeldialog.ui")
AddModelDialog::AddModelDialog(weld::Window* pParent, bool bIsEdit)
: GenericDialogController(pParent, "svx/ui/addmodeldialog.ui", "AddModelDialog")
, m_xNameED(m_xBuilder->weld_entry("name"))
, m_xModifyCB(m_xBuilder->weld_check_button("modify"))
, m_xAltTitle(m_xBuilder->weld_label("alttitle"))
{
get(m_pNameED, "name");
get(m_pModifyCB, "modify");
if (bIsEdit)
SetText(get<FixedText>("alttitle")->GetText());
m_xDialog->set_title(m_xAltTitle->get_label());
}
AddModelDialog::~AddModelDialog()
{
disposeOnce();
}
void AddModelDialog::dispose()
{
m_pNameED.clear();
m_pModifyCB.clear();
ModalDialog::dispose();
}
AddInstanceDialog::AddInstanceDialog(weld::Window* pParent, bool _bEdit)

View file

@ -583,26 +583,24 @@ namespace svxform
const css::uno::Reference< css::xforms::XSubmission >& GetNewSubmission() const { return m_xNewSubmission; }
};
class AddModelDialog : public ModalDialog
class AddModelDialog : public weld::GenericDialogController
{
private:
VclPtr<Edit> m_pNameED;
VclPtr<CheckBox> m_pModifyCB;
std::unique_ptr<weld::Entry> m_xNameED;
std::unique_ptr<weld::CheckButton> m_xModifyCB;
std::unique_ptr<weld::Label> m_xAltTitle;
public:
AddModelDialog( vcl::Window* pParent, bool _bEdit );
AddModelDialog(weld::Window* pParent, bool _bEdit);
virtual ~AddModelDialog() override;
virtual void dispose() override;
OUString GetName() const { return m_pNameED->GetText(); }
void SetName( const OUString& _rName ) { m_pNameED->SetText( _rName );}
OUString GetName() const { return m_xNameED->get_text(); }
void SetName( const OUString& _rName ) { m_xNameED->set_text( _rName );}
bool GetModifyDoc() const { return m_pModifyCB->IsChecked(); }
void SetModifyDoc( const bool bModify ) { m_pModifyCB->Check( bModify ); }
bool GetModifyDoc() const { return m_xModifyCB->get_active(); }
void SetModifyDoc( const bool bModify ) { m_xModifyCB->set_active(bModify); }
};
class AddInstanceDialog : public weld::GenericDialogController
{
private:

View file

@ -1,12 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.22.1 -->
<interface domain="svx">
<requires lib="gtk+" version="3.18"/>
<object class="GtkDialog" id="AddModelDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="addmodeldialog|AddModelDialog">Add Model</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/>
</child>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
@ -97,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>
</object>
<packing>
<property name="left_attach">1</property>
@ -107,10 +114,10 @@
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="addmodeldialog|label2">_Name:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">name</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>