From f1eac8be9689c2eac1f4897286ebe8fdc723117f Mon Sep 17 00:00:00 2001 From: namedkitten Date: Tue, 12 May 2020 14:38:39 +0100 Subject: [PATCH] Fix mouse ui showhide. Fix settings button icon. --- src/qml/ControlsBar.qml | 19 +++-------- src/qml/MainMenu.qml | 1 + src/qml/UIComponents/MenuTitleBar.qml | 19 ++++------- src/qml/icons/RoosterTeeth/settings.svg | 2 +- src/qml/icons/YouTube/settings.svg | 2 +- src/qml/main.qml | 45 +++++++++++++------------ 6 files changed, 37 insertions(+), 51 deletions(-) diff --git a/src/qml/ControlsBar.qml b/src/qml/ControlsBar.qml index db6fddc..11fd250 100644 --- a/src/qml/ControlsBar.qml +++ b/src/qml/ControlsBar.qml @@ -6,23 +6,12 @@ import player 1.0 Item { id: controlsBarItem property var combinedHeight: progressBar.height + controlsBackground.height - property bool controlsShowing: true anchors { bottom: parent.bottom left: parent.left right: parent.right } - Connections { - target: globalConnections - onHideUI: function (force) { - controlsBarItem.controlsShowing = false - } - onShowUI: { - controlsBarItem.controlsShowing = true - } - } - Connections { target: appearance onThemeNameChanged: setControlsTheme(appearance.themeName) @@ -48,7 +37,7 @@ Item { VideoProgress { id: progressBar - visible: controlsBarItem.controlsShowing + visible: mainWindow.controlsShowing && appearance.themeName != "RoosterTeeth" bottomPadding: 0 rightPadding: 0 @@ -72,7 +61,7 @@ Item { Layout.fillWidth: true Layout.fillHeight: true color: getAppearanceValueForTheme(appearance.themeName, "mainBackground") - visible: controlsBarItem.controlsShowing + visible: mainWindow.controlsShowing z: 10 anchors { bottom: parent.bottom @@ -83,8 +72,8 @@ Item { Item { id: controlsBar - height: controlsBar.visible ? mainWindow.virtualHeight / 20 : 0 - visible: controlsBarItem.controlsShowing + height: mainWindow.controlsShowing ? mainWindow.virtualHeight / 20 : 0 + visible: mainWindow.controlsShowing z: 30 anchors { right: parent.right diff --git a/src/qml/MainMenu.qml b/src/qml/MainMenu.qml index 73cc2f8..c43c55b 100644 --- a/src/qml/MainMenu.qml +++ b/src/qml/MainMenu.qml @@ -16,6 +16,7 @@ MenuBar { return true } } + return false } Connections { diff --git a/src/qml/UIComponents/MenuTitleBar.qml b/src/qml/UIComponents/MenuTitleBar.qml index 4a7ef2e..958876d 100644 --- a/src/qml/UIComponents/MenuTitleBar.qml +++ b/src/qml/UIComponents/MenuTitleBar.qml @@ -5,25 +5,18 @@ import QtQuick.Window 2.2 Item { id: menuTitleBar height: menuBar.height - visible: true + visible: mainWindow.controlsShowing + + function anythingOpen() { + return menuBar.anythingOpen() + } + anchors { left: parent.left right: parent.right top: parent.top } - Connections { - target: globalConnections - onHideUI: function () { - if (!menuBar.anythingOpen()) { - menuTitleBar.visible = false - } - } - onShowUI: { - menuTitleBar.visible = true - } - } - MainMenu { id: menuBar } diff --git a/src/qml/icons/RoosterTeeth/settings.svg b/src/qml/icons/RoosterTeeth/settings.svg index 7fcd49d..ef27416 100644 --- a/src/qml/icons/RoosterTeeth/settings.svg +++ b/src/qml/icons/RoosterTeeth/settings.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/qml/icons/YouTube/settings.svg b/src/qml/icons/YouTube/settings.svg index 7fcd49d..ef27416 100644 --- a/src/qml/icons/YouTube/settings.svg +++ b/src/qml/icons/YouTube/settings.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/qml/main.qml b/src/qml/main.qml index fa732ae..63e738e 100644 --- a/src/qml/main.qml +++ b/src/qml/main.qml @@ -10,6 +10,7 @@ Window { visible: true width: Math.min(720, Screen.width) height: Math.min(480, Screen.height) + property bool controlsShowing: true property int virtualHeight: Screen.height * appearance.scaleFactor property int virtualWidth: Screen.width * appearance.scaleFactor property bool onTop: false @@ -300,19 +301,8 @@ Window { anchors.centerIn: player height: player.height width: player.width - property bool controlsShowing: true z: 2 - Connections { - target: globalConnections - onHideUI: function () { - mouseAreaPlayer.cursorShape = Qt.BlankCursor - } - onShowUI: { - mouseAreaPlayer.cursorShape = Qt.ArrowCursor - } - } - MouseArea { id: mouseAreaBar width: parent.width @@ -334,6 +324,7 @@ Window { width: parent.width hoverEnabled: true propagateComposedEvents: true + cursorShape: mainWindow.controlsShowing ? Qt.ArrowCursor : Qt.BlankCursor property real velocity: 0.0 property int xStart: 0 property int xPrev: 0 @@ -352,11 +343,7 @@ Window { id: mouseTapTimer interval: 200 onTriggered: { - if (topBar.visible) { - globalConnections.hideUI() - } else { - globalConnections.showUI() - } + mainWindow.controlsShowing = !mainWindow.controlsShowing || topBar.anythingOpen() || mouseAreaTopBar.containsMouse mouseAreaPlayerTimer.restart() } } @@ -402,10 +389,8 @@ Window { velocity = (velocity + currVel) / 2.0 xPrev = mouse.x } - if (!topBar.visible) { - globalConnections.showUI() - mouseAreaPlayerTimer.restart() - } + mainWindow.controlsShowing = true + mouseAreaPlayerTimer.restart() } Action { onTriggered: { @@ -421,7 +406,7 @@ Window { repeat: false onTriggered: { if (!(appearance.uiFadeTimer == 0)) { - globalConnections.hideUI() + mainWindow.controlsShowing = !mainWindow.controlsShowing || topBar.anythingOpen() || mouseAreaTopBar.containsMouse } } } @@ -472,4 +457,22 @@ Window { id: controlsBar } } + MouseArea { + id: mouseAreaTopBar + anchors { + top: parent.top + left: parent.left + right: parent.right + } + height: topBar.height * 3 + hoverEnabled: true + propagateComposedEvents: true + } + + MouseArea { + anchors.fill: parent + onExited: { + mouseAreaPlayerTimer.start() + } + } }