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

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue Nov 5 20:05:51 UTC 2019


 sw/source/uibase/envelp/syncbtn.cxx    |   61 ++++++++++++++++-----------------
 sw/source/uibase/inc/syncbtn.hxx       |   20 ++++------
 sw/uiconfig/swriter/ui/floatingsync.ui |   34 ++++++++++++------
 3 files changed, 64 insertions(+), 51 deletions(-)

New commits:
commit 71003b6641a8cd49bacc104d906e2e2cfb4b98ab
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Oct 30 09:08:43 2019 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Nov 5 21:04:12 2019 +0100

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

diff --git a/sw/source/uibase/envelp/syncbtn.cxx b/sw/source/uibase/envelp/syncbtn.cxx
index 2ebcc26a255c..3f8a8d633fff 100644
--- a/sw/source/uibase/envelp/syncbtn.cxx
+++ b/sw/source/uibase/envelp/syncbtn.cxx
@@ -28,57 +28,58 @@
 #include <syncbtn.hxx>
 #include <swtypes.hxx>
 
-SFX_IMPL_FLOATINGWINDOW( SwSyncChildWin, FN_SYNC_LABELS )
+SFX_IMPL_MODELESSDIALOGCONTOLLER(SwSyncChildWin, FN_SYNC_LABELS)
 
-SwSyncChildWin::SwSyncChildWin( vcl::Window* _pParent,
-                                sal_uInt16 nId,
-                                SfxBindings* pBindings,
-                                SfxChildWinInfo* pInfo ) :
-                                SfxChildWindow( _pParent, nId )
+SwSyncChildWin::SwSyncChildWin(vcl::Window* _pParent,
+                               sal_uInt16 nId,
+                               SfxBindings* pBindings,
+                               SfxChildWinInfo* pInfo)
+    : SfxChildWindow(_pParent, nId)
 {
-    SetWindow(VclPtr<SwSyncBtnDlg>::Create( pBindings, this, _pParent));
+    SetController(std::make_shared<SwSyncBtnDlg>(pBindings, this, _pParent->GetFrameWeld()));
+    SwSyncBtnDlg* pBtnDlg = static_cast<SwSyncBtnDlg*>(GetController().get());
 
     if (!pInfo->aSize.Width() || !pInfo->aSize.Height())
     {
+        weld::Dialog* pDlg = pBtnDlg->getDialog();
+        Point aPos;
+
         SwView* pActiveView = ::GetActiveView();
-        if(pActiveView)
+        if (pActiveView)
         {
             const SwEditWin &rEditWin = pActiveView->GetEditWin();
-            GetWindow()->SetPosPixel(rEditWin.OutputToScreenPixel(Point(0, 0)));
+            aPos = rEditWin.OutputToScreenPixel(Point(0, 0));
         }
         else
-            GetWindow()->SetPosPixel(_pParent->OutputToScreenPixel(Point(0, 0)));
-        pInfo->aPos = GetWindow()->GetPosPixel();
-        pInfo->aSize = GetWindow()->GetSizePixel();
-    }
+            aPos = _pParent->OutputToScreenPixel(Point(0, 0));
 
-    static_cast<SwSyncBtnDlg *>(GetWindow())->Initialize(pInfo);
+        WindowStateData aState;
+        aState.SetMask(WindowStateMask::Pos);
+        aState.SetX(aPos.X());
+        aState.SetY(aPos.Y());
+        pDlg->set_window_state(aState.ToStr());
 
-    GetWindow()->Show();
-}
+        pInfo->aPos = pDlg->get_position();
+        pInfo->aSize = pDlg->get_size();
+    }
 
-SwSyncBtnDlg::SwSyncBtnDlg( SfxBindings* _pBindings,
-                            SfxChildWindow* pChild,
-                            vcl::Window *pParent)
-    : SfxFloatingWindow(_pBindings, pChild, pParent, "FloatingSync", "modules/swriter/ui/floatingsync.ui")
-{
-    get(m_pSyncBtn, "sync");
-    m_pSyncBtn->SetClickHdl(LINK(this, SwSyncBtnDlg, BtnHdl));
-    Show();
+    pBtnDlg->Initialize(pInfo);
 }
 
-SwSyncBtnDlg::~SwSyncBtnDlg()
+SwSyncBtnDlg::SwSyncBtnDlg(SfxBindings* pBindings,
+                           SfxChildWindow* pChild,
+                           weld::Window *pParent)
+    : SfxModelessDialogController(pBindings, pChild, pParent, "modules/swriter/ui/floatingsync.ui", "FloatingSync")
+    , m_xSyncBtn(m_xBuilder->weld_button("sync"))
 {
-    disposeOnce();
+    m_xSyncBtn->connect_clicked(LINK(this, SwSyncBtnDlg, BtnHdl));
 }
 
