From 06c2a24c9e626667a0b7273d8e6b343e76996cd4 Mon Sep 17 00:00:00 2001 From: miruka Date: Sun, 19 Jul 2020 20:27:08 -0400 Subject: [PATCH] Image viewer: separate fullscreen functions --- src/gui/Popups/ImageViewerPopup.qml | 33 ++++++++++++++++++----------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/gui/Popups/ImageViewerPopup.qml b/src/gui/Popups/ImageViewerPopup.qml index ab2d01bf..ae6bb9bc 100644 --- a/src/gui/Popups/ImageViewerPopup.qml +++ b/src/gui/Popups/ImageViewerPopup.qml @@ -39,11 +39,30 @@ HPopup { signal openExternallyRequested() + function showFullScreen() { + if (activedFullScreen) return + window.showFullScreen() + popup.activedFullScreen = true + popup.alternateScaling = true + } + + function exitFullScreen() { + if (! activedFullScreen) return + window.showNormal() + popup.activedFullScreen = false + popup.alternateScaling = false + } + + function toggleFulLScreen() { + const isFull = window.visibility === Window.FullScreen + return isFull ? exitFullScreen() : showFullScreen() + } + margins: 0 background: null - onAboutToHide: if (activedFullScreen) window.showNormal() + onAboutToHide: exitFullScreen() HFlickable { id: flickable @@ -157,17 +176,7 @@ HPopup { popup.alternateScaling = ! popup.alternateScaling : resetScaleAnimation.start() } - onDoubleTapped: { - if (window.visibility === Window.FullScreen) { - window.showNormal() - popup.activedFullScreen = false - popup.alternateScaling = false - } else { - window.showFullScreen() - popup.activedFullScreen = true - popup.alternateScaling = true - } - } + onDoubleTapped: popup.toggleFulLScreen() } TapHandler {