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
|
|
|
*/
|
|
|
|
#include "settings.h"
|
2016-04-27 12:02:17 +00:00
|
|
|
|
2019-09-13 10:24:06 +00:00
|
|
|
#include "ui/emoji_config.h"
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
constexpr auto kRecentEmojiLimit = 42;
|
|
|
|
|
|
|
|
auto UpdatesRecentEmoji = rpl::event_stream<>();
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
Qt::LayoutDirection gLangDir = Qt::LeftToRight;
|
2015-04-19 10:29:19 +00:00
|
|
|
|
2018-09-26 15:11:16 +00:00
|
|
|
bool gInstallBetaVersion = AppBetaVersion;
|
2018-09-26 14:58:09 +00:00
|
|
|
uint64 gAlphaVersion = AppAlphaVersion;
|
|
|
|
uint64 gRealAlphaVersion = AppAlphaVersion;
|
|
|
|
QByteArray gAlphaPrivateKey;
|
2015-12-03 18:16:34 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
bool gTestMode = false;
|
|
|
|
bool gManyInstance = false;
|
|
|
|
QString gKeyFile;
|
2014-11-27 18:20:48 +00:00
|
|
|
QString gWorkingDir, gExeDir, gExeName;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2014-07-18 10:37:34 +00:00
|
|
|
QStringList gSendPaths;
|
2014-12-03 13:10:32 +00:00
|
|
|
QString gStartUrl;
|
2014-07-18 10:37:34 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
QString gDialogLastPath, gDialogHelperPath; // optimize QFileDialog
|
|
|
|
|
|
|
|
bool gStartMinimized = false;
|
2015-01-27 16:58:58 +00:00
|
|
|
bool gStartInTray = false;
|
2014-05-30 08:53:19 +00:00
|
|
|
bool gAutoStart = false;
|
2014-07-18 10:37:34 +00:00
|
|
|
bool gSendToMenu = false;
|
2017-02-17 12:50:27 +00:00
|
|
|
bool gUseExternalVideoPlayer = false;
|
2014-05-30 08:53:19 +00:00
|
|
|
bool gAutoUpdate = true;
|
|
|
|
TWindowPos gWindowPos;
|
2016-01-11 15:43:29 +00:00
|
|
|
LaunchMode gLaunchMode = LaunchModeNormal;
|
2015-01-15 14:22:15 +00:00
|
|
|
bool gSupportTray = true;
|
2014-05-30 08:53:19 +00:00
|
|
|
bool gSeenTrayTooltip = false;
|
2014-12-19 21:20:30 +00:00
|
|
|
bool gRestartingUpdate = false, gRestarting = false, gRestartingToSettings = false, gWriteProtected = false;
|
2014-05-30 08:53:19 +00:00
|
|
|
int32 gLastUpdateCheck = 0;
|
|
|
|
bool gNoStartUpdate = false;
|
|
|
|
bool gStartToSettings = false;
|
|
|
|
|
|
|
|
uint32 gConnectionsInSession = 1;
|
|
|
|
QString gLoggedPhoneNumber;
|
|
|
|
|
|
|
|
QByteArray gLocalSalt;
|
2019-09-13 10:24:06 +00:00
|
|
|
int gScreenScale = style::kScaleAuto;
|
|
|
|
int gConfigScale = style::kScaleAuto;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-02-10 18:55:04 +00:00
|
|
|
QString gTimeFormat = qsl("hh:mm");
|
|
|
|
|
2017-02-15 08:50:11 +00:00
|
|
|
RecentEmojiPack gRecentEmoji;
|
|
|
|
RecentEmojiPreload gRecentEmojiPreload;
|
2015-05-08 12:45:14 +00:00
|
|
|
EmojiColorVariants gEmojiVariants;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-05-19 15:46:45 +00:00
|
|
|
RecentStickerPreload gRecentStickersPreload;
|
2015-01-02 14:55:24 +00:00
|
|
|
RecentStickerPack gRecentStickers;
|
|
|
|
|
2015-03-24 10:00:27 +00:00
|
|
|
RecentHashtagPack gRecentWriteHashtags, gRecentSearchHashtags;
|
|
|
|
|
2016-01-01 14:48:32 +00:00
|
|
|
RecentInlineBots gRecentInlineBots;
|
|
|
|
|
2015-04-02 10:33:19 +00:00
|
|
|
bool gPasswordRecovered = false;
|
2015-04-04 20:01:34 +00:00
|
|
|
int32 gPasscodeBadTries = 0;
|
2019-02-19 06:57:53 +00:00
|
|
|
crl::time gPasscodeLastTry = 0;
|
2015-04-02 10:33:19 +00:00
|
|
|
|
2014-06-14 19:32:11 +00:00
|
|
|
float64 gRetinaFactor = 1.;
|
2014-06-15 12:31:03 +00:00
|
|
|
int32 gIntRetinaFactor = 1;
|
2014-06-16 09:31:10 +00:00
|
|
|
|
2015-01-26 13:04:41 +00:00
|
|
|
int gOtherOnline = 0;
|
|
|
|
|
2015-12-23 21:19:57 +00:00
|
|
|
int32 gAutoDownloadPhoto = 0; // all auto download
|
|
|
|
int32 gAutoDownloadAudio = 0;
|
|
|
|
int32 gAutoDownloadGif = 0;
|
2019-09-13 10:24:06 +00:00
|
|
|
|
|
|
|
RecentEmojiPack &GetRecentEmoji() {
|
|
|
|
if (cRecentEmoji().isEmpty()) {
|
|
|
|
RecentEmojiPack result;
|
|
|
|
auto haveAlready = [&result](EmojiPtr emoji) {
|
|
|
|
for (auto &row : result) {
|
|
|
|
if (row.first->id() == emoji->id()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
if (!cRecentEmojiPreload().isEmpty()) {
|
|
|
|
auto preload = cRecentEmojiPreload();
|
|
|
|
cSetRecentEmojiPreload(RecentEmojiPreload());
|
|
|
|
result.reserve(preload.size());
|
|
|
|
for (auto i = preload.cbegin(), e = preload.cend(); i != e; ++i) {
|
|
|
|
if (auto emoji = Ui::Emoji::Find(i->first)) {
|
|
|
|
if (!haveAlready(emoji)) {
|
|
|
|
result.push_back(qMakePair(emoji, i->second));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const auto defaultRecent = {
|
|
|
|
0xD83DDE02LLU,
|
|
|
|
0xD83DDE18LLU,
|
|
|
|
0x2764LLU,
|
|
|
|
0xD83DDE0DLLU,
|
|
|
|
0xD83DDE0ALLU,
|
|
|
|
0xD83DDE01LLU,
|
|
|
|
0xD83DDC4DLLU,
|
|
|
|
0x263ALLU,
|
|
|
|
0xD83DDE14LLU,
|
|
|
|
0xD83DDE04LLU,
|
|
|
|
0xD83DDE2DLLU,
|
|
|
|
0xD83DDC8BLLU,
|
|
|
|
0xD83DDE12LLU,
|
|
|
|
0xD83DDE33LLU,
|
|
|
|
0xD83DDE1CLLU,
|
|
|
|
0xD83DDE48LLU,
|
|
|
|
0xD83DDE09LLU,
|
|
|
|
0xD83DDE03LLU,
|
|
|
|
0xD83DDE22LLU,
|
|
|
|
0xD83DDE1DLLU,
|
|
|
|
0xD83DDE31LLU,
|
|
|
|
0xD83DDE21LLU,
|
|
|
|
0xD83DDE0FLLU,
|
|
|
|
0xD83DDE1ELLU,
|
|
|
|
0xD83DDE05LLU,
|
|
|
|
0xD83DDE1ALLU,
|
|
|
|
0xD83DDE4ALLU,
|
|
|
|
0xD83DDE0CLLU,
|
|
|
|
0xD83DDE00LLU,
|
|
|
|
0xD83DDE0BLLU,
|
|
|
|
0xD83DDE06LLU,
|
|
|
|
0xD83DDC4CLLU,
|
|
|
|
0xD83DDE10LLU,
|
|
|
|
0xD83DDE15LLU,
|
|
|
|
};
|
|
|
|
for (const auto emoji : Ui::Emoji::GetDefaultRecent()) {
|
|
|
|
if (result.size() >= kRecentEmojiLimit) break;
|
|
|
|
|
|
|
|
if (!haveAlready(emoji)) {
|
|
|
|
result.push_back(qMakePair(emoji, 1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cSetRecentEmoji(result);
|
|
|
|
}
|
|
|
|
return cRefRecentEmoji();
|
|
|
|
}
|
|
|
|
|
|
|
|
EmojiPack GetRecentEmojiSection() {
|
|
|
|
const auto &recent = GetRecentEmoji();
|
|
|
|
|
|
|
|
auto result = EmojiPack();
|
|
|
|
result.reserve(recent.size());
|
|
|
|
for (const auto &item : recent) {
|
|
|
|
result.push_back(item.first);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AddRecentEmoji(EmojiPtr emoji) {
|
|
|
|
auto &recent = GetRecentEmoji();
|
|
|
|
auto i = recent.begin(), e = recent.end();
|
|
|
|
for (; i != e; ++i) {
|
|
|
|
if (i->first == emoji) {
|
|
|
|
++i->second;
|
|
|
|
if (i->second > 0x8000) {
|
|
|
|
for (auto j = recent.begin(); j != e; ++j) {
|
|
|
|
if (j->second > 1) {
|
|
|
|
j->second /= 2;
|
|
|
|
} else {
|
|
|
|
j->second = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (; i != recent.begin(); --i) {
|
|
|
|
if ((i - 1)->second > i->second) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
std::swap(*i, *(i - 1));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i == e) {
|
|
|
|
while (recent.size() >= kRecentEmojiLimit) {
|
|
|
|
recent.pop_back();
|
|
|
|
}
|
|
|
|
recent.push_back(qMakePair(emoji, 1));
|
|
|
|
for (i = recent.end() - 1; i != recent.begin(); --i) {
|
|
|
|
if ((i - 1)->second > i->second) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
std::swap(*i, *(i - 1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
UpdatesRecentEmoji.fire({});
|
|
|
|
}
|
|
|
|
|
|
|
|
rpl::producer<> UpdatedRecentEmoji() {
|
|
|
|
return UpdatesRecentEmoji.events();
|
|
|
|
}
|