diff options
author | link2xt <link2xt@testrun.org> | 2021-08-15 12:19:11 +0000 |
---|---|---|
committer | link2xt <link2xt@testrun.org> | 2021-08-15 12:22:15 +0000 |
commit | e225605ff433ba2ebbfcf5d0d6889e1fd45d6d32 (patch) | |
tree | 03c3725368a67b0982fb3bee5313a3450b7c77a2 /qml/NewChatPage.qml | |
parent | f6f3e9de77e9b67dab7c2869dc94389f0252caa9 (diff) | |
download | kdeltachat-e225605ff433ba2ebbfcf5d0d6889e1fd45d6d32.tar.gz kdeltachat-e225605ff433ba2ebbfcf5d0d6889e1fd45d6d32.zip |
Make it possible to create contacts
Diffstat (limited to 'qml/NewChatPage.qml')
-rw-r--r-- | qml/NewChatPage.qml | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/qml/NewChatPage.qml b/qml/NewChatPage.qml index d848c17..aee1393 100644 --- a/qml/NewChatPage.qml +++ b/qml/NewChatPage.qml @@ -6,15 +6,16 @@ import org.kde.kirigami 2.13 as Kirigami import DeltaChat 1.0 Kirigami.ScrollablePage { - id: newChatPageRoot + id: root title: "New chat" required property DcContext context function updateContacts() { - let contacts = context.getContacts(0, ""); + let contacts = context.getContacts(0, searchField.text); + contactsModel.clear() for (let i = 0; i < contacts.length; i++) { let contactId = contacts[i] @@ -26,7 +27,13 @@ Kirigami.ScrollablePage { } Component.onCompleted: { - newChatPageRoot.updateContacts() + root.updateContacts() + } + + header: Kirigami.SearchField { + id: searchField + + onTextChanged: root.updateContacts() } ListModel { @@ -69,10 +76,25 @@ Kirigami.ScrollablePage { Kirigami.PlaceholderMessage { anchors.centerIn: parent - visible: contactsList.count == 0 + visible: contactsList.count == 0 && searchField.text == "" text: "You have no contacts in addressbook yet" } + Kirigami.PlaceholderMessage { + anchors.centerIn: parent + visible: contactsList.count == 0 && searchField.text != "" + helpfulAction: Kirigami.Action { + icon.name: "list-add" + text: "Add contact" + onTriggered: { + let contactId = root.context.createContact("", searchField.text) + context.createChatByContactId(contactId); + pageStack.layers.pop(); + } + } + text: "Contact " + searchField.text + " is not in your address book." + } + onCurrentItemChanged: { if (currentIndex == -1) { return; |