feat(window):解决全屏切换闪烁问题
This commit is contained in:
parent
2f8d48b481
commit
f7b4b23a1f
|
@ -271,6 +271,7 @@ ListView {
|
||||||
Extension.FavoriteDelegate {
|
Extension.FavoriteDelegate {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: 12
|
anchors.margins: 12
|
||||||
|
isFullScreen: true
|
||||||
|
|
||||||
visualIndex: container.DelegateModel.itemsIndex
|
visualIndex: container.DelegateModel.itemsIndex
|
||||||
delegateLayout.anchors.topMargin: 16
|
delegateLayout.anchors.topMargin: 16
|
||||||
|
|
|
@ -24,9 +24,8 @@ FocusScope {
|
||||||
fullScreenUI.focus = true;
|
fullScreenUI.focus = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
UkuiItems.StyleBackground {
|
Item {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
paletteRole: Platform.Theme.Dark
|
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
|
@ -42,11 +42,18 @@ Item {
|
||||||
Layout.preferredHeight: 36
|
Layout.preferredHeight: 36
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
|
||||||
ToolTip.delay: 500
|
UkuiItems.ToolTip.text: mainWindow.isFullScreen ? qsTr("Contract") : qsTr("Expand")
|
||||||
ToolTip.text: mainWindow.isFullScreen ? qsTr("Contract") : qsTr("Expand")
|
|
||||||
ToolTip.visible: containsMouse
|
onEntered: {
|
||||||
|
UkuiItems.ToolTip.show(fullScreenButton.mapToGlobal(0, fullScreenButton.height));
|
||||||
|
}
|
||||||
|
|
||||||
|
onExited: {
|
||||||
|
UkuiItems.ToolTip.hide();
|
||||||
|
}
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
UkuiItems.ToolTip.hide();
|
||||||
if (mainWindow.isFullScreen) {
|
if (mainWindow.isFullScreen) {
|
||||||
mainWindow.exitFullScreen();
|
mainWindow.exitFullScreen();
|
||||||
} else {
|
} else {
|
||||||
|
@ -86,9 +93,15 @@ Item {
|
||||||
icon.width: 24
|
icon.width: 24
|
||||||
icon.height: 24
|
icon.height: 24
|
||||||
|
|
||||||
ToolTip.delay: 500
|
UkuiItems.ToolTip.text: totalUtils.realName
|
||||||
ToolTip.text: totalUtils.realName
|
|
||||||
ToolTip.visible: containsMouse
|
onEntered: {
|
||||||
|
UkuiItems.ToolTip.show(userInfoButton.mapToGlobal(0, userInfoButton.height));
|
||||||
|
}
|
||||||
|
|
||||||
|
onExited: {
|
||||||
|
UkuiItems.ToolTip.hide();
|
||||||
|
}
|
||||||
|
|
||||||
onClicked: totalUtils.openUserCenter()
|
onClicked: totalUtils.openUserCenter()
|
||||||
Keys.onPressed: {
|
Keys.onPressed: {
|
||||||
|
@ -109,9 +122,15 @@ Item {
|
||||||
Layout.preferredHeight: 36
|
Layout.preferredHeight: 36
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
|
||||||
ToolTip.delay: 500
|
UkuiItems.ToolTip.text: qsTr("Computer")
|
||||||
ToolTip.text: qsTr("Computer")
|
|
||||||
ToolTip.visible: containsMouse
|
onEntered: {
|
||||||
|
UkuiItems.ToolTip.show(computerButton.mapToGlobal(0, computerButton.height));
|
||||||
|
}
|
||||||
|
|
||||||
|
onExited: {
|
||||||
|
UkuiItems.ToolTip.hide();
|
||||||
|
}
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
totalUtils.openPeonyComputer();
|
totalUtils.openPeonyComputer();
|
||||||
|
@ -134,9 +153,15 @@ Item {
|
||||||
Layout.preferredHeight: 36
|
Layout.preferredHeight: 36
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
|
||||||
ToolTip.delay: 500
|
UkuiItems.ToolTip.text: qsTr("Applications System")
|
||||||
ToolTip.text: qsTr("Applications System")
|
|
||||||
ToolTip.visible: containsMouse
|
onEntered: {
|
||||||
|
UkuiItems.ToolTip.show(setButton.mapToGlobal(0, setButton.height));
|
||||||
|
}
|
||||||
|
|
||||||
|
onExited: {
|
||||||
|
UkuiItems.ToolTip.hide();
|
||||||
|
}
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
totalUtils.openControlCenter();
|
totalUtils.openControlCenter();
|
||||||
|
@ -159,9 +184,7 @@ Item {
|
||||||
Layout.preferredHeight: 36
|
Layout.preferredHeight: 36
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
|
||||||
ToolTip.delay: 500
|
UkuiItems.ToolTip.text: powerButtonBase.toolTip
|
||||||
ToolTip.visible: containsMouse
|
|
||||||
ToolTip.text: powerButtonBase.toolTip
|
|
||||||
|
|
||||||
PowerButton {
|
PowerButton {
|
||||||
id: powerButtonBase
|
id: powerButtonBase
|
||||||
|
@ -176,6 +199,14 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onEntered: {
|
||||||
|
UkuiItems.ToolTip.show(powerButton.mapToGlobal(0, powerButton.height));
|
||||||
|
}
|
||||||
|
|
||||||
|
onExited: {
|
||||||
|
UkuiItems.ToolTip.hide();
|
||||||
|
}
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
var buttonPosition = mapToGlobal(width, height);
|
var buttonPosition = mapToGlobal(width, height);
|
||||||
powerButtonBase.clicked(mouse.button === Qt.LeftButton, buttonPosition.x + spacingFromMenu, buttonPosition.y + spacingFromMenu, mainWindow.isFullScreen);
|
powerButtonBase.clicked(mouse.button === Qt.LeftButton, buttonPosition.x + spacingFromMenu, buttonPosition.y + spacingFromMenu, mainWindow.isFullScreen);
|
||||||
|
|
|
@ -12,6 +12,7 @@ UkuiItems.StyleBackground {
|
||||||
property bool hold: false
|
property bool hold: false
|
||||||
property alias delegateLayout: itemLayout
|
property alias delegateLayout: itemLayout
|
||||||
property alias mergePrompt: mergePrompt
|
property alias mergePrompt: mergePrompt
|
||||||
|
property bool isFullScreen: false
|
||||||
radius: 8
|
radius: 8
|
||||||
useStyleTransparency: false
|
useStyleTransparency: false
|
||||||
paletteRole: Platform.Theme.Text
|
paletteRole: Platform.Theme.Text
|
||||||
|
@ -90,7 +91,7 @@ UkuiItems.StyleBackground {
|
||||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (mainWindow.isFullScreen) {
|
if (isFullScreen) {
|
||||||
fullScreenUI.focus =false;
|
fullScreenUI.focus =false;
|
||||||
} else {
|
} else {
|
||||||
normalUI.focus = false;
|
normalUI.focus = false;
|
||||||
|
@ -100,7 +101,7 @@ UkuiItems.StyleBackground {
|
||||||
}
|
}
|
||||||
onPressAndHold: {
|
onPressAndHold: {
|
||||||
if (mouse.button === Qt.LeftButton) {
|
if (mouse.button === Qt.LeftButton) {
|
||||||
if (mainWindow.isFullScreen) {
|
if (isFullScreen) {
|
||||||
fullScreenUI.focus =false;
|
fullScreenUI.focus =false;
|
||||||
} else {
|
} else {
|
||||||
normalUI.focus = false;
|
normalUI.focus = false;
|
||||||
|
@ -264,11 +265,11 @@ UkuiItems.StyleBackground {
|
||||||
icons: icon
|
icons: icon
|
||||||
columns: rows
|
columns: rows
|
||||||
|
|
||||||
width: mainWindow.isFullScreen ? 84: 40
|
width: isFullScreen ? 84: 40
|
||||||
rows: mainWindow.isFullScreen ? 4 : 2
|
rows: isFullScreen ? 4 : 2
|
||||||
spacing: mainWindow.isFullScreen ? 4 : 2
|
spacing: isFullScreen ? 4 : 2
|
||||||
padding: mainWindow.isFullScreen ? 8 : 2
|
padding: isFullScreen ? 8 : 2
|
||||||
radius: mainWindow.isFullScreen ? Platform.Theme.maxRadius : Platform.Theme.normalRadius
|
radius: isFullScreen ? Platform.Theme.maxRadius : Platform.Theme.normalRadius
|
||||||
}
|
}
|
||||||
function itemClicked(mouseButton) {
|
function itemClicked(mouseButton) {
|
||||||
if (mouseButton === Qt.RightButton) {
|
if (mouseButton === Qt.RightButton) {
|
||||||
|
|
|
@ -142,6 +142,7 @@ GridView {
|
||||||
id: iconItem
|
id: iconItem
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: 2
|
anchors.margins: 2
|
||||||
|
isFullScreen: false
|
||||||
|
|
||||||
visualIndex: container.DelegateModel.itemsIndex
|
visualIndex: container.DelegateModel.itemsIndex
|
||||||
mergePrompt.anchors.topMargin: 6
|
mergePrompt.anchors.topMargin: 6
|
||||||
|
|
138
qml/main.qml
138
qml/main.qml
|
@ -27,14 +27,12 @@ Item {
|
||||||
id: root
|
id: root
|
||||||
clip: true
|
clip: true
|
||||||
property int animationDuration: menuSetting.get("animationDuration")
|
property int animationDuration: menuSetting.get("animationDuration")
|
||||||
property double transparency: mainWindow.transparency
|
property var normalGeometry: mainWindow.normalRect
|
||||||
property bool onComlpeted: false
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
mainWindow.fullScreenChanged.connect(enterFullScreen);
|
mainWindow.fullScreenChanged.connect(enterFullScreen);
|
||||||
mainWindow.beforeFullScreenExited.connect(exitFullScreen);
|
mainWindow.beforeFullScreenExited.connect(exitFullScreen);
|
||||||
menuSetting.changed.connect(updateAnimationDuration);
|
menuSetting.changed.connect(updateAnimationDuration);
|
||||||
onComlpeted = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function enterFullScreen() {
|
function enterFullScreen() {
|
||||||
|
@ -42,9 +40,6 @@ Item {
|
||||||
normalHide.start();
|
normalHide.start();
|
||||||
fullShow.start();
|
fullShow.start();
|
||||||
enterFullScreenAnimation.start();
|
enterFullScreenAnimation.start();
|
||||||
if (root.transparency <= 0.6) {
|
|
||||||
maskHide.start();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,9 +47,6 @@ Item {
|
||||||
normalShow.start();
|
normalShow.start();
|
||||||
fullHide.start();
|
fullHide.start();
|
||||||
exitFullScreenAnimation.start();
|
exitFullScreenAnimation.start();
|
||||||
if (root.transparency <= 0.6) {
|
|
||||||
maskShow.start();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateAnimationDuration(key) {
|
function updateAnimationDuration(key) {
|
||||||
|
@ -63,121 +55,51 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onTransparencyChanged: {
|
|
||||||
if (transparency > 0.6) {
|
|
||||||
backgroundMask.opacity = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
UkuiItems.StyleBackground {
|
UkuiItems.StyleBackground {
|
||||||
id: backgroundMask
|
id: backgroundMask
|
||||||
// 初始状态默认为normalScreen
|
// 初始状态默认为normalScreen
|
||||||
x: 0; y: 0
|
x: normalGeometry.x
|
||||||
height: normalScreenGeometry.normalGeometry.height
|
y: normalGeometry.y
|
||||||
width: normalScreenGeometry.normalGeometry.width
|
height: normalGeometry.height
|
||||||
radius: Platform.Theme.windowRadius
|
width: normalGeometry.width
|
||||||
|
radius: mainWindow.isFullScreen ? 0 : Platform.Theme.windowRadius
|
||||||
|
|
||||||
onHeightChanged: {
|
border.width: 1
|
||||||
if (root.transparency <= 0.6 && root.onComlpeted) {
|
borderColor: Platform.Theme.Text
|
||||||
switch (mainWindow.panelPos) {
|
borderAlpha: 0.15
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
NumberAnimation {
|
Component.onCompleted: mainWindow.changeWindowBlurRegion(x, y, width, height, radius)
|
||||||
id: maskHide
|
onRadiusChanged: mainWindow.changeWindowBlurRegion(x, y, width, height, radius)
|
||||||
target: backgroundMask; property: "opacity"
|
onWidthChanged: mainWindow.changeWindowBlurRegion(x, y, width, height, radius)
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
ParallelAnimation {
|
ParallelAnimation {
|
||||||
id: enterFullScreenAnimation
|
id: enterFullScreenAnimation
|
||||||
PropertyAnimation {
|
PropertyAnimation {
|
||||||
target: backgroundMask; property: "x"
|
target: backgroundMask; property: "x"
|
||||||
from: normalScreenGeometry.normalScreenX; to: 0
|
from: normalGeometry.x; to: 0
|
||||||
duration: root.animationDuration; easing.type: Easing.InOutQuad
|
duration: root.animationDuration; easing.type: Easing.InOutQuad
|
||||||
}
|
}
|
||||||
PropertyAnimation {
|
PropertyAnimation {
|
||||||
target: backgroundMask; property: "y"
|
target: backgroundMask; property: "y"
|
||||||
from: normalScreenGeometry.normalScreenY; to: 0
|
from: normalGeometry.y; to: 0
|
||||||
duration: root.animationDuration; easing.type: Easing.InOutQuad
|
duration: root.animationDuration; easing.type: Easing.InOutQuad
|
||||||
}
|
}
|
||||||
PropertyAnimation {
|
PropertyAnimation {
|
||||||
target: backgroundMask; property: "height"
|
target: backgroundMask; property: "height"
|
||||||
from: normalScreenGeometry.normalGeometry.height; to: root.height
|
from: normalGeometry.height; to: root.height
|
||||||
duration: root.animationDuration; easing.type: Easing.InOutQuad
|
duration: root.animationDuration; easing.type: Easing.InOutQuad
|
||||||
}
|
}
|
||||||
PropertyAnimation {
|
PropertyAnimation {
|
||||||
target: backgroundMask; property: "width"
|
target: backgroundMask; property: "width"
|
||||||
from: normalScreenGeometry.normalGeometry.width; to: root.width
|
from: normalGeometry.width; to: root.width
|
||||||
duration: root.animationDuration; easing.type: Easing.InOutQuad
|
duration: root.animationDuration; easing.type: Easing.InOutQuad
|
||||||
}
|
}
|
||||||
|
|
||||||
onStarted: {
|
onStarted: {
|
||||||
fullScreenLoader.active = true;
|
fullScreenLoader.active = true;
|
||||||
normalScreenLoader.x = normalScreenGeometry.normalScreenX;
|
|
||||||
normalScreenLoader.y = normalScreenGeometry.normalScreenY;
|
|
||||||
}
|
}
|
||||||
onFinished: {
|
onFinished: {
|
||||||
normalScreenLoader.active = false;
|
normalScreenLoader.active = false;
|
||||||
mainWindow.enableWindowBlur(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,35 +107,29 @@ Item {
|
||||||
id: exitFullScreenAnimation
|
id: exitFullScreenAnimation
|
||||||
PropertyAnimation {
|
PropertyAnimation {
|
||||||
target: backgroundMask; property: "x"
|
target: backgroundMask; property: "x"
|
||||||
from: 0; to: normalScreenGeometry.normalScreenX
|
from: 0; to: normalGeometry.x
|
||||||
duration: root.animationDuration; easing.type: Easing.InOutQuad
|
duration: root.animationDuration; easing.type: Easing.InOutQuad
|
||||||
}
|
}
|
||||||
PropertyAnimation {
|
PropertyAnimation {
|
||||||
target: backgroundMask; property: "y"
|
target: backgroundMask; property: "y"
|
||||||
from: 0; to: normalScreenGeometry.normalScreenY
|
from: 0; to: normalGeometry.y
|
||||||
duration: root.animationDuration; easing.type: Easing.InOutQuad
|
duration: root.animationDuration; easing.type: Easing.InOutQuad
|
||||||
}
|
}
|
||||||
PropertyAnimation {
|
PropertyAnimation {
|
||||||
target: backgroundMask; property: "height"
|
target: backgroundMask; property: "height"
|
||||||
from: root.height; to: normalScreenGeometry.normalGeometry.height
|
from: root.height; to: normalGeometry.height
|
||||||
duration: root.animationDuration; easing.type: Easing.InOutQuad
|
duration: root.animationDuration; easing.type: Easing.InOutQuad
|
||||||
}
|
}
|
||||||
PropertyAnimation {
|
PropertyAnimation {
|
||||||
target: backgroundMask; property: "width"
|
target: backgroundMask; property: "width"
|
||||||
from: root.width; to: normalScreenGeometry.normalGeometry.width
|
from: root.width; to: normalGeometry.width
|
||||||
duration: root.animationDuration; easing.type: Easing.InOutQuad
|
duration: root.animationDuration; easing.type: Easing.InOutQuad
|
||||||
}
|
}
|
||||||
|
|
||||||
onStarted: {
|
onStarted: {
|
||||||
normalScreenLoader.active = true;
|
normalScreenLoader.active = true;
|
||||||
mainWindow.enableWindowBlur(false);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
onFinished: {
|
onFinished: {
|
||||||
normalScreenLoader.x = 0;
|
|
||||||
normalScreenLoader.y = 0;
|
|
||||||
backgroundMask.x = 0;
|
|
||||||
backgroundMask.y = 0;
|
|
||||||
fullScreenLoader.active = false;
|
fullScreenLoader.active = false;
|
||||||
mainWindow.isFullScreen = false;
|
mainWindow.isFullScreen = false;
|
||||||
}
|
}
|
||||||
|
@ -224,7 +140,10 @@ Item {
|
||||||
id: normalScreenLoader
|
id: normalScreenLoader
|
||||||
focus: !mainWindow.isFullScreen
|
focus: !mainWindow.isFullScreen
|
||||||
active: false
|
active: false
|
||||||
height: normalScreenGeometry.normalGeometry.height; width: normalScreenGeometry.normalGeometry.width
|
x: normalGeometry.x
|
||||||
|
y: normalGeometry.y
|
||||||
|
height: normalGeometry.height
|
||||||
|
width: normalGeometry.width
|
||||||
sourceComponent: normalComponent
|
sourceComponent: normalComponent
|
||||||
NumberAnimation { id: normalShow; target: normalScreenLoader; properties: "opacity"; from: 0; to: 1; duration: root.animationDuration; easing.type: Easing.InQuint }
|
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 }
|
NumberAnimation { id: normalHide; target: normalScreenLoader; properties: "opacity"; from: 1; to: 0; duration: root.animationDuration; easing.type: Easing.OutQuint }
|
||||||
|
@ -239,10 +158,15 @@ Item {
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
id: fullScreenLoader
|
id: fullScreenLoader
|
||||||
anchors.fill: parent
|
x: 0; y: 0
|
||||||
|
width: parent.width; height: parent.height
|
||||||
focus: mainWindow.isFullScreen
|
focus: mainWindow.isFullScreen
|
||||||
sourceComponent: fullSceenComponent
|
sourceComponent: fullSceenComponent
|
||||||
NumberAnimation { id: fullShow; target: fullScreenLoader; properties: "opacity"; from: 0; to: 1; duration: root.animationDuration; easing.type: Easing.InQuint }
|
ParallelAnimation {
|
||||||
|
id: fullShow
|
||||||
|
NumberAnimation { target: fullScreenLoader; properties: "opacity"; from: 0; to: 1; duration: root.animationDuration; easing.type: Easing.InQuint }
|
||||||
|
NumberAnimation { target: fullScreenLoader; properties: "y"; from: -100; to: 0; duration: root.animationDuration; easing.type: Easing.InOutQuad }
|
||||||
|
}
|
||||||
NumberAnimation { id: fullHide; target: fullScreenLoader; properties: "opacity"; from: 1; to: 0; duration: root.animationDuration; easing.type: Easing.OutQuint }
|
NumberAnimation { id: fullHide; target: fullScreenLoader; properties: "opacity"; from: 1; to: 0; duration: root.animationDuration; easing.type: Easing.OutQuint }
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
#include <KWindowSystem>
|
#include <KWindowSystem>
|
||||||
#include <KWindowEffects>
|
#include <KWindowEffects>
|
||||||
|
#include <QPainterPath>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
// kysdk
|
// kysdk
|
||||||
|
@ -133,7 +134,15 @@ void WindowHelper::windowBlur(QWindow *window, bool enable, const QRegion ®io
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//use KWindowEffects
|
//use KWindowEffects
|
||||||
KWindowEffects::enableBlurBehind(window->winId(), enable, region);
|
KWindowEffects::enableBlurBehind(window, enable, region);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WindowHelper::setRegion(QWindow *window, qreal x, qreal y, qreal w, qreal h, qreal radius)
|
||||||
|
{
|
||||||
|
QPainterPath path;
|
||||||
|
path.addRoundedRect(x, y, w, h, radius, radius);
|
||||||
|
|
||||||
|
windowBlur(window, true, QRegion(path.toFillPolygon().toPolygon()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ====== WindowGeometryHelper ====== //
|
// ====== WindowGeometryHelper ====== //
|
||||||
|
@ -155,7 +164,7 @@ void WindowGeometryHelper::updateGeometry()
|
||||||
if (!m_primaryScreen) {
|
if (!m_primaryScreen) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QRect screenRect = m_primaryScreen->geometry(), normalRect, fullRect;
|
QRect screenRect = m_primaryScreen->geometry(), normalMaskRect, fullRect;
|
||||||
|
|
||||||
int width = MenuSetting::instance()->get(MENU_WIDTH).toInt();
|
int width = MenuSetting::instance()->get(MENU_WIDTH).toInt();
|
||||||
int height = MenuSetting::instance()->get(MENU_HEIGHT).toInt();
|
int height = MenuSetting::instance()->get(MENU_HEIGHT).toInt();
|
||||||
|
@ -168,62 +177,55 @@ void WindowGeometryHelper::updateGeometry()
|
||||||
height = screenRect.height();
|
height = screenRect.height();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//上: 1, 下: 0, 左: 2, 右: 3
|
//上: 1, 下: 0, 左: 2, 右: 3
|
||||||
switch (m_panelPos) {
|
switch (m_panelPos) {
|
||||||
case 0: {
|
case 0: {
|
||||||
QPoint topLeft;
|
|
||||||
topLeft.setX(screenRect.x() + margin);
|
|
||||||
topLeft.setY(screenRect.y() + screenRect.height() - height - margin - m_panelSize);
|
|
||||||
|
|
||||||
normalRect.setTopLeft(topLeft);
|
|
||||||
normalRect.setSize({width, height});
|
|
||||||
|
|
||||||
fullRect.setTopLeft(screenRect.topLeft());
|
fullRect.setTopLeft(screenRect.topLeft());
|
||||||
fullRect.setSize({screenRect.width(), screenRect.height() - m_panelSize});
|
fullRect.setSize({screenRect.width(), screenRect.height() - m_panelSize});
|
||||||
|
|
||||||
|
normalMaskRect.setTopLeft({margin, screenRect.height() - height - margin - m_panelSize});
|
||||||
|
normalMaskRect.setSize({width, height});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1: {
|
case 1: {
|
||||||
normalRect.setTopLeft({screenRect.x() + margin, screenRect.y() + margin + m_panelSize});
|
|
||||||
normalRect.setSize({width, height});
|
|
||||||
|
|
||||||
fullRect.setTopLeft({screenRect.x(), screenRect.y() + m_panelSize});
|
fullRect.setTopLeft({screenRect.x(), screenRect.y() + m_panelSize});
|
||||||
fullRect.setSize({screenRect.width(), screenRect.height() - m_panelSize});
|
fullRect.setSize({screenRect.width(), screenRect.height() - m_panelSize});
|
||||||
|
|
||||||
|
normalMaskRect.setTopLeft({margin, margin});
|
||||||
|
normalMaskRect.setSize({width, height});
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2: {
|
case 2: {
|
||||||
normalRect.setTopLeft({screenRect.x() + margin + m_panelSize, screenRect.y() + margin});
|
|
||||||
normalRect.setSize({width, height});
|
|
||||||
|
|
||||||
fullRect.setTopLeft({screenRect.x() + m_panelSize, screenRect.y()});
|
fullRect.setTopLeft({screenRect.x() + m_panelSize, screenRect.y()});
|
||||||
fullRect.setSize({screenRect.width() - m_panelSize, screenRect.height()});
|
fullRect.setSize({screenRect.width() - m_panelSize, screenRect.height()});
|
||||||
|
|
||||||
|
normalMaskRect.setTopLeft({margin, margin});
|
||||||
|
normalMaskRect.setSize({width, height});
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 3: {
|
case 3: {
|
||||||
QPoint topLeft;
|
|
||||||
topLeft.setX(screenRect.x() + screenRect.width() - width - margin - m_panelSize);
|
|
||||||
topLeft.setY(screenRect.y() + margin);
|
|
||||||
|
|
||||||
normalRect.setTopLeft(topLeft);
|
|
||||||
normalRect.setSize({width, height});
|
|
||||||
|
|
||||||
fullRect.setTopLeft(screenRect.topLeft());
|
fullRect.setTopLeft(screenRect.topLeft());
|
||||||
fullRect.setSize({screenRect.width() - m_panelSize, screenRect.height()});
|
fullRect.setSize({screenRect.width() - m_panelSize, screenRect.height()});
|
||||||
|
|
||||||
|
normalMaskRect.setTopLeft({screenRect.width() - width - margin - m_panelSize, margin});
|
||||||
|
normalMaskRect.setSize({width, height});
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
normalRect.setTopLeft({screenRect.x() + margin, screenRect.y() + screenRect.height() - height - margin});
|
|
||||||
normalRect.setSize({width, height});
|
|
||||||
|
|
||||||
fullRect.setTopLeft({screenRect.x(), screenRect.y()});
|
fullRect.setTopLeft({screenRect.x(), screenRect.y()});
|
||||||
fullRect.setSize({screenRect.width(), screenRect.height()});
|
fullRect.setSize({screenRect.width(), screenRect.height()});
|
||||||
|
|
||||||
|
normalMaskRect.setTopLeft({margin, screenRect.height() - height - margin - m_panelSize});
|
||||||
|
normalMaskRect.setSize({width, height});
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_normalGeometry = normalRect;
|
m_normalGeometry = normalMaskRect;
|
||||||
m_fullScreenGeometry = fullRect;
|
m_fullScreenGeometry = fullRect;
|
||||||
|
|
||||||
Q_EMIT geometryChanged();
|
Q_EMIT geometryChanged();
|
||||||
|
@ -317,7 +319,6 @@ void MenuWindow::init()
|
||||||
setFlags(Qt::Window);
|
setFlags(Qt::Window);
|
||||||
WindowHelper::setWindowAttribute(this);
|
WindowHelper::setWindowAttribute(this);
|
||||||
WindowHelper::removeHeaderBar(this);
|
WindowHelper::removeHeaderBar(this);
|
||||||
WindowHelper::windowBlur(this, true);
|
|
||||||
|
|
||||||
// 访问窗口api
|
// 访问窗口api
|
||||||
rootContext()->setContextProperty("mainWindow", this);
|
rootContext()->setContextProperty("mainWindow", this);
|
||||||
|
@ -326,6 +327,7 @@ void MenuWindow::init()
|
||||||
QEvent event(QEvent::Move);
|
QEvent event(QEvent::Move);
|
||||||
QCoreApplication::sendEvent(this, &event);
|
QCoreApplication::sendEvent(this, &event);
|
||||||
Q_EMIT panelPosChanged();
|
Q_EMIT panelPosChanged();
|
||||||
|
Q_EMIT normalRectChanged();
|
||||||
});
|
});
|
||||||
|
|
||||||
rootContext()->setContextProperty("isLiteMode", GlobalSetting::instance()->get(GlobalSetting::IsLiteMode));
|
rootContext()->setContextProperty("isLiteMode", GlobalSetting::instance()->get(GlobalSetting::IsLiteMode));
|
||||||
|
@ -346,20 +348,15 @@ void MenuWindow::init()
|
||||||
|
|
||||||
void MenuWindow::updateGeometry()
|
void MenuWindow::updateGeometry()
|
||||||
{
|
{
|
||||||
QRect rect = m_isFullScreen ? m_geometryHelper->fullScreenGeometry() : m_geometryHelper->normalGeometry();
|
QRect rect = m_geometryHelper->fullScreenGeometry();
|
||||||
if (rect == geometry()) {
|
if (rect != geometry()) {
|
||||||
return;
|
WindowHelper::setWindowGeometry(this, rect);
|
||||||
|
setMinimumSize(geometry().size());
|
||||||
|
setMaximumSize(geometry().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_isFullScreen) {
|
updateGeometryOfMask();
|
||||||
setMaximumSize(rect.size());
|
WindowHelper::setRegion(this, m_maskGeometry.x(), m_maskGeometry.y(), m_maskGeometry.width(), m_maskGeometry.height(), 16);
|
||||||
} else {
|
|
||||||
setMinimumSize(rect.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
WindowHelper::setWindowGeometry(this, rect);
|
|
||||||
setMinimumSize(geometry().size());
|
|
||||||
setMaximumSize(geometry().size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MenuWindow::isFullScreen() const
|
bool MenuWindow::isFullScreen() const
|
||||||
|
@ -367,11 +364,6 @@ bool MenuWindow::isFullScreen() const
|
||||||
return m_isFullScreen;
|
return m_isFullScreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect MenuWindow::normalScreenSize()
|
|
||||||
{
|
|
||||||
return m_geometryHelper->normalGeometry();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* beforeFullScreenChanged -> (qml)onWidthChanged -> fullScreenChanged
|
* beforeFullScreenChanged -> (qml)onWidthChanged -> fullScreenChanged
|
||||||
* @param isFullScreen
|
* @param isFullScreen
|
||||||
|
@ -384,9 +376,7 @@ void MenuWindow::setFullScreen(bool isFullScreen)
|
||||||
|
|
||||||
m_isFullScreen = isFullScreen;
|
m_isFullScreen = isFullScreen;
|
||||||
|
|
||||||
WindowHelper::windowBlur(this, !m_isFullScreen);
|
updateGeometryOfMask();
|
||||||
|
|
||||||
updateGeometry();
|
|
||||||
|
|
||||||
// 更新contentItem尺寸
|
// 更新contentItem尺寸
|
||||||
QEvent event(QEvent::Resize);
|
QEvent event(QEvent::Resize);
|
||||||
|
@ -395,10 +385,9 @@ void MenuWindow::setFullScreen(bool isFullScreen)
|
||||||
Q_EMIT fullScreenChanged();
|
Q_EMIT fullScreenChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuWindow::changeWindowBlurRegion(int x, int y, int width, int height)
|
void MenuWindow::changeWindowBlurRegion(qreal x, qreal y, qreal w, qreal h, qreal radius)
|
||||||
{
|
{
|
||||||
QRegion region(x, y, width, height);
|
WindowHelper::setRegion(this, x, y, w, h, radius);
|
||||||
WindowHelper::windowBlur(this, true, region);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuWindow::exitFullScreen()
|
void MenuWindow::exitFullScreen()
|
||||||
|
@ -406,11 +395,6 @@ void MenuWindow::exitFullScreen()
|
||||||
Q_EMIT beforeFullScreenExited();
|
Q_EMIT beforeFullScreenExited();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuWindow::enableWindowBlur(bool enable)
|
|
||||||
{
|
|
||||||
WindowHelper::windowBlur(this, enable);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MenuWindow::exposeEvent(QExposeEvent *event)
|
void MenuWindow::exposeEvent(QExposeEvent *event)
|
||||||
{
|
{
|
||||||
if (isExposed()) {
|
if (isExposed()) {
|
||||||
|
@ -485,4 +469,20 @@ void MenuWindow::setEditMode(bool mode)
|
||||||
Q_EMIT editModeChanged();
|
Q_EMIT editModeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MenuWindow::updateGeometryOfMask()
|
||||||
|
{
|
||||||
|
if (m_isFullScreen) {
|
||||||
|
m_maskGeometry = QRect(0, 0, m_geometryHelper->fullScreenGeometry().width(), m_geometryHelper->fullScreenGeometry().height());
|
||||||
|
} else {
|
||||||
|
m_maskGeometry = m_geometryHelper->normalGeometry();
|
||||||
|
}
|
||||||
|
|
||||||
|
setMask(m_maskGeometry);
|
||||||
|
}
|
||||||
|
|
||||||
|
QRect MenuWindow::normalRect() const
|
||||||
|
{
|
||||||
|
return m_geometryHelper->normalGeometry();
|
||||||
|
}
|
||||||
|
|
||||||
} // UkuiMenu
|
} // UkuiMenu
|
||||||
|
|
|
@ -40,6 +40,7 @@ public:
|
||||||
static void setWindowAttribute(QWindow *window);
|
static void setWindowAttribute(QWindow *window);
|
||||||
static void removeHeaderBar(QWindow *window);
|
static void removeHeaderBar(QWindow *window);
|
||||||
static void windowBlur(QWindow *window, bool enable, const QRegion ®ion = QRegion());
|
static void windowBlur(QWindow *window, bool enable, const QRegion ®ion = QRegion());
|
||||||
|
static void setRegion(QWindow *window, qreal x, qreal y, qreal w, qreal h, qreal radius);
|
||||||
};
|
};
|
||||||
|
|
||||||
class WindowGeometryHelper final : public QObject
|
class WindowGeometryHelper final : public QObject
|
||||||
|
@ -81,23 +82,25 @@ class MenuWindow : public QQuickView
|
||||||
Q_PROPERTY(bool editMode READ editMode WRITE setEditMode NOTIFY editModeChanged)
|
Q_PROPERTY(bool editMode READ editMode WRITE setEditMode NOTIFY editModeChanged)
|
||||||
Q_PROPERTY(double transparency READ transparency NOTIFY transparencyChanged)
|
Q_PROPERTY(double transparency READ transparency NOTIFY transparencyChanged)
|
||||||
Q_PROPERTY(int panelPos READ panelPos NOTIFY panelPosChanged)
|
Q_PROPERTY(int panelPos READ panelPos NOTIFY panelPosChanged)
|
||||||
|
Q_PROPERTY(QRect normalRect READ normalRect NOTIFY normalRectChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MenuWindow(QWindow *parent = nullptr);
|
explicit MenuWindow(QWindow *parent = nullptr);
|
||||||
MenuWindow(QQmlEngine* engine, QWindow *parent);
|
MenuWindow(QQmlEngine* engine, QWindow *parent);
|
||||||
|
|
||||||
bool effectEnabled() const;
|
|
||||||
bool isFullScreen() const;
|
bool isFullScreen() const;
|
||||||
double transparency() const;
|
|
||||||
void setFullScreen(bool isFullScreen);
|
void setFullScreen(bool isFullScreen);
|
||||||
int panelPos() const;
|
|
||||||
bool editMode() const;
|
bool editMode() const;
|
||||||
void setEditMode(bool mode);
|
void setEditMode(bool mode);
|
||||||
|
|
||||||
Q_INVOKABLE void changeWindowBlurRegion(int x, int y, int width, int height);
|
bool effectEnabled() const;
|
||||||
Q_INVOKABLE QRect normalScreenSize();
|
double transparency() const;
|
||||||
|
int panelPos() const;
|
||||||
|
QRect normalRect() const;
|
||||||
|
|
||||||
|
Q_INVOKABLE void changeWindowBlurRegion(qreal x, qreal y, qreal w, qreal h, qreal radius = 8);
|
||||||
Q_INVOKABLE void exitFullScreen();
|
Q_INVOKABLE void exitFullScreen();
|
||||||
Q_INVOKABLE void enableWindowBlur(bool enable);
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void effectEnabledChanged();
|
void effectEnabledChanged();
|
||||||
|
@ -107,6 +110,7 @@ Q_SIGNALS:
|
||||||
void beforeFullScreenExited();
|
void beforeFullScreenExited();
|
||||||
void panelPosChanged();
|
void panelPosChanged();
|
||||||
void editModeChanged();
|
void editModeChanged();
|
||||||
|
void normalRectChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void exposeEvent(QExposeEvent *event) override;
|
void exposeEvent(QExposeEvent *event) override;
|
||||||
|
@ -117,11 +121,13 @@ protected:
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
void updateGeometry();
|
void updateGeometry();
|
||||||
|
void updateGeometryOfMask();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_editMode {false};
|
bool m_editMode {false};
|
||||||
bool m_isFullScreen{false};
|
bool m_isFullScreen{false};
|
||||||
WindowGeometryHelper *m_geometryHelper{nullptr};
|
WindowGeometryHelper *m_geometryHelper{nullptr};
|
||||||
|
QRect m_maskGeometry = QRect(0,0,0,0);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // UkuiMenu
|
} // UkuiMenu
|
||||||
|
|
Loading…
Reference in New Issue