[Libreoffice-commits] core.git: cui/source include/sfx2 include/vcl sfx2/source sfx2/uiconfig vcl/source vcl/unx

Caolán McNamara caolanm at redhat.com
Sun Mar 4 23:32:57 UTC 2018


 cui/source/options/optjava.cxx            |   10 ++---
 include/sfx2/inputdlg.hxx                 |   37 +++++++-------------
 include/vcl/weld.hxx                      |    1 
 sfx2/source/control/templatelocalview.cxx |   10 ++---
 sfx2/source/dialog/inputdlg.cxx           |   54 +++++++-----------------------
 sfx2/source/doc/templatedlg.cxx           |   14 +++----
 sfx2/uiconfig/ui/inputdialog.ui           |   12 +++++-
 vcl/source/app/salvtables.cxx             |    8 ++++
 vcl/unx/gtk3/gtk3gtkinst.cxx              |    5 ++
 9 files changed, 67 insertions(+), 84 deletions(-)

New commits:
commit ab63510e104c4b8e42982390357af1281c4b11a7
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Mar 4 21:28:44 2018 +0000

    weld InputDialog
    
    Change-Id: I821dcea904cad7cc6f9394bccf6560624d23729b
    Reviewed-on: https://gerrit.libreoffice.org/50756
    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/cui/source/options/optjava.cxx b/cui/source/options/optjava.cxx
