From 6eb6c21688f0e9da903ab3e81b5cc35c669277d9 Mon Sep 17 00:00:00 2001 From: namedkitten Date: Tue, 28 Apr 2020 11:16:24 +0100 Subject: [PATCH] Move to one less MouseArea. --- src/qml/Dialogs/SettingsDialog.qml | 6 --- src/qml/MainMenu.qml | 1 - src/qml/main.qml | 72 ++++++++++++------------------ version | 2 +- 4 files changed, 30 insertions(+), 51 deletions(-) diff --git a/src/qml/Dialogs/SettingsDialog.qml b/src/qml/Dialogs/SettingsDialog.qml index 5e0564d..dfff6e4 100644 --- a/src/qml/Dialogs/SettingsDialog.qml +++ b/src/qml/Dialogs/SettingsDialog.qml @@ -39,12 +39,6 @@ Dialog { text: translate.getTranslation("TITLE_ONLY_ON_FULLSCREEN", i18n.language) Layout.leftMargin: 30 } - CheckBox { - checked: appearance.clickToPause - onClicked: appearance.clickToPause = !appearance.clickToPause - text: translate.getTranslation("CLICK_TO_PAUSE", i18n.language) - Layout.leftMargin: 30 - } CheckBox { checked: appearance.doubleTapToSeek onClicked: appearance.doubleTapToSeek = !appearance.doubleTapToSeek diff --git a/src/qml/MainMenu.qml b/src/qml/MainMenu.qml index db49a6a..1b64872 100644 --- a/src/qml/MainMenu.qml +++ b/src/qml/MainMenu.qml @@ -122,7 +122,6 @@ MenuBar { delegate: MenuBarItem { id: menuBarItem - padding: 4 topPadding: padding leftPadding: padding diff --git a/src/qml/main.qml b/src/qml/main.qml index ccd6ae9..ccb0dee 100644 --- a/src/qml/main.qml +++ b/src/qml/main.qml @@ -61,7 +61,6 @@ Window { id: appearance category: "Appearance" property bool titleOnlyOnFullscreen: true - property bool clickToPause: false property bool useMpvSubs: false property string themeName: "YouTube" property string fontName: "Roboto" @@ -301,39 +300,6 @@ Window { } } - MouseArea { - anchors { - fill: parent - bottomMargin: controlsBar.combinedHeight - } - width: parent.width - height: parent.height - enabled: appearance.swipeToResize - property real velocity: 0.0 - property int xStart: 0 - property int xPrev: 0 - hoverEnabled: false - propagateComposedEvents: true - z: 1010 - onPressed: { - xStart = mouse.x - xPrev = mouse.x - velocity = 0 - } - onPositionChanged: { - var currVel = (mouse.x - xPrev) - velocity = (velocity + currVel) / 2.0 - xPrev = mouse.x - } - onReleased: { - if (velocity > 2 && mouse.x > parent.width * 0.2) { - appearance.scaleFactor += 0.2 - } else if (velocity < -2 && mouse.x > parent.width * 0.2) { - appearance.scaleFactor -= 0.2 - } - } - } - Item { id: controlsOverlay anchors.centerIn: player @@ -373,6 +339,9 @@ Window { width: parent.width hoverEnabled: true propagateComposedEvents: true + property real velocity: 0.0 + property int xStart: 0 + property int xPrev: 0 anchors { bottom: mouseAreaBar.top bottomMargin: 10 @@ -388,15 +357,12 @@ Window { id: mouseTapTimer interval: 200 onTriggered: { - if (appearance.clickToPause) { - player.playerCommand(Enums.Commands.TogglePlayPause) - return - } if (topBar.visible) { globalConnections.hideUI() } else { globalConnections.showUI() } + mouseAreaPlayerTimer.restart() } } @@ -413,8 +379,10 @@ Window { toggleFullscreen() } } - onClicked: function (mouse) { + xStart = mouse.x + xPrev = mouse.x + velocity = 0 if (mouseTapTimer.running) { doubleMouseClick(mouse) mouseTapTimer.stop() @@ -422,6 +390,28 @@ Window { mouseTapTimer.restart() } } + onReleased: { + var isLongEnough = Math.hypot(xStart, mouse.x) > mainWindow.width * 0.3 + if (velocity > 2 && isLongEnough) { + appearance.scaleFactor += 0.2 + } else if (velocity < -2 && isLongEnough) { + if (appearance.scaleFactor > 0.8) { + appearance.scaleFactor -= 0.2 + } + } + } + onPositionChanged: { + //console.warn(mouseAreaPlayer.mapToItem(controlsBar, mouse.x, mouse.y).y) + if (mouseAreaPlayer.containsPress) { + var currVel = (mouse.x - xPrev) + velocity = (velocity + currVel) / 2.0 + xPrev = mouse.x + } + if (!topBar.visible) { + globalConnections.showUI() + mouseAreaPlayerTimer.restart() + } + } Action { onTriggered: { toggleFullscreen() @@ -438,10 +428,6 @@ Window { globalConnections.hideUI() } } - onPositionChanged: { - globalConnections.showUI() - mouseAreaPlayerTimer.restart() - } } Timer { diff --git a/version b/version index bf0d87a..7813681 100644 --- a/version +++ b/version @@ -1 +1 @@ -4 \ No newline at end of file +5 \ No newline at end of file