temporarly remove the horizontal activity switcher

This commit is contained in:
Marco Martin 2020-07-16 11:37:43 +02:00
parent dfe40102d8
commit 96f4e7be53

View file

@ -29,158 +29,21 @@ import org.kde.kquickcontrolsaddons 2.0
import org.kde.activities 0.1 as Activities import org.kde.activities 0.1 as Activities
//import "../components" //import "../components"
Item {
Rectangle {
id: root id: root
width: 0
height: 0
property Item containment; visible: false //adjust borders is run during setup. We want to avoid painting till completed
property Item containmentNextActivityPreview;
property Item wallpaper;
property int notificationId: 0;
property int buttonHeight: width/4
property bool loadCompleted: false
NumberAnimation {
id: switchAnim
target: activitiesView
property: "contentX"
duration: units.longDuration
easing.type: Easing.InOutQuad
}
Flickable {
id: activitiesView
z: 99
visible: root.containment
anchors.fill: parent
property int currentIndex: -1
property Item nextContainment: root.containment
contentWidth: activitiesLayout.width
function adjustPosition() {
if (!activitiesLayout.loadCompleted) {
activitiesView.contentX = currentIndex * width;
return;
}
switchAnim.from = activitiesView.contentX;
switchAnim.to = currentIndex * width;
switchAnim.running = true;
}
onCurrentIndexChanged: adjustPosition();
//don't animate
onWidthChanged: contentX = currentIndex * width;
onMovementEnded: {
currentIndex = Math.round(activitiesView.contentX / width);
adjustPosition();
}
onFlickEnded: movementEnded();
Row {
id: activitiesLayout
height: activitiesView.height
spacing: 0
//don't try to do anything until we are well set 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 property Item containment
//inViewport should be only the current, and the other adjacent two
readonly property bool inViewport: activitiesLayout.loadCompleted && root.containment &&
((x >= activitiesView.contentX &&
x <= activitiesView.contentX + activitiesView.width) ||
(x + width >= activitiesView.contentX &&
x + width < activitiesView.contentX + activitiesView.width))
readonly property bool currentActivity: root.containment && model.current
Component.onCompleted: { color: containment.backgroundHints == PlasmaCore.Types.NoBackground ? "transparent" : theme.textColor
inViewportChanged();
}
Connections {
target: activitiesView
onCurrentIndexChanged: {
if (activitiesView.currentIndex == index && !model.current) {
activityModel.setCurrentActivity(model.id, function() {
inViewportChanged();
mainDelegate.containment.parent = mainDelegate;
});
}
}
}
Connections {
target: desktop
onCandidateContainmentsChanged: {
inViewportChanged();
}
}
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;
mainDelegate.containment.visible = true;
}
}
onCurrentActivityChanged: {
if (currentActivity) {
activitiesView.currentIndex = index;
}
mainDelegate.containment.visible = 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
}
PlasmaCore.FrameSvgItem {
z: 100
opacity: activitiesView.flicking || activitiesView.draggingHorizontally ? 1 : 0
anchors.centerIn: parent
imagePath: "widgets/background"
width: activityNameLabel.implicitWidth + units.gridUnit*2
height: activityNameLabel.implicitHeight + units.gridUnit*2
PlasmaComponents.Label {
id: activityNameLabel
anchors.centerIn: parent
text: activitiesView.nextContainment ? activitiesView.nextContainment.activityName : ""
}
Behavior on opacity {
OpacityAnimator {
duration: units.longDuration
easing.type: Easing.InOutQuad
}
}
}
function toggleWidgetExplorer(containment) { function toggleWidgetExplorer(containment) {
console.log("Widget Explorer toggled"); console.log("Widget Explorer toggled");
if (widgetExplorerStack.source != "") { if (widgetExplorerStack.source != "") {
widgetExplorerStack.source = ""; widgetExplorerStack.source = "";
} else { } else {
widgetExplorerStack.setSource(desktop.fileFromPackage("explorer", "WidgetExplorer.qml"), {"containment": containment, "containmentInterface": root.containment}) widgetExplorerStack.setSource(Qt.resolvedUrl("../explorer/WidgetExplorer.qml"), {"containment": containment, "containmentInterface": root.containment})
} }
} }
@ -188,37 +51,20 @@ Item {
id: widgetExplorerStack id: widgetExplorerStack
z: 99 z: 99
asynchronous: true asynchronous: true
y: containment ? containment.availableScreenRect.y : 0 anchors.fill: parent
height: containment ? containment.availableScreenRect.height : parent.height
width: parent.width
onLoaded: { onLoaded: {
if (widgetExplorerStack.item) { if (widgetExplorerStack.item) {
item.closed.connect(function() { item.closed.connect(function() {
widgetExplorerStack.source = "" widgetExplorerStack.source = ""
}); });
}
}
}
Binding { item.topPanelHeight = containment.availableScreenRect.y
target: containment item.bottomPanelHeight = root.height - (containment.availableScreenRect.height + containment.availableScreenRect.y)
property: "width"
value: root.width
}
//some properties that shouldn't be accessible from elsewhere
QtObject {
id: internal;
property Item oldContainment: null; item.leftPanelWidth = containment.availableScreenRect.x
property Item newContainment: null; item.rightPanelWidth = root.width - (containment.availableScreenRect.width + containment.availableScreenRect.x)
} }
//pass the focus to the containment, so it can react to homescreen activate/inactivate
Connections {
target: desktop
onActiveChanged: {
containment.focus = desktop.active;
} }
} }
@ -233,21 +79,14 @@ Item {
source: Qt.resolvedUrl("Pin.qml") source: Qt.resolvedUrl("Pin.qml")
} }
onWidthChanged: { onContainmentChanged: {
//There will be a resize at the very start which we can't avoid, don't do anything until then containment.parent = root;
//configure the view behavior containment.visible = true;
if (desktop && root.width > 0) { containment.anchors.fill = root;
desktop.width = width; panel.backgroundHints = containment.backgroundHints;
desktop.height = height;
root.loadCompleted = true;
}
} }
Component.onCompleted: { Component.onCompleted: {
//configure the view behavior visible = true
if (desktop && root.width > 0) {
desktop.width = width;
desktop.height = height;
root.loadCompleted = true;
}
} }
} }