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

Caolán McNamara caolanm at redhat.com
Mon May 14 13:03:58 UTC 2018


 svx/source/form/datanavi.cxx          |   58 ++++++++++++++--------------------
 svx/source/inc/datanavi.hxx           |   26 +++++++--------
 svx/uiconfig/ui/addnamespacedialog.ui |   13 +++++--
 3 files changed, 46 insertions(+), 51 deletions(-)

New commits:
commit f645481d29d09c412d34ea6cbba89135d10babee
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon May 14 12:01:53 2018 +0100

    weld ManageNamespaceDialog
    
    Change-Id: Ieb5605fcab285de26e4fab64b8178d4d7818eb2d
    Reviewed-on: https://gerrit.libreoffice.org/54311
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/svx/source/form/datanavi.cxx b/svx/source/form/datanavi.cxx
index 3a7f2a2e7b40..06eade7b63b1 100644
--- a/svx/source/form/datanavi.cxx
+++ b/svx/source/form/datanavi.cxx
@@ -2937,32 +2937,32 @@ namespace svxform
         PushButton* pBtn = static_cast<PushButton*>(pButton);
         if ( m_pAddNamespaceBtn == pBtn )
         {
-            ScopedVclPtrInstance< ManageNamespaceDialog > aDlg(this, m_pConditionDlg, false);
-            if ( aDlg->Execute() == RET_OK )
+            ManageNamespaceDialog aDlg(GetFrameWeld(), m_pConditionDlg, false);
+            if (aDlg.run() == RET_OK)
             {
-                OUString sEntry = aDlg->GetPrefix();
+                OUString sEntry = aDlg.GetPrefix();
                 sEntry += "\t";
-                sEntry += aDlg->GetURL();
+                sEntry += aDlg.GetURL();
                 m_pNamespacesList->InsertEntry( sEntry );
             }
         }
         else if ( m_pEditNamespaceBtn == pBtn )
         {
-            ScopedVclPtrInstance< ManageNamespaceDialog > aDlg( this, m_pConditionDlg, true );
+            ManageNamespaceDialog aDlg(GetFrameWeld(), m_pConditionDlg, true);
             SvTreeListEntry* pEntry = m_pNamespacesList->FirstSelected();
             DBG_ASSERT( pEntry, "NamespaceItemDialog::ClickHdl(): no entry" );
             OUString sPrefix( SvTabListBox::GetEntryText( pEntry, 0 ) );
-            aDlg->SetNamespace(
+            aDlg.SetNamespace(
                 sPrefix,
                 SvTabListBox::GetEntryText( pEntry, 1 ) );
-            if ( aDlg->Execute() == RET_OK )
+            if (aDlg.run() == RET_OK)
             {
                 // if a prefix was changed, mark the old prefix as 'removed'
-                if( sPrefix != aDlg->GetPrefix() )
+                if( sPrefix != aDlg.GetPrefix() )
                     m_aRemovedList.push_back( sPrefix );
 
-                m_pNamespacesList->SetEntryText( aDlg->GetPrefix(), pEntry, 0 );
-                m_pNamespacesList->SetEntryText( aDlg->GetURL(), pEntry, 1 );
+                m_pNamespacesList->SetEntryText( aDlg.GetPrefix(), pEntry, 0 );
+                m_pNamespacesList->SetEntryText( aDlg.GetURL(), pEntry, 1 );
             }
         }
         else if ( m_pDeleteNamespaceBtn == pBtn )
@@ -3044,43 +3044,33 @@ namespace svxform
         }
     }
 
-    ManageNamespaceDialog::ManageNamespaceDialog(vcl::Window* pParent, AddConditionDialog* _pCondDlg, bool bIsEdit)
-        : ModalDialog(pParent, "AddNamespaceDialog", "svx/ui/addnamespacedialog.ui")
-        , m_pConditionDlg ( _pCondDlg )
+    ManageNamespaceDialog::ManageNamespaceDialog(weld::Window* pParent, AddConditionDialog* _pCondDlg, bool bIsEdit)
+        : GenericDialogController(pParent, "svx/ui/addnamespacedialog.ui", "AddNamespaceDialog")
+        , m_xConditionDlg(_pCondDlg)
+        , m_xPrefixED(m_xBuilder->weld_entry("prefix"))
+        , m_xUrlED(m_xBuilder->weld_entry("url"))
+        , m_xOKBtn(m_xBuilder->weld_button("ok"))
+        , m_xAltTitle(m_xBuilder->weld_label("alttitle"))
     {
-        get(m_pOKBtn, "ok");
-        get(m_pPrefixED, "prefix");
-        get(m_pUrlED, "url");
-
         if (bIsEdit)
-            SetText(get<FixedText>("alttitle")->GetText());
+            m_xDialog->set_title(m_xAltTitle->get_label());
 
-        m_pOKBtn->SetClickHdl( LINK( this, ManageNamespaceDialog, OKHdl ) );
+        m_xOKBtn->connect_clicked(LINK(this, ManageNamespaceDialog, OKHdl));
     }
 
     ManageNamespaceDialog::~ManageNamespaceDialog()
     {
-        disposeOnce();
     }
 
-    void ManageNamespaceDialog::dispose()
+    IMPL_LINK_NOARG(ManageNamespaceDialog, OKHdl, weld::Button&, void)
     {
-        m_pOKBtn.clear();
-        m_pPrefixED.clear();
-        m_pUrlED.clear();
-        m_pConditionDlg.clear();
-        ModalDialog::dispose();
-    }
-
-    IMPL_LINK_NOARG(ManageNamespaceDialog, OKHdl, Button*, void)
-    {
-        OUString sPrefix = m_pPrefixED->GetText();
+        OUString sPrefix = m_xPrefixED->get_text();
 
         try
         {
-            if ( !m_pConditionDlg->GetUIHelper()->isValidPrefixName( sPrefix ) )
+            if (!m_xConditionDlg->GetUIHelper()->isValidPrefixName(sPrefix))
             {
-                std::unique_ptr<weld::MessageDialog> xErrBox(Application::CreateMessageDialog(GetFrameWeld(),
+                std::unique_ptr<weld::MessageDialog> xErrBox(Application::CreateMessageDialog(m_xDialog.get(),
                                                                          VclMessageType::Warning, VclButtonsType::Ok,
                                                                          SvxResId(RID_STR_INVALID_XMLPREFIX)));
                 xErrBox->set_primary_text(xErrBox->get_primary_text().replaceFirst(MSG_VARIABLE, sPrefix));
@@ -3094,7 +3084,7 @@ namespace svxform
         }
 
         // no error so close the dialog
-        EndDialog( RET_OK );
+        m_xDialog->response(RET_OK);
     }
 
     AddSubmissionDialog::AddSubmissionDialog(
diff --git a/svx/source/inc/datanavi.hxx b/svx/source/inc/datanavi.hxx
index 323b7bad3029..b424c472de0b 100644
--- a/svx/source/inc/datanavi.hxx
+++ b/svx/source/inc/datanavi.hxx
@@ -516,33 +516,31 @@ namespace svxform
         virtual void dispose() override;
     };
 
-
-    class ManageNamespaceDialog : public ModalDialog
+    class ManageNamespaceDialog : public weld::GenericDialogController
     {
     private:
-        VclPtr<Edit>               m_pPrefixED;
-        VclPtr<Edit>               m_pUrlED;
-        VclPtr<OKButton>           m_pOKBtn;
+        VclPtr<AddConditionDialog> m_xConditionDlg;
 
-        VclPtr<AddConditionDialog> m_pConditionDlg;
+        std::unique_ptr<weld::Entry> m_xPrefixED;
+        std::unique_ptr<weld::Entry> m_xUrlED;
+        std::unique_ptr<weld::Button> m_xOKBtn;
+        std::unique_ptr<weld::Label> m_xAltTitle;
 
-        DECL_LINK(OKHdl, Button*, void);
+        DECL_LINK(OKHdl, weld::Button&, void);
 
     public:
-        ManageNamespaceDialog(vcl::Window* pParent, AddConditionDialog* _pCondDlg, bool bIsEdit);
+        ManageNamespaceDialog(weld::Window* pParent, AddConditionDialog* _pCondDlg, bool bIsEdit);
         virtual ~ManageNamespaceDialog() override;
-        virtual void dispose() override;
 
         void SetNamespace(const OUString& _rPrefix, const OUString& _rURL)
         {
-            m_pPrefixED->SetText( _rPrefix );
-            m_pUrlED->SetText( _rURL );
+            m_xPrefixED->set_text(_rPrefix);
+            m_xUrlED->set_text(_rURL);
         }
-        OUString GetPrefix() const { return m_pPrefixED->GetText(); }
-        OUString GetURL() const { return m_pUrlED->GetText(); }
+        OUString GetPrefix() const { return m_xPrefixED->get_text(); }
+        OUString GetURL() const { return m_xUrlED->get_text(); }
     };
 
-
     class AddSubmissionDialog : public ModalDialog
     {
     private:
diff --git a/svx/uiconfig/ui/addnamespacedialog.ui b/svx/uiconfig/ui/addnamespacedialog.ui
index ef4b242bf9a6..49c92cbd9bbc 100644
--- a/svx/uiconfig/ui/addnamespacedialog.ui
+++ b/svx/uiconfig/ui/addnamespacedialog.ui
@@ -1,5 +1,5 @@
 <?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="AddNamespaceDialog">
@@ -7,7 +7,12 @@
     <property name="border_width">6</property>
     <property name="title" translatable="yes" context="addnamespacedialog|AddNamespaceDialog">Add Namespace</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>
@@ -81,10 +86,10 @@
               <object class="GtkLabel" id="label1">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="xalign">0</property>
                 <property name="label" translatable="yes" context="addnamespacedialog|label1">_Prefix:</property>
                 <property name="use_underline">True</property>
                 <property name="mnemonic_widget">prefix</property>
+                <property name="xalign">0</property>
               </object>
               <packing>
                 <property name="left_attach">0</property>
@@ -96,6 +101,7 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="hexpand">True</property>
+                <property name="activates_default">True</property>
                 <property name="width_chars">12</property>
               </object>
               <packing>
@@ -108,6 +114,7 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="hexpand">True</property>
+                <property name="activates_default">True</property>
                 <property name="width_chars">34</property>
               </object>
               <packing>
@@ -119,10 +126,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="addnamespacedialog|label2">_URL:</property>
                 <property name="use_underline">True</property>
                 <property name="mnemonic_widget">url</property>
+                <property name="xalign">0</property>
               </object>
               <packing>
                 <property name="left_attach">1</property>


More information about the Libreoffice-commits mailing list