2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-03 07:56:03 +00:00

Allow sending silent messages.

This commit is contained in:
John Preston
2019-07-26 18:06:22 +02:00
parent f1cd70d8a8
commit 3f2cc01f48
16 changed files with 118 additions and 66 deletions

View File

@@ -14,8 +14,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/qthelp_url.h"
#include "boxes/abstract_box.h"
#include "ui/wrap/vertical_layout.h"
#include "ui/widgets/popup_menu.h"
#include "data/data_session.h"
#include "data/data_user.h"
#include "core/event_filter.h"
#include "chat_helpers/emoji_suggestions_widget.h"
#include "window/window_session_controller.h"
#include "lang/lang_keys.h"
@@ -772,3 +774,19 @@ void MessageLinksParser::apply(
}
_list = std::move(parsed);
}
void SetupSendWithoutSound(
not_null<Ui::RpWidget*> button,
Fn<bool()> enabled,
Fn<void()> send) {
const auto menu = std::make_shared<base::unique_qptr<Ui::PopupMenu>>();
Core::InstallEventFilter(button, [=](not_null<QEvent*> e) {
if (e->type() == QEvent::ContextMenu && enabled()) {
*menu = base::make_unique_q<Ui::PopupMenu>(button);
(*menu)->addAction(tr::lng_send_silent_message(tr::now), send);
(*menu)->popup(QCursor::pos());
return true;
}
return false;
});
}