diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-06-14 09:18:44 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-06-14 13:06:54 +0200 |
commit | 252239ae30313142195b3da81aea45a89b2d6674 (patch) | |
tree | b77efb3d2405bba253e6cd6f3633dff51ad21783 /sfx2 | |
parent | 8303e7ed668fbcbd0ba75bd9dd259f03073ffd46 (diff) |
disable 'quit' menu entry when modal dialog waiting response
Traditionally when a modal dialog is active, the quit menu entry of all
LibreOffice toplevel frames, not just those which are themselves modal, is get
disabled.
This has come unstuck because its implemented by dialogs emitting
MouseNotifyEvent::[END]EXECUTEDIALOG on its parent, and SfxFrameWindow_Impl
listening for that event. But if the dialog parent is the toplevel parent of
SfxFrameWindow_Impl then it doesn't get seen by the SfxFrameWindow_Impl child.
Change-Id: I0c4a5472d16d9169e68f6b0c230d039f1119489a
Reviewed-on: https://gerrit.libreoffice.org/73975
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/view/frame2.cxx | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/sfx2/source/view/frame2.cxx b/sfx2/source/view/frame2.cxx index 804440a4f24f..dd894c87dc37 100644 --- a/sfx2/source/view/frame2.cxx +++ b/sfx2/source/view/frame2.cxx @@ -61,9 +61,9 @@ using namespace ::com::sun::star::container; using namespace ::com::sun::star::beans; using ::com::sun::star::frame::XComponentLoader; - class SfxFrameWindow_Impl : public vcl::Window { + DECL_LINK(ModalHierarchyHdl, bool, void); public: SfxFrame* pFrame; @@ -75,13 +75,21 @@ public: virtual bool EventNotify( NotifyEvent& rEvt ) override; virtual void Resize() override; virtual void GetFocus() override; + virtual void dispose() override; void DoResize(); }; -SfxFrameWindow_Impl::SfxFrameWindow_Impl( SfxFrame* pF, vcl::Window& i_rContainerWindow ) - : Window( &i_rContainerWindow, WB_BORDER | WB_CLIPCHILDREN | WB_NODIALOGCONTROL | WB_3DLOOK ) - , pFrame( pF ) +SfxFrameWindow_Impl::SfxFrameWindow_Impl(SfxFrame* pF, vcl::Window& i_rContainerWindow) + : Window(&i_rContainerWindow, WB_BORDER | WB_CLIPCHILDREN | WB_NODIALOGCONTROL | WB_3DLOOK) + , pFrame(pF) +{ + i_rContainerWindow.SetModalHierarchyHdl(LINK(this, SfxFrameWindow_Impl, ModalHierarchyHdl)); +} + +void SfxFrameWindow_Impl::dispose() { + GetParent()->SetModalHierarchyHdl(Link<bool, void>()); + vcl::Window::dispose(); } void SfxFrameWindow_Impl::DataChanged( const DataChangedEvent& rDCEvt ) @@ -119,20 +127,18 @@ bool SfxFrameWindow_Impl::EventNotify( NotifyEvent& rNEvt ) if ( pView->GetViewShell()->KeyInput( *rNEvt.GetKeyEvent() ) ) return true; } - else if ( rNEvt.GetType() == MouseNotifyEvent::EXECUTEDIALOG ) - { - pView->SetModalMode( true ); - return true; - } - else if ( rNEvt.GetType() == MouseNotifyEvent::ENDEXECUTEDIALOG /*|| rNEvt.GetType() == MouseNotifyEvent::INPUTENABLE*/ ) - { - pView->SetModalMode( false ); - return true; - } return Window::EventNotify( rNEvt ); } +IMPL_LINK(SfxFrameWindow_Impl, ModalHierarchyHdl, bool, bSetModal, void) +{ + SfxViewFrame* pView = pFrame->GetCurrentViewFrame(); + if (!pView || !pView->GetObjectShell()) + return; + pView->SetModalMode(bSetModal); +} + bool SfxFrameWindow_Impl::PreNotify( NotifyEvent& rNEvt ) { MouseNotifyEvent nType = rNEvt.GetType(); |