tdesktop/Telegram/SourceFiles/facades.h

155 lines
3.6 KiB
C
Raw Normal View History

2015-12-07 13:05:00 +00:00
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
2015-12-07 13:05:00 +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"
class History;
namespace Data {
struct FileOrigin;
} // namespace Data
namespace InlineBots {
namespace Layout {
class ItemBase;
} // namespace Layout
} // namespace InlineBots
2015-12-07 13:05:00 +00:00
namespace App {
template <typename Guard, typename Lambda>
[[nodiscard]] inline auto LambdaDelayed(int duration, Guard &&object, Lambda &&lambda) {
auto guarded = crl::guard(
std::forward<Guard>(object),
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));
};
}
void sendBotCommand(
2020-06-10 18:08:17 +00:00
not_null<PeerData*> peer,
UserData *bot,
const QString &cmd,
MsgId replyTo = 0);
bool insertBotCommand(const QString &cmd);
void activateBotCommand(
not_null<const HistoryItem*> msg,
int row,
int column);
void searchByHashtag(const QString &tag, PeerData *inPeer);
} // namespace App
2015-12-07 13:05:00 +00:00
namespace Ui {
// Legacy global methods.
2015-12-07 18:09:05 +00:00
void showPeerProfile(not_null<PeerData*> peer);
void showPeerProfile(not_null<const History*> history);
void showPeerHistoryAtItem(not_null<const HistoryItem*> item);
2020-06-10 18:08:17 +00:00
void showPeerHistory(not_null<const PeerData*> peer, MsgId msgId);
void showPeerHistory(not_null<const History*> history, MsgId msgId);
void showChatsList(not_null<Main::Session*> session);
PeerData *getPeerForMouseAction();
bool skipPaintEvent(QWidget *widget, QPaintEvent *event);
} // 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
bool switchInlineBotButtonReceived(
not_null<Main::Session*> session,
const QString &query,
UserData *samePeerBot = nullptr,
MsgId samePeerReplyTo = 0);
} // namespace Notify
#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 {
enum class WindowLayout {
OneColumn,
Normal,
ThreeColumn,
};
enum class ChatLayout {
Normal,
Wide,
};
} // namespace Adaptive
namespace Global {
bool started();
void start();
void finish();
DeclareVar(bool, ScreenIsLocked);
DeclareVar(Adaptive::ChatLayout, AdaptiveChatLayout);
DeclareVar(Adaptive::WindowLayout, AdaptiveWindowLayout);
DeclareRefVar(base::Observable<void>, AdaptiveChanged);
DeclareVar(bool, NotificationsDemoIsShown);
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);
DeclareRefVar(base::Observable<void>, ConnectionTypeChanged);
DeclareVar(bool, LocalPasscode);
DeclareRefVar(base::Observable<void>, LocalPasscodeChanged);
DeclareRefVar(base::Variable<DBIWorkMode>, WorkMode);
DeclareRefVar(base::Observable<void>, PeerChooseCancel);
} // namespace Global
namespace Adaptive {
inline base::Observable<void> &Changed() {
return Global::RefAdaptiveChanged();
}
inline bool OneColumn() {
return Global::AdaptiveWindowLayout() == WindowLayout::OneColumn;
}
inline bool Normal() {
return Global::AdaptiveWindowLayout() == WindowLayout::Normal;
}
inline bool ThreeColumn() {
return Global::AdaptiveWindowLayout() == WindowLayout::ThreeColumn;
}
} // namespace Adaptive