2023-03-17 17:25:50 +08:00
|
|
|
|
/*
|
2023-02-08 10:58:51 +08:00
|
|
|
|
* Copyright (C) 2023, KylinSoft Co., Ltd.
|
2023-01-03 11:00:52 +08:00
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2022-12-02 15:58:09 +08:00
|
|
|
|
import QtQuick 2.12
|
2022-12-23 11:32:21 +08:00
|
|
|
|
import AppUI 1.0 as AppUI
|
2023-03-17 17:25:50 +08:00
|
|
|
|
import AppControls2 1.0 as AppControls2
|
|
|
|
|
import org.ukui.menu.core 1.0
|
2024-01-18 03:24:01 +08:00
|
|
|
|
import org.ukui.quick.items 1.0 as UkuiItems
|
2022-12-23 11:08:16 +08:00
|
|
|
|
|
2023-02-08 10:58:51 +08:00
|
|
|
|
Item {
|
2023-03-17 17:25:50 +08:00
|
|
|
|
id: root
|
|
|
|
|
clip: true
|
2023-03-20 15:33:32 +08:00
|
|
|
|
|
|
|
|
|
property int animationDuration: menuSetting.get("animationDuration")
|
|
|
|
|
property double transparency: mainWindow.transparency
|
|
|
|
|
property bool onComlpeted: false
|
2023-03-17 17:25:50 +08:00
|
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
2023-03-20 15:33:32 +08:00
|
|
|
|
mainWindow.fullScreenChanged.connect(enterFullScreen);
|
|
|
|
|
mainWindow.beforeFullScreenExited.connect(exitFullScreen);
|
|
|
|
|
menuSetting.changed.connect(updateAnimationDuration);
|
|
|
|
|
onComlpeted = true;
|
2023-03-17 17:25:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-20 15:33:32 +08:00
|
|
|
|
function enterFullScreen() {
|
|
|
|
|
if (mainWindow.isFullScreen) {
|
|
|
|
|
normalHide.start();
|
|
|
|
|
fullShow.start();
|
2023-04-03 17:15:32 +08:00
|
|
|
|
enterFullScreenAnimation.start();
|
2023-03-20 15:33:32 +08:00
|
|
|
|
if (root.transparency <= 0.6) {
|
|
|
|
|
maskHide.start();
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-17 17:25:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-20 15:33:32 +08:00
|
|
|
|
function exitFullScreen() {
|
|
|
|
|
normalShow.start();
|
|
|
|
|
fullHide.start();
|
2023-04-03 17:15:32 +08:00
|
|
|
|
exitFullScreenAnimation.start();
|
2023-03-20 15:33:32 +08:00
|
|
|
|
if (root.transparency <= 0.6) {
|
|
|
|
|
maskShow.start();
|
2023-03-17 17:25:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-20 15:33:32 +08:00
|
|
|
|
function updateAnimationDuration(key) {
|
|
|
|
|
if (key === "animationDuration") {
|
|
|
|
|
root.animationDuration = menuSetting.get("animationDuration");
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-17 17:25:50 +08:00
|
|
|
|
|
2023-03-20 15:33:32 +08:00
|
|
|
|
onTransparencyChanged: {
|
|
|
|
|
if (transparency > 0.6) {
|
|
|
|
|
backgroundMask.opacity = 1;
|
2023-03-17 17:25:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-03 17:15:32 +08:00
|
|
|
|
QtObject {
|
|
|
|
|
id: normalScreenGeometry
|
|
|
|
|
property var normalGeometry: mainWindow.normalScreenSize()
|
|
|
|
|
property int normalScreenX: normalScreenMargin
|
|
|
|
|
property int normalScreenY: root.height - normalGeometry.height - normalScreenMargin
|
|
|
|
|
property int normalScreenMargin: 8
|
|
|
|
|
property bool isFullScreen: mainWindow.isFullScreen
|
|
|
|
|
|
|
|
|
|
onIsFullScreenChanged: {
|
|
|
|
|
switch (mainWindow.panelPos) {
|
|
|
|
|
case 0 :
|
|
|
|
|
normalScreenX = normalScreenMargin;
|
|
|
|
|
normalScreenY = root.height - normalGeometry.height - normalScreenMargin;
|
|
|
|
|
break;
|
|
|
|
|
case 1 :
|
|
|
|
|
normalScreenX = normalScreenMargin;
|
|
|
|
|
normalScreenY = normalScreenMargin;
|
|
|
|
|
break;
|
|
|
|
|
case 2 :
|
|
|
|
|
normalScreenX = normalScreenMargin;
|
|
|
|
|
normalScreenY = normalScreenMargin;
|
|
|
|
|
break;
|
|
|
|
|
case 3 :
|
|
|
|
|
normalScreenX = root.width - normalGeometry.width - normalScreenMargin;
|
|
|
|
|
normalScreenY = normalScreenMargin;
|
|
|
|
|
break;
|
|
|
|
|
default :
|
|
|
|
|
normalScreenX = normalScreenMargin;
|
|
|
|
|
normalScreenY = root.height - normalGeometry.height - normalScreenMargin;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-18 03:24:01 +08:00
|
|
|
|
UkuiItems.StyleBackground {
|
2023-03-17 17:25:50 +08:00
|
|
|
|
id: backgroundMask
|
2023-04-03 17:15:32 +08:00
|
|
|
|
// 初始状态默认为normalScreen
|
|
|
|
|
x: 0; y: 0
|
|
|
|
|
height: normalScreenGeometry.normalGeometry.height
|
|
|
|
|
width: normalScreenGeometry.normalGeometry.width
|
2023-03-20 15:33:32 +08:00
|
|
|
|
radius: 12
|
2023-03-17 17:25:50 +08:00
|
|
|
|
|
2023-04-03 17:15:32 +08:00
|
|
|
|
onHeightChanged: {
|
2023-03-20 15:33:32 +08:00
|
|
|
|
if (root.transparency <= 0.6 && root.onComlpeted) {
|
2023-04-03 17:15:32 +08:00
|
|
|
|
switch (mainWindow.panelPos) {
|
|
|
|
|
case 0 :
|
|
|
|
|
mainWindow.changeWindowBlurRegion(0, root.height - height, width, height);
|
|
|
|
|
break;
|
|
|
|
|
case 1 :
|
|
|
|
|
mainWindow.changeWindowBlurRegion(0, 0, width, height);
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
mainWindow.changeWindowBlurRegion(0, 0, width, height);
|
|
|
|
|
break;
|
|
|
|
|
case 3 :
|
|
|
|
|
mainWindow.changeWindowBlurRegion(root.width - width, 0, width, height);
|
|
|
|
|
break;
|
|
|
|
|
default :
|
|
|
|
|
mainWindow.changeWindowBlurRegion(0, root.height - height, width, height);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2023-03-20 15:33:32 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NumberAnimation {
|
|
|
|
|
id: maskHide
|
|
|
|
|
target: backgroundMask; property: "opacity"
|
|
|
|
|
from: 1.0; to: 0;
|
|
|
|
|
duration: root.animationDuration / 4; easing.type: Easing.InOutQuad
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NumberAnimation {
|
|
|
|
|
id: maskShow
|
|
|
|
|
target: backgroundMask; property: "opacity"
|
|
|
|
|
from: 0; to: 1.0;
|
|
|
|
|
duration: root.animationDuration * 2; easing.type: Easing.InOutExpo
|
|
|
|
|
}
|
2023-03-17 17:25:50 +08:00
|
|
|
|
|
2023-04-03 17:15:32 +08:00
|
|
|
|
ParallelAnimation {
|
|
|
|
|
id: enterFullScreenAnimation
|
|
|
|
|
PropertyAnimation {
|
|
|
|
|
target: backgroundMask; property: "x"
|
|
|
|
|
from: normalScreenGeometry.normalScreenX; to: 0
|
|
|
|
|
duration: root.animationDuration; easing.type: Easing.InOutQuad
|
2023-03-17 17:25:50 +08:00
|
|
|
|
}
|
2023-04-03 17:15:32 +08:00
|
|
|
|
PropertyAnimation {
|
|
|
|
|
target: backgroundMask; property: "y"
|
|
|
|
|
from: normalScreenGeometry.normalScreenY; to: 0
|
|
|
|
|
duration: root.animationDuration; easing.type: Easing.InOutQuad
|
|
|
|
|
}
|
|
|
|
|
PropertyAnimation {
|
|
|
|
|
target: backgroundMask; property: "height"
|
|
|
|
|
from: normalScreenGeometry.normalGeometry.height; to: root.height
|
|
|
|
|
duration: root.animationDuration; easing.type: Easing.InOutQuad
|
|
|
|
|
}
|
|
|
|
|
PropertyAnimation {
|
|
|
|
|
target: backgroundMask; property: "width"
|
|
|
|
|
from: normalScreenGeometry.normalGeometry.width; to: root.width
|
|
|
|
|
duration: root.animationDuration; easing.type: Easing.InOutQuad
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onStarted: {
|
|
|
|
|
fullScreenLoader.active = true;
|
|
|
|
|
normalScreenLoader.x = normalScreenGeometry.normalScreenX;
|
|
|
|
|
normalScreenLoader.y = normalScreenGeometry.normalScreenY;
|
2023-03-17 17:25:50 +08:00
|
|
|
|
}
|
2023-04-03 17:15:32 +08:00
|
|
|
|
onFinished: {
|
|
|
|
|
normalScreenLoader.active = false;
|
|
|
|
|
mainWindow.enableWindowBlur(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ParallelAnimation {
|
|
|
|
|
id: exitFullScreenAnimation
|
|
|
|
|
PropertyAnimation {
|
|
|
|
|
target: backgroundMask; property: "x"
|
|
|
|
|
from: 0; to: normalScreenGeometry.normalScreenX
|
|
|
|
|
duration: root.animationDuration; easing.type: Easing.InOutQuad
|
|
|
|
|
}
|
|
|
|
|
PropertyAnimation {
|
|
|
|
|
target: backgroundMask; property: "y"
|
|
|
|
|
from: 0; to: normalScreenGeometry.normalScreenY
|
|
|
|
|
duration: root.animationDuration; easing.type: Easing.InOutQuad
|
|
|
|
|
}
|
|
|
|
|
PropertyAnimation {
|
|
|
|
|
target: backgroundMask; property: "height"
|
|
|
|
|
from: root.height; to: normalScreenGeometry.normalGeometry.height
|
|
|
|
|
duration: root.animationDuration; easing.type: Easing.InOutQuad
|
|
|
|
|
}
|
|
|
|
|
PropertyAnimation {
|
|
|
|
|
target: backgroundMask; property: "width"
|
|
|
|
|
from: root.width; to: normalScreenGeometry.normalGeometry.width
|
|
|
|
|
duration: root.animationDuration; easing.type: Easing.InOutQuad
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onStarted: {
|
|
|
|
|
normalScreenLoader.active = true;
|
|
|
|
|
mainWindow.enableWindowBlur(false);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
onFinished: {
|
|
|
|
|
normalScreenLoader.x = 0;
|
|
|
|
|
normalScreenLoader.y = 0;
|
|
|
|
|
backgroundMask.x = 0;
|
|
|
|
|
backgroundMask.y = 0;
|
|
|
|
|
fullScreenLoader.active = false;
|
|
|
|
|
mainWindow.isFullScreen = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-20 15:33:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
|
id: normalScreenLoader
|
2023-04-26 17:04:22 +08:00
|
|
|
|
focus: !mainWindow.isFullScreen
|
2023-04-03 17:15:32 +08:00
|
|
|
|
height: normalScreenGeometry.normalGeometry.height; width: normalScreenGeometry.normalGeometry.width
|
2023-03-20 15:33:32 +08:00
|
|
|
|
sourceComponent: normalComponent
|
|
|
|
|
NumberAnimation { id: normalShow; target: normalScreenLoader; properties: "opacity"; from: 0; to: 1; duration: root.animationDuration; easing.type: Easing.InQuint }
|
|
|
|
|
NumberAnimation { id: normalHide; target: normalScreenLoader; properties: "opacity"; from: 1; to: 0; duration: root.animationDuration; easing.type: Easing.OutQuint }
|
2023-03-24 17:47:17 +08:00
|
|
|
|
Component.onCompleted: {
|
|
|
|
|
active = mainWindow.isFullScreen ? false : true;
|
|
|
|
|
opacity = mainWindow.isFullScreen ? 0 : 1;
|
|
|
|
|
}
|
2023-04-26 17:04:22 +08:00
|
|
|
|
Keys.onPressed: {
|
|
|
|
|
item.keyPressed(event);
|
|
|
|
|
}
|
2023-03-20 15:33:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
|
id: fullScreenLoader
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
sourceComponent: fullSceenComponent
|
|
|
|
|
NumberAnimation { id: fullShow; target: fullScreenLoader; properties: "opacity"; from: 0; to: 1; duration: root.animationDuration; easing.type: Easing.InQuint }
|
|
|
|
|
NumberAnimation { id: fullHide; target: fullScreenLoader; properties: "opacity"; from: 1; to: 0; duration: root.animationDuration; easing.type: Easing.OutQuint }
|
2023-03-24 17:47:17 +08:00
|
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
|
active = mainWindow.isFullScreen ? true : false;
|
|
|
|
|
opacity = mainWindow.isFullScreen ? 1 : 0;
|
|
|
|
|
}
|
2023-03-17 17:25:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Component {
|
|
|
|
|
id: fullSceenComponent
|
|
|
|
|
AppUI.FullScreenUI {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Component {
|
|
|
|
|
id: normalComponent
|
|
|
|
|
AppUI.NormalUI {}
|
2022-12-02 15:58:09 +08:00
|
|
|
|
}
|
|
|
|
|
}
|