From 2f7183e67c8e8009dd55a26dd90e026e57a3a0b0 Mon Sep 17 00:00:00 2001 From: RadRussianRus Date: Tue, 21 Apr 2020 06:49:33 +0300 Subject: [PATCH] Moved settings variables --- Telegram/CMakeLists.txt | 2 + Telegram/SourceFiles/config.h | 1 + Telegram/SourceFiles/kotato/settings.cpp | 129 +++++++++++++++++++++++ Telegram/SourceFiles/kotato/settings.h | 102 ++++++++++++++++++ Telegram/SourceFiles/settings.cpp | 121 --------------------- Telegram/SourceFiles/settings.h | 79 -------------- 6 files changed, 234 insertions(+), 200 deletions(-) create mode 100644 Telegram/SourceFiles/kotato/settings.cpp create mode 100644 Telegram/SourceFiles/kotato/settings.h diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index d6cdf7edb..cac46794b 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -1021,6 +1021,8 @@ PRIVATE observer_peer.h settings.cpp settings.h + kotato/settings.cpp + kotato/settings.h ) if (DESKTOP_APP_USE_PACKAGED) diff --git a/Telegram/SourceFiles/config.h b/Telegram/SourceFiles/config.h index 5b701dcc2..b20303afc 100644 --- a/Telegram/SourceFiles/config.h +++ b/Telegram/SourceFiles/config.h @@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "core/version.h" #include "settings.h" +#include "kotato/settings.h" enum { MaxSelectedItems = 100, diff --git a/Telegram/SourceFiles/kotato/settings.cpp b/Telegram/SourceFiles/kotato/settings.cpp new file mode 100644 index 000000000..f8497b4f1 --- /dev/null +++ b/Telegram/SourceFiles/kotato/settings.cpp @@ -0,0 +1,129 @@ +/* +This file is part of Kotatogram Desktop, +the unofficial app based on Telegram Desktop. + +For license and copyright information please follow this link: +https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL +*/ +#include "kotato/settings.h" + +bool gKotatoFirstRun = true; + +QString gMainFont, gSemiboldFont, gMonospaceFont; +bool gSemiboldFontIsBold = false; + +#ifdef DESKTOP_APP_USE_PACKAGED_FONTS +bool gUseSystemFont = true; +#else +bool gUseSystemFont = false; +#endif + +bool gUseOriginalMetrics = false; + +rpl::variable gStickerHeight = 170; +void SetStickerHeight(int height) { + gStickerHeight = height; +} +int StickerHeight() { + return gStickerHeight.current(); +} +rpl::producer StickerHeightChanges() { + return gStickerHeight.changes(); +} + +rpl::variable gBigEmojiOutline = true; +void SetBigEmojiOutline(bool enabled) { + gBigEmojiOutline = enabled; +} +bool BigEmojiOutline() { + return gBigEmojiOutline.current(); +} +rpl::producer BigEmojiOutlineChanges() { + return gBigEmojiOutline.changes(); +} + +rpl::variable gAdaptiveBubbles = false; +void SetAdaptiveBubbles(bool enabled) { + gAdaptiveBubbles = enabled; +} +bool AdaptiveBubbles() { + return gAdaptiveBubbles.current(); +} +rpl::producer AdaptiveBubblesChanges() { + return gAdaptiveBubbles.changes(); +} + +bool gAlwaysShowScheduled = false; +bool gShowChatId = false; + +int gNetSpeedBoost = 0; +int gNetRequestsCount = 2; +int gNetUploadSessionsCount = 2; +int gNetUploadRequestInterval = 500; + +bool gShowPhoneInDrawer = true; + +ScaleVector gInterfaceScales; + +bool HasCustomScales() { + return (!gInterfaceScales.empty()); +} + +bool AddCustomScale(int scale) { + if (gInterfaceScales.size() >= 6) { + return false; + } + gInterfaceScales.push_back(style::CheckScale(scale)); + return true; +} + +void ClearCustomScales() { + gInterfaceScales.clear(); +} + +rpl::variable gDialogListLines = 2; +void SetDialogListLines(int lines) { + gDialogListLines = lines; +} +int DialogListLines() { + return gDialogListLines.current(); +} +rpl::producer DialogListLinesChanges() { + return gDialogListLines.changes(); +} + +bool gDisableUpEdit = false; + +CustomReplacementsMap gCustomReplaces; +bool AddCustomReplace(QString from, QString to) { + gCustomReplaces.insert(from, to); + return true; +} + +bool gConfirmBeforeCall = false; +bool gNoTaskbarFlashing = false; + +rpl::variable gRecentStickersLimit = 20; +void SetRecentStickersLimit(int limit) { + if (limit >= 0 || limit <= 200) { + gRecentStickersLimit = limit; + } +} +int RecentStickersLimit() { + return gRecentStickersLimit.current(); +} +rpl::producer RecentStickersLimitChanges() { + return gRecentStickersLimit.changes(); +} + +int gUserpicCornersType = 3; +bool gShowTopBarUserpic = false; +int gCustomAppIcon = 0; + +int gDefaultFilterId = 0; +bool gUnmutedFilterCounterOnly = false; +bool gHideFilterEditButton = false; +bool gHideFilterNames = false; +bool gHideFilterAllChats = false; + +bool gProfileTopBarNotifications = false; diff --git a/Telegram/SourceFiles/kotato/settings.h b/Telegram/SourceFiles/kotato/settings.h new file mode 100644 index 000000000..8823329f2 --- /dev/null +++ b/Telegram/SourceFiles/kotato/settings.h @@ -0,0 +1,102 @@ +/* +This file is part of Kotatogram Desktop, +the unofficial app based on Telegram Desktop. + +For license and copyright information please follow this link: +https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL +*/ +#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; \ +} + +#define DeclareRefSetting(Type, Name) DeclareSetting(Type, Name) \ +inline Type &cRef##Name() { \ + return g##Name; \ +} + +DeclareSetting(bool, KotatoFirstRun); + +DeclareSetting(QString, MainFont); +DeclareSetting(QString, SemiboldFont); +DeclareSetting(bool, SemiboldFontIsBold); +DeclareSetting(QString, MonospaceFont); +DeclareSetting(bool, UseSystemFont); +DeclareSetting(bool, UseOriginalMetrics); + +void SetBigEmojiOutline(bool enabled); +[[nodiscard]] bool BigEmojiOutline(); +[[nodiscard]] rpl::producer BigEmojiOutlineChanges(); + +void SetStickerHeight(int height); +[[nodiscard]] int StickerHeight(); +[[nodiscard]] rpl::producer StickerHeightChanges(); + +void SetAdaptiveBubbles(bool enabled); +[[nodiscard]] bool AdaptiveBubbles(); +[[nodiscard]] rpl::producer AdaptiveBubblesChanges(); + +DeclareSetting(bool, AlwaysShowScheduled); +DeclareSetting(bool, ShowChatId); + +DeclareSetting(int, NetSpeedBoost); +DeclareSetting(int, NetRequestsCount); +DeclareSetting(int, NetUploadSessionsCount); +DeclareSetting(int, NetUploadRequestInterval); + +inline void SetNetworkBoost(int boost) { + if (boost < 0) { + cSetNetSpeedBoost(0); + } else if (boost > 3) { + cSetNetSpeedBoost(3); + } else { + cSetNetSpeedBoost(boost); + } + + cSetNetRequestsCount(2 + (2 * cNetSpeedBoost())); + cSetNetUploadSessionsCount(2 + (2 * cNetSpeedBoost())); + cSetNetUploadRequestInterval(500 - (100 * cNetSpeedBoost())); +} + +DeclareSetting(bool, ShowPhoneInDrawer); + +using ScaleVector = std::vector; +DeclareRefSetting(ScaleVector, InterfaceScales); +bool HasCustomScales(); +bool AddCustomScale(int scale); +void ClearCustomScales(); + +void SetDialogListLines(int lines); +[[nodiscard]] int DialogListLines(); +[[nodiscard]] rpl::producer DialogListLinesChanges(); + +DeclareSetting(bool, DisableUpEdit); + +using CustomReplacementsMap = QMap; +DeclareRefSetting(CustomReplacementsMap, CustomReplaces); +bool AddCustomReplace(QString from, QString to); +DeclareSetting(bool, ConfirmBeforeCall); +DeclareSetting(bool, NoTaskbarFlashing); + +void SetRecentStickersLimit(int limit); +[[nodiscard]] int RecentStickersLimit(); +[[nodiscard]] rpl::producer RecentStickersLimitChanges(); + +DeclareSetting(int, UserpicCornersType); +DeclareSetting(bool, ShowTopBarUserpic); +DeclareSetting(int, CustomAppIcon); + +DeclareSetting(int, DefaultFilterId); +DeclareSetting(bool, UnmutedFilterCounterOnly); +DeclareSetting(bool, HideFilterEditButton); +DeclareSetting(bool, HideFilterNames); +DeclareSetting(bool, HideFilterAllChats); + +DeclareSetting(bool, ProfileTopBarNotifications); diff --git a/Telegram/SourceFiles/settings.cpp b/Telegram/SourceFiles/settings.cpp index d450bb32d..1052fc7d1 100644 --- a/Telegram/SourceFiles/settings.cpp +++ b/Telegram/SourceFiles/settings.cpp @@ -206,124 +206,3 @@ void AddRecentEmoji(EmojiPtr emoji) { rpl::producer<> UpdatedRecentEmoji() { return UpdatesRecentEmoji.events(); } - -bool gKotatoFirstRun = true; - -QString gMainFont, gSemiboldFont, gMonospaceFont; -bool gSemiboldFontIsBold = false; - -#ifdef DESKTOP_APP_USE_PACKAGED_FONTS -bool gUseSystemFont = true; -#else -bool gUseSystemFont = false; -#endif - -bool gUseOriginalMetrics = false; - -rpl::variable gStickerHeight = 170; -void SetStickerHeight(int height) { - gStickerHeight = height; -} -int StickerHeight() { - return gStickerHeight.current(); -} -rpl::producer StickerHeightChanges() { - return gStickerHeight.changes(); -} - -rpl::variable gBigEmojiOutline = true; -void SetBigEmojiOutline(bool enabled) { - gBigEmojiOutline = enabled; -} -bool BigEmojiOutline() { - return gBigEmojiOutline.current(); -} -rpl::producer BigEmojiOutlineChanges() { - return gBigEmojiOutline.changes(); -} - -rpl::variable gAdaptiveBubbles = false; -void SetAdaptiveBubbles(bool enabled) { - gAdaptiveBubbles = enabled; -} -bool AdaptiveBubbles() { - return gAdaptiveBubbles.current(); -} -rpl::producer AdaptiveBubblesChanges() { - return gAdaptiveBubbles.changes(); -} - -bool gAlwaysShowScheduled = false; -bool gShowChatId = false; - -int gNetSpeedBoost = 0; -int gNetRequestsCount = 2; -int gNetUploadSessionsCount = 2; -int gNetUploadRequestInterval = 500; - -bool gShowPhoneInDrawer = true; - -ScaleVector gInterfaceScales; - -bool HasCustomScales() { - return (!gInterfaceScales.empty()); -} - -bool AddCustomScale(int scale) { - if (gInterfaceScales.size() >= 6) { - return false; - } - gInterfaceScales.push_back(style::CheckScale(scale)); - return true; -} - -void ClearCustomScales() { - gInterfaceScales.clear(); -} - -rpl::variable gDialogListLines = 2; -void SetDialogListLines(int lines) { - gDialogListLines = lines; -} -int DialogListLines() { - return gDialogListLines.current(); -} -rpl::producer DialogListLinesChanges() { - return gDialogListLines.changes(); -} - -bool gDisableUpEdit = false; - -CustomReplacementsMap gCustomReplaces; -bool AddCustomReplace(QString from, QString to) { - gCustomReplaces.insert(from, to); - return true; -} - -bool gConfirmBeforeCall = false; -bool gNoTaskbarFlashing = false; - -rpl::variable gRecentStickersLimit = 20; -void SetRecentStickersLimit(int limit) { - if (limit >= 0 || limit <= 200) { - gRecentStickersLimit = limit; - } -} -int RecentStickersLimit() { - return gRecentStickersLimit.current(); -} -rpl::producer RecentStickersLimitChanges() { - return gRecentStickersLimit.changes(); -} - -int gUserpicCornersType = 3; -bool gShowTopBarUserpic = false; -int gCustomAppIcon = 0; - -int gDefaultFilterId = 0; -bool gUnmutedFilterCounterOnly = false; -bool gHideFilterEditButton = false; -bool gHideFilterNames = false; -bool gHideFilterAllChats = false; - -bool gProfileTopBarNotifications = false; diff --git a/Telegram/SourceFiles/settings.h b/Telegram/SourceFiles/settings.h index 97669af82..b33e80119 100644 --- a/Telegram/SourceFiles/settings.h +++ b/Telegram/SourceFiles/settings.h @@ -178,82 +178,3 @@ inline void ValidateScale() { SetScaleChecked(cConfigScale()); style::SetScale(cEvalScale(cConfigScale())); } - -DeclareSetting(bool, KotatoFirstRun); - -DeclareSetting(QString, MainFont); -DeclareSetting(QString, SemiboldFont); -DeclareSetting(bool, SemiboldFontIsBold); -DeclareSetting(QString, MonospaceFont); -DeclareSetting(bool, UseSystemFont); -DeclareSetting(bool, UseOriginalMetrics); - -void SetBigEmojiOutline(bool enabled); -[[nodiscard]] bool BigEmojiOutline(); -[[nodiscard]] rpl::producer BigEmojiOutlineChanges(); - -void SetStickerHeight(int height); -[[nodiscard]] int StickerHeight(); -[[nodiscard]] rpl::producer StickerHeightChanges(); - -void SetAdaptiveBubbles(bool enabled); -[[nodiscard]] bool AdaptiveBubbles(); -[[nodiscard]] rpl::producer AdaptiveBubblesChanges(); - -DeclareSetting(bool, AlwaysShowScheduled); -DeclareSetting(bool, ShowChatId); - -DeclareSetting(int, NetSpeedBoost); -DeclareSetting(int, NetRequestsCount); -DeclareSetting(int, NetUploadSessionsCount); -DeclareSetting(int, NetUploadRequestInterval); - -inline void SetNetworkBoost(int boost) { - if (boost < 0) { - cSetNetSpeedBoost(0); - } else if (boost > 3) { - cSetNetSpeedBoost(3); - } else { - cSetNetSpeedBoost(boost); - } - - cSetNetRequestsCount(2 + (2 * cNetSpeedBoost())); - cSetNetUploadSessionsCount(2 + (2 * cNetSpeedBoost())); - cSetNetUploadRequestInterval(500 - (100 * cNetSpeedBoost())); -} - -DeclareSetting(bool, ShowPhoneInDrawer); - -using ScaleVector = std::vector; -DeclareRefSetting(ScaleVector, InterfaceScales); -bool HasCustomScales(); -bool AddCustomScale(int scale); -void ClearCustomScales(); - -void SetDialogListLines(int lines); -[[nodiscard]] int DialogListLines(); -[[nodiscard]] rpl::producer DialogListLinesChanges(); - -DeclareSetting(bool, DisableUpEdit); - -using CustomReplacementsMap = QMap; -DeclareRefSetting(CustomReplacementsMap, CustomReplaces); -bool AddCustomReplace(QString from, QString to); -DeclareSetting(bool, ConfirmBeforeCall); -DeclareSetting(bool, NoTaskbarFlashing); - -void SetRecentStickersLimit(int limit); -[[nodiscard]] int RecentStickersLimit(); -[[nodiscard]] rpl::producer RecentStickersLimitChanges(); - -DeclareSetting(int, UserpicCornersType); -DeclareSetting(bool, ShowTopBarUserpic); -DeclareSetting(int, CustomAppIcon); - -DeclareSetting(int, DefaultFilterId); -DeclareSetting(bool, UnmutedFilterCounterOnly); -DeclareSetting(bool, HideFilterEditButton); -DeclareSetting(bool, HideFilterNames); -DeclareSetting(bool, HideFilterAllChats); - -DeclareSetting(bool, ProfileTopBarNotifications);