mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-29 15:03:09 +00:00
almost functional even if hacky swipe activity switcher
This commit is contained in:
parent
5e1e5e9009
commit
89fef3ed7b
1 changed files with 38 additions and 32 deletions
|
|
@ -42,28 +42,15 @@ MouseArea {
|
||||||
property bool containmentsEnterFromRight: true
|
property bool containmentsEnterFromRight: true
|
||||||
drag.filterChildren: false
|
drag.filterChildren: false
|
||||||
|
|
||||||
//HACK: needs better api from kactivities qml
|
//HACK FIXME this timer hack is to wait activitiesView finished all its setup
|
||||||
PathView {
|
//which we can't know for sure and suggests that we can't really use it
|
||||||
id: activitiesRepresentation
|
Timer {
|
||||||
model: Activities.ActivityModel {
|
id: hackTimer
|
||||||
id: activityModel
|
interval: 1000
|
||||||
}
|
running: true
|
||||||
width: 10
|
|
||||||
height: 10
|
|
||||||
cacheItemCount: 999//count
|
|
||||||
delegate: Item {
|
|
||||||
Connections {
|
|
||||||
target: activitiesRepresentation
|
|
||||||
onCurrentIndexChanged: {
|
|
||||||
if (index == activitiesRepresentation.currentIndex) {
|
|
||||||
activityModel.setCurrentActivity(model.id, function(){});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ListView {
|
ListView {
|
||||||
id: mainView
|
id: activitiesView
|
||||||
z: 998
|
z: 998
|
||||||
visible: root.containment
|
visible: root.containment
|
||||||
interactive: true
|
interactive: true
|
||||||
|
|
@ -71,24 +58,38 @@ MouseArea {
|
||||||
orientation: ListView.Horizontal
|
orientation: ListView.Horizontal
|
||||||
snapMode: ListView.SnapOneItem
|
snapMode: ListView.SnapOneItem
|
||||||
boundsBehavior: Flickable.StopAtBounds
|
boundsBehavior: Flickable.StopAtBounds
|
||||||
|
highlightMoveDuration: 0
|
||||||
|
highlightRangeMode: ListView.StrictlyEnforceRange
|
||||||
cacheBuffer: width * count * 2
|
cacheBuffer: width * count * 2
|
||||||
model: Activities.ActivityModel {
|
model: Activities.ActivityModel {
|
||||||
id: activityModel2
|
id: activityModel
|
||||||
}
|
}
|
||||||
|
|
||||||
delegate: Rectangle {
|
delegate: Rectangle {
|
||||||
radius: 100
|
radius: 100
|
||||||
id: mainDelegate
|
id: mainDelegate
|
||||||
width: mainView.width
|
width: activitiesView.width
|
||||||
height: mainView.height
|
height: activitiesView.height
|
||||||
property bool inViewport: root.containment && mainView.contentX <= x && mainView.contentX+mainView.width <= x + width
|
|
||||||
property bool current: containment == root.containment
|
|
||||||
property Item containment
|
property Item containment
|
||||||
onCurrentChanged: {
|
readonly property bool inViewport: !hackTimer.running && root.containment &&
|
||||||
if (current) {
|
((x >= activitiesView.contentX &&
|
||||||
mainView.currentIndex = index
|
x < activitiesView.contentX + activitiesView.width) ||
|
||||||
|
(x + width > activitiesView.contentX &&
|
||||||
|
x + width < activitiesView.contentX + activitiesView.width))
|
||||||
|
readonly property bool currentActivity: root.containment && model.current
|
||||||
|
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: activitiesView
|
||||||
|
onMovementEnded: {return;
|
||||||
|
if (activitiesView.currentIndex == index) {
|
||||||
|
activityModel.setCurrentActivity(model.id, function(){
|
||||||
|
mainDelegate.containment.parent = mainDelegate;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
onFlickEnded: onMovementEnded()
|
||||||
|
}
|
||||||
onInViewportChanged: {
|
onInViewportChanged: {
|
||||||
if (inViewport && !mainDelegate.containment) {
|
if (inViewport && !mainDelegate.containment) {
|
||||||
mainDelegate.containment = desktop.containmentItemForActivity(model.id);
|
mainDelegate.containment = desktop.containmentItemForActivity(model.id);
|
||||||
|
|
@ -98,11 +99,16 @@ MouseArea {
|
||||||
mainDelegate.containment.anchors.fill = mainDelegate;
|
mainDelegate.containment.anchors.fill = mainDelegate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
onCurrentActivityChanged: {
|
||||||
|
if (currentActivity) {
|
||||||
|
activitiesView.positionViewAtIndex(index, ListView.Beginning);
|
||||||
|
activitiesView.currentIndex = index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
x: -100
|
|
||||||
z: 100
|
z: 100
|
||||||
text: mainDelegate.inViewport + " " + mainView.contentX +" "+ mainDelegate.x +" "+ (mainView.contentX + mainView.width) + " " + (mainDelegate.x + mainDelegate.width)
|
text: mainDelegate.inViewport + " " + activitiesView.contentX +" "+ mainDelegate.x +" "+ (activitiesView.contentX + activitiesView.width) + " " + (mainDelegate.x + mainDelegate.width)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -112,8 +118,8 @@ MouseArea {
|
||||||
bottom: parent.bottom
|
bottom: parent.bottom
|
||||||
horizontalCenter: parent.horizontalCenter
|
horizontalCenter: parent.horizontalCenter
|
||||||
}
|
}
|
||||||
count: mainView.count
|
count: activitiesView.count
|
||||||
currentIndex: mainView.currentIndex
|
currentIndex: activitiesView.currentIndex
|
||||||
}
|
}
|
||||||
/* property int startX
|
/* property int startX
|
||||||
onPressed: {
|
onPressed: {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue