[Libreoffice-commits] core.git: extensions/source extensions/uiconfig

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sun Oct 7 17:44:24 UTC 2018


 extensions/source/propctrlr/newdatatype.cxx                  |   30 +++--------
 extensions/source/propctrlr/newdatatype.hxx                  |   21 ++-----
 extensions/source/propctrlr/xsdvalidationpropertyhandler.cxx |    6 +-
 extensions/uiconfig/spropctrlr/ui/datatypedialog.ui          |    9 ++-
 4 files changed, 28 insertions(+), 38 deletions(-)

New commits:
commit 6846f2f204dbaaf9f32c2f717eb39d3a01711087
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sat Oct 6 20:54:44 2018 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Sun Oct 7 19:44:02 2018 +0200

    weld NewDataTypeDialog
    
    Change-Id: Ice5146e72baba397e60fbcb8d64d1ddaeb32e45c
    Reviewed-on: https://gerrit.libreoffice.org/61481
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/extensions/source/propctrlr/newdatatype.cxx b/extensions/source/propctrlr/newdatatype.cxx
index 6aa4dc633992..8c2876e73b38 100644
--- a/extensions/source/propctrlr/newdatatype.cxx
+++ b/extensions/source/propctrlr/newdatatype.cxx
@@ -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
 
 
diff --git a/extensions/source/propctrlr/newdatatype.hxx b/extensions/source/propctrlr/newdatatype.hxx
index 9185d1f02100..19a88f31c75f 100644
--- a/extensions/source/propctrlr/newdatatype.hxx
+++ b/extensions/source/propctrlr/newdatatype.hxx
@@ -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);
     };
 
 
diff --git a/extensions/source/propctrlr/xsdvalidationpropertyhandler.cxx b/extensions/source/propctrlr/xsdvalidationpropertyhandler.cxx
index 37eb19bdf6da..ec4d6c9f914a 100644
--- a/extensions/source/propctrlr/xsdvalidationpropertyhandler.cxx
+++ b/extensions/source/propctrlr/xsdvalidationpropertyhandler.cxx
@@ -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;
     }
 
diff --git a/extensions/uiconfig/spropctrlr/ui/datatypedialog.ui b/extensions/uiconfig/spropctrlr/ui/datatypedialog.ui
index 043196eade9f..be40857a472d 100644
--- a/extensions/uiconfig/spropctrlr/ui/datatypedialog.ui
+++ b/extensions/uiconfig/spropctrlr/ui/datatypedialog.ui
@@ -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="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>


More information about the Libreoffice-commits mailing list