summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Grulich <[email protected]>2016-11-30 09:11:31 +0100
committerJan Grulich <[email protected]>2016-11-30 09:11:31 +0100
commit3dd157852c7b104951cb402acbed638ab480113e (patch)
tree1d8552f617afaf935751c57359ed22365820dcdc
parent1be623c416647b219bcae4fdf911f2350889c89f (diff)
Add a button to remove selected connection to the bottom of the list view
-rw-r--r--kcm/qml/ConnectionItem.qml5
-rwxr-xr-xkcm/qml/main.qml47
2 files changed, 28 insertions, 24 deletions
diff --git a/kcm/qml/ConnectionItem.qml b/kcm/qml/ConnectionItem.qml
index 020670c..6e95880 100644
--- a/kcm/qml/ConnectionItem.qml
+++ b/kcm/qml/ConnectionItem.qml
@@ -26,7 +26,7 @@ import org.kde.plasma.networkmanagement 0.2 as PlasmaNM
PlasmaComponents.ListItem {
id: connectionItem
- checked: mouseArea.containsMouse || ConnectionPath === connectionView.currentConnection
+ checked: mouseArea.containsMouse || ConnectionPath === connectionView.currentConnectionPath
height: connectionItemBase.height
signal aboutToRemove(string name, string path)
@@ -135,7 +135,8 @@ PlasmaComponents.ListItem {
onClicked: {
if (mouse.button === Qt.LeftButton) {
- connectionView.currentConnection = ConnectionPath
+ connectionView.currentConnectionName = Name
+ connectionView.currentConnectionPath = ConnectionPath
} else if (mouse.button == Qt.RightButton) {
connectionItemMenu.open(mouse.x, mouse.y)
}
diff --git a/kcm/qml/main.qml b/kcm/qml/main.qml
index 11b19d1..89da6d9 100755
--- a/kcm/qml/main.qml
+++ b/kcm/qml/main.qml
@@ -81,6 +81,7 @@ Item {
anchors {
bottom: buttonRow.top
+ bottomMargin: Math.round(units.gridUnit / 3)
left: parent.left
right: parent.right
top: searchField.bottom
@@ -89,7 +90,8 @@ Item {
ListView {
id: connectionView
- property string currentConnection
+ property string currentConnectionName
+ property string currentConnectionPath
anchors.fill: parent
clip: true
@@ -106,45 +108,46 @@ Item {
}
}
- onCurrentConnectionChanged: {
- root.selectedConnectionChanged(currentConnection)
+ onCurrentConnectionPathChanged: {
+ root.selectedConnectionChanged(currentConnectionPath)
}
}
}
- Column {
+ Row {
id: buttonRow
anchors {
bottom: parent.bottom
left: parent.left
- right: parent.right
- margins: Math.round(units.gridUnit / 2)
+ margins: Math.round(units.gridUnit / 3)
}
-
spacing: Math.round(units.gridUnit / 2)
- PlasmaCore.SvgItem {
- id: separator
- height: lineSvg.elementSize("horizontal-line").height; width: parent.width
- elementId: "horizontal-line"
- svg: PlasmaCore.Svg { id: lineSvg; imagePath: "widgets/line" }
- }
-
- PlasmaComponents.Button {
+ PlasmaComponents.ToolButton {
id: addConnectionButton
- anchors {
- right: parent.right
- }
-
iconSource: "list-add"
- text: i18n("Add new connection")
+ tooltip: i18n("Add new connection")
onClicked: {
addNewConnectionDialog.open()
}
}
+
+ PlasmaComponents.ToolButton {
+ id: removeConnectionButton
+
+ enabled: connectionView.currentConnectionPath && connectionView.currentConnectionPath.length
+ iconSource: "list-remove"
+ tooltip: i18n("Remove selected connection")
+
+ onClicked: {
+ deleteConfirmationDialog.connectionName = connectionView.currentConnectionName
+ deleteConfirmationDialog.connectionPath = connectionView.currentConnectionPath
+ deleteConfirmationDialog.open()
+ }
+ }
}
MessageDialog {
@@ -159,7 +162,7 @@ Item {
text: i18n("Do you want to remove the connection '%1'", connectionName)
onAccepted: {
- if (connectionPath == connectionView.currentConnection) {
+ if (connectionPath == connectionView.currentConnectionPath) {
// Deselect now non-existing connection
deselectConnections()
}
@@ -176,6 +179,6 @@ Item {
}
function deselectConnections() {
- connectionView.currentConnection = ""
+ connectionView.currentConnectionPath = ""
}
}