2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-05 17:15:16 +00:00
Files
kotatogram-desktop/Telegram/SourceFiles/settings.h

254 lines
7.2 KiB
C
Raw Normal View History

/*
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
2019-09-13 13:24:06 +03:00
#include "ui/style/style_core.h"
#include "emoji.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; \
}
2015-05-08 15:45:14 +03:00
#define DeclareRefSetting(Type, Name) DeclareSetting(Type, Name) \
inline Type &cRef##Name() { \
return g##Name; \
}
2015-04-19 13:29:19 +03:00
DeclareSetting(Qt::LayoutDirection, LangDir);
inline bool rtl() {
2019-09-13 13:24:06 +03:00
return style::RightToLeft();
2015-04-19 13:29:19 +03:00
}
DeclareSetting(bool, InstallBetaVersion);
DeclareSetting(uint64, AlphaVersion);
DeclareSetting(uint64, RealAlphaVersion);
DeclareSetting(QByteArray, AlphaPrivateKey);
2015-01-23 18:24:36 +03:00
DeclareSetting(bool, TestMode);
DeclareSetting(QString, LoggedPhoneNumber);
DeclareSetting(bool, AutoStart);
DeclareSetting(bool, StartMinimized);
DeclareSetting(bool, StartInTray);
DeclareSetting(bool, SendToMenu);
DeclareSetting(bool, UseExternalVideoPlayer);
enum LaunchMode {
LaunchModeNormal = 0,
LaunchModeAutoStart,
LaunchModeFixPrevious,
LaunchModeCleanup,
};
DeclareReadSetting(LaunchMode, LaunchMode);
DeclareSetting(QString, WorkingDir);
inline void cForceWorkingDir(const QString &newDir) {
cSetWorkingDir(newDir);
if (!gWorkingDir.isEmpty()) {
QDir().mkpath(gWorkingDir);
QFile::setPermissions(gWorkingDir,
QFileDevice::ReadUser | QFileDevice::WriteUser | QFileDevice::ExeUser);
}
}
2014-11-27 21:20:48 +03:00
DeclareReadSetting(QString, ExeName);
DeclareReadSetting(QString, ExeDir);
DeclareSetting(QString, DialogLastPath);
DeclareSetting(QString, DialogHelperPath);
inline const QString &cDialogHelperPathFinal() {
return cDialogHelperPath().isEmpty() ? cExeDir() : cDialogHelperPath();
}
2015-02-03 18:02:46 +03:00
DeclareSetting(bool, AutoUpdate);
struct TWindowPos {
TWindowPos() = default;
int32 moncrc = 0;
int maximized = 0;
int x = 0;
int y = 0;
int w = 0;
int h = 0;
};
DeclareSetting(TWindowPos, WindowPos);
DeclareSetting(bool, SupportTray);
DeclareSetting(bool, SeenTrayTooltip);
DeclareSetting(bool, RestartingUpdate);
DeclareSetting(bool, Restarting);
DeclareSetting(bool, RestartingToSettings);
DeclareSetting(bool, WriteProtected);
DeclareSetting(int32, LastUpdateCheck);
DeclareSetting(bool, NoStartUpdate);
DeclareSetting(bool, StartToSettings);
DeclareReadSetting(bool, ManyInstance);
DeclareSetting(QByteArray, LocalSalt);
DeclareSetting(int, ScreenScale);
DeclareSetting(int, ConfigScale);
DeclareSetting(QString, TimeFormat);
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 15:45:14 +03:00
DeclareRefSetting(EmojiColorVariants, EmojiVariants);
class DocumentData;
typedef QList<QPair<DocumentData*, int16>> RecentStickerPackOld;
typedef QVector<QPair<uint64, ushort>> RecentStickerPreload;
typedef QVector<QPair<DocumentData*, ushort>> RecentStickerPack;
2015-05-19 18:46:45 +03:00
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);
2015-04-04 23:01:34 +03:00
DeclareSetting(int32, PasscodeBadTries);
DeclareSetting(crl::time, PasscodeLastTry);
2015-04-04 23:01:34 +03:00
2019-09-13 13:24:06 +03:00
DeclareSetting(QStringList, SendPaths);
DeclareSetting(QString, StartUrl);
DeclareSetting(int, OtherOnline);
inline void cChangeTimeFormat(const QString &newFormat) {
if (!newFormat.isEmpty()) cSetTimeFormat(newFormat);
}
RecentEmojiPack &GetRecentEmoji();
QVector<EmojiPtr> GetRecentEmojiSection();
void AddRecentEmoji(EmojiPtr emoji);
[[nodiscard]] rpl::producer<> UpdatedRecentEmoji();
2015-04-04 23:01:34 +03:00
inline bool passcodeCanTry() {
if (cPasscodeBadTries() < 3) return true;
auto dt = crl::now() - cPasscodeLastTry();
2015-04-04 23:01:34 +03: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;
}
2019-09-13 13:24:06 +03:00
inline float64 cRetinaFactor() {
return style::DevicePixelRatio();
}
2019-09-13 13:24:06 +03:00
inline int32 cIntRetinaFactor() {
return style::DevicePixelRatio();
}
2019-09-13 13:24:06 +03:00
inline int cEvalScale(int scale) {
return (scale == style::kScaleAuto) ? cScreenScale() : scale;
}
2019-09-13 13:24:06 +03:00
inline int cScale() {
return style::Scale();
}
2019-09-13 13:24:06 +03:00
inline void SetScaleChecked(int scale) {
cSetConfigScale(style::CheckScale(scale));
2019-02-27 15:36:19 +04:00
}
2019-09-13 13:24:06 +03:00
inline void ValidateScale() {
SetScaleChecked(cConfigScale());
style::SetScale(cEvalScale(cConfigScale()));
}
2019-09-21 19:10:46 +03:00
2020-02-03 14:28:59 +03:00
DeclareSetting(bool, KotatoFirstRun);
2019-09-21 19:10:46 +03:00
DeclareSetting(QString, MainFont);
DeclareSetting(QString, SemiboldFont);
DeclareSetting(bool, SemiboldFontIsBold);
DeclareSetting(QString, MonospaceFont);
2020-01-30 11:54:57 +04:00
DeclareSetting(bool, UseSystemFont);
2020-02-05 21:27:25 +03:00
DeclareSetting(bool, UseOriginalMetrics);
2019-10-04 16:15:45 +03:00
void SetBigEmojiOutline(bool enabled);
[[nodiscard]] bool BigEmojiOutline();
[[nodiscard]] rpl::producer<bool> BigEmojiOutlineChanges();
void SetStickerHeight(int height);
[[nodiscard]] int StickerHeight();
[[nodiscard]] rpl::producer<int> StickerHeightChanges();
void SetAdaptiveBubbles(bool enabled);
[[nodiscard]] bool AdaptiveBubbles();
[[nodiscard]] rpl::producer<bool> AdaptiveBubblesChanges();
2019-10-04 17:02:27 +03:00
DeclareSetting(bool, AlwaysShowScheduled);
2019-10-04 17:26:05 +03:00
DeclareSetting(bool, ShowChatId);
2019-10-11 06:54:49 +03:00
DeclareSetting(int, NetSpeedBoost);
DeclareSetting(int, NetRequestsCount);
DeclareSetting(int, NetUploadSessionsCount);
DeclareSetting(int, NetUploadRequestInterval);
2019-10-07 02:58:56 +03:00
inline void SetNetworkBoost(int boost) {
if (boost < 0) {
2019-10-11 06:54:49 +03:00
cSetNetSpeedBoost(0);
} else if (boost > 3) {
2019-10-11 06:54:49 +03:00
cSetNetSpeedBoost(3);
} else {
cSetNetSpeedBoost(boost);
}
2019-10-11 06:54:49 +03:00
cSetNetRequestsCount(2 + (2 * cNetSpeedBoost()));
cSetNetUploadSessionsCount(2 + (2 * cNetSpeedBoost()));
cSetNetUploadRequestInterval(500 - (100 * cNetSpeedBoost()));
}
2019-10-07 04:44:41 +03:00
DeclareSetting(bool, ShowPhoneInDrawer);
2019-10-08 02:37:03 +03:00
using ScaleVector = std::vector<int>;
2019-10-07 04:44:41 +03:00
DeclareRefSetting(ScaleVector, InterfaceScales);
bool HasCustomScales();
bool AddCustomScale(int scale);
2019-10-24 03:38:11 +03:00
void ClearCustomScales();
void SetDialogListLines(int lines);
[[nodiscard]] int DialogListLines();
2020-01-18 18:31:41 +03:00
[[nodiscard]] rpl::producer<int> DialogListLinesChanges();
DeclareSetting(bool, DisableUpEdit);
2020-01-26 08:01:06 +03:00
using CustomReplacementsMap = QMap<QString, QString>;
DeclareRefSetting(CustomReplacementsMap, CustomReplaces);
bool AddCustomReplace(QString from, QString to);
2020-02-03 05:51:15 +03:00
DeclareSetting(bool, ConfirmBeforeCall);
2020-02-23 05:30:39 +03:00
DeclareSetting(bool, NoTaskbarFlashing);
2020-02-23 04:53:24 +03:00
void SetRecentStickersLimit(int limit);
[[nodiscard]] int RecentStickersLimit();
[[nodiscard]] rpl::producer<int> RecentStickersLimitChanges();
2020-03-09 00:31:01 +03:00
DeclareSetting(int, UserpicCornersType);
2020-03-09 20:43:26 +03:00
DeclareSetting(bool, ShowTopBarUserpic);
2020-03-18 03:37:33 +03:00
DeclareSetting(int, CustomAppIcon);
2020-03-28 18:06:15 +03:00
DeclareSetting(int, DefaultFilterId);