aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlink2xt <link2xt@testrun.org>2021-08-15 12:19:11 +0000
committerlink2xt <link2xt@testrun.org>2021-08-15 12:22:15 +0000
commite225605ff433ba2ebbfcf5d0d6889e1fd45d6d32 (patch)
tree03c3725368a67b0982fb3bee5313a3450b7c77a2
parentf6f3e9de77e9b67dab7c2869dc94389f0252caa9 (diff)
downloadkdeltachat-e225605ff433ba2ebbfcf5d0d6889e1fd45d6d32.tar.gz
kdeltachat-e225605ff433ba2ebbfcf5d0d6889e1fd45d6d32.zip
Make it possible to create contacts
-rw-r--r--qml/NewChatPage.qml30
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;