-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathsettings.h
144 lines (119 loc) · 3.96 KB
/
settings.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "base/integration.h"
#include "ui/style/style_core.h"
#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; \
}
#define DeclareRefSetting(Type, Name) DeclareSetting(Type, Name) \
inline Type &cRef##Name() { \
return g##Name; \
}
DeclareSetting(Qt::LayoutDirection, LangDir);
inline bool rtl() {
return style::RightToLeft();
}
DeclareSetting(bool, InstallBetaVersion);
DeclareSetting(uint64, AlphaVersion);
DeclareSetting(uint64, RealAlphaVersion);
DeclareSetting(QByteArray, AlphaPrivateKey);
DeclareSetting(bool, AutoStart);
DeclareSetting(bool, StartMinimized);
DeclareSetting(bool, StartInTray);
DeclareSetting(bool, SendToMenu);
enum LaunchMode {
LaunchModeNormal = 0,
LaunchModeAutoStart,
LaunchModeFixPrevious,
LaunchModeCleanup,
};
DeclareReadSetting(LaunchMode, LaunchMode);
DeclareSetting(QString, WorkingDir);
inline void cForceWorkingDir(const QString &newDir) {
cSetWorkingDir(newDir);
if (!gWorkingDir.isEmpty()) {
cSetWorkingDir(QDir(gWorkingDir).absolutePath() + '/');
QDir().mkpath(gWorkingDir);
QFile::setPermissions(gWorkingDir,
QFileDevice::ReadUser | QFileDevice::WriteUser | QFileDevice::ExeUser);
}
}
inline QString cExeName() {
return base::Integration::Instance().executableName();
}
inline QString cExeDir() {
return base::Integration::Instance().executableDir();
}
DeclareSetting(QString, DialogLastPath);
DeclareSetting(QString, DialogHelperPath);
inline QString cDialogHelperPathFinal() {
return cDialogHelperPath().isEmpty() ? cExeDir() : cDialogHelperPath();
}
DeclareSetting(bool, AutoUpdate);
DeclareSetting(bool, SeenTrayTooltip);
DeclareSetting(bool, RestartingUpdate);
DeclareSetting(bool, Restarting);
DeclareSetting(bool, RestartingToSettings);
DeclareSetting(bool, WriteProtected);
DeclareSetting(int32, LastUpdateCheck);
DeclareSetting(bool, NoStartUpdate);
DeclareSetting(bool, StartToSettings);
DeclareSetting(bool, DebugMode);
DeclareReadSetting(bool, ManyInstance);
DeclareSetting(bool, Quit);
DeclareSetting(QByteArray, LocalSalt);
DeclareSetting(int, ScreenScale);
DeclareSetting(int, ConfigScale);
class DocumentData;
typedef QList<QPair<DocumentData*, int16>> RecentStickerPackOld;
typedef QVector<QPair<uint64, ushort>> RecentStickerPreload;
typedef QVector<QPair<DocumentData*, ushort>> RecentStickerPack;
DeclareSetting(RecentStickerPreload, RecentStickersPreload);
DeclareRefSetting(RecentStickerPack, RecentStickers);
typedef QList<QPair<QString, ushort>> RecentHashtagPack;
DeclareRefSetting(RecentHashtagPack, RecentWriteHashtags);
DeclareSetting(RecentHashtagPack, RecentSearchHashtags);
class UserData;
typedef QVector<UserData*> RecentInlineBots;
DeclareRefSetting(RecentInlineBots, RecentInlineBots);
DeclareSetting(bool, PasswordRecovered);
DeclareSetting(int32, PasscodeBadTries);
DeclareSetting(crl::time, PasscodeLastTry);
DeclareSetting(QStringList, SendPaths);
DeclareSetting(QString, StartUrl);
DeclareSetting(int, OtherOnline);
inline bool passcodeCanTry() {
if (cPasscodeBadTries() < 3) return true;
auto dt = crl::now() - cPasscodeLastTry();
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;
}
inline int cEvalScale(int scale) {
return (scale == style::kScaleAuto) ? cScreenScale() : scale;
}
inline int cScale() {
return style::Scale();
}
inline void SetScaleChecked(int scale) {
cSetConfigScale(style::CheckScale(scale));
}
inline void ValidateScale() {
SetScaleChecked(cConfigScale());
style::SetScale(cEvalScale(cConfigScale()));
}