close panel when an applet wants to close

This commit is contained in:
Marco Martin 2016-10-05 18:03:41 +02:00
parent efc09b0011
commit e64fda4a63
3 changed files with 27 additions and 5 deletions

View file

@ -45,7 +45,9 @@ ColumnLayout {
if (text != "") {
activityModel.addActivity(text, function(id) {
visible = false;
activityModel.setCurrentActivity(id, function() {});
activityModel.setCurrentActivity(id, function() {
plasmoid.expanded = false;
});
});
}
}
@ -107,7 +109,9 @@ ColumnLayout {
height: Math.max(label.height, label.height)
onClicked: {
listView.currentIndex = index;
activityModel.setCurrentActivity(model.id, function() {});
activityModel.setCurrentActivity(model.id, function() {
plasmoid.expanded = false;
});
}
onPressAndHold: {
edit.visible = true

View file

@ -36,6 +36,12 @@ FullScreenPanel {
width: Screen.width
height: Screen.height
function open() {
mouseArea.state = "open";
}
function close() {
mouseArea.state = "closed";
}
function updateState() {
var delta = offset - mouseArea.startOffset;
if (delta > units.gridUnit * 8) {

View file

@ -44,6 +44,15 @@ PlasmaCore.ColorScope {
LayoutManager.save();
}
Connections {
target: expandedApplet
onExpandedChanged: {
if (!expanded) {
slidingPanel.close();
}
}
}
function addApplet(applet, x, y) {
var container = appletContainerComponent.createObject(appletIconsRow)
@ -98,12 +107,14 @@ PlasmaCore.ColorScope {
z: 999
onClicked: {
if (root.expandedApplet != applet) {
//temp var needed for oldExpandedApplet not to catch one expandedChanged too much by our Connections
var oldExpandedApplet = root.expandedApplet;
root.expandedApplet = applet;
applet.expanded = true;
appletsStack.replace(applet.fullRepresentationItem);
if (root.expandedApplet) {
root.expandedApplet.expanded = false;
if (oldExpandedApplet) {
oldExpandedApplet.expanded = false;
}
root.expandedApplet = applet;
}
}
}
@ -209,6 +220,7 @@ PlasmaCore.ColorScope {
var factor = 1;
slidingPanel.offset = slidingPanel.offset + (mouse.y - oldMouseY) * factor;
oldMouseY = mouse.y;
root.expandedApplet.expanded = true;
}
onReleased: slidingPanel.updateState();
}