1 /*
2 This file is part of Telegram Desktop,
3 the official desktop application for the Telegram messaging service.
4 
5 For license and copyright information please follow this link:
6 https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
7 */
8 #pragma once
9 
10 #include "base/type_traits.h"
11 #include "base/observer.h"
12 #include "base/call_delayed.h"
13 #include "mtproto/mtproto_proxy_data.h"
14 
15 class History;
16 
17 namespace Main {
18 class Session;
19 } // namespace Main
20 
21 namespace Window {
22 class SessionController;
23 } // namespace Window
24 
25 namespace App {
26 
27 template <typename Guard, typename Lambda>
LambdaDelayed(int duration,Guard && object,Lambda && lambda)28 [[nodiscard]] inline auto LambdaDelayed(int duration, Guard &&object, Lambda &&lambda) {
29 	auto guarded = crl::guard(
30 		std::forward<Guard>(object),
31 		std::forward<Lambda>(lambda));
32 	return [saved = std::move(guarded), duration] {
33 		auto copy = saved;
34 		base::call_delayed(duration, std::move(copy));
35 	};
36 }
37 
38 bool insertBotCommand(const QString &cmd);
39 void activateBotCommand(
40 	Window::SessionController *sessionController,
41 	not_null<const HistoryItem*> msg,
42 	int row,
43 	int column);
44 
45 } // namespace App
46 
47 namespace Ui {
48 
49 // Legacy global methods.
50 
51 void showPeerProfile(not_null<PeerData*> peer);
52 void showPeerProfile(not_null<const History*> history);
53 
54 void showPeerHistory(not_null<const PeerData*> peer, MsgId msgId);
55 void showPeerHistory(not_null<const History*> history, MsgId msgId);
56 void showChatsList(not_null<Main::Session*> session);
57 PeerData *getPeerForMouseAction();
58 
59 bool skipPaintEvent(QWidget *widget, QPaintEvent *event);
60 
61 } // namespace Ui
62 
63 enum ClipStopperType {
64 	ClipStopperMediaview,
65 	ClipStopperSavedGifsPanel,
66 };
67 
68 namespace Notify {
69 
70 bool switchInlineBotButtonReceived(
71 	not_null<Main::Session*> session,
72 	const QString &query,
73 	UserData *samePeerBot = nullptr,
74 	MsgId samePeerReplyTo = 0);
75 
76 } // namespace Notify
77