From 3c855c44050da5be935258e2b38c5b402269c996 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 5 Mar 2021 11:25:01 +0000 Subject: move handler for ESC to close slideshow from navigator down to contents MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ie021bcf86043cf2ae02eb39911c748135452853c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112007 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- sd/source/ui/dlg/navigatr.cxx | 69 ++++++++----------------------------------- sd/source/ui/dlg/sdtreelb.cxx | 2 +- sd/source/ui/inc/navigatr.hxx | 6 +--- sd/source/ui/inc/sdtreelb.hxx | 6 ++++ 4 files changed, 21 insertions(+), 62 deletions(-) (limited to 'sd') diff --git a/sd/source/ui/dlg/navigatr.cxx b/sd/source/ui/dlg/navigatr.cxx index aa8d9cf273c6..6c478bad5741 100644 --- a/sd/source/ui/dlg/navigatr.cxx +++ b/sd/source/ui/dlg/navigatr.cxx @@ -85,6 +85,10 @@ SdNavigatorWin::SdNavigatorWin(vcl::Window* pParent, SfxBindings* pInBindings) SetDragImage(); + mxToolbox->connect_key_press(LINK(this, SdNavigatorWin, KeyInputHdl)); + mxTlbObjects->connect_key_press(LINK(this, SdNavigatorWin, KeyInputHdl)); + mxLbDocs->connect_key_press(LINK(this, SdNavigatorWin, KeyInputHdl)); + m_pInitialFocusWidget = mxToolbox.get(); } @@ -577,73 +581,26 @@ NavDocInfo* SdNavigatorWin::GetDocInfo() return nPos < maDocList.size() ? &(maDocList[ nPos ]) : nullptr; } -/** - * PreNotify - */ -bool SdNavigatorWin::EventNotify(NotifyEvent& rNEvt) -{ - const KeyEvent* pKEvt = rNEvt.GetKeyEvent(); - bool bOK = false; - - if( pKEvt ) - { - if( KEY_ESCAPE == pKEvt->GetKeyCode().GetCode() ) - { - if( SdPageObjsTLV::IsInDrag() ) - { - // during drag'n'drop we just stop the drag but do not close the navigator - bOK = true; - } - else - { - ::sd::ViewShellBase* pBase = ::sd::ViewShellBase::GetViewShellBase( mpBindings->GetDispatcher()->GetFrame()); - if( pBase ) - { - sd::SlideShow::Stop( *pBase ); - // Stopping the slide show may result in a synchronous - // deletion of the navigator window. Calling the - // parent's EventNotify after this is unsafe. Therefore we - // return now. - return true; - } - } - } - } - - if( !bOK ) - bOK = Window::EventNotify(rNEvt); - - return bOK; -} - /** * catch ESCAPE in order to end show */ -void SdNavigatorWin::KeyInput( const KeyEvent& rKEvt ) +IMPL_LINK(SdNavigatorWin, KeyInputHdl, const KeyEvent&, rKEvt, bool) { - bool bOK = false; + bool bConsumed = false; - if (rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE) + if (KEY_ESCAPE == rKEvt.GetKeyCode().GetCode()) { - if( SdPageObjsTLV::IsInDrag() ) - { - // during drag'n'drop we just stop the drag but do not close the navigator - bOK = true; - } - else + // during drag'n'drop we just stop the drag but do not close the navigator + if (!SdPageObjsTLV::IsInDrag()) { ::sd::ViewShellBase* pBase = ::sd::ViewShellBase::GetViewShellBase( mpBindings->GetDispatcher()->GetFrame()); - if(pBase) - { - ::sd::SlideShow::Stop( *pBase ); - } + if (pBase) + sd::SlideShow::Stop(*pBase); + bConsumed = true; } } - if (!bOK) - { - Window::KeyInput(rKEvt); - } + return bConsumed; } void SdNavigatorWin::SetDragImage() diff --git a/sd/source/ui/dlg/sdtreelb.cxx b/sd/source/ui/dlg/sdtreelb.cxx index 576117dfe89f..764301858ad4 100644 --- a/sd/source/ui/dlg/sdtreelb.cxx +++ b/sd/source/ui/dlg/sdtreelb.cxx @@ -321,7 +321,7 @@ IMPL_LINK(SdPageObjsTLV, KeyInputHdl, const KeyEvent&, rKEvt, bool) m_aRowActivatedHdl.Call(*m_xTreeView); return true; } - return false; + return m_aKeyPressHdl.Call(rKEvt); } IMPL_LINK(SdPageObjsTLV, MousePressHdl, const MouseEvent&, rMEvt, bool) diff --git a/sd/source/ui/inc/navigatr.hxx b/sd/source/ui/inc/navigatr.hxx index 5e54e193c526..01f8b43d20da 100644 --- a/sd/source/ui/inc/navigatr.hxx +++ b/sd/source/ui/inc/navigatr.hxx @@ -92,8 +92,6 @@ public: virtual ~SdNavigatorWin() override; virtual void dispose() override; - virtual void KeyInput( const KeyEvent& rKEvt ) override; - void InitTreeLB( const SdDrawDocument* pDoc ); void RefreshDocumentLB( const OUString* pDocName = nullptr ); @@ -102,9 +100,6 @@ public: NavigatorDragType GetNavigatorDragType(); SdPageObjsTLV& GetObjects(); -protected: - virtual bool EventNotify(NotifyEvent& rNEvt) override; - private: friend class ::sd::NavigatorChildWindow; friend class SdNavigatorControllerItem; @@ -138,6 +133,7 @@ private: DECL_LINK( SelectDocumentHdl, weld::ComboBox&, void ); DECL_LINK( MenuSelectHdl, const OString&, void ); DECL_LINK( ShapeFilterCallback, const OString&, void ); + DECL_LINK( KeyInputHdl, const KeyEvent&, bool ); void SetDragImage(); diff --git a/sd/source/ui/inc/sdtreelb.hxx b/sd/source/ui/inc/sdtreelb.hxx index 328cc0f23b47..20df211605b7 100644 --- a/sd/source/ui/inc/sdtreelb.hxx +++ b/sd/source/ui/inc/sdtreelb.hxx @@ -105,6 +105,7 @@ private: ::sd::DrawDocShellRef m_xBookmarkDocShRef; ///< for the loading of bookmarks Link m_aChangeHdl; Link m_aRowActivatedHdl; + Link m_aKeyPressHdl; /** Return the name of the object. When the object has no user supplied name and the bCreate flag is then a name is created @@ -206,6 +207,11 @@ public: m_aRowActivatedHdl = rLink; } + void connect_key_press(const Link& rLink) + { + m_aKeyPressHdl = rLink; + } + bool HasSelectedChildren(std::u16string_view rName); bool SelectEntry(std::u16string_view rName); -- cgit