diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-11-01 13:49:09 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-11-02 15:54:40 +0100 |
commit | b461740a9ca89eb3b036c366ba60f24c7aad2b60 (patch) | |
tree | 073f7b021ed770d2569982e62d75dba201a4a6a9 /sfx2 | |
parent | 47c88b2c4db23f33a4371139745b8427564d3667 (diff) |
weld SfxRecordingFloat_Impl utility window
we can't abuse action_name anymore as the uno command
are not legal actions
Change-Id: Iaf9306c6e3eec852d2a50df9161bd20383881a04
Reviewed-on: https://gerrit.libreoffice.org/81902
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/dialog/recfloat.cxx | 72 | ||||
-rw-r--r-- | sfx2/source/inc/recfloat.hxx | 17 | ||||
-rw-r--r-- | sfx2/uiconfig/ui/floatingrecord.ui | 38 |
3 files changed, 70 insertions, 57 deletions
diff --git a/sfx2/source/dialog/recfloat.cxx b/sfx2/source/dialog/recfloat.cxx index bfc6d1196488..b431cc619298 100644 --- a/sfx2/source/dialog/recfloat.cxx +++ b/sfx2/source/dialog/recfloat.cxx @@ -22,6 +22,7 @@ #include <svl/eitem.hxx> #include <vcl/svapp.hxx> #include <vcl/weld.hxx> +#include <vcl/weldutils.hxx> #include <recfloat.hxx> #include <sfx2/strings.hrc> @@ -33,18 +34,35 @@ #include <sfx2/viewfrm.hxx> #include <sfx2/viewsh.hxx> -SFX_IMPL_FLOATINGWINDOW( SfxRecordingFloatWrapper_Impl, SID_RECORDING_FLOATWINDOW ); +SFX_IMPL_MODELESSDIALOGCONTOLLER(SfxRecordingFloatWrapper_Impl, SID_RECORDING_FLOATWINDOW); -SfxRecordingFloatWrapper_Impl::SfxRecordingFloatWrapper_Impl( vcl::Window* pParentWnd , - sal_uInt16 nId , - SfxBindings* pBind , - SfxChildWinInfo const * pInfo ) - : SfxChildWindow( pParentWnd, nId ) - , pBindings( pBind ) +SfxRecordingFloatWrapper_Impl::SfxRecordingFloatWrapper_Impl(vcl::Window* pParentWnd, + sal_uInt16 nId, + SfxBindings* pBind, + SfxChildWinInfo const * pInfo) + : SfxChildWindow(pParentWnd, nId) + , pBindings(pBind) { - SetWindow( VclPtr<SfxRecordingFloat_Impl>::Create( pBindings, this, pParentWnd ) ); - SetWantsFocus( false ); - static_cast<SfxFloatingWindow*>(GetWindow())->Initialize( pInfo ); + SetController(std::make_shared<SfxRecordingFloat_Impl>(pBindings, this, pParentWnd->GetFrameWeld())); + SetWantsFocus(false); + SfxRecordingFloat_Impl* pFloatDlg = static_cast<SfxRecordingFloat_Impl*>(GetController().get()); + + weld::Dialog* pDlg = pFloatDlg->getDialog(); + + SfxViewFrame *pFrame = pBind->GetDispatcher_Impl()->GetFrame(); + vcl::Window* pEditWin = pFrame->GetViewShell()->GetWindow(); + + Point aPos = pEditWin->OutputToScreenPixel( pEditWin->GetPosPixel() ); + aPos.AdjustX(20); + aPos.AdjustY(10); + + WindowStateData aState; + aState.SetMask(WindowStateMask::Pos); + aState.SetX(aPos.X()); + aState.SetY(aPos.Y()); + pDlg->set_window_state(aState.ToStr()); + + pFloatDlg->Initialize(pInfo); } SfxRecordingFloatWrapper_Impl::~SfxRecordingFloatWrapper_Impl() @@ -76,14 +94,12 @@ bool SfxRecordingFloatWrapper_Impl::QueryClose() return bRet; } -SfxRecordingFloat_Impl::SfxRecordingFloat_Impl( - SfxBindings* pBind , - SfxChildWindow* pChildWin , - vcl::Window* pParent ) - : SfxFloatingWindow( pBind, - pChildWin, - pParent, - "FloatingRecord", "sfx/ui/floatingrecord.ui", pBind->GetActiveFrame() ) +SfxRecordingFloat_Impl::SfxRecordingFloat_Impl(SfxBindings* pBind, SfxChildWindow* pChildWin, + weld::Window* pParent) + : SfxModelessDialogController(pBind, pChildWin, pParent, "sfx/ui/floatingrecord.ui", + "FloatingRecord") + , m_xToolbar(m_xBuilder->weld_toolbar("toolbar")) + , m_aDispatcher(*m_xToolbar, pBind->GetActiveFrame()) { // start recording SfxBoolItem aItem( SID_RECORDMACRO, true ); @@ -93,30 +109,12 @@ SfxRecordingFloat_Impl::SfxRecordingFloat_Impl( SfxRecordingFloat_Impl::~SfxRecordingFloat_Impl() { - disposeOnce(); } void SfxRecordingFloat_Impl::FillInfo( SfxChildWinInfo& rInfo ) const { - SfxFloatingWindow::FillInfo( rInfo ); + SfxModelessDialogController::FillInfo( rInfo ); rInfo.bVisible = false; } -void SfxRecordingFloat_Impl::StateChanged( StateChangedType nStateChange ) -{ - if ( nStateChange == StateChangedType::InitShow ) - { - SfxViewFrame *pFrame = GetBindings().GetDispatcher_Impl()->GetFrame(); - vcl::Window* pEditWin = pFrame->GetViewShell()->GetWindow(); - - Point aPoint = pEditWin->OutputToScreenPixel( pEditWin->GetPosPixel() ); - aPoint = GetParent()->ScreenToOutputPixel( aPoint ); - aPoint.AdjustX(20 ); - aPoint.AdjustY(10 ); - SetPosPixel( aPoint ); - } - - SfxFloatingWindow::StateChanged( nStateChange ); -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/inc/recfloat.hxx b/sfx2/source/inc/recfloat.hxx index 7fc02c97dcee..e9d2dd7eb97e 100644 --- a/sfx2/source/inc/recfloat.hxx +++ b/sfx2/source/inc/recfloat.hxx @@ -22,6 +22,7 @@ #include <sfx2/childwin.hxx> #include <sfx2/basedlgs.hxx> +#include <vcl/weldutils.hxx> class SfxRecordingFloatWrapper_Impl : public SfxChildWindow { @@ -37,18 +38,18 @@ public: virtual bool QueryClose() override; }; -class SfxRecordingFloat_Impl : public SfxFloatingWindow +class SfxRecordingFloat_Impl : public SfxModelessDialogController { + std::unique_ptr<weld::Toolbar> m_xToolbar; + weld::ToolbarUnoDispatcher m_aDispatcher; public: - SfxRecordingFloat_Impl( SfxBindings* pBindings , - SfxChildWindow* pChildWin , - vcl::Window* pParent ); - virtual ~SfxRecordingFloat_Impl() override; - virtual void FillInfo( SfxChildWinInfo& rInfo ) const override; - virtual void StateChanged( StateChangedType nStateChange ) override; + SfxRecordingFloat_Impl(SfxBindings* pBindings, + SfxChildWindow* pChildWin, + weld::Window* pParent); + virtual ~SfxRecordingFloat_Impl() override; + virtual void FillInfo(SfxChildWinInfo& rInfo) const override; }; #endif - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/uiconfig/ui/floatingrecord.ui b/sfx2/uiconfig/ui/floatingrecord.ui index d91f3b0e6b52..66fe08ddf34b 100644 --- a/sfx2/uiconfig/ui/floatingrecord.ui +++ b/sfx2/uiconfig/ui/floatingrecord.ui @@ -1,23 +1,38 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.16.1 --> +<!-- Generated with glade 3.22.1 --> <interface domain="sfx"> <requires lib="gtk+" version="3.18"/> - <object class="GtkWindow" id="FloatingRecord"> + <object class="GtkDialog" id="FloatingRecord"> <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="floatingrecord|FloatingRecord">Record Macro</property> + <property name="default_width">0</property> + <property name="default_height">0</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="sfxlo-SidebarToolBox" id="toolbar"> + <object class="GtkToolbar" id="toolbar"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="hexpand">True</property> @@ -25,12 +40,11 @@ <property name="toolbar_style">text</property> <property name="show_arrow">False</property> <child> - <object class="GtkToolButton" id="stop"> + <object class="GtkToolButton" id=".uno:StopRecording"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="hexpand">True</property> <property name="vexpand">True</property> - <property name="action_name">.uno:StopRecording</property> <property name="use_underline">True</property> </object> <packing> @@ -42,7 +56,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> |