Commit 928912b0 authored by Melvin Keskin's avatar Melvin Keskin Committed by Linus Jahn

Improve renaming of contact

* Fix functionality by adding QML import
* Focus field for entering name on opening
* Simulate clicking of button for renaming on enter button
* Remove unnecessary label
* Rename 'currentName' to 'enteredName'
* Rename 'nickField' to 'nameField' for consistency
* Rename 'addButton' to 'renameButton'
parent 52b513d3
Pipeline #16838 passed with stages
in 82 minutes and 1 second
......@@ -81,7 +81,10 @@ Kirigami.Page {
rightAction: Kirigami.Action {
icon.name: "edit-rename"
onTriggered: renameSheet.open()
onTriggered: {
renameSheet.open()
renameSheet.forceFocus()
}
}
RosterRemoveContactSheet {
......@@ -92,9 +95,9 @@ Kirigami.Page {
RosterRenameContactSheet {
id: renameSheet
jid: root.jid
currentName: {
enteredName: {
if (name === jid)
return null;
return "";
return name;
}
}
......
......@@ -33,9 +33,11 @@ import QtQuick.Controls 2.12 as Controls
import QtQuick.Layouts 1.12
import org.kde.kirigami 2.8 as Kirigami
import im.kaidan.kaidan 1.0
Kirigami.OverlaySheet {
property string jid
property alias currentName: nickField.text
property alias enteredName: nameField.text
ColumnLayout {
width: 300
......@@ -45,13 +47,11 @@ Kirigami.OverlaySheet {
Layout.fillWidth: true
}
Controls.Label {
text: qsTr("Edit name:")
}
Controls.TextField {
id: nickField
id: nameField
selectByMouse: true
Layout.fillWidth: true
onAccepted: renameButton.clicked()
}
RowLayout {
......@@ -64,14 +64,19 @@ Kirigami.OverlaySheet {
}
Button {
id: addButton
id: renameButton
text: qsTr("Rename")
Layout.fillWidth: true
onClicked: {
Kaidan.renameContact(jid, nickField.text);
close();
Kaidan.renameContact(jid, enteredName)
close()
}
Layout.fillWidth: true
}
}
}
function forceFocus() {
nameField.forceActiveFocus()
}
}
Markdown is supported
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