-void SwSyncBtnDlg::dispose()
+SwSyncBtnDlg::~SwSyncBtnDlg()
 {
-    m_pSyncBtn.clear();
-    SfxFloatingWindow::dispose();
 }
 
-IMPL_STATIC_LINK_NOARG(SwSyncBtnDlg, BtnHdl, Button*, void)
+IMPL_STATIC_LINK_NOARG(SwSyncBtnDlg, BtnHdl, weld::Button&, void)
 {
     SfxViewFrame::Current()->GetDispatcher()->Execute(FN_UPDATE_ALL_LINKS, SfxCallMode::ASYNCHRON);
 }
diff --git a/sw/source/uibase/inc/syncbtn.hxx b/sw/source/uibase/inc/syncbtn.hxx
index 4934b41f9b9a..43ae7ac43f34 100644
--- a/sw/source/uibase/inc/syncbtn.hxx
+++ b/sw/source/uibase/inc/syncbtn.hxx
@@ -21,29 +21,27 @@
 
 #include <sfx2/basedlgs.hxx>
 #include <sfx2/childwin.hxx>
-#include <vcl/button.hxx>
 
-class SwSyncBtnDlg : public SfxFloatingWindow
+class SwSyncBtnDlg : public SfxModelessDialogController
 {
-    VclPtr<PushButton> m_pSyncBtn;
+    std::unique_ptr<weld::Button> m_xSyncBtn;
 
-    DECL_STATIC_LINK( SwSyncBtnDlg, BtnHdl, Button*, void );
+    DECL_STATIC_LINK( SwSyncBtnDlg, BtnHdl, weld::Button&, void );
 
 public:
-    SwSyncBtnDlg(SfxBindings*, SfxChildWindow*, vcl::Window *pParent);
+    SwSyncBtnDlg(SfxBindings*, SfxChildWindow*, weld::Window *pParent);
     virtual ~SwSyncBtnDlg() override;
-    virtual void dispose() override;
 };
 
 class SwSyncChildWin : public SfxChildWindow
 {
 public:
-    SwSyncChildWin( vcl::Window* ,
-                    sal_uInt16 nId,
-                    SfxBindings*,
-                    SfxChildWinInfo*  );
+    SwSyncChildWin(vcl::Window*,
+                   sal_uInt16 nId,
+                   SfxBindings*,
+                   SfxChildWinInfo*);
 
-    SFX_DECL_CHILDWINDOW( SwSyncChildWin );
+    SFX_DECL_CHILDWINDOW(SwSyncChildWin);
 };
 
 #endif
diff --git a/sw/uiconfig/swriter/ui/floatingsync.ui b/sw/uiconfig/swriter/ui/floatingsync.ui
index 38dc1344c941..92b2c287d893 100644
--- a/sw/uiconfig/swriter/ui/floatingsync.ui
+++ b/sw/uiconfig/swriter/ui/floatingsync.ui
@@ -1,23 +1,37 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.16.1 -->
+<!-- Generated with glade 3.22.1 -->
 <interface domain="sw">
   <requires lib="gtk+" version="3.18"/>
-  <object class="GtkWindow" id="FloatingSync">
-    <property name="visible">True</property>
+  <object class="GtkDialog" id="FloatingSync">
     <property name="can_focus">False</property>
-    <property name="no_show_all">True</property>
-    <property name="border_width">6</property>
     <property name="title" translatable="yes" context="floatingsync|FloatingSync">Synchronize</property>
+    <property name="default_width">0</property>
+    <property name="default_height">0</property>
     <property name="destroy_with_parent">True</property>
     <property name="type_hint">utility</property>
     <property name="deletable">False</property>
     <child>
-      <object class="GtkBox" id="box1">
-        <property name="visible">True</property>
+      <placeholder/>
+    </child>
+    <child internal-child="vbox">
+      <object class="GtkBox">
         <property name="can_focus">False</property>
-        <property name="hexpand">True</property>
-        <property name="vexpand">True</property>
         <property name="orientation">vertical</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox">
+            <property name="can_focus">False</property>
+            <property name="no_show_all">True</property>
+            <property name="layout_style">end</property>
+            <child>
+              <placeholder/>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
         <child>
           <object class="GtkButton" id="sync">
             <property name="label" translatable="yes" context="floatingsync|sync">Synchronize Labels</property>
@@ -33,7 +47,7 @@
           <packing>
             <property name="expand">False</property>
             <property name="fill">True</property>
-            <property name="position">0</property>
+            <property name="position">1</property>
           </packing>
         </child>
       </object>


More information about the Libreoffice-commits mailing list