From: APTX Date: Mon, 21 Feb 2022 13:48:54 +0000 (+0900) Subject: Add borderless fullscreen X-Git-Url: https://gitweb.tyo.aptx.org/?a=commitdiff_plain;h=b42eac3af35c4e7f705c32c30c98159f7d56b6e3;p=aniplayer.git Add borderless fullscreen --- diff --git a/uiplugins/ui_desktop_qml_default/qml/PlayerControls.qml b/uiplugins/ui_desktop_qml_default/qml/PlayerControls.qml index f00bd55..c9a1301 100644 --- a/uiplugins/ui_desktop_qml_default/qml/PlayerControls.qml +++ b/uiplugins/ui_desktop_qml_default/qml/PlayerControls.qml @@ -115,11 +115,7 @@ Flow { text: "FS" checkable: true onCheckedChanged: { - if (!checked) { - controlledWindow.showNormal(); - } else { - controlledWindow.showFullScreen(); - } + controlledWindow.borderlessFullScreen = checked } } BasicButton { @@ -127,31 +123,14 @@ Flow { text: "OnTop" enabled: !controlledWindow.isFullScreen() checkable: true - onCheckedChanged: { - if (!checked) { - controlledWindow.flags = controlledWindow.flags & ~Qt.WindowStaysOnTopHint - } else { - controlledWindow.flags = controlledWindow.flags - | Qt.WindowStaysOnTopHint - | Qt.WindowTitleHint - | Qt.WindowSystemMenuHint - | Qt.WindowMinMaxButtonsHint - | Qt.WindowCloseButtonHint - } - } + onCheckedChanged: controlledWindow.stayOnTop = checked } BasicButton { id: framelessButton text: "Frameless" enabled: !controlledWindow.isFullScreen() checkable: true - onCheckedChanged: { - if (!checked) { - controlledWindow.flags = controlledWindow.flags & ~Qt.FramelessWindowHint - } else { - controlledWindow.flags = controlledWindow.flags | Qt.FramelessWindowHint - } - } + onCheckedChanged: controlledWindow.borderless = checked } SeekSlider { width: 800 diff --git a/uiplugins/ui_desktop_qml_default/qml/main.qml b/uiplugins/ui_desktop_qml_default/qml/main.qml index ecdd9e7..c74f820 100644 --- a/uiplugins/ui_desktop_qml_default/qml/main.qml +++ b/uiplugins/ui_desktop_qml_default/qml/main.qml @@ -1,5 +1,5 @@ -import QtQuick.Window 2.2 import org.aptx.aniplayer 1.0 +import QtQuick.Window 2.13 import QtQuick 2.7 Window { @@ -7,28 +7,124 @@ Window { width: 300 height: 300 property bool controlsVisible: true - //property Visibility previousVisibility: Window.Normal + property bool borderlessFullScreen: false + property bool stayOnTop: false + property bool borderless: false + + title: player.displayTitle Component.onCompleted: { loadSettings(); window.visible = true } + // TODO remove this once QTBUG-47917/QTCREATORBUG-13347 is actually fixed + // @disable-check M16 onClosing: saveSettings() function isFullScreen() { - return visibility === Window.FullScreen + return visibility === Window.FullScreen || borderlessFullScreen + } + + StateGroup { + states: [ + State { + name: "borderlessFullScreen" + when: borderlessFullScreen + PropertyChanges { + target: window + borderless: true + stayOnTop: true + x: screen.virtualX + y: screen.virtualY + width: screen.width + height: screen.height + } + }, + State { + name: "borderlessFullScreenInactive" + when: borderlessFullScreen && !active + extend: "borderlessFullScreen" + PropertyChanges { + target: window + stayOnTop: false + } + } + ] + } +/* + onBorderlessFullScreenChanged: { + if (borderlessFullScreen) { + console.log("Turnning borderlessFullScreen on"); + console.log("Window.x: ", x); + console.log("Window.y: ", y); + console.log("Window.width: ", width); + console.log("Window.height: ", height); + nonFullScreenData.x = x; + nonFullScreenData.y = y; + nonFullScreenData.width = width; + nonFullScreenData.height = height; + nonFullScreenData.stayOnTop = stayOnTop; + nonFullScreenData.borderless = borderless; + + borderless = true; + stayOnTop = true; + x = screen.virtualX; + y = screen.virtualY; + console.log("Screen: ", screen); + console.log("Screen.w: ", screen.width); + console.log("Screen.h: ", screen.height); + width = screen.width; + height = screen.height; + } else { + console.log("Turnning borderlessFullScreen off"); + console.log("x: ", x); + console.log("y: ", y); + console.log("width: ", width); + console.log("height: ", height); + width = nonFullScreenData.width; + height = nonFullScreenData.height; + x = nonFullScreenData.x; + y = nonFullScreenData.y; + borderless = nonFullScreenData.borderless; + stayOnTop = nonFullScreenData.stayOnTop; + } + } +*/ + onBorderlessChanged: { + if (borderless) { + flags = flags | Qt.FramelessWindowHint + } else { + flags = flags & ~Qt.FramelessWindowHint + } + } + + onStayOnTopChanged: { + if (stayOnTop) { + flags = flags + | Qt.WindowStaysOnTopHint + | Qt.WindowTitleHint + | Qt.WindowSystemMenuHint + | Qt.WindowMinMaxButtonsHint + | Qt.WindowCloseButtonHint + } else { + flags = flags & ~Qt.WindowStaysOnTopHint + } } function saveSettings() { console.log("Saving settings"); + controls.saveSettings(); + // Exit fullscreen here to save geometry without fullscreen + // Fullscreen enabled/disabled state is saved by controls + window.borderlessFullScreen = false; settings.savePlayerState(player); settings.set("x", x); settings.set("y", y); settings.set("width", width); settings.set("height", height); settings.set("controlsVisible", controls.visible); - controls.saveSettings(); + } function loadSettings() { @@ -120,7 +216,7 @@ Window { else if (mouse.button === Qt.MiddleButton) player.togglePlay(); } - cursorShape: !controls.visible && window.visibility === Window.FullScreen ? Qt.BlankCursor : Qt.ArrowCursor; + cursorShape: !controls.visible && window.isFullScreen() ? Qt.BlankCursor : Qt.ArrowCursor; } DropArea {