diff --git a/harbour-fernschreiber.pro b/harbour-fernschreiber.pro
index dc12009..f751a28 100644
--- a/harbour-fernschreiber.pro
+++ b/harbour-fernschreiber.pro
@@ -84,6 +84,7 @@ DISTFILES += qml/harbour-fernschreiber.qml \
qml/pages/AboutPage.qml \
qml/pages/PollCreationPage.qml \
qml/pages/PollResultsPage.qml \
+ qml/pages/SearchChatsPage.qml \
qml/pages/SettingsPage.qml \
qml/pages/VideoPage.qml \
rpm/harbour-fernschreiber.changes \
diff --git a/qml/pages/OverviewPage.qml b/qml/pages/OverviewPage.qml
index cbb7775..4c24d69 100644
--- a/qml/pages/OverviewPage.qml
+++ b/qml/pages/OverviewPage.qml
@@ -230,6 +230,10 @@ Page {
text: qsTr("Settings")
onClicked: pageStack.push(Qt.resolvedUrl("../pages/SettingsPage.qml"))
}
+ MenuItem {
+ text: qsTr("Search Chats")
+ onClicked: pageStack.push(Qt.resolvedUrl("../pages/SearchChatsPage.qml"))
+ }
MenuItem {
text: qsTr("New Chat")
onClicked: pageStack.push(Qt.resolvedUrl("../pages/NewChatPage.qml"))
@@ -285,7 +289,6 @@ Page {
width: visible ? ( parent.width - pageStatus.width ) : 0
height: pageHeader.height
placeholderText: qsTr("Filter your chats...")
- active: searchHeaderItem.visible
canHide: text === ""
onTextChanged: {
diff --git a/qml/pages/SearchChatsPage.qml b/qml/pages/SearchChatsPage.qml
new file mode 100644
index 0000000..1bd590c
--- /dev/null
+++ b/qml/pages/SearchChatsPage.qml
@@ -0,0 +1,258 @@
+/*
+ Copyright (C) 2020 Sebastian J. Wolf and other contributors
+
+ This file is part of Fernschreiber.
+
+ Fernschreiber is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Fernschreiber is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Fernschreiber. If not, see .
+*/
+import QtQuick 2.6
+import Sailfish.Silica 1.0
+import WerkWolf.Fernschreiber 1.0
+import "../components"
+import "../js/debug.js" as Debug
+import "../js/twemoji.js" as Emoji
+import "../js/functions.js" as Functions
+
+Page {
+ id: searchChatsPage
+ allowedOrientations: Orientation.All
+
+ function resetFocus() {
+ publicChatsSearchField.focus = false;
+ searchChatsPage.focus = true;
+ }
+
+ Timer {
+ id: searchPublicChatsTimer
+ interval: 800
+ running: false
+ repeat: false
+ onTriggered: {
+ Debug.log("Searching for '" + publicChatsSearchField.text + "'");
+ tdLibWrapper.searchPublicChats(publicChatsSearchField.text);
+ searchChatsPage.isLoading = true;
+ }
+ }
+
+ Connections {
+ target: tdLibWrapper
+ onChatsReceived: {
+ searchChatsPage.isLoading = false;
+ Debug.log(JSON.stringify(chats));
+ chatsFound = chats;
+ }
+ }
+
+ property bool isLoading: false;
+ property var chatsFound;
+ readonly property var ownUserId: tdLibWrapper.getUserInformation().id;
+
+ SilicaFlickable {
+ id: searchChatsContainer
+ contentHeight: searchChatsPage.height
+ anchors.fill: parent
+
+ Column {
+ id: searchChatsPageColumn
+ width: searchChatsPage.width
+ height: searchChatsPage.height
+
+ PageHeader {
+ id: searchChatsPageHeader
+ title: qsTr("Search Chats")
+ }
+
+ Item {
+ id: publicChatsItem
+
+ width: searchChatsPageColumn.width
+ height: searchChatsPageColumn.height - searchChatsPageHeader.height
+
+ Column {
+
+ width: parent.width
+ height: parent.height
+
+ SearchField {
+ id: publicChatsSearchField
+ width: parent.width
+ placeholderText: qsTr("Search a chat...")
+ focus: true
+
+ onTextChanged: {
+ searchPublicChatsTimer.restart();
+ }
+
+ EnterKey.iconSource: "image://theme/icon-m-enter-close"
+ EnterKey.onClicked: {
+ resetFocus();
+ }
+
+ }
+
+ SilicaListView {
+ id: searchChatsListView
+ clip: true
+ width: parent.width
+ height: parent.height - publicChatsSearchField.height
+ visible: !searchChatsPage.isLoading
+ opacity: visible ? 1 : 0
+ Behavior on opacity { FadeAnimation {} }
+ model: searchChatsPage.chatsFound.chat_ids
+
+ ViewPlaceholder {
+ y: Theme.paddingLarge
+ enabled: searchChatsListView.count === 0
+ text: publicChatsSearchField.text.length < 5 ? qsTr("Enter your query to start searching (at least 5 characters needed)") : qsTr("No chats found.")
+ }
+
+ delegate: Item {
+ id: foundChatListDelegate
+ width: parent.width
+ height: foundChatListItem.height
+
+ property var foundChatInformation: tdLibWrapper.getChat(modelData);
+ property var relatedInformation;
+ property bool isPrivateChat: false;
+ property bool isBasicGroup: false;
+ property bool isSupergroup: false;
+
+ Component.onCompleted: {
+ switch (foundChatInformation.type["@type"]) {
+ case "chatTypePrivate":
+ relatedInformation = tdLibWrapper.getUserInformation(foundChatInformation.type.user_id);
+ foundChatListItem.prologSecondaryText.text = qsTr("Private Chat");
+ foundChatListItem.secondaryText.text = "@" + ( relatedInformation.username !== "" ? relatedInformation.username : relatedInformation.user_id );
+ tdLibWrapper.getUserFullInfo(foundChatInformation.type.user_id);
+ isPrivateChat = true;
+ break;
+ case "chatTypeBasicGroup":
+ relatedInformation = tdLibWrapper.getBasicGroup(foundChatInformation.type.basic_group_id);
+ foundChatListItem.prologSecondaryText.text = qsTr("Group");
+ tdLibWrapper.getGroupFullInfo(foundChatInformation.type.basic_group_id, false);
+ isBasicGroup = true;
+ break;
+ case "chatTypeSupergroup":
+ relatedInformation = tdLibWrapper.getSuperGroup(foundChatInformation.type.supergroup_id);
+ if (relatedInformation.is_channel) {
+ foundChatListItem.prologSecondaryText.text = qsTr("Channel");
+ } else {
+ foundChatListItem.prologSecondaryText.text = qsTr("Group");
+ }
+ tdLibWrapper.getGroupFullInfo(foundChatInformation.type.supergroup_id, true);
+ isSupergroup = true;
+ break;
+ }
+ }
+
+ Connections {
+ target: tdLibWrapper
+ onUserFullInfoUpdated: {
+ if (foundChatListDelegate.isPrivateChat && userId.toString() === foundChatListDelegate.foundChatInformation.type.user_id.toString()) {
+ foundChatListItem.tertiaryText.text = Emoji.emojify(userFullInfo.bio, foundChatListItem.tertiaryText.font.pixelSize, "../js/emoji/");
+ }
+ }
+ onUserFullInfoReceived: {
+ if (foundChatListDelegate.isPrivateChat && userFullInfo["@extra"].toString() === foundChatListDelegate.foundChatInformation.type.user_id.toString()) {
+ foundChatListItem.tertiaryText.text = Emoji.emojify(userFullInfo.bio, foundChatListItem.tertiaryText.font.pixelSize, "../js/emoji/");
+ }
+ }
+
+ onBasicGroupFullInfoUpdated: {
+ if (foundChatListDelegate.isBasicGroup && groupId.toString() === foundChatListDelegate.foundChatInformation.type.basic_group_id.toString()) {
+ foundChatListItem.secondaryText.text = qsTr("%1 members").arg(Number(groupFullInfo.members.length).toLocaleString(Qt.locale(), "f", 0));
+ foundChatListItem.tertiaryText.text = Emoji.emojify(groupFullInfo.description, foundChatListItem.tertiaryText.font.pixelSize, "../js/emoji/");
+ }
+ }
+ onBasicGroupFullInfoReceived: {
+ if (foundChatListDelegate.isBasicGroup && groupId.toString() === foundChatListDelegate.foundChatInformation.type.basic_group_id.toString()) {
+ foundChatListItem.secondaryText.text = qsTr("%1 members").arg(Number(groupFullInfo.members.length).toLocaleString(Qt.locale(), "f", 0));
+ foundChatListItem.tertiaryText.text = Emoji.emojify(groupFullInfo.description, foundChatListItem.tertiaryText.font.pixelSize, "../js/emoji/");
+ }
+ }
+
+ onSupergroupFullInfoUpdated: {
+ if (foundChatListDelegate.isSupergroup && groupId.toString() === foundChatListDelegate.foundChatInformation.type.supergroup_id.toString()) {
+ if (foundChatListDelegate.relatedInformation.is_channel) {
+ foundChatListItem.secondaryText.text = qsTr("%1 subscribers").arg(Number(groupFullInfo.member_count).toLocaleString(Qt.locale(), "f", 0));
+ } else {
+ foundChatListItem.secondaryText.text = qsTr("%1 members").arg(Number(groupFullInfo.member_count).toLocaleString(Qt.locale(), "f", 0));
+ }
+ foundChatListItem.tertiaryText.text = Emoji.emojify(groupFullInfo.description, foundChatListItem.tertiaryText.font.pixelSize, "../js/emoji/");
+ }
+ }
+ onSupergroupFullInfoReceived: {
+ if (foundChatListDelegate.isSupergroup && groupId.toString() === foundChatListDelegate.foundChatInformation.type.supergroup_id.toString()) {
+ if (foundChatListDelegate.relatedInformation.is_channel) {
+ foundChatListItem.secondaryText.text = qsTr("%1 subscribers").arg(Number(groupFullInfo.member_count).toLocaleString(Qt.locale(), "f", 0));
+ } else {
+ foundChatListItem.secondaryText.text = qsTr("%1 members").arg(Number(groupFullInfo.member_count).toLocaleString(Qt.locale(), "f", 0));
+ }
+ foundChatListItem.tertiaryText.text = Emoji.emojify(groupFullInfo.description, foundChatListItem.tertiaryText.font.pixelSize, "../js/emoji/");
+ }
+ }
+ }
+
+ PhotoTextsListItem {
+ id: foundChatListItem
+
+ pictureThumbnail {
+ photoData: typeof foundChatInformation.photo.small !== "undefined" ? foundChatInformation.photo.small : {}
+ }
+ width: parent.width
+
+ primaryText.text: Emoji.emojify(foundChatInformation.title, primaryText.font.pixelSize, "../js/emoji/")
+ tertiaryText.maximumLineCount: 1
+
+ onClicked: {
+ pageStack.push(Qt.resolvedUrl("../pages/ChatPage.qml"), { "chatInformation" : foundChatInformation });
+ }
+ }
+ }
+
+ VerticalScrollDecorator {}
+ }
+
+ }
+
+ Column {
+
+ opacity: visible ? 1 : 0
+ Behavior on opacity { FadeAnimation {} }
+ visible: searchChatsPage.isLoading
+ width: parent.width
+ height: loadingLabel.height + loadingBusyIndicator.height + Theme.paddingMedium
+
+ spacing: Theme.paddingMedium
+
+ anchors.verticalCenter: parent.verticalCenter
+
+ InfoLabel {
+ id: loadingLabel
+ text: qsTr("Searching chats...")
+ }
+
+ BusyIndicator {
+ id: loadingBusyIndicator
+ anchors.horizontalCenter: parent.horizontalCenter
+ running: searchChatsPage.isLoading
+ size: BusyIndicatorSize.Large
+ }
+ }
+
+ }
+
+ }
+ }
+}
diff --git a/src/tdlibreceiver.h b/src/tdlibreceiver.h
index aae67bc..6a3068d 100644
--- a/src/tdlibreceiver.h
+++ b/src/tdlibreceiver.h
@@ -74,7 +74,7 @@ signals:
void stickerSet(const QVariantMap &stickerSet);
void chatMembers(const QString &extra, const QVariantList &members, int totalMembers);
void userFullInfo(const QVariantMap &userFullInfo);
- void userFullInfoUpdated(const QString &userId,const QVariantMap &userFullInfo);
+ void userFullInfoUpdated(const QString &userId, const QVariantMap &userFullInfo);
void basicGroupFullInfo(const QString &groupId, const QVariantMap &groupFullInfo);
void basicGroupFullInfoUpdated(const QString &groupId, const QVariantMap &groupFullInfo);
void supergroupFullInfo(const QString &groupId, const QVariantMap &groupFullInfo);
diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp
index eb76c7a..6192505 100644
--- a/src/tdlibwrapper.cpp
+++ b/src/tdlibwrapper.cpp
@@ -951,6 +951,16 @@ void TDLibWrapper::searchChatMessages(const qlonglong &chatId, const QString &qu
this->sendRequest(requestObject);
}
+void TDLibWrapper::searchPublicChats(const QString &query)
+{
+ LOG("Searching public chats" << query);
+ QVariantMap requestObject;
+ requestObject.insert(_TYPE, "searchPublicChats");
+ requestObject.insert("query", query);
+ requestObject.insert(_EXTRA, "searchPublicChats");
+ this->sendRequest(requestObject);
+}
+
void TDLibWrapper::searchEmoji(const QString &queryString)
{
LOG("Searching emoji" << queryString);
diff --git a/src/tdlibwrapper.h b/src/tdlibwrapper.h
index ee808db..cf8053a 100644
--- a/src/tdlibwrapper.h
+++ b/src/tdlibwrapper.h
@@ -180,6 +180,7 @@ public:
Q_INVOKABLE void closeSecretChat(qlonglong secretChatId);
Q_INVOKABLE void importContacts(const QVariantList &contacts);
Q_INVOKABLE void searchChatMessages(const qlonglong &chatId, const QString &query, const qlonglong fromMessageId = 0);
+ Q_INVOKABLE void searchPublicChats(const QString &query);
// Others (candidates for extraction ;))
Q_INVOKABLE void searchEmoji(const QString &queryString);
diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts
index eb1a53b..cc375b2 100644
--- a/translations/harbour-fernschreiber-de.ts
+++ b/translations/harbour-fernschreiber-de.ts
@@ -1038,6 +1038,10 @@
Ihre Chats filtern...
+
+
+ Chats suchen
+
PinnedMessageItem
@@ -1232,6 +1236,49 @@
+
+ SearchChatsPage
+
+
+ Keine Chats gefunden.
+
+
+
+ Suche Chats...
+
+
+
+ Privater Chat
+
+
+
+ Gruppe
+
+
+
+ Kanal
+
+
+
+ %1 Mitglied
+
+
+
+ %1 Abonnent
+
+
+
+ Chats suchen
+
+
+
+ Einen Chat suchen...
+
+
+
+ Geben Sie Ihre Anfrage ein, um die Suche zu starten (mindestens 5 Zeichen benötigt)
+
+
SettingsPage
diff --git a/translations/harbour-fernschreiber-en.ts b/translations/harbour-fernschreiber-en.ts
index 37bbccd..900d55b 100644
--- a/translations/harbour-fernschreiber-en.ts
+++ b/translations/harbour-fernschreiber-en.ts
@@ -1038,6 +1038,10 @@
Filter your chats...
+
+
+ Search Chats
+
PinnedMessageItem
@@ -1232,6 +1236,49 @@
+
+ SearchChatsPage
+
+
+ No chats found.
+
+
+
+ Searching chats...
+
+
+
+ Private Chat
+
+
+
+ Group
+
+
+
+ Channel
+
+
+
+ %1 member
+
+
+
+ %1 subscriber
+
+
+
+ Search Chats
+
+
+
+ Search a chat...
+
+
+
+ Enter your query to start searching (at least 5 characters needed)
+
+
SettingsPage
diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts
index 016a015..f86dab6 100644
--- a/translations/harbour-fernschreiber-es.ts
+++ b/translations/harbour-fernschreiber-es.ts
@@ -1027,6 +1027,10 @@
+
+
+
+
PinnedMessageItem
@@ -1213,6 +1217,49 @@
+
+ SearchChatsPage
+
+
+
+
+
+
+
+
+
+
+ Privado
+
+
+
+
+
+
+
+
+
+
+
+ %1 miembros
+
+
+
+ %1 suscriptores
+
+
+
+
+
+
+
+
+
+
+
+
+
+
SettingsPage
diff --git a/translations/harbour-fernschreiber-fi.ts b/translations/harbour-fernschreiber-fi.ts
index 617a8b2..d6f435b 100644
--- a/translations/harbour-fernschreiber-fi.ts
+++ b/translations/harbour-fernschreiber-fi.ts
@@ -1039,6 +1039,10 @@
+
+
+
+
PinnedMessageItem
@@ -1233,6 +1237,49 @@
+
+ SearchChatsPage
+
+
+
+
+
+
+
+
+
+
+ Yksityinen keskustelu
+
+
+
+
+
+
+
+
+
+
+
+ %1 jäsen
+
+
+
+ %1 tilaaja
+
+
+
+
+
+
+
+
+
+
+
+
+
+
SettingsPage
diff --git a/translations/harbour-fernschreiber-hu.ts b/translations/harbour-fernschreiber-hu.ts
index 7c8f35e..6942ca8 100644
--- a/translations/harbour-fernschreiber-hu.ts
+++ b/translations/harbour-fernschreiber-hu.ts
@@ -1027,6 +1027,10 @@
+
+
+
+
PinnedMessageItem
@@ -1213,6 +1217,49 @@
+
+ SearchChatsPage
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ %1 tag
+
+
+
+ %1 feliratkozott
+
+
+
+
+
+
+
+
+
+
+
+
+
+
SettingsPage
diff --git a/translations/harbour-fernschreiber-it.ts b/translations/harbour-fernschreiber-it.ts
index 11ec827..bb1740c 100644
--- a/translations/harbour-fernschreiber-it.ts
+++ b/translations/harbour-fernschreiber-it.ts
@@ -1038,6 +1038,10 @@
+
+
+
+
PinnedMessageItem
@@ -1232,6 +1236,49 @@
+
+ SearchChatsPage
+
+
+
+
+
+
+
+
+
+
+ Chat privata
+
+
+
+
+
+
+
+
+
+
+
+ %1 membro
+
+
+
+ %1 abbonato
+
+
+
+
+
+
+
+
+
+
+
+
+
+
SettingsPage
diff --git a/translations/harbour-fernschreiber-pl.ts b/translations/harbour-fernschreiber-pl.ts
index d279543..2bfbaf1 100644
--- a/translations/harbour-fernschreiber-pl.ts
+++ b/translations/harbour-fernschreiber-pl.ts
@@ -1049,6 +1049,10 @@
+
+
+
+
PinnedMessageItem
@@ -1251,6 +1255,49 @@
+
+ SearchChatsPage
+
+
+
+
+
+
+
+
+
+
+ Prywatny czat
+
+
+
+
+
+
+
+
+
+
+
+ %1 członek
+
+
+
+ %1 subskrybent
+
+
+
+
+
+
+
+
+
+
+
+
+
+
SettingsPage
diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts
index d76f441..a3ee0c4 100644
--- a/translations/harbour-fernschreiber-ru.ts
+++ b/translations/harbour-fernschreiber-ru.ts
@@ -1049,6 +1049,10 @@
+
+
+
+
PinnedMessageItem
@@ -1251,6 +1255,49 @@
+
+ SearchChatsPage
+
+
+
+
+
+
+
+
+
+
+ Приватный Чат
+
+
+
+
+
+
+
+
+
+
+
+ %1 участников
+
+
+
+ %1 подписчиков
+
+
+
+
+
+
+
+
+
+
+
+
+
+
SettingsPage
diff --git a/translations/harbour-fernschreiber-sv.ts b/translations/harbour-fernschreiber-sv.ts
index 8e64333..95bb2ff 100644
--- a/translations/harbour-fernschreiber-sv.ts
+++ b/translations/harbour-fernschreiber-sv.ts
@@ -1038,6 +1038,10 @@
+
+
+
+
PinnedMessageItem
@@ -1232,6 +1236,49 @@
Valt av:
+
+ SearchChatsPage
+
+
+
+
+
+
+
+
+
+
+ Privat chatt
+
+
+
+
+
+
+
+
+
+
+
+ %1 medlem
+
+
+
+ %1 prenumerant
+
+
+
+
+
+
+
+
+
+
+
+
+
+
SettingsPage
diff --git a/translations/harbour-fernschreiber-zh_CN.ts b/translations/harbour-fernschreiber-zh_CN.ts
index a0b1304..f7113f7 100644
--- a/translations/harbour-fernschreiber-zh_CN.ts
+++ b/translations/harbour-fernschreiber-zh_CN.ts
@@ -1027,6 +1027,10 @@
+
+
+
+
PinnedMessageItem
@@ -1213,6 +1217,49 @@
+
+ SearchChatsPage
+
+
+
+
+
+
+
+
+
+
+ 个人对话
+
+
+
+
+
+
+
+
+
+
+
+ %1 位成员
+
+
+
+ %1 位订阅者
+
+
+
+
+
+
+
+
+
+
+
+
+
+
SettingsPage
diff --git a/translations/harbour-fernschreiber.ts b/translations/harbour-fernschreiber.ts
index abe8bad..c382b0a 100644
--- a/translations/harbour-fernschreiber.ts
+++ b/translations/harbour-fernschreiber.ts
@@ -1038,6 +1038,10 @@
+
+
+
+
PinnedMessageItem
@@ -1232,6 +1236,49 @@
+
+ SearchChatsPage
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ %1 member
+
+
+
+ %1 subscriber
+
+
+
+
+
+
+
+
+
+
+
+
+
+
SettingsPage