[Libreoffice-commits] core.git: sd/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Fri Mar 5 16:16:12 UTC 2021


 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(-)

New commits:
commit 3c855c44050da5be935258e2b38c5b402269c996
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Mar 5 11:25:01 2021 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Mar 5 17:15:28 2021 +0100

    move handler for ESC to close slideshow from navigator down to contents
    
    Change-Id: Ie021bcf86043cf2ae02eb39911c748135452853c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112007
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

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<weld::TreeView&, void> m_aChangeHdl;
     Link<weld::TreeView&, bool> m_aRowActivatedHdl;
+    Link<const KeyEvent&, bool> m_aKeyPressHdl;
 
     /** Return the name of the object.  When the object has no user supplied
         name and the bCreate flag is <TRUE/> then a name is created
@@ -206,6 +207,11 @@ public:
         m_aRowActivatedHdl = rLink;
     }
 
+    void connect_key_press(const Link<const KeyEvent&, bool>& rLink)
+    {
+        m_aKeyPressHdl = rLink;
+    }
+
     bool HasSelectedChildren(std::u16string_view rName);
     bool SelectEntry(std::u16string_view rName);
 


More information about the Libreoffice-commits mailing list