Commit 3e32e78e authored by Marco Martin's avatar Marco Martin
Browse files

Always ensure there is an user selected

when creating or deleting a user is not enough to pop the old page,
but a new user needs to be selected (either the newly created one or the
one just on top of the deleted one) so that the kcm doesn't stay
half empty with an ui that looks broken

BUG:450182
parent f7a1a5dd
Pipeline #141093 passed with stage
in 13 minutes and 24 seconds
......@@ -70,10 +70,8 @@ KCM.SimpleKCM {
text: i18n("Create")
enabled: !passwordWarning.visible && verifyField.text && passwordField.text && realNameField.text && userNameField.text
onClicked: {
if (kcm.createUser(userNameField.text, realNameField.text, passwordField.text, (usertypeBox.model[usertypeBox.currentIndex]["type"] == "administrator"))) {
kcm.pop()
}
kcm.mainUi.createUser(userNameField.text, realNameField.text, passwordField.text, (usertypeBox.model[usertypeBox.currentIndex]["type"] == "administrator"))
}
}
}
}
\ No newline at end of file
}
......@@ -187,18 +187,14 @@ SimpleKCM {
text: i18n("Delete files")
icon.name: "edit-delete-shred"
onClicked: {
if (kcm.deleteUser(usersDetailPage.user.uid, true)) {
kcm.pop()
}
kcm.mainUi.deleteUser(usersDetailPage.user.uid, true)
}
}
QQC2.MenuItem {
text: i18n("Keep files")
icon.name: "document-multiple"
onClicked: {
if (kcm.deleteUser(usersDetailPage.user.uid, false)) {
kcm.pop()
}
kcm.mainUi.deleteUser(usersDetailPage.user.uid, false)
}
}
}
......
......@@ -36,6 +36,17 @@ KCM.ScrollViewKCM {
// appending it to image source with '?', we force avatar to reload
property int avatarVersion: 0
function createUser(userName, realName, password, isAdministrator) {
if (kcm.createUser(userName, realName, password, isAdministrator)) {
userList.indexToActivate = userList.count
}
}
function deleteUser(uid, deleteData) {
if (kcm.deleteUser(uid, deleteData)) {
userList.indexToActivate = userList.count-1
}
}
Connections {
target: kcm
onApply: {
......@@ -51,7 +62,16 @@ KCM.ScrollViewKCM {
view: ListView {
id: userList
model: kcm.userModel
property int indexToActivate: -1
onCountChanged: {
if (indexToActivate >= 0) {
kcm.pop();
currentIndex = Math.min(Math.max(0, indexToActivate), count - 1);
kcm.push("UserDetailsPage.qml", {user: currentItem.userObject});
indexToActivate = -1;
}
}
section {
property: "sectionHeader"
delegate: Kirigami.ListSectionHeader {
......@@ -63,6 +83,7 @@ KCM.ScrollViewKCM {
text: model.display ? model.display : model.name
subtitle: model.display ? model.name : ""
reserveSpaceForSubtitle: true
property var userObject: model.userObject
highlighted: index == userList.currentIndex
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment