mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
[Improvement] Allow to search messages from user
This commit is contained in:
committed by
Eric Kotato
parent
f6431aa08b
commit
cbda1d7d39
@@ -84,6 +84,7 @@
|
|||||||
"ktg_hide_pinned_message": "Hide",
|
"ktg_hide_pinned_message": "Hide",
|
||||||
"ktg_stickers_copy_title": "Copy name",
|
"ktg_stickers_copy_title": "Copy name",
|
||||||
"ktg_stickers_title_copied": "Sticker pack name copied to clipboard.",
|
"ktg_stickers_title_copied": "Sticker pack name copied to clipboard.",
|
||||||
|
"ktg_context_show_messages_from": "User messages",
|
||||||
"ktg_settings_tray_icon": "Tray icon",
|
"ktg_settings_tray_icon": "Tray icon",
|
||||||
"ktg_settings_tray_icon_default": "Default",
|
"ktg_settings_tray_icon_default": "Default",
|
||||||
"ktg_settings_tray_icon_blue": "Blue",
|
"ktg_settings_tray_icon_blue": "Blue",
|
||||||
|
@@ -7,6 +7,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
*/
|
*/
|
||||||
#include "boxes/peers/edit_participants_box.h"
|
#include "boxes/peers/edit_participants_box.h"
|
||||||
|
|
||||||
|
#include "kotato/kotato_lang.h"
|
||||||
|
#include "core/application.h"
|
||||||
#include "api/api_chat_participants.h"
|
#include "api/api_chat_participants.h"
|
||||||
#include "boxes/peers/edit_participant_box.h"
|
#include "boxes/peers/edit_participant_box.h"
|
||||||
#include "boxes/peers/add_participants_box.h"
|
#include "boxes/peers/add_participants_box.h"
|
||||||
@@ -20,6 +22,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
#include "mtproto/mtproto_config.h"
|
#include "mtproto/mtproto_config.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
|
#include "mainwindow.h"
|
||||||
|
#include "mainwidget.h"
|
||||||
#include "dialogs/dialogs_indexed_list.h"
|
#include "dialogs/dialogs_indexed_list.h"
|
||||||
#include "data/data_peer_values.h"
|
#include "data/data_peer_values.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
@@ -32,6 +36,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
#include "ui/effects/outline_segments.h"
|
#include "ui/effects/outline_segments.h"
|
||||||
#include "ui/widgets/popup_menu.h"
|
#include "ui/widgets/popup_menu.h"
|
||||||
#include "info/profile/info_profile_values.h"
|
#include "info/profile/info_profile_values.h"
|
||||||
|
#include "window/window_controller.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "styles/style_menu_icons.h"
|
#include "styles/style_menu_icons.h"
|
||||||
@@ -1630,6 +1635,20 @@ base::unique_qptr<Ui::PopupMenu> ParticipantsBoxController::rowContextMenu(
|
|||||||
? &st::menuIconProfile
|
? &st::menuIconProfile
|
||||||
: &st::menuIconInfo));
|
: &st::menuIconInfo));
|
||||||
}
|
}
|
||||||
|
if (const auto window = _navigation->parentController()) {
|
||||||
|
if (const auto mainwidget = window->widget()->sessionContent()) {
|
||||||
|
result->addAction(
|
||||||
|
ktr("ktg_context_show_messages_from"),
|
||||||
|
crl::guard(this, [=] {
|
||||||
|
mainwidget->searchMessages(
|
||||||
|
" ",
|
||||||
|
(_peer && !_peer->isUser())
|
||||||
|
? _peer->owner().history(_peer).get()
|
||||||
|
: Dialogs::Key(),
|
||||||
|
user);
|
||||||
|
}), &st::menuIconSearch);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (const auto by = _additional.restrictedBy(participant)) {
|
if (const auto by = _additional.restrictedBy(participant)) {
|
||||||
result->addAction(
|
result->addAction(
|
||||||
(_role == Role::Kicked
|
(_role == Role::Kicked
|
||||||
|
@@ -41,6 +41,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "main/main_domain.h"
|
#include "main/main_domain.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
|
#include "main/main_account.h"
|
||||||
#include "main/main_session_settings.h"
|
#include "main/main_session_settings.h"
|
||||||
#include "api/api_chat_filters.h"
|
#include "api/api_chat_filters.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
@@ -2088,7 +2089,10 @@ void Widget::showMainMenu() {
|
|||||||
controller()->widget()->showMainMenu();
|
controller()->widget()->showMainMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::searchMessages(QString query, Key inChat) {
|
void Widget::searchMessages(
|
||||||
|
QString query,
|
||||||
|
Key inChat,
|
||||||
|
UserData *from) {
|
||||||
if (_childList) {
|
if (_childList) {
|
||||||
const auto forum = controller()->shownForum().current();
|
const auto forum = controller()->shownForum().current();
|
||||||
const auto topic = inChat.topic();
|
const auto topic = inChat.topic();
|
||||||
@@ -2138,13 +2142,19 @@ void Widget::searchMessages(QString query, Key inChat) {
|
|||||||
cancelSearch();
|
cancelSearch();
|
||||||
setSearchInChat(inChat, nullptr, tags);
|
setSearchInChat(inChat, nullptr, tags);
|
||||||
}
|
}
|
||||||
|
if (!query.trimmed().isEmpty()) {
|
||||||
setSearchQuery(query);
|
setSearchQuery(query);
|
||||||
|
}
|
||||||
applySearchUpdate(true);
|
applySearchUpdate(true);
|
||||||
_searchTimer.cancel();
|
_searchTimer.cancel();
|
||||||
searchMessages();
|
searchMessages();
|
||||||
|
|
||||||
session().local().saveRecentSearchHashtags(query);
|
session().local().saveRecentSearchHashtags(query);
|
||||||
}
|
}
|
||||||
|
if (inChat && from) {
|
||||||
|
setSearchInChat(inChat, from);
|
||||||
|
applySearchUpdate(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::searchTopics() {
|
void Widget::searchTopics() {
|
||||||
|
@@ -120,7 +120,7 @@ public:
|
|||||||
|
|
||||||
void scrollToEntry(const RowDescriptor &entry);
|
void scrollToEntry(const RowDescriptor &entry);
|
||||||
|
|
||||||
void searchMessages(QString query, Key inChat = {});
|
void searchMessages(QString query, Key inChat = {}, UserData *from = nullptr);
|
||||||
void searchTopics();
|
void searchTopics();
|
||||||
void searchMore();
|
void searchMore();
|
||||||
|
|
||||||
|
@@ -8,6 +8,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
#include "history/history_inner_widget.h"
|
#include "history/history_inner_widget.h"
|
||||||
|
|
||||||
#include "kotato/kotato_settings.h"
|
#include "kotato/kotato_settings.h"
|
||||||
|
#include "kotato/kotato_lang.h"
|
||||||
|
#include "mainwidget.h"
|
||||||
#include "chat_helpers/stickers_emoji_pack.h"
|
#include "chat_helpers/stickers_emoji_pack.h"
|
||||||
#include "core/file_utilities.h"
|
#include "core/file_utilities.h"
|
||||||
#include "core/click_handler_types.h"
|
#include "core/click_handler_types.h"
|
||||||
@@ -2162,6 +2164,17 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||||||
Window::ToggleMessagePinned(controller, pinItemId, !isPinned);
|
Window::ToggleMessagePinned(controller, pinItemId, !isPinned);
|
||||||
}), isPinned ? &st::menuIconUnpin : &st::menuIconPin);
|
}), isPinned ? &st::menuIconUnpin : &st::menuIconPin);
|
||||||
}
|
}
|
||||||
|
const auto peer = item->history()->peer;
|
||||||
|
if (peer->isChat() || peer->isMegagroup()) {
|
||||||
|
_menu->addAction(ktr("ktg_context_show_messages_from"), [=] {
|
||||||
|
controller->content()->searchMessages(
|
||||||
|
" ",
|
||||||
|
(peer && !peer->isUser())
|
||||||
|
? peer->owner().history(peer).get()
|
||||||
|
: Dialogs::Key(),
|
||||||
|
item->from()->asUser());
|
||||||
|
}, &st::menuIconSearch);
|
||||||
|
}
|
||||||
if (!item->isService()
|
if (!item->isService()
|
||||||
&& peerIsChannel(itemId.peer)
|
&& peerIsChannel(itemId.peer)
|
||||||
&& !_peer->isMegagroup()) {
|
&& !_peer->isMegagroup()) {
|
||||||
|
@@ -731,9 +731,9 @@ void MainWidget::hideSingleUseKeyboard(FullMsgId replyToId) {
|
|||||||
_history->hideSingleUseKeyboard(replyToId);
|
_history->hideSingleUseKeyboard(replyToId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::searchMessages(const QString &query, Dialogs::Key inChat) {
|
void MainWidget::searchMessages(const QString &query, Dialogs::Key inChat, UserData *from) {
|
||||||
if (controller()->isPrimary()) {
|
if (controller()->isPrimary()) {
|
||||||
_dialogs->searchMessages(query, inChat);
|
_dialogs->searchMessages(query, inChat, from);
|
||||||
if (isOneColumn()) {
|
if (isOneColumn()) {
|
||||||
_controller->clearSectionStack();
|
_controller->clearSectionStack();
|
||||||
} else {
|
} else {
|
||||||
@@ -753,7 +753,7 @@ void MainWidget::searchMessages(const QString &query, Dialogs::Key inChat) {
|
|||||||
const auto account = &session().account();
|
const auto account = &session().account();
|
||||||
if (const auto window = Core::App().windowFor(account)) {
|
if (const auto window = Core::App().windowFor(account)) {
|
||||||
if (const auto controller = window->sessionController()) {
|
if (const auto controller = window->sessionController()) {
|
||||||
controller->content()->searchMessages(query, inChat);
|
controller->content()->searchMessages(query, inChat, from);
|
||||||
controller->widget()->activate();
|
controller->widget()->activate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -185,7 +185,7 @@ public:
|
|||||||
void sendBotCommand(Bot::SendCommandRequest request);
|
void sendBotCommand(Bot::SendCommandRequest request);
|
||||||
void hideSingleUseKeyboard(FullMsgId replyToId);
|
void hideSingleUseKeyboard(FullMsgId replyToId);
|
||||||
|
|
||||||
void searchMessages(const QString &query, Dialogs::Key inChat);
|
void searchMessages(const QString &query, Dialogs::Key inChat, UserData *from = nullptr);
|
||||||
|
|
||||||
void setChatBackground(
|
void setChatBackground(
|
||||||
const Data::WallPaper &background,
|
const Data::WallPaper &background,
|
||||||
|
Reference in New Issue
Block a user