make it a flickable again

otherwise too many mose events get stolen
This commit is contained in:
Marco Martin 2019-09-16 18:43:55 +02:00
parent 93ee01c36e
commit 4832735497
2 changed files with 18 additions and 25 deletions

View file

@ -99,7 +99,7 @@ ContainmentLayoutManager.ItemContainer {
plasmoid.nativeInterface.applicationListModel.runApplication(modelData.ApplicationStorageIdRole); plasmoid.nativeInterface.applicationListModel.runApplication(modelData.ApplicationStorageIdRole);
} }
preventStealing: true
ColumnLayout { ColumnLayout {
anchors.fill: parent anchors.fill: parent
spacing: 0 spacing: 0

View file

@ -41,32 +41,29 @@ Item {
property int buttonHeight: width/4 property int buttonHeight: width/4
property bool loadCompleted: false property bool loadCompleted: false
XAnimator { NumberAnimation {
id: switchAnim id: switchAnim
target: activitiesLayout target: activitiesView
property: "contentX"
duration: units.longDuration duration: units.longDuration
easing.type: Easing.InOutQuad easing.type: Easing.InOutQuad
} }
MouseArea { Flickable {
id: activitiesView id: activitiesView
z: 99 z: 99
visible: root.containment visible: root.containment
anchors.fill: parent anchors.fill: parent
drag.filterChildren: true
drag.target: activitiesLayout
drag.axis: Drag.XAxis
drag.minimumX: -activitiesLayout.width + width
drag.maximumX: 0
property int currentIndex: -1 property int currentIndex: -1
property Item nextContainment: root.containment property Item nextContainment: root.containment
contentWidth: activitiesLayout.width
function adjustPosition() { function adjustPosition() {
if (!activitiesLayout.loadCompleted) { if (!activitiesLayout.loadCompleted) {
activitiesLayout.x = - currentIndex * width; activitiesView.contentX = currentIndex * width;
return; return;
} }
switchAnim.from = activitiesLayout.x; switchAnim.from = activitiesView.contentX;
switchAnim.to = - currentIndex * width; switchAnim.to = currentIndex * width;
switchAnim.running = true; switchAnim.running = true;
} }
onCurrentIndexChanged: adjustPosition(); onCurrentIndexChanged: adjustPosition();
@ -74,15 +71,11 @@ Item {
//don't animate //don't animate
onWidthChanged: contentX = currentIndex * width; onWidthChanged: contentX = currentIndex * width;
onPositionChanged: { onMovementEnded: {
var tempIndex = Math.round(-activitiesLayout.x / width); currentIndex = Math.round(activitiesView.contentX / width);
nextContainment = activitiesLayout.children[tempIndex].containment;
}
onReleased: {
currentIndex = Math.round(-activitiesLayout.x / width);
//unconditionally run the slide anim
adjustPosition(); adjustPosition();
} }
onFlickEnded: movementEnded();
Row { Row {
id: activitiesLayout id: activitiesLayout
height: activitiesView.height height: activitiesView.height
@ -104,10 +97,10 @@ Item {
property Item containment property Item containment
//inViewport should be only the current, and the other adjacent two //inViewport should be only the current, and the other adjacent two
readonly property bool inViewport: activitiesLayout.loadCompleted && root.containment && readonly property bool inViewport: activitiesLayout.loadCompleted && root.containment &&
((x >= -activitiesLayout.x && ((x >= activitiesView.contentX &&
x <= -activitiesLayout.x + activitiesView.width) || x <= activitiesView.contentX + activitiesView.width) ||
(x + width >= -activitiesLayout.x && (x + width >= activitiesView.contentX &&
x + width < -activitiesLayout.x + activitiesView.width)) x + width < activitiesView.contentX + activitiesView.width))
readonly property bool currentActivity: root.containment && model.current readonly property bool currentActivity: root.containment && model.current
Component.onCompleted: { Component.onCompleted: {
@ -164,7 +157,7 @@ Item {
} }
PlasmaCore.FrameSvgItem { PlasmaCore.FrameSvgItem {
z: 100 z: 100
opacity: activitiesView.drag.active ? 1 : 0 opacity: activitiesView.flicking || activitiesView.draggingHorizontally ? 1 : 0
anchors.centerIn: parent anchors.centerIn: parent
imagePath: "widgets/background" imagePath: "widgets/background"
width: activityNameLabel.implicitWidth + units.gridUnit*2 width: activityNameLabel.implicitWidth + units.gridUnit*2