diff --git a/shell/contents/loader.qml b/shell/contents/loader.qml index 9d8fac8..79e34f6 100644 --- a/shell/contents/loader.qml +++ b/shell/contents/loader.qml @@ -1,34 +1,34 @@ /* vim:set foldmethod=marker: * * Copyright (C) 2013 Ivan Cukic * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, * or (at your option) any later version, as published by the Free * Software Foundation * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2 Item { id: main property string shell : "org.kde.plasma.phone" property bool willing : true - property int priority : currentSession == "plasma-mobile" ? 0 : 10 + property int priority : 10 // This is not needed, but allows the // handler to know whether its shell is loaded property bool loaded : false } diff --git a/shell/contents/views/ActivityHandle.qml b/shell/contents/views/ActivityHandle.qml index 6c29dac..b32fd8c 100644 --- a/shell/contents/views/ActivityHandle.qml +++ b/shell/contents/views/ActivityHandle.qml @@ -1,87 +1,88 @@ /* * Copyright 2014 Aaron Seigo * Copyright 2017 Marco Martin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.6 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents MouseArea { id: handle z: 999 property bool mirrored: false anchors { top: parent.top bottom: parent.bottom right: handle.mirrored ? parent.right : undefined left: handle.mirrored ? undefined : parent.left } + property Item frame: nextActivityLabel width: units.gridUnit drag.target: nextActivityLabel drag.axis: Drag.XAxis property real position: (mirrored ? -1 : 1) * (nextActivityLabel.x + nextActivityLabel.width/2) / (parent.width/2) PlasmaCore.FrameSvgItem { id: nextActivityLabel anchors.verticalCenter: parent.verticalCenter x: handle.mirrored ? handle.width : -width opacity: parent.position imagePath: "widgets/background" width: childrenRect.width + units.gridUnit*2 height: childrenRect.height + units.gridUnit*2 PlasmaComponents.Label { anchors.centerIn: parent text: handle.mirrored ? i18n("Go To Next Activity") : i18n("Go To Previous Activity") } } onPressed: { nextActivityLabel.x = handle.mirrored ? handle.width : -nextActivityLabel.width } onReleased: { if (position > 0.5) { if (handle.mirrored) { root.containmentsEnterFromRight = true; activitiesRepresentation.incrementCurrentIndex(); } else { root.containmentsEnterFromRight = false; activitiesRepresentation.decrementCurrentIndex(); } acceptAnim.running = true; } else { dismissAnim.running = true; } } OpacityAnimator { id: acceptAnim target: nextActivityLabel from: nextActivityLabel.opacity to: 0 duration: units.longDuration easing.type: Easing.InOutQuad } XAnimator { id: dismissAnim target: nextActivityLabel from: nextActivityLabel.x to: handle.mirrored ? 0 : -nextActivityLabel.width duration: units.longDuration easing.type: Easing.InOutQuad } } diff --git a/shell/contents/views/Desktop.qml b/shell/contents/views/Desktop.qml index bd77d72..1bc8928 100644 --- a/shell/contents/views/Desktop.qml +++ b/shell/contents/views/Desktop.qml @@ -1,215 +1,250 @@ /* * Copyright 2014 Aaron Seigo * Copyright 2012 Marco Martin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import QtQuick 2.6 +import QtQuick 2.7 import QtGraphicalEffects 1.0 +import QtQuick.Controls 2.3 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.shell 2.0 as Shell import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.workspace.components 2.0 as PlasmaWorkspace import org.kde.kquickcontrolsaddons 2.0 import org.kde.activities 0.1 as Activities import "../components" Item { id: root - width: 1080 - height: 1920 + width: 0 + height: 0 property Item containment; + property Item containmentNextActivityPreview; property Item wallpaper; property int notificationId: 0; property int buttonHeight: width/4 - property bool containmentsEnterFromRight: true + property bool loadCompleted: false - //NOTE: this - PathView { - id: activitiesRepresentation - model: Activities.ActivityModel { - id: activityModel + XAnimator { + id: switchAnim + target: activitiesLayout + duration: units.longDuration + easing.type: Easing.InOutQuad + } + MouseArea { + id: activitiesView + z: 99 + visible: root.containment + 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 Item nextContainment: root.containment + + function adjustPosition() { + if (!activitiesLayout.loadCompleted) { + activitiesLayout.x = - currentIndex * width; + return; + } + switchAnim.from = activitiesLayout.x; + switchAnim.to = - currentIndex * width; + switchAnim.running = true; } - width: 10 - height: 10 - cacheItemCount: 999//count - delegate: Item { - Connections { - target: activitiesRepresentation - onCurrentIndexChanged: { - if (index == activitiesRepresentation.currentIndex) { - activityModel.setCurrentActivity(model.id, function(){}); + onCurrentIndexChanged: adjustPosition(); + + //don't animate + onWidthChanged: contentX = currentIndex * width; + + onPositionChanged: { + var tempIndex = Math.round(-activitiesLayout.x / width); + nextContainment = activitiesLayout.children[tempIndex].containment; + } + onReleased: { + currentIndex = Math.round(-activitiesLayout.x / width); + //unconditionally run the slide anim + adjustPosition(); + } + Row { + id: activitiesLayout + height: activitiesView.height + spacing: 0 + //don't try to do anything until we are well setted up + property bool loadCompleted: root.loadCompleted && width == activitiesView.width * (activitiesLayout.children.length - 1) && activitiesLayout.children.length == activityRepeater.count + 1 + onLoadCompletedChanged: activitiesView.currentIndexChanged(); + + Repeater { + id: activityRepeater + model: Activities.ActivityModel { + id: activityModel + } + + delegate: Item { + id: mainDelegate + width: activitiesView.width + height: activitiesView.height + property Item containment + //inViewport should be only the current, and the other adjacent two + readonly property bool inViewport: activitiesLayout.loadCompleted && root.containment && + ((x >= -activitiesLayout.x && + x <= -activitiesLayout.x + activitiesView.width) || + (x + width >= -activitiesLayout.x && + x + width < -activitiesLayout.x + activitiesView.width)) + readonly property bool currentActivity: root.containment && model.current + + + Connections { + target: activitiesView + onCurrentIndexChanged: { + if (activitiesView.currentIndex == index) { + activityModel.setCurrentActivity(model.id, function(){ + mainDelegate.containment.parent = mainDelegate; + }); + } + } + onFlickEnded: activitiesView.movementEnded() + } + onInViewportChanged: { + if (inViewport && !mainDelegate.containment) { + mainDelegate.containment = desktop.candidateContainments[model.id]; + //desktop.containmentItemForActivity(model.id); + containmentNextActivityPreview = containment; + mainDelegate.containment.parent = mainDelegate; + mainDelegate.containment.anchors.fill = mainDelegate; + } + } + onCurrentActivityChanged: { + if (currentActivity) { + activitiesView.currentIndex = index; + } + mainDelegate.containment.visible = true; } } } } } - ActivityHandle { - mirrored: true + //TODO: adjust its Y to current containment availablescreenrect + PageIndicator { + z: 100 + anchors { + bottom: parent.bottom + bottomMargin: root.containment.availableScreenRect.y + root.containment.availableScreenRect.height + horizontalCenter: parent.horizontalCenter + } + count: activitiesView.count + currentIndex: activitiesView.currentIndex } - ActivityHandle { - mirrored: false + PlasmaCore.FrameSvgItem { + z: 100 + opacity: activitiesView.drag.active ? 1 : 0 + anchors.centerIn: parent + imagePath: "widgets/background" + width: childrenRect.width + units.gridUnit*2 + height: childrenRect.height + units.gridUnit*2 + PlasmaComponents.Label { + anchors.centerIn: parent + text: activitiesView.nextContainment.activityName + } + Behavior on opacity { + OpacityAnimator { + duration: units.longDuration + easing.type: Easing.InOutQuad + } + } } function toggleWidgetExplorer(containment) { console.log("Widget Explorer toggled"); if (widgetExplorerStack.source != "") { widgetExplorerStack.source = ""; } else { widgetExplorerStack.setSource(Qt.resolvedUrl("../explorer/WidgetExplorer.qml"), {"containment": containment}) } } Loader { id: widgetExplorerStack z: 99 asynchronous: true y: containment ? containment.availableScreenRect.y : 0 height: containment ? containment.availableScreenRect.height : parent.height width: parent.width onLoaded: { if (widgetExplorerStack.item) { item.closed.connect(function() { widgetExplorerStack.source = "" }); } } } - onContainmentChanged: { - if (containment == null) { - return; - } - - if (switchAnim.running) { - //If the animation was still running, stop it and reset - //everything so that a consistent state can be kept - switchAnim.running = false; - internal.newContainment.visible = false; - internal.oldContainment.visible = false; - internal.oldContainment = null; - } - - internal.newContainment = containment; - containment.visible = true; - - if (internal.oldContainment != null && internal.oldContainment != containment) { - switchAnim.running = true; - } else { - containment.anchors.left = root.left; - containment.anchors.top = root.top; - containment.anchors.right = root.right; - containment.anchors.bottom = root.bottom; - if (internal.oldContainment) { - internal.oldContainment.visible = false; - } - internal.oldContainment = containment; - } + Binding { + target: containment + property: "width" + value: root.width } - //some properties that shouldn't be accessible from elsewhere QtObject { id: internal; property Item oldContainment: null; property Item newContainment: null; } - SequentialAnimation { - id: switchAnim - ScriptAction { - script: { - if (containment) { - containment.anchors.left = undefined; - containment.anchors.top = undefined; - containment.anchors.right = undefined; - containment.anchors.bottom = undefined; - containment.z = 1; - containment.x = root.containmentsEnterFromRight ? root.width : -root.width; - } - if (internal.oldContainment) { - internal.oldContainment.anchors.left = undefined; - internal.oldContainment.anchors.top = undefined; - internal.oldContainment.anchors.right = undefined; - internal.oldContainment.anchors.bottom = undefined; - internal.oldContainment.z = 0; - internal.oldContainment.x = 0; - } - } - } - ParallelAnimation { - NumberAnimation { - target: internal.oldContainment - properties: "x" - to: internal.newContainment != null ? (root.containmentsEnterFromRight ? -root.width : root.width) : 0 - duration: 400 - easing.type: Easing.InOutQuad - } - NumberAnimation { - target: internal.newContainment - properties: "x" - to: 0 - duration: units.longDuration - easing.type: Easing.InOutQuad - } - } - ScriptAction { - script: { - if (internal.oldContainment) { - internal.oldContainment.visible = false; - } - if (containment) { - containment.anchors.left = root.left; - containment.anchors.top = root.top; - containment.anchors.right = root.right; - containment.anchors.bottom = root.bottom; - internal.oldContainment = containment; - } - } - } - } - //pass the focus to the containment, so it can react to homescreen activate/inactivate Connections { target: desktop onActiveChanged: { containment.focus = desktop.active; } } Loader { id: pinOverlay anchors { fill: parent topMargin: containment.availableScreenRect.y bottomMargin: parent.height - containment.availableScreenRect.height - containment.availableScreenRect.y } z: 222 source: Qt.resolvedUrl("Pin.qml") } + onWidthChanged: { + //There will be a resize at the very start which we can't avoid, don't do anything until then + //configure the view behavior + if (desktop && root.width > 0) { + desktop.width = width; + desktop.height = height; + root.loadCompleted = true; + } + } Component.onCompleted: { //configure the view behavior - if (desktop) { + if (desktop && root.width > 0) { desktop.width = width; desktop.height = height; + root.loadCompleted = true; } } }