index 30d968607df6..50264e96e777 100644
--- a/cui/source/options/optjava.cxx
+++ b/cui/source/options/optjava.cxx
@@ -806,14 +806,14 @@ void SvxJavaParameterDlg::EditParameter()
 
     if ( nPos != LISTBOX_ENTRY_NOTFOUND )
     {
-        ScopedVclPtrInstance< InputDialog > pParamEditDlg(CuiResId(RID_SVXSTR_JAVA_START_PARAM), this);
+        InputDialog aParamEditDlg(GetFrameWeld(), CuiResId(RID_SVXSTR_JAVA_START_PARAM));
         OUString editableClassPath = m_pAssignedList->GetSelectedEntry();
-        pParamEditDlg->SetEntryText( editableClassPath );
-        pParamEditDlg->HideHelpBtn();
+        aParamEditDlg.SetEntryText(editableClassPath);
+        aParamEditDlg.HideHelpBtn();
 
-        if(!pParamEditDlg->Execute())
+        if (!aParamEditDlg.run())
             return;
-        OUString editedClassPath = comphelper::string::strip( pParamEditDlg->GetEntryText(), ' ');
+        OUString editedClassPath = comphelper::string::strip(aParamEditDlg.GetEntryText(), ' ');
 
         if ( !editedClassPath.isEmpty() && editableClassPath != editedClassPath )
         {
diff --git a/include/sfx2/inputdlg.hxx b/include/sfx2/inputdlg.hxx
index 78221831b74c..bef84fcbd7f7 100644
--- a/include/sfx2/inputdlg.hxx
+++ b/include/sfx2/inputdlg.hxx
@@ -10,35 +10,24 @@
 #ifndef INCLUDED_SFX2_SOURCE_INC_INPUTDLG_HXX
 #define INCLUDED_SFX2_SOURCE_INC_INPUTDLG_HXX
 
-#include <vcl/dialog.hxx>
 #include <sfx2/dllapi.h>
+#include <vcl/weld.hxx>
 
-class Edit;
-class FixedText;
-class PushButton;
-class Button;
-
-class SFX2_DLLPUBLIC InputDialog : public ModalDialog
+class SFX2_DLLPUBLIC InputDialog
 {
-public:
-    InputDialog (const OUString &labelText, vcl::Window *pParent);
-    OUString GetEntryText () const;
-    void SetEntryText( OUString const & sStr );
-    void HideHelpBtn();
-    virtual ~InputDialog() override;
-    virtual void dispose() override;
-
 private:
+    std::unique_ptr<weld::Builder> m_xBuilder;
+    std::unique_ptr<weld::Dialog> m_xDialog;
+    std::unique_ptr<weld::Entry> m_xEntry;
+    std::unique_ptr<weld::Label> m_xLabel;
+    std::unique_ptr<weld::Button> m_xHelp;
 
-    DECL_LINK(ClickHdl, Button*, void);
-
-private:
-
-    VclPtr<Edit>       m_pEntry;
-    VclPtr<FixedText>  m_pLabel;
-    VclPtr<PushButton> m_pOK;
-    VclPtr<PushButton> m_pCancel;
-    VclPtr<PushButton> m_pHelp;
+public:
+    InputDialog(weld::Window* pParent, const OUString &rLabelText);
+    short run() { return m_xDialog->run(); }
+    OUString GetEntryText() const;
+    void SetEntryText(const OUString& rStr);
+    void HideHelpBtn();
 };
 
 #endif // INCLUDED_SFX2_SOURCE_INC_INPUTDLG_HXX
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index 0aad7d0d943f..9a46a191e7a0 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -286,6 +286,7 @@ public:
     virtual OUString get_text() const = 0;
     virtual void set_width_chars(int nChars) = 0;
     virtual void select_region(int nStartPos, int nEndPos) = 0;
+    virtual void set_position(int nCursorPos) = 0;
 
     void connect_changed(const Link<Entry&, void>& rLink) { m_aChangeHdl = rLink; }
 
diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx
index b95a7f60c535..447353c4b116 100644
--- a/sfx2/source/control/templatelocalview.cxx
+++ b/sfx2/source/control/templatelocalview.cxx
@@ -265,14 +265,14 @@ IMPL_LINK(TemplateLocalView, ContextMenuSelectHdl, Menu*, pMenu, bool)
         break;
     case MNI_RENAME:
     {
-        ScopedVclPtrInstance< InputDialog > m_pTitleEditDlg( SfxResId(STR_RENAME_TEMPLATE), this);
+        InputDialog aTitleEditDlg(GetFrameWeld(), SfxResId(STR_RENAME_TEMPLATE));
         OUString sOldTitle = maSelectedItem->getTitle();
-        m_pTitleEditDlg->SetEntryText( sOldTitle );
-        m_pTitleEditDlg->HideHelpBtn();
+        aTitleEditDlg.SetEntryText(sOldTitle);
+        aTitleEditDlg.HideHelpBtn();
 
-        if(!m_pTitleEditDlg->Execute())
+        if (!aTitleEditDlg.run())
             break;
-        OUString sNewTitle = comphelper::string::strip( m_pTitleEditDlg->GetEntryText(), ' ');
+        OUString sNewTitle = comphelper::string::strip(aTitleEditDlg.GetEntryText(), ' ');
 
         if ( !sNewTitle.isEmpty() && sNewTitle != sOldTitle )
         {
diff --git a/sfx2/source/dialog/inputdlg.cxx b/sfx2/source/dialog/inputdlg.cxx
index cbcbe2d0b98e..ff864ddd01a5 100644
--- a/sfx2/source/dialog/inputdlg.cxx
+++ b/sfx2/source/dialog/inputdlg.cxx
@@ -8,59 +8,33 @@
  */
 
 #include <sfx2/inputdlg.hxx>
-
 #include <sfx2/sfxresid.hxx>
-#include <vcl/button.hxx>
-#include <vcl/edit.hxx>
-#include <vcl/fixed.hxx>
-
-InputDialog::InputDialog(const OUString &rLabelText, vcl::Window *pParent)
-    : ModalDialog(pParent, "InputDialog", "sfx/ui/inputdialog.ui")
-{
-    get(m_pEntry, "entry");
-    get(m_pLabel, "label");
-    get(m_pOK, "ok");
-    get(m_pCancel, "cancel");
-    get(m_pHelp, "help");
-    m_pLabel->SetText(rLabelText);
-    m_pOK->SetClickHdl(LINK(this,InputDialog,ClickHdl));
-    m_pCancel->SetClickHdl(LINK(this,InputDialog,ClickHdl));
-}
-
-InputDialog::~InputDialog()
+#include <vcl/svapp.hxx>
+
+InputDialog::InputDialog(weld::Window* pParent, const OUString &rLabelText)
+    : m_xBuilder(Application::CreateBuilder(pParent, "sfx/ui/inputdialog.ui"))
+    , m_xDialog(m_xBuilder->weld_dialog("InputDialog"))
+    , m_xEntry(m_xBuilder->weld_entry("entry"))
+    , m_xLabel(m_xBuilder->weld_label("label"))
+    , m_xHelp(m_xBuilder->weld_button("help"))
 {
-    disposeOnce();
-}
-
-void InputDialog::dispose()
-{
-    m_pEntry.clear();
-    m_pLabel.clear();
-    m_pOK.clear();
-    m_pCancel.clear();
-    m_pHelp.clear();
-    ModalDialog::dispose();
+    m_xLabel->set_label(rLabelText);
 }
 
 void InputDialog::HideHelpBtn()
 {
-    m_pHelp->Hide();
+    m_xHelp->hide();
 }
 
 OUString InputDialog::GetEntryText() const
 {
-    return m_pEntry->GetText();
-}
-
-void InputDialog::SetEntryText( OUString const & sStr)
-{
-    m_pEntry->SetText(sStr);
-    m_pEntry->SetCursorAtLast();
+    return m_xEntry->get_text();
 }
 
-IMPL_LINK(InputDialog,ClickHdl, Button*, pButton, void)
+void InputDialog::SetEntryText(const OUString& rStr)
 {
-    EndDialog(pButton == m_pOK ? RET_OK : RET_CANCEL);
+    m_xEntry->set_text(rStr);
+    m_xEntry->set_position(-1);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index a5388e1a5649..b9c728e19475 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -1114,13 +1114,13 @@ void SfxTemplateManagerDlg::OnTemplateOpen ()
 
 void SfxTemplateManagerDlg::OnCategoryNew()
 {
-    ScopedVclPtrInstance< InputDialog > dlg(SfxResId(STR_INPUT_NEW),this);
+    InputDialog dlg(GetFrameWeld(), SfxResId(STR_INPUT_NEW));
 
-    int ret = dlg->Execute();
+    int ret = dlg.run();
 
     if (ret)
     {
-        OUString aName = dlg->GetEntryText();
+        OUString aName = dlg.GetEntryText();
 
         if(mpLocalView->createRegion(aName))
             mpCBFolder->InsertEntry(aName);
@@ -1137,14 +1137,14 @@ void SfxTemplateManagerDlg::OnCategoryNew()
 void SfxTemplateManagerDlg::OnCategoryRename()
 {
     OUString sCategory = mpCBFolder->GetSelectedEntry();
-    ScopedVclPtrInstance< InputDialog > dlg(SfxResId(STR_INPUT_NEW),this);
+    InputDialog dlg(GetFrameWeld(), SfxResId(STR_INPUT_NEW));
 
-    dlg->SetEntryText(sCategory);
-    int ret = dlg->Execute();
+    dlg.SetEntryText(sCategory);
+    int ret = dlg.run();
 
     if (ret)
     {
-        OUString aName = dlg->GetEntryText();
+        OUString aName = dlg.GetEntryText();
 
         if(mpLocalView->renameRegion(sCategory, aName))
         {
diff --git a/sfx2/uiconfig/ui/inputdialog.ui b/sfx2/uiconfig/ui/inputdialog.ui
index 5bebaf3508bf..ebef9c13c946 100644
--- a/sfx2/uiconfig/ui/inputdialog.ui
+++ b/sfx2/uiconfig/ui/inputdialog.ui
@@ -1,10 +1,13 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.19.0 -->
+<!-- Generated with glade 3.20.2 -->
 <interface domain="sfx">
-  <requires lib="gtk+" version="3.0"/>
+  <requires lib="gtk+" version="3.20"/>
   <object class="GtkDialog" id="InputDialog">
     <property name="can_focus">False</property>
     <property name="border_width">6</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 internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox1">
@@ -95,7 +98,6 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="hexpand">True</property>
-                <property name="invisible_char">•</property>
               </object>
               <packing>
                 <property name="left_attach">0</property>
@@ -112,8 +114,12 @@
       </object>
     </child>
     <action-widgets>
+      <action-widget response="-11">help</action-widget>
       <action-widget response="-5">ok</action-widget>
       <action-widget response="-6">cancel</action-widget>
     </action-widgets>
+    <child>
+      <placeholder/>
+    </child>
   </object>
 </interface>
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 6e459298a683..02626e61b2d2 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -782,6 +782,14 @@ public:
         m_xEntry->SetSelection(Selection(nStartPos, nEndPos < 0 ? SELECTION_MAX : nEndPos));
     }
 
+    virtual void set_position(int nCursorPos) override
+    {
+        if (nCursorPos < 0)
+            m_xEntry->SetCursorAtLast();
+        else
+            m_xEntry->SetSelection(Selection(nCursorPos, nCursorPos));
+    }
+
     virtual ~SalInstanceEntry() override
     {
         m_xEntry->SetTextFilter(nullptr);
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 87e981a7c6fe..6754d2089328 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -1900,6 +1900,11 @@ public:
         gtk_editable_select_region(GTK_EDITABLE(m_pEntry), nStartPos, nEndPos);
     }
 
+    virtual void set_position(int nCursorPos) override
+    {
+        gtk_editable_set_position(GTK_EDITABLE(m_pEntry), nCursorPos);
+    }
+
     virtual ~GtkInstanceEntry() override
     {
         g_signal_handler_disconnect(m_pEntry, m_nInsertTextSignalId);


More information about the Libreoffice-commits mailing list