115 lines
3.3 KiB
QML
115 lines
3.3 KiB
QML
/*
|
|
* Copyright (C) 2023, KylinSoft Co., Ltd.
|
|
*
|
|
* 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/>.
|
|
*
|
|
*/
|
|
|
|
import QtQuick 2.12
|
|
import QtQml 2.12
|
|
|
|
import AppUI 1.0 as AppUI
|
|
import AppControls2 1.0 as AppControls2
|
|
import org.ukui.menu.core 1.0
|
|
|
|
Item {
|
|
id: root
|
|
clip: true
|
|
property int animationDuration: 150
|
|
|
|
Component.onCompleted: {
|
|
loader.reloadUI();
|
|
mainWindow.beforeFullScreenChanged.connect(beforeFullScreenSlot);
|
|
mainWindow.fullScreenChanged.connect(fullScreenChangedSlot);
|
|
}
|
|
|
|
function fullScreenChangedSlot() {
|
|
loader.opacity = 0;
|
|
fullScreenAnimation.start();
|
|
}
|
|
|
|
function beforeFullScreenSlot(status) {
|
|
if (!status) {
|
|
loader.sourceComponent = undefined;
|
|
}
|
|
backgroundMask.alpha = status ? 0.5 : 0
|
|
backgroundMask.enableSizeChange = false;
|
|
}
|
|
|
|
ParallelAnimation {
|
|
id: fullScreenAnimation
|
|
NumberAnimation { target: backgroundMask; property: "width"; to: root.width; duration: root.animationDuration }
|
|
NumberAnimation { target: backgroundMask; property: "height"; to: root.height; duration: root.animationDuration }
|
|
|
|
onFinished: {
|
|
backgroundMask.enableSizeChange = true;
|
|
loader.reloadUI();
|
|
}
|
|
}
|
|
|
|
AppControls2.StyleBackground {
|
|
id: backgroundMask
|
|
anchors.left: parent.left
|
|
anchors.bottom: parent.bottom
|
|
alpha: 0
|
|
useStyleTransparent: false
|
|
paletteRole: Palette.Dark
|
|
|
|
property bool enableSizeChange: true
|
|
|
|
states: [
|
|
State {
|
|
name: "disableSizeChange"
|
|
when: !backgroundMask.enableSizeChange
|
|
AnchorChanges {
|
|
target: backgroundMask
|
|
anchors.top: undefined
|
|
anchors.right: undefined
|
|
}
|
|
},
|
|
State {
|
|
name: "enableSizeChange"
|
|
when: backgroundMask.enableSizeChange
|
|
AnchorChanges {
|
|
target: backgroundMask
|
|
anchors.top: parent.top
|
|
anchors.right: parent.right
|
|
}
|
|
}
|
|
]
|
|
|
|
Loader {
|
|
id: loader
|
|
anchors.fill: parent
|
|
Behavior on opacity {
|
|
NumberAnimation { duration: root.animationDuration }
|
|
}
|
|
function reloadUI() {
|
|
loader.sourceComponent = mainWindow.isFullScreen ? fullSceenComponent : normalComponent;
|
|
loader.opacity = 1;
|
|
}
|
|
}
|
|
}
|
|
|
|
Component {
|
|
id: fullSceenComponent
|
|
AppUI.FullScreenUI {}
|
|
}
|
|
|
|
Component {
|
|
id: normalComponent
|
|
AppUI.NormalUI {}
|
|
}
|
|
}
|