2014-05-30 08:53:19 +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.
|
2014-05-30 08:53:19 +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
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#define DeclareReadSetting(Type, Name) extern Type g##Name; \
|
|
|
|
inline const Type &c##Name() { \
|
|
|
|
return g##Name; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define DeclareSetting(Type, Name) DeclareReadSetting(Type, Name) \
|
|
|
|
inline void cSet##Name(const Type &Name) { \
|
|
|
|
g##Name = Name; \
|
|
|
|
}
|
|
|
|
|
2015-05-08 12:45:14 +00:00
|
|
|
#define DeclareRefSetting(Type, Name) DeclareSetting(Type, Name) \
|
|
|
|
inline Type &cRef##Name() { \
|
|
|
|
return g##Name; \
|
|
|
|
}
|
|
|
|
|
2015-04-19 10:29:19 +00:00
|
|
|
DeclareSetting(bool, Rtl);
|
|
|
|
DeclareSetting(Qt::LayoutDirection, LangDir);
|
|
|
|
inline bool rtl() {
|
|
|
|
return cRtl();
|
|
|
|
}
|
|
|
|
|
2018-09-26 15:11:16 +00:00
|
|
|
DeclareSetting(bool, InstallBetaVersion);
|
2018-09-26 14:58:09 +00:00
|
|
|
DeclareSetting(uint64, AlphaVersion);
|
|
|
|
DeclareSetting(uint64, RealAlphaVersion);
|
|
|
|
DeclareSetting(QByteArray, AlphaPrivateKey);
|
2015-07-28 13:47:21 +00:00
|
|
|
|
2015-01-23 15:24:36 +00:00
|
|
|
DeclareSetting(bool, TestMode);
|
2014-05-30 08:53:19 +00:00
|
|
|
DeclareSetting(QString, LoggedPhoneNumber);
|
|
|
|
DeclareSetting(bool, AutoStart);
|
|
|
|
DeclareSetting(bool, StartMinimized);
|
2015-01-27 16:58:58 +00:00
|
|
|
DeclareSetting(bool, StartInTray);
|
2014-07-18 10:37:34 +00:00
|
|
|
DeclareSetting(bool, SendToMenu);
|
2017-02-17 12:50:27 +00:00
|
|
|
DeclareSetting(bool, UseExternalVideoPlayer);
|
2016-01-11 15:43:29 +00:00
|
|
|
enum LaunchMode {
|
|
|
|
LaunchModeNormal = 0,
|
|
|
|
LaunchModeAutoStart,
|
|
|
|
LaunchModeFixPrevious,
|
|
|
|
LaunchModeCleanup,
|
|
|
|
};
|
|
|
|
DeclareReadSetting(LaunchMode, LaunchMode);
|
2014-05-30 08:53:19 +00:00
|
|
|
DeclareSetting(QString, WorkingDir);
|
|
|
|
inline void cForceWorkingDir(const QString &newDir) {
|
|
|
|
cSetWorkingDir(newDir);
|
2017-08-27 22:03:06 +00:00
|
|
|
if (!gWorkingDir.isEmpty()) {
|
|
|
|
QDir().mkpath(gWorkingDir);
|
|
|
|
QFile::setPermissions(gWorkingDir,
|
|
|
|
QFileDevice::ReadUser | QFileDevice::WriteUser | QFileDevice::ExeUser);
|
|
|
|
}
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
2014-11-27 18:20:48 +00:00
|
|
|
DeclareReadSetting(QString, ExeName);
|
2014-05-30 08:53:19 +00:00
|
|
|
DeclareReadSetting(QString, ExeDir);
|
|
|
|
DeclareSetting(QString, DialogLastPath);
|
|
|
|
DeclareSetting(QString, DialogHelperPath);
|
|
|
|
inline const QString &cDialogHelperPathFinal() {
|
|
|
|
return cDialogHelperPath().isEmpty() ? cExeDir() : cDialogHelperPath();
|
|
|
|
}
|
2015-02-03 15:02:46 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
DeclareSetting(bool, AutoUpdate);
|
|
|
|
|
|
|
|
struct TWindowPos {
|
2017-07-03 12:23:41 +00:00
|
|
|
TWindowPos() = default;
|
|
|
|
|
|
|
|
int32 moncrc = 0;
|
|
|
|
int maximized = 0;
|
|
|
|
int x = 0;
|
|
|
|
int y = 0;
|
|
|
|
int w = 0;
|
|
|
|
int h = 0;
|
2014-05-30 08:53:19 +00:00
|
|
|
};
|
|
|
|
DeclareSetting(TWindowPos, WindowPos);
|
2015-01-15 14:22:15 +00:00
|
|
|
DeclareSetting(bool, SupportTray);
|
2014-05-30 08:53:19 +00:00
|
|
|
DeclareSetting(bool, SeenTrayTooltip);
|
|
|
|
DeclareSetting(bool, RestartingUpdate);
|
|
|
|
DeclareSetting(bool, Restarting);
|
2014-12-19 21:20:30 +00:00
|
|
|
DeclareSetting(bool, RestartingToSettings);
|
2014-12-02 16:25:17 +00:00
|
|
|
DeclareSetting(bool, WriteProtected);
|
2014-05-30 08:53:19 +00:00
|
|
|
DeclareSetting(int32, LastUpdateCheck);
|
|
|
|
DeclareSetting(bool, NoStartUpdate);
|
|
|
|
DeclareSetting(bool, StartToSettings);
|
|
|
|
DeclareReadSetting(bool, ManyInstance);
|
2016-08-27 04:49:18 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
DeclareSetting(QByteArray, LocalSalt);
|
2018-10-15 11:44:48 +00:00
|
|
|
DeclareSetting(int, ScreenScale);
|
|
|
|
DeclareSetting(int, ConfigScale);
|
2015-02-10 18:55:04 +00:00
|
|
|
DeclareSetting(QString, TimeFormat);
|
|
|
|
|
2018-10-15 11:44:48 +00:00
|
|
|
inline void cChangeTimeFormat(const QString &newFormat) {
|
|
|
|
if (!newFormat.isEmpty()) cSetTimeFormat(newFormat);
|
2014-11-12 22:35:00 +00:00
|
|
|
}
|
|
|
|
|
2017-02-15 08:50:11 +00:00
|
|
|
namespace Ui {
|
|
|
|
namespace Emoji {
|
|
|
|
class One;
|
|
|
|
} // namespace Emoji
|
|
|
|
} // namespace Ui
|
|
|
|
|
|
|
|
using EmojiPtr = const Ui::Emoji::One*;
|
|
|
|
|
|
|
|
using EmojiPack = QVector<EmojiPtr>;
|
|
|
|
using RecentEmojiPreloadOldOld = QVector<QPair<uint32, ushort>>;
|
|
|
|
using RecentEmojiPreloadOld = QVector<QPair<uint64, ushort>>;
|
|
|
|
using RecentEmojiPreload = QVector<QPair<QString, ushort>>;
|
|
|
|
using RecentEmojiPack = QVector<QPair<EmojiPtr, ushort>>;
|
|
|
|
using EmojiColorVariantsOld = QMap<uint32, uint64>;
|
|
|
|
using EmojiColorVariants = QMap<QString, int>;
|
|
|
|
DeclareRefSetting(RecentEmojiPack, RecentEmoji);
|
|
|
|
DeclareSetting(RecentEmojiPreload, RecentEmojiPreload);
|
2015-05-08 12:45:14 +00:00
|
|
|
DeclareRefSetting(EmojiColorVariants, EmojiVariants);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-12-24 19:26:28 +00:00
|
|
|
class DocumentData;
|
2015-01-05 20:17:33 +00:00
|
|
|
|
2017-12-11 14:45:29 +00:00
|
|
|
typedef QList<QPair<DocumentData*, int16>> RecentStickerPackOld;
|
|
|
|
typedef QVector<QPair<uint64, ushort>> RecentStickerPreload;
|
|
|
|
typedef QVector<QPair<DocumentData*, ushort>> RecentStickerPack;
|
2015-05-19 15:46:45 +00:00
|
|
|
DeclareSetting(RecentStickerPreload, RecentStickersPreload);
|
|
|
|
DeclareRefSetting(RecentStickerPack, RecentStickers);
|
|
|
|
|
2017-12-11 14:45:29 +00:00
|
|
|
typedef QList<QPair<QString, ushort>> RecentHashtagPack;
|
2016-01-01 14:48:32 +00:00
|
|
|
DeclareRefSetting(RecentHashtagPack, RecentWriteHashtags);
|
2015-03-24 10:00:27 +00:00
|
|
|
DeclareSetting(RecentHashtagPack, RecentSearchHashtags);
|
|
|
|
|
2016-01-01 14:48:32 +00:00
|
|
|
class UserData;
|
|
|
|
typedef QVector<UserData*> RecentInlineBots;
|
|
|
|
DeclareRefSetting(RecentInlineBots, RecentInlineBots);
|
|
|
|
|
2015-04-02 10:33:19 +00:00
|
|
|
DeclareSetting(bool, PasswordRecovered);
|
|
|
|
|
2015-04-04 20:01:34 +00:00
|
|
|
DeclareSetting(int32, PasscodeBadTries);
|
2019-02-19 06:57:53 +00:00
|
|
|
DeclareSetting(crl::time, PasscodeLastTry);
|
2015-04-04 20:01:34 +00:00
|
|
|
|
|
|
|
inline bool passcodeCanTry() {
|
|
|
|
if (cPasscodeBadTries() < 3) return true;
|
2019-02-19 06:57:53 +00:00
|
|
|
auto dt = crl::now() - cPasscodeLastTry();
|
2015-04-04 20:01:34 +00:00
|
|
|
switch (cPasscodeBadTries()) {
|
|
|
|
case 3: return dt >= 5000;
|
|
|
|
case 4: return dt >= 10000;
|
|
|
|
case 5: return dt >= 15000;
|
|
|
|
case 6: return dt >= 20000;
|
|
|
|
case 7: return dt >= 25000;
|
|
|
|
}
|
|
|
|
return dt >= 30000;
|
|
|
|
}
|
|
|
|
|
2014-07-18 10:37:34 +00:00
|
|
|
DeclareSetting(QStringList, SendPaths);
|
2014-12-03 13:10:32 +00:00
|
|
|
DeclareSetting(QString, StartUrl);
|
2014-07-18 10:37:34 +00:00
|
|
|
|
2014-06-14 19:32:11 +00:00
|
|
|
DeclareSetting(float64, RetinaFactor);
|
2014-06-15 12:31:03 +00:00
|
|
|
DeclareSetting(int32, IntRetinaFactor);
|
2014-06-14 19:32:11 +00:00
|
|
|
|
|
|
|
DeclareReadSetting(DBIPlatform, Platform);
|
2016-02-02 11:48:46 +00:00
|
|
|
DeclareReadSetting(QString, PlatformString);
|
2015-12-03 18:16:34 +00:00
|
|
|
DeclareReadSetting(bool, IsElCapitan);
|
2017-12-01 16:55:16 +00:00
|
|
|
DeclareReadSetting(bool, IsSnowLeopard);
|
2014-06-14 19:32:11 +00:00
|
|
|
|
2015-01-26 13:04:41 +00:00
|
|
|
DeclareSetting(int, OtherOnline);
|
|
|
|
|
2015-09-22 10:19:57 +00:00
|
|
|
class PeerData;
|
2015-08-07 12:11:50 +00:00
|
|
|
typedef QMap<PeerData*, QDateTime> SavedPeers;
|
|
|
|
typedef QMultiMap<QDateTime, PeerData*> SavedPeersByTime;
|
|
|
|
DeclareRefSetting(SavedPeers, SavedPeers);
|
|
|
|
DeclareRefSetting(SavedPeersByTime, SavedPeersByTime);
|
|
|
|
|
2015-09-08 17:22:29 +00:00
|
|
|
typedef QMap<uint64, DBIPeerReportSpamStatus> ReportSpamStatuses;
|
|
|
|
DeclareRefSetting(ReportSpamStatuses, ReportSpamStatuses);
|
2015-09-07 15:53:46 +00:00
|
|
|
|
2015-12-27 21:37:48 +00:00
|
|
|
DeclareSetting(bool, AutoPlayGif);
|
2018-10-15 19:42:10 +00:00
|
|
|
|
|
|
|
constexpr auto kInterfaceScaleAuto = 0;
|
|
|
|
constexpr auto kInterfaceScaleMin = 100;
|
|
|
|
constexpr auto kInterfaceScaleDefault = 100;
|
|
|
|
constexpr auto kInterfaceScaleMax = 300;
|
|
|
|
|
|
|
|
inline int cEvalScale(int scale) {
|
|
|
|
return (scale == kInterfaceScaleAuto) ? cScreenScale() : scale;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int cScale() {
|
2018-10-26 10:58:46 +00:00
|
|
|
return cEvalScale(cConfigScale());
|
2018-10-15 19:42:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
inline T ConvertScale(T value, int scale) {
|
|
|
|
return (value < 0.)
|
|
|
|
? (-ConvertScale(-value, scale))
|
|
|
|
: T(std::round((float64(value) * scale / 100.) - 0.01));
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
inline T ConvertScale(T value) {
|
|
|
|
return ConvertScale(value, cScale());
|
|
|
|
}
|
|
|
|
|
2019-02-27 11:36:19 +00:00
|
|
|
inline QSize ConvertScale(QSize size) {
|
|
|
|
return QSize(ConvertScale(size.width()), ConvertScale(size.height()));
|
|
|
|
}
|
|
|
|
|
2018-10-15 19:42:10 +00:00
|
|
|
inline void SetScaleChecked(int scale) {
|
|
|
|
const auto checked = (scale == kInterfaceScaleAuto)
|
|
|
|
? kInterfaceScaleAuto
|
|
|
|
: snap(scale, kInterfaceScaleMin, kInterfaceScaleMax / cIntRetinaFactor());
|
|
|
|
cSetConfigScale(checked);
|
|
|
|
}
|