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

weld NewDataTypeDialog

Change-Id: Ice5146e72baba397e60fbcb8d64d1ddaeb32e45c
Reviewed-on: https://gerrit.libreoffice.org/61481
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 08d4100a
......@@ -28,15 +28,13 @@ namespace pcr
//= NewDataTypeDialog
NewDataTypeDialog::NewDataTypeDialog( vcl::Window* _pParent, const OUString& _rNameBase, const std::vector< OUString >& _rProhibitedNames )
: ModalDialog( _pParent, "DataTypeDialog",
"modules/spropctrlr/ui/datatypedialog.ui" )
NewDataTypeDialog::NewDataTypeDialog(weld::Window* pParent, const OUString& _rNameBase, const std::vector< OUString >& _rProhibitedNames)
: GenericDialogController(pParent, "modules/spropctrlr/ui/datatypedialog.ui", "DataTypeDialog")
, m_aProhibitedNames( _rProhibitedNames.begin(), _rProhibitedNames.end() )
, m_xName(m_xBuilder->weld_entry("entry"))
, m_xOK(m_xBuilder->weld_button("ok"))
{
get(m_pName, "entry");
get(m_pOK, "ok");
m_pName->SetModifyHdl( LINK( this, NewDataTypeDialog, OnNameModified ) );
m_xName->connect_changed(LINK(this, NewDataTypeDialog, OnNameModified));
// find an initial name
// for this, first remove trailing digits
......@@ -61,32 +59,22 @@ namespace pcr
}
while ( m_aProhibitedNames.find( sInitialName ) != m_aProhibitedNames.end() );
m_pName->SetText( sInitialName );
OnNameModified( *m_pName );
m_xName->set_text(sInitialName);
OnNameModified(*m_xName);
}
NewDataTypeDialog::~NewDataTypeDialog()
{
disposeOnce();
}
void NewDataTypeDialog::dispose()
{
m_pName.clear();
m_pOK.clear();
ModalDialog::dispose();
}
IMPL_LINK_NOARG( NewDataTypeDialog, OnNameModified, Edit&, void )
IMPL_LINK_NOARG(NewDataTypeDialog, OnNameModified, weld::Entry&, void)
{
OUString sCurrentName = GetName();
bool bNameIsOK = ( !sCurrentName.isEmpty() )
&& ( m_aProhibitedNames.find( sCurrentName ) == m_aProhibitedNames.end() );
m_pOK->Enable( bNameIsOK );
m_xOK->set_sensitive(bNameIsOK);
}
} // namespace pcr
......
......@@ -20,10 +20,7 @@
#ifndef INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_NEWDATATYPE_HXX
#define INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_NEWDATATYPE_HXX
#include <vcl/dialog.hxx>
#include <vcl/fixed.hxx>
#include <vcl/button.hxx>
#include <vcl/edit.hxx>
#include <vcl/weld.hxx>
#include <set>
#include <vector>
......@@ -32,24 +29,22 @@
namespace pcr
{
//= NewDataTypeDialog
class NewDataTypeDialog : public ModalDialog
class NewDataTypeDialog : public weld::GenericDialogController
{
private:
VclPtr<Edit> m_pName;
VclPtr<OKButton> m_pOK;
std::set< OUString > m_aProhibitedNames;
std::set<OUString> m_aProhibitedNames;
std::unique_ptr<weld::Entry> m_xName;
std::unique_ptr<weld::Button> m_xOK;
public:
NewDataTypeDialog(vcl::Window* _pParent, const OUString& _rNameBase,
NewDataTypeDialog(weld::Window* _pParent, const OUString& _rNameBase,
const std::vector< OUString >& _rProhibitedNames );
virtual ~NewDataTypeDialog() override;
virtual void dispose() override;
OUString GetName() const { return m_pName->GetText(); }
OUString GetName() const { return m_xName->get_text(); }
private:
DECL_LINK( OnNameModified, Edit&, void );
DECL_LINK(OnNameModified, weld::Entry&, void);
};
......
......@@ -488,11 +488,11 @@ namespace pcr
std::vector< OUString > aExistentNames;
m_pHelper->getAvailableDataTypeNames( aExistentNames );
ScopedVclPtrInstance<NewDataTypeDialog> aDialog( nullptr, pType->getName(), aExistentNames ); // TODO/eForms: proper parent
if ( aDialog->Execute() != RET_OK )
NewDataTypeDialog aDialog( nullptr, pType->getName(), aExistentNames ); // TODO/eForms: proper parent
if (aDialog.run() != RET_OK)
return false;
_rNewName = aDialog->GetName();
_rNewName = aDialog.GetName();
return true;
}
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.22.1 -->
<interface domain="pcr">
<requires lib="gtk+" version="3.18"/>
<object class="GtkDialog" id="DataTypeDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="datatypedialog|DataTypeDialog">New Data Type</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>
......@@ -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">0</property>
......
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