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

Caolán McNamara caolanm at redhat.com
Tue Apr 3 19:02:07 UTC 2018


 include/vcl/weld.hxx                     |    1 
 sfx2/source/dialog/versdlg.cxx           |   79 ++++++++++++-------------------
 sfx2/source/inc/versdlg.hxx              |   23 ++++-----
 sfx2/uiconfig/ui/versioncommentdialog.ui |   12 +++-
 vcl/source/app/salvtables.cxx            |    5 +
 vcl/unx/gtk3/gtk3gtkinst.cxx             |    4 +
 6 files changed, 62 insertions(+), 62 deletions(-)

New commits:
commit 4329d9d8cf83f3642c068a1493c979a894328e26
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Apr 3 15:41:17 2018 +0100

    weld SfxViewVersionDialog_Impl
    
    Change-Id: I5486df92b4e1d0ad5be18a35e72a7a6dbcc3b715
    Reviewed-on: https://gerrit.libreoffice.org/52334
    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/include/vcl/weld.hxx b/include/vcl/weld.hxx
index a5a6d75035fb..63b27b0f7162 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -565,6 +565,7 @@ public:
     virtual OUString get_text() const = 0;
     virtual Selection get_selection() const = 0;
     virtual void set_selection(const Selection&) = 0;
+    virtual void set_editable(bool bEditable) = 0;
 };
 
 class VCL_DLLPUBLIC Expander : virtual public Container
diff --git a/sfx2/source/dialog/versdlg.cxx b/sfx2/source/dialog/versdlg.cxx
index 9e29f167aade..79e59754ea9e 100644
--- a/sfx2/source/dialog/versdlg.cxx
+++ b/sfx2/source/dialog/versdlg.cxx
@@ -391,8 +391,8 @@ IMPL_LINK( SfxVersionDialog, ButtonHdl_Impl, Button*, pButton, void )
     {
         SfxVersionInfo aInfo;
         aInfo.aAuthor = SvtUserOptions().GetFullName();
-        VclPtrInstance< SfxViewVersionDialog_Impl > pDlg(this, aInfo, true);
-        short nRet = pDlg->Execute();
+        SfxViewVersionDialog_Impl aDlg(GetFrameWeld(), aInfo, true);
+        short nRet = aDlg.run();
         if ( nRet == RET_OK )
         {
             SfxStringItem aComment( SID_DOCINFO_COMMENTS, aInfo.aComment );
@@ -423,8 +423,8 @@ IMPL_LINK( SfxVersionDialog, ButtonHdl_Impl, Button*, pButton, void )
     else if (pButton == m_pViewButton && pEntry)
     {
         SfxVersionInfo* pInfo = static_cast<SfxVersionInfo*>(pEntry->GetUserData());
-        VclPtrInstance<SfxViewVersionDialog_Impl> pDlg(this, *pInfo, false);
-        pDlg->Execute();
+        SfxViewVersionDialog_Impl aDlg(GetFrameWeld(), *pInfo, false);
+        aDlg.run();
     }
     else if (pEntry && pButton == m_pCompareButton)
     {
@@ -451,65 +451,48 @@ IMPL_LINK( SfxVersionDialog, ButtonHdl_Impl, Button*, pButton, void )
     }
 }
 
-SfxViewVersionDialog_Impl::SfxViewVersionDialog_Impl(vcl::Window *pParent, SfxVersionInfo& rInfo, bool bEdit)
-    : SfxModalDialog(pParent, "VersionCommentDialog", "sfx/ui/versioncommentdialog.ui")
+SfxViewVersionDialog_Impl::SfxViewVersionDialog_Impl(weld::Window *pParent, SfxVersionInfo& rInfo, bool bEdit)
+    : GenericDialogController(pParent, "sfx/ui/versioncommentdialog.ui", "VersionCommentDialog")
     , m_rInfo(rInfo)
+    , m_xDateTimeText(m_xBuilder->weld_label("timestamp"))
+    , m_xSavedByText(m_xBuilder->weld_label("author"))
+    , m_xEdit(m_xBuilder->weld_text_view("textview"))
+    , m_xOKButton(m_xBuilder->weld_button("ok"))
+    , m_xCancelButton(m_xBuilder->weld_button("cancel"))
+    , m_xCloseButton(m_xBuilder->weld_button("close"))
 {
-    get(m_pDateTimeText, "timestamp");
-    get(m_pSavedByText, "author");
-    get(m_pEdit, "textview");
-    get(m_pOKButton, "ok");
-    get(m_pCancelButton, "cancel");
-    get(m_pCloseButton, "close");
-
     OUString sAuthor = rInfo.aAuthor.isEmpty() ? SfxResId(STR_NO_NAME_SET) : rInfo.aAuthor;
 
     const LocaleDataWrapper& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() );
-    m_pDateTimeText->SetText(m_pDateTimeText->GetText() + formatTime(rInfo.aCreationDate, rLocaleWrapper));
-    m_pSavedByText->SetText(m_pSavedByText->GetText() + sAuthor);
-    m_pEdit->SetText(rInfo.aComment);
-    m_pEdit->set_height_request(7 * m_pEdit->GetTextHeight());
-    m_pEdit->set_width_request(40 * m_pEdit->approximate_char_width());
-    m_pOKButton->SetClickHdl(LINK(this, SfxViewVersionDialog_Impl, ButtonHdl));
+    m_xDateTimeText->set_label(m_xDateTimeText->get_label() + formatTime(rInfo.aCreationDate, rLocaleWrapper));
+    m_xSavedByText->set_label(m_xSavedByText->get_label() + sAuthor);
+    m_xEdit->set_text(rInfo.aComment);
+    m_xEdit->set_size_request(40 * m_xEdit->get_approximate_digit_width(),
+                              7 * m_xEdit->get_text_height());
+    m_xOKButton->connect_clicked(LINK(this, SfxViewVersionDialog_Impl, ButtonHdl));
 
     if (!bEdit)
     {
-        m_pOKButton->Hide();
-        m_pCancelButton->Hide();
-        m_pEdit->SetReadOnly();
-        SetText(SfxResId(STR_VIEWVERSIONCOMMENT));
-        m_pCloseButton->GrabFocus();
+        m_xOKButton->hide();
+        m_xCancelButton->hide();
+        m_xEdit->set_editable(false);
+        m_xDialog->set_title(SfxResId(STR_VIEWVERSIONCOMMENT));
+        m_xCloseButton->grab_focus();
     }
     else
     {
-        m_pDateTimeText->Hide();
-        m_pCloseButton->Hide();
-        m_pEdit->GrabFocus();
+        m_xDateTimeText->hide();
+        m_xCloseButton->hide();
+        m_xEdit->grab_focus();
     }
 }
 
