2015-12-07 13:05:00 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2015-12-07 13:05:00 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2015-12-07 13:05:00 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-04-06 14:38:10 +00:00
|
|
|
#include "base/type_traits.h"
|
|
|
|
#include "base/observer.h"
|
2019-09-26 10:55:35 +00:00
|
|
|
#include "base/call_delayed.h"
|
2019-11-13 14:12:04 +00:00
|
|
|
#include "mtproto/mtproto_proxy_data.h"
|
2016-10-14 17:10:15 +00:00
|
|
|
|
2019-09-13 06:06:02 +00:00
|
|
|
class History;
|
2016-10-14 18:27:42 +00:00
|
|
|
|
2019-01-04 11:09:48 +00:00
|
|
|
namespace Data {
|
|
|
|
struct FileOrigin;
|
|
|
|
} // namespace Data
|
|
|
|
|
2016-08-27 04:49:18 +00:00
|
|
|
namespace InlineBots {
|
|
|
|
namespace Layout {
|
|
|
|
class ItemBase;
|
|
|
|
} // namespace Layout
|
|
|
|
} // namespace InlineBots
|
|
|
|
|
2015-12-07 13:05:00 +00:00
|
|
|
namespace App {
|
2017-10-27 17:00:56 +00:00
|
|
|
|
2018-06-04 15:35:11 +00:00
|
|
|
template <typename Guard, typename Lambda>
|
2019-08-16 17:07:30 +00:00
|
|
|
[[nodiscard]] inline auto LambdaDelayed(int duration, Guard &&object, Lambda &&lambda) {
|
2018-06-04 15:35:11 +00:00
|
|
|
auto guarded = crl::guard(
|
|
|
|
std::forward<Guard>(object),
|
2017-10-27 17:00:56 +00:00
|
|
|
std::forward<Lambda>(lambda));
|
|
|
|
return [saved = std::move(guarded), duration] {
|
|
|
|
auto copy = saved;
|
2019-09-26 10:55:35 +00:00
|
|
|
base::call_delayed(duration, std::move(copy));
|
2017-10-27 17:00:56 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-12-18 15:44:50 +00:00
|
|
|
void sendBotCommand(
|
2020-06-10 18:08:17 +00:00
|
|
|
not_null<PeerData*> peer,
|
2017-12-18 15:44:50 +00:00
|
|
|
UserData *bot,
|
|
|
|
const QString &cmd,
|
|
|
|
MsgId replyTo = 0);
|
2017-03-27 18:11:51 +00:00
|
|
|
bool insertBotCommand(const QString &cmd);
|
2017-12-18 15:44:50 +00:00
|
|
|
void activateBotCommand(
|
|
|
|
not_null<const HistoryItem*> msg,
|
|
|
|
int row,
|
|
|
|
int column);
|
2016-04-11 10:59:01 +00:00
|
|
|
void searchByHashtag(const QString &tag, PeerData *inPeer);
|
|
|
|
void showSettings();
|
2016-03-31 14:06:40 +00:00
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
} // namespace App
|
2015-12-07 13:05:00 +00:00
|
|
|
|
2016-01-11 15:43:29 +00:00
|
|
|
namespace Ui {
|
2016-12-13 17:07:56 +00:00
|
|
|
|
2019-09-13 06:06:02 +00:00
|
|
|
// Legacy global methods.
|
2015-12-07 18:09:05 +00:00
|
|
|
|
2020-06-18 18:04:16 +00:00
|
|
|
void showPeerProfile(not_null<PeerData*> peer);
|
2018-01-13 12:45:11 +00:00
|
|
|
void showPeerProfile(not_null<const History*> history);
|
2016-04-30 17:04:14 +00:00
|
|
|
|
2018-01-11 19:33:26 +00:00
|
|
|
void showPeerHistoryAtItem(not_null<const HistoryItem*> item);
|
2020-06-10 18:08:17 +00:00
|
|
|
void showPeerHistory(not_null<const PeerData*> peer, MsgId msgId);
|
2018-01-13 12:45:11 +00:00
|
|
|
void showPeerHistory(not_null<const History*> history, MsgId msgId);
|
2020-06-18 18:04:16 +00:00
|
|
|
void showChatsList(not_null<Main::Session*> session);
|
2016-04-11 10:59:01 +00:00
|
|
|
PeerData *getPeerForMouseAction();
|
2015-12-12 22:29:33 +00:00
|
|
|
|
2016-05-12 16:05:20 +00:00
|
|
|
bool skipPaintEvent(QWidget *widget, QPaintEvent *event);
|
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
} // namespace Ui
|
2015-12-07 13:05:00 +00:00
|
|
|
|
2015-12-27 21:37:48 +00:00
|
|
|
enum ClipStopperType {
|
|
|
|
ClipStopperMediaview,
|
|
|
|
ClipStopperSavedGifsPanel,
|
|
|
|
};
|
|
|
|
|
2015-12-07 13:05:00 +00:00
|
|
|
namespace Notify {
|
|
|
|
|
2020-06-10 18:08:17 +00:00
|
|
|
void replyMarkupUpdated(not_null<const HistoryItem*> item);
|
|
|
|
void inlineKeyboardMoved(
|
|
|
|
not_null<const HistoryItem*> item,
|
|
|
|
int oldKeyboardTop,
|
|
|
|
int newKeyboardTop);
|
|
|
|
bool switchInlineBotButtonReceived(
|
|
|
|
not_null<Main::Session*> session,
|
|
|
|
const QString &query,
|
|
|
|
UserData *samePeerBot = nullptr,
|
|
|
|
MsgId samePeerReplyTo = 0);
|
2016-01-01 09:58:05 +00:00
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
} // namespace Notify
|
2016-01-09 11:24:16 +00:00
|
|
|
|
2016-02-08 14:54:55 +00:00
|
|
|
#define DeclareReadOnlyVar(Type, Name) const Type &Name();
|
|
|
|
#define DeclareRefVar(Type, Name) DeclareReadOnlyVar(Type, Name) \
|
|
|
|
Type &Ref##Name();
|
|
|
|
#define DeclareVar(Type, Name) DeclareRefVar(Type, Name) \
|
|
|
|
void Set##Name(const Type &Name);
|
|
|
|
|
|
|
|
namespace Adaptive {
|
2017-01-14 18:50:16 +00:00
|
|
|
|
|
|
|
enum class WindowLayout {
|
|
|
|
OneColumn,
|
|
|
|
Normal,
|
2017-09-16 16:53:41 +00:00
|
|
|
ThreeColumn,
|
2017-01-14 18:50:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum class ChatLayout {
|
|
|
|
Normal,
|
|
|
|
Wide,
|
2016-02-08 14:54:55 +00:00
|
|
|
};
|
2017-01-14 18:50:16 +00:00
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
} // namespace Adaptive
|
2016-02-08 14:54:55 +00:00
|
|
|
|
|
|
|
namespace Global {
|
2016-01-11 15:43:29 +00:00
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
bool started();
|
|
|
|
void start();
|
|
|
|
void finish();
|
2016-01-11 15:43:29 +00:00
|
|
|
|
2020-06-18 11:17:58 +00:00
|
|
|
DeclareVar(bool, ScreenIsLocked);
|
2017-01-14 18:50:16 +00:00
|
|
|
DeclareVar(Adaptive::ChatLayout, AdaptiveChatLayout);
|
2020-06-18 18:04:16 +00:00
|
|
|
DeclareVar(Adaptive::WindowLayout, AdaptiveWindowLayout);
|
2016-08-27 04:49:18 +00:00
|
|
|
DeclareRefVar(base::Observable<void>, AdaptiveChanged);
|
|
|
|
|
2016-10-06 16:41:09 +00:00
|
|
|
DeclareVar(bool, NotificationsDemoIsShown);
|
2016-08-27 04:49:18 +00:00
|
|
|
|
2018-05-06 21:29:53 +00:00
|
|
|
DeclareVar(bool, TryIPv6);
|
2019-11-13 14:12:04 +00:00
|
|
|
DeclareVar(std::vector<MTP::ProxyData>, ProxiesList);
|
|
|
|
DeclareVar(MTP::ProxyData, SelectedProxy);
|
|
|
|
DeclareVar(MTP::ProxyData::Settings, ProxySettings);
|
2018-05-06 21:29:53 +00:00
|
|
|
DeclareVar(bool, UseProxyForCalls);
|
2016-08-27 04:49:18 +00:00
|
|
|
DeclareRefVar(base::Observable<void>, ConnectionTypeChanged);
|
|
|
|
|
2016-08-28 19:16:23 +00:00
|
|
|
DeclareVar(bool, LocalPasscode);
|
|
|
|
DeclareRefVar(base::Observable<void>, LocalPasscodeChanged);
|
|
|
|
|
2017-03-04 19:36:59 +00:00
|
|
|
DeclareRefVar(base::Variable<DBIWorkMode>, WorkMode);
|
|
|
|
|
2016-11-06 17:23:13 +00:00
|
|
|
DeclareRefVar(base::Observable<void>, PeerChooseCancel);
|
2019-01-14 06:34:51 +00:00
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
} // namespace Global
|
2016-02-08 14:54:55 +00:00
|
|
|
|
|
|
|
namespace Adaptive {
|
2016-04-11 10:59:01 +00:00
|
|
|
|
2016-08-27 04:49:18 +00:00
|
|
|
inline base::Observable<void> &Changed() {
|
|
|
|
return Global::RefAdaptiveChanged();
|
|
|
|
}
|
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
inline bool OneColumn() {
|
2017-01-14 18:50:16 +00:00
|
|
|
return Global::AdaptiveWindowLayout() == WindowLayout::OneColumn;
|
2016-04-11 10:59:01 +00:00
|
|
|
}
|
2017-01-14 18:50:16 +00:00
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
inline bool Normal() {
|
2017-01-14 18:50:16 +00:00
|
|
|
return Global::AdaptiveWindowLayout() == WindowLayout::Normal;
|
2016-04-11 10:59:01 +00:00
|
|
|
}
|
2017-01-14 18:50:16 +00:00
|
|
|
|
2017-09-16 16:53:41 +00:00
|
|
|
inline bool ThreeColumn() {
|
|
|
|
return Global::AdaptiveWindowLayout() == WindowLayout::ThreeColumn;
|
|
|
|
}
|
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
} // namespace Adaptive
|