hide edit boxes when needed

This commit is contained in:
Marco Martin 2016-10-05 17:34:32 +02:00
parent 49cde86d37
commit efc09b0011

View file

@ -25,6 +25,7 @@ import org.kde.activities 0.1 as Activities
ColumnLayout { ColumnLayout {
PlasmaComponents.ToolButton { PlasmaComponents.ToolButton {
id: newButton
Layout.fillWidth: true Layout.fillWidth: true
text: i18n("New Activity...") text: i18n("New Activity...")
onClicked: { onClicked: {
@ -50,10 +51,15 @@ ColumnLayout {
} }
} }
} }
ListView { MouseArea {
id: listView id: rootMouseArea
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
drag.filterChildren: true
onClicked: newEdit.visible = false
ListView {
id: listView
anchors.fill: parent
model: Activities.ActivityModel { model: Activities.ActivityModel {
id: activityModel id: activityModel
} }
@ -67,6 +73,18 @@ ColumnLayout {
visible: model.current visible: model.current
anchors.fill:parent anchors.fill:parent
} }
Connections {
target: rootMouseArea
onClicked: {
if (!delegate.contains(rootMouseArea.mapToItem(delegate, mouse.x, mouse.y))) {
edit.visible = false;
}
}
}
Connections {
target: newButton
onClicked: edit.visible = false;
}
SequentialAnimation { SequentialAnimation {
id: positionAnim id: positionAnim
property alias to: xAnim.to property alias to: xAnim.to
@ -86,7 +104,7 @@ ColumnLayout {
} }
} }
width: listView.width width: listView.width
height: label.height height: Math.max(label.height, label.height)
onClicked: { onClicked: {
listView.currentIndex = index; listView.currentIndex = index;
activityModel.setCurrentActivity(model.id, function() {}); activityModel.setCurrentActivity(model.id, function() {});
@ -113,6 +131,7 @@ ColumnLayout {
PlasmaComponents.Label { PlasmaComponents.Label {
id: label id: label
text: model.name text: model.name
anchors.verticalCenter: parent.verticalCenter
x: units.smallSpacing x: units.smallSpacing
} }
PlasmaComponents.TextField { PlasmaComponents.TextField {
@ -134,3 +153,4 @@ ColumnLayout {
} }
} }
} }
}