-SfxViewVersionDialog_Impl::~SfxViewVersionDialog_Impl()
-{
-    disposeOnce();
-}
-
-void SfxViewVersionDialog_Impl::dispose()
-{
-    m_pDateTimeText.clear();
-    m_pSavedByText.clear();
-    m_pEdit.clear();
-    m_pOKButton.clear();
-    m_pCancelButton.clear();
-    m_pCloseButton.clear();
-    SfxModalDialog::dispose();
-}
-
-IMPL_LINK(SfxViewVersionDialog_Impl, ButtonHdl, Button*, pButton, void)
+IMPL_LINK(SfxViewVersionDialog_Impl, ButtonHdl, weld::Button&, rButton, void)
 {
-    assert(pButton == m_pOKButton);
-    (void)pButton;
-    m_rInfo.aComment = m_pEdit->GetText();
-    EndDialog(RET_OK);
+    assert(&rButton == m_xOKButton.get());
+    (void)rButton;
+    m_rInfo.aComment = m_xEdit->get_text();
+    m_xDialog->response(RET_OK);
 }
 
 SfxCmisVersionsDialog::SfxCmisVersionsDialog ( SfxViewFrame* pVwFrame )
diff --git a/sfx2/source/inc/versdlg.hxx b/sfx2/source/inc/versdlg.hxx
index 3fe32e8e065b..4d81c139a1e9 100644
--- a/sfx2/source/inc/versdlg.hxx
+++ b/sfx2/source/inc/versdlg.hxx
@@ -26,6 +26,7 @@
 #include <svtools/svtabbx.hxx>
 #include <vcl/button.hxx>
 #include <vcl/fixed.hxx>
+#include <vcl/weld.hxx>
 
 class SfxViewFrame;
 struct SfxVersionInfo;
@@ -70,22 +71,22 @@ public:
     bool                        IsSaveVersionOnClose() const { return m_bIsSaveVersionOnClose; }
 };
 
-class SfxViewVersionDialog_Impl : public SfxModalDialog
+class SfxViewVersionDialog_Impl : public weld::GenericDialogController
 {
-    VclPtr<FixedText>        m_pDateTimeText;
-    VclPtr<FixedText>        m_pSavedByText;
-    VclPtr<VclMultiLineEdit> m_pEdit;
-    VclPtr<OKButton>         m_pOKButton;
-    VclPtr<CancelButton>     m_pCancelButton;
-    VclPtr<CloseButton>      m_pCloseButton;
+private:
     SfxVersionInfo&   m_rInfo;
 
-    DECL_LINK(ButtonHdl, Button*, void);
+    std::unique_ptr<weld::Label> m_xDateTimeText;
+    std::unique_ptr<weld::Label> m_xSavedByText;
+    std::unique_ptr<weld::TextView> m_xEdit;
+    std::unique_ptr<weld::Button> m_xOKButton;
+    std::unique_ptr<weld::Button> m_xCancelButton;
+    std::unique_ptr<weld::Button> m_xCloseButton;
+
+    DECL_LINK(ButtonHdl, weld::Button&, void);
 
 public:
-    SfxViewVersionDialog_Impl(vcl::Window *pParent, SfxVersionInfo& rInfo, bool bEdit);
-    virtual ~SfxViewVersionDialog_Impl() override;
-    virtual void dispose() override;
+    SfxViewVersionDialog_Impl(weld::Window *pParent, SfxVersionInfo& rInfo, bool bEdit);
 };
 
 class SfxCmisVersionsDialog : public SfxModalDialog
diff --git a/sfx2/uiconfig/ui/versioncommentdialog.ui b/sfx2/uiconfig/ui/versioncommentdialog.ui
index 582795a9433c..7f610e2e96b2 100644
--- a/sfx2/uiconfig/ui/versioncommentdialog.ui
+++ b/sfx2/uiconfig/ui/versioncommentdialog.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.20.4 -->
 <interface domain="sfx">
   <requires lib="gtk+" version="3.18"/>
   <object class="GtkDialog" id="VersionCommentDialog">
@@ -7,6 +7,9 @@
     <property name="border_width">6</property>
     <property name="title" translatable="yes" context="versioncommentdialog|VersionCommentDialog">Insert Version Comment</property>
     <property name="resizable">False</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">
@@ -97,8 +100,8 @@
               <object class="GtkLabel" id="timestamp">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="xalign">0</property>
                 <property name="label" translatable="yes" context="versioncommentdialog|timestamp">Date and time: </property>
+                <property name="xalign">0</property>
               </object>
               <packing>
                 <property name="left_attach">0</property>
@@ -109,8 +112,8 @@
               <object class="GtkLabel" id="author">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="xalign">0</property>
                 <property name="label" translatable="yes" context="versioncommentdialog|author">Saved by: </property>
+                <property name="xalign">0</property>
               </object>
               <packing>
                 <property name="left_attach">0</property>
@@ -153,5 +156,8 @@
       <action-widget response="-6">cancel</action-widget>
       <action-widget response="-11">help</action-widget>
     </action-widgets>
+    <child>
+      <placeholder/>
+    </child>
   </object>
 </interface>
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index e4b556027389..48f1959f0d74 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -1284,6 +1284,11 @@ public:
     {
         m_xTextView->SetSelection(rSelection);
     }
+
+    virtual void set_editable(bool bEditable) override
+    {
+        m_xTextView->SetReadOnly(!bEditable);
+    }
 };
 
 class SalInstanceExpander : public SalInstanceContainer, public virtual weld::Expander
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 20d61600893c..ebe1e226b723 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -3010,6 +3010,10 @@ public:
         gtk_text_view_scroll_mark_onscreen(m_pTextView, mark);
     }
 
+    virtual void set_editable(bool bEditable) override
+    {
+        gtk_text_view_set_editable(m_pTextView, bEditable);
+    }
 };
 
 static MouseEventModifiers ImplGetMouseButtonMode(sal_uInt16 nButton, sal_uInt16 nCode)


More information about the Libreoffice-commits mailing list