优化切换全屏动画,可以跟随任务栏位置改变
This commit is contained in:
parent
38f3673a7d
commit
e74de65c27
188
qml/main.qml
188
qml/main.qml
|
@ -26,7 +26,6 @@ Item {
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
property int animationDuration: menuSetting.get("animationDuration")
|
property int animationDuration: menuSetting.get("animationDuration")
|
||||||
property var normalGeometry: mainWindow.normalScreenSize()
|
|
||||||
property double transparency: mainWindow.transparency
|
property double transparency: mainWindow.transparency
|
||||||
property bool onComlpeted: false
|
property bool onComlpeted: false
|
||||||
|
|
||||||
|
@ -41,7 +40,7 @@ Item {
|
||||||
if (mainWindow.isFullScreen) {
|
if (mainWindow.isFullScreen) {
|
||||||
normalHide.start();
|
normalHide.start();
|
||||||
fullShow.start();
|
fullShow.start();
|
||||||
backgroundMask.state = "fullScreen";
|
enterFullScreenAnimation.start();
|
||||||
if (root.transparency <= 0.6) {
|
if (root.transparency <= 0.6) {
|
||||||
maskHide.start();
|
maskHide.start();
|
||||||
}
|
}
|
||||||
|
@ -51,7 +50,7 @@ Item {
|
||||||
function exitFullScreen() {
|
function exitFullScreen() {
|
||||||
normalShow.start();
|
normalShow.start();
|
||||||
fullHide.start();
|
fullHide.start();
|
||||||
backgroundMask.state = "normalScreen";
|
exitFullScreenAnimation.start();
|
||||||
if (root.transparency <= 0.6) {
|
if (root.transparency <= 0.6) {
|
||||||
maskShow.start();
|
maskShow.start();
|
||||||
}
|
}
|
||||||
|
@ -69,16 +68,67 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
AppControls2.StyleBackground {
|
AppControls2.StyleBackground {
|
||||||
id: backgroundMask
|
id: backgroundMask
|
||||||
anchors.left: parent.left
|
// 初始状态默认为normalScreen
|
||||||
anchors.bottom: parent.bottom
|
x: 0; y: 0
|
||||||
|
height: normalScreenGeometry.normalGeometry.height
|
||||||
|
width: normalScreenGeometry.normalGeometry.width
|
||||||
radius: 12
|
radius: 12
|
||||||
state: mainWindow.isFullScreen ? "fullScreen" : "normalScreen"
|
|
||||||
|
|
||||||
onHeightChanged: {
|
onHeightChanged: {
|
||||||
if (root.transparency <= 0.6 && root.onComlpeted) {
|
if (root.transparency <= 0.6 && root.onComlpeted) {
|
||||||
mainWindow.changeWindowBlurRegion(0, root.height - height, width, height)
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,66 +146,82 @@ Item {
|
||||||
duration: root.animationDuration * 2; easing.type: Easing.InOutExpo
|
duration: root.animationDuration * 2; easing.type: Easing.InOutExpo
|
||||||
}
|
}
|
||||||
|
|
||||||
states: [
|
ParallelAnimation {
|
||||||
State {
|
id: enterFullScreenAnimation
|
||||||
name: "normalScreen"
|
PropertyAnimation {
|
||||||
PropertyChanges { target: backgroundMask; height: root.normalGeometry.height; width: root.normalGeometry.width }
|
target: backgroundMask; property: "x"
|
||||||
},
|
from: normalScreenGeometry.normalScreenX; to: 0
|
||||||
State {
|
duration: root.animationDuration; easing.type: Easing.InOutQuad
|
||||||
name: "fullScreen"
|
}
|
||||||
PropertyChanges { target: backgroundMask; height: root.height; width: root.width }
|
PropertyAnimation {
|
||||||
PropertyChanges { target: normalScreenLoader; anchors.margins: 8 }
|
target: backgroundMask; property: "y"
|
||||||
AnchorChanges { target: normalScreenLoader; anchors.bottom: root.bottom; anchors.left: root.left }
|
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
|
||||||
}
|
}
|
||||||
]
|
|
||||||
|
|
||||||
transitions: [
|
onStarted: {
|
||||||
Transition {
|
fullScreenLoader.active = true;
|
||||||
to: "fullScreen"
|
normalScreenLoader.x = normalScreenGeometry.normalScreenX;
|
||||||
SequentialAnimation {
|
normalScreenLoader.y = normalScreenGeometry.normalScreenY;
|
||||||
ScriptAction {
|
|
||||||
script: {
|
|
||||||
normalScreenLoader.anchors.left = root.left;
|
|
||||||
normalScreenLoader.anchors.bottom = root.bottom;
|
|
||||||
normalScreenLoader.anchors.margins = 8;
|
|
||||||
fullScreenLoader.active = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
NumberAnimation { properties: "height,width"; duration: root.animationDuration; easing.type: Easing.InOutQuad }
|
|
||||||
ScriptAction {
|
|
||||||
script: {
|
|
||||||
normalScreenLoader.active = false;
|
|
||||||
mainWindow.enableWindowBlur(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Transition {
|
|
||||||
to: "normalScreen"
|
|
||||||
SequentialAnimation {
|
|
||||||
ScriptAction {
|
|
||||||
script: {
|
|
||||||
normalScreenLoader.active = true;
|
|
||||||
mainWindow.enableWindowBlur(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
NumberAnimation { properties: "height,width"; duration: root.animationDuration; easing.type: Easing.InOutQuad }
|
|
||||||
ScriptAction {
|
|
||||||
script: {
|
|
||||||
fullScreenLoader.active = false;
|
|
||||||
mainWindow.isFullScreen = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
id: normalScreenLoader
|
id: normalScreenLoader
|
||||||
height: root.normalGeometry.height; width: root.normalGeometry.width
|
height: normalScreenGeometry.normalGeometry.height; width: normalScreenGeometry.normalGeometry.width
|
||||||
anchors.bottom: root.bottom
|
|
||||||
anchors.left: root.left
|
|
||||||
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 }
|
||||||
|
|
|
@ -364,6 +364,11 @@ const QRect &WindowGeometryHelper::normalGeometry()
|
||||||
return m_normalGeometry;
|
return m_normalGeometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const int WindowGeometryHelper::getPanelPos()
|
||||||
|
{
|
||||||
|
return m_panelPos;
|
||||||
|
}
|
||||||
|
|
||||||
//======MenuWindow======//
|
//======MenuWindow======//
|
||||||
MenuWindow::MenuWindow(QWindow *parent) : QQuickView(parent), m_geometryHelper(new WindowGeometryHelper(this))
|
MenuWindow::MenuWindow(QWindow *parent) : QQuickView(parent), m_geometryHelper(new WindowGeometryHelper(this))
|
||||||
{
|
{
|
||||||
|
@ -394,6 +399,7 @@ void MenuWindow::init()
|
||||||
connect(m_geometryHelper, &WindowGeometryHelper::geometryChanged, this, [this] {
|
connect(m_geometryHelper, &WindowGeometryHelper::geometryChanged, this, [this] {
|
||||||
QEvent event(QEvent::Move);
|
QEvent event(QEvent::Move);
|
||||||
QCoreApplication::sendEvent(this, &event);
|
QCoreApplication::sendEvent(this, &event);
|
||||||
|
Q_EMIT panelPosChanged();
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(GlobalSetting::instance(), &GlobalSetting::styleChanged, this , [this] (const GlobalSetting::Key& key) {
|
connect(GlobalSetting::instance(), &GlobalSetting::styleChanged, this , [this] (const GlobalSetting::Key& key) {
|
||||||
|
@ -510,4 +516,9 @@ double MenuWindow::transparency() const
|
||||||
return GlobalSetting::instance()->get(GlobalSetting::Transparency).toDouble();
|
return GlobalSetting::instance()->get(GlobalSetting::Transparency).toDouble();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int MenuWindow::panelPos() const
|
||||||
|
{
|
||||||
|
return m_geometryHelper->getPanelPos();
|
||||||
|
}
|
||||||
|
|
||||||
} // UkuiMenu
|
} // UkuiMenu
|
||||||
|
|
|
@ -50,6 +50,7 @@ public:
|
||||||
|
|
||||||
const QRect &normalGeometry();
|
const QRect &normalGeometry();
|
||||||
const QRect &fullScreenGeometry();
|
const QRect &fullScreenGeometry();
|
||||||
|
const int getPanelPos();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void geometryChanged();
|
void geometryChanged();
|
||||||
|
@ -107,6 +108,7 @@ class MenuWindow : public QQuickView
|
||||||
Q_PROPERTY(bool isFullScreen READ isFullScreen WRITE setFullScreen NOTIFY fullScreenChanged)
|
Q_PROPERTY(bool isFullScreen READ isFullScreen WRITE setFullScreen NOTIFY fullScreenChanged)
|
||||||
Q_PROPERTY(bool effectEnabled READ effectEnabled NOTIFY effectEnabledChanged)
|
Q_PROPERTY(bool effectEnabled READ effectEnabled NOTIFY effectEnabledChanged)
|
||||||
Q_PROPERTY(double transparency READ transparency NOTIFY transparencyChanged)
|
Q_PROPERTY(double transparency READ transparency NOTIFY transparencyChanged)
|
||||||
|
Q_PROPERTY(int panelPos READ panelPos NOTIFY panelPosChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MenuWindow(QWindow *parent = nullptr);
|
explicit MenuWindow(QWindow *parent = nullptr);
|
||||||
|
@ -116,6 +118,7 @@ public:
|
||||||
bool isFullScreen() const;
|
bool isFullScreen() const;
|
||||||
double transparency() const;
|
double transparency() const;
|
||||||
void setFullScreen(bool isFullScreen);
|
void setFullScreen(bool isFullScreen);
|
||||||
|
int panelPos() const;
|
||||||
|
|
||||||
Q_INVOKABLE void changeWindowBlurRegion(int x, int y, int width, int height);
|
Q_INVOKABLE void changeWindowBlurRegion(int x, int y, int width, int height);
|
||||||
Q_INVOKABLE QRect normalScreenSize();
|
Q_INVOKABLE QRect normalScreenSize();
|
||||||
|
@ -128,6 +131,7 @@ Q_SIGNALS:
|
||||||
void fullScreenChanged();
|
void fullScreenChanged();
|
||||||
void beforeFullScreenChanged();
|
void beforeFullScreenChanged();
|
||||||
void beforeFullScreenExited();
|
void beforeFullScreenExited();
|
||||||
|
void panelPosChanged();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onActiveFocusItemChanged();
|
void onActiveFocusItemChanged();
|
||||||
|
|
Loading…
Reference in New Issue