mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-29 15:03:09 +00:00
better behavior for the switcher
This commit is contained in:
parent
a5014f6920
commit
5ff1199099
1 changed files with 60 additions and 39 deletions
|
|
@ -68,7 +68,7 @@ Rectangle {
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
readonly property alias desktop: desktopLayer
|
readonly property alias desktop: desktopLayer
|
||||||
readonly property alias windows: windowsLayer
|
readonly property alias windows: windowsLayerBackground
|
||||||
readonly property alias panel: panelLayer
|
readonly property alias panel: panelLayer
|
||||||
readonly property alias keyboard: keyboardLayer
|
readonly property alias keyboard: keyboardLayer
|
||||||
|
|
||||||
|
|
@ -89,36 +89,40 @@ Rectangle {
|
||||||
bottomMargin: bottomBarHeight
|
bottomMargin: bottomBarHeight
|
||||||
}
|
}
|
||||||
color: Qt.rgba(0, 0, 0, 0.9)
|
color: Qt.rgba(0, 0, 0, 0.9)
|
||||||
|
function addWindow (window) {
|
||||||
|
window.parent = windowsLayout
|
||||||
|
}
|
||||||
|
property bool switchMode: windowsZoom.scale < 1
|
||||||
|
|
||||||
Flickable {
|
Item {
|
||||||
id: windowsLayer
|
id: windowsZoom
|
||||||
anchors {
|
anchors.fill: parent
|
||||||
left: parent.left
|
Flickable {
|
||||||
right: parent.right
|
id: windowsLayer
|
||||||
verticalCenter: parent.verticalCenter
|
anchors.centerIn: parent
|
||||||
}
|
|
||||||
height: windowsLayout.height
|
|
||||||
interactive: windowsLayer.switchMode
|
|
||||||
contentWidth: windowsLayout.width * windowsLayout.scale
|
|
||||||
contentHeight: windowsLayout.height
|
|
||||||
|
|
||||||
property bool switchMode: windowsLayout.scale < 1
|
flickableDirection: Flickable.HorizontalFlick
|
||||||
function addWindow (window) {
|
height: windowsZoom.height * 2
|
||||||
window.parent = windowsLayout
|
width: windowsZoom.width * 2
|
||||||
}
|
interactive: windowsLayerBackground.switchMode
|
||||||
|
contentWidth: windowsLayout.width
|
||||||
|
contentHeight: windowsLayout.height
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
height: windowsLayer.height
|
||||||
onClicked: {
|
width: windowsLayout.width
|
||||||
compositorRoot.state = "homeScreen";
|
onClicked: {
|
||||||
}
|
compositorRoot.state = "homeScreen";
|
||||||
Row {
|
}
|
||||||
id: windowsLayout
|
Row {
|
||||||
height: windowsLayerBackground.height
|
id: windowsLayout
|
||||||
transformOrigin: Item.Left
|
anchors.centerIn: parent
|
||||||
onChildrenChanged: {
|
height: windowsLayerBackground.height
|
||||||
if (children.length == 0) {
|
transformOrigin: Item.Left
|
||||||
compositorRoot.state = "homeScreen";
|
onChildrenChanged: {
|
||||||
|
if (children.length == 0) {
|
||||||
|
compositorRoot.state = "homeScreen";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -151,7 +155,7 @@ Rectangle {
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
height: compositorRoot.state == "homeScreen" ? 0 : bottomBarHeight
|
height: compositorRoot.state == "homeScreen" ? 0 : bottomBarHeight
|
||||||
color: Qt.rgba(0, 0, 0, 0.9 + 0.1*windowsLayout.scale)
|
color: Qt.rgba(0, 0, 0, 0.9 + 0.1*windowsZoom.scale)
|
||||||
|
|
||||||
Behavior on height {
|
Behavior on height {
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
|
|
@ -212,25 +216,27 @@ Rectangle {
|
||||||
bottom: parent.bottom
|
bottom: parent.bottom
|
||||||
}
|
}
|
||||||
height: 8
|
height: 8
|
||||||
enabled: windowsLayout.children.length > 0
|
enabled: windowsLayout.children.length > 0 && compositorRoot.state != "switcher"
|
||||||
property int oldX: 0
|
property int oldX: 0
|
||||||
onPressed: {
|
onPressed: {
|
||||||
oldX = mouse.x;
|
oldX = mouse.x;
|
||||||
}
|
}
|
||||||
onPositionChanged: {
|
onPositionChanged: {
|
||||||
compositorRoot.state = "switcher";
|
compositorRoot.state = "changing";
|
||||||
compositorRoot.showKeyboard = false;
|
compositorRoot.showKeyboard = false;
|
||||||
|
|
||||||
var newScale = (1-Math.abs(mouse.y)/(compositorRoot.height/2))
|
var newScale = (1-Math.abs(mouse.y)/(compositorRoot.height/2))
|
||||||
if (newScale > 0.3) {
|
if (newScale > 0.3) {
|
||||||
windowsLayout.scale = newScale
|
windowsZoom.scale = newScale
|
||||||
}
|
}
|
||||||
windowsLayer.contentX -= (mouse.x - oldX);
|
windowsLayer.contentX -= (mouse.x - oldX);
|
||||||
oldX = mouse.x;
|
oldX = mouse.x;
|
||||||
}
|
}
|
||||||
onReleased: {
|
onReleased: {
|
||||||
if (windowsLayout.scale > 0.7) {
|
if (windowsZoom.scale > 0.7) {
|
||||||
compositorRoot.state = compositorRoot.currentWindow ? "application" : "homeScreen";
|
compositorRoot.state = compositorRoot.currentWindow ? "application" : "homeScreen";
|
||||||
|
} else {
|
||||||
|
compositorRoot.state = "switcher";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -243,7 +249,7 @@ Rectangle {
|
||||||
opacity: 0
|
opacity: 0
|
||||||
}
|
}
|
||||||
PropertyChanges {
|
PropertyChanges {
|
||||||
target: windowsLayout
|
target: windowsZoom
|
||||||
scale: 1
|
scale: 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -254,12 +260,12 @@ Rectangle {
|
||||||
opacity: 1
|
opacity: 1
|
||||||
}
|
}
|
||||||
PropertyChanges {
|
PropertyChanges {
|
||||||
target: windowsLayout
|
target: windowsZoom
|
||||||
scale: 1
|
scale: 1
|
||||||
}
|
}
|
||||||
PropertyChanges {
|
PropertyChanges {
|
||||||
target: windowsLayer
|
target: windowsLayer
|
||||||
contentX: compositorRoot.currentWindow ? compositorRoot.currentWindow.x : 0
|
contentX: compositorRoot.currentWindow ? compositorRoot.currentWindow.x - windowsLayerBackground.width/2 : 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
State {
|
State {
|
||||||
|
|
@ -268,16 +274,31 @@ Rectangle {
|
||||||
target: windowsLayerBackground
|
target: windowsLayerBackground
|
||||||
opacity: 1
|
opacity: 1
|
||||||
}
|
}
|
||||||
|
PropertyChanges {
|
||||||
|
target: windowsZoom
|
||||||
|
scale: 0.5
|
||||||
|
}
|
||||||
PropertyChanges {
|
PropertyChanges {
|
||||||
target: windowsLayer
|
target: windowsLayer
|
||||||
contentX: compositorRoot.currentWindow ? compositorRoot.currentWindow.x : 0
|
contentX: compositorRoot.currentWindow ? compositorRoot.currentWindow.x - windowsLayerBackground.width/2 : 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
State {
|
||||||
|
name: "changing"
|
||||||
|
PropertyChanges {
|
||||||
|
target: windowsLayerBackground
|
||||||
|
opacity: 1
|
||||||
|
}
|
||||||
|
PropertyChanges {
|
||||||
|
target: windowsLayer
|
||||||
|
contentX: compositorRoot.currentWindow ? compositorRoot.currentWindow.x - windowsLayerBackground.width/2 : 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
transitions: [
|
transitions: [
|
||||||
Transition {
|
Transition {
|
||||||
to: "switcher"
|
to: "changing"
|
||||||
SequentialAnimation {
|
SequentialAnimation {
|
||||||
ScriptAction {
|
ScriptAction {
|
||||||
script: {
|
script: {
|
||||||
|
|
@ -303,7 +324,7 @@ Rectangle {
|
||||||
properties: "opacity"
|
properties: "opacity"
|
||||||
}
|
}
|
||||||
PropertyAnimation {
|
PropertyAnimation {
|
||||||
target: windowsLayout
|
target: windowsZoom
|
||||||
duration: units.shortDuration
|
duration: units.shortDuration
|
||||||
easing.type: Easing.InOutQuad
|
easing.type: Easing.InOutQuad
|
||||||
properties: "scale"
|
properties: "scale"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue