core_settings.h 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #pragma once
  8. #include "core/core_settings_proxy.h"
  9. #include "media/media_common.h"
  10. #include "dialogs/ui/dialogs_quick_action.h"
  11. #include "window/themes/window_themes_embedded.h"
  12. #include "ui/chat/attach/attach_send_files_way.h"
  13. #include "base/flags.h"
  14. #include "emoji.h"
  15. enum class RectPart;
  16. struct LanguageId;
  17. namespace Ui {
  18. enum class InputSubmitSettings;
  19. } // namespace Ui
  20. namespace HistoryView {
  21. enum class DoubleClickQuickAction;
  22. } // namespace HistoryView
  23. namespace Window {
  24. enum class Column;
  25. } // namespace Window
  26. namespace Calls::Group {
  27. enum class StickedTooltip;
  28. } // namespace Calls::Group
  29. namespace Core {
  30. struct WindowPosition {
  31. int32 moncrc = 0;
  32. int maximized = 0;
  33. int scale = 0;
  34. int x = 0;
  35. int y = 0;
  36. int w = 0;
  37. int h = 0;
  38. friend inline constexpr auto operator<=>(
  39. WindowPosition,
  40. WindowPosition) = default;
  41. [[nodiscard]] QRect rect() const {
  42. return QRect(x, y, w, h);
  43. }
  44. };
  45. [[nodiscard]] WindowPosition AdjustToScale(
  46. WindowPosition position,
  47. const QString &name);
  48. struct WindowTitleContent {
  49. bool hideChatName : 1 = false;
  50. bool hideAccountName : 1 = false;
  51. bool hideTotalUnread : 1 = false;
  52. friend inline constexpr auto operator<=>(
  53. WindowTitleContent,
  54. WindowTitleContent) = default;
  55. };
  56. constexpr auto kRecentEmojiLimit = 54;
  57. struct RecentEmojiDocument {
  58. DocumentId id = 0;
  59. bool test = false;
  60. friend inline auto operator<=>(
  61. RecentEmojiDocument,
  62. RecentEmojiDocument) = default;
  63. };
  64. struct RecentEmojiId {
  65. std::variant<EmojiPtr, RecentEmojiDocument> data;
  66. friend inline bool operator==(
  67. RecentEmojiId,
  68. RecentEmojiId) = default;
  69. };
  70. struct RecentEmoji {
  71. RecentEmojiId id;
  72. ushort rating = 0;
  73. };
  74. class Settings final {
  75. public:
  76. enum class ScreenCorner {
  77. TopLeft = 0,
  78. TopRight = 1,
  79. BottomRight = 2,
  80. BottomLeft = 3,
  81. };
  82. enum class NotifyView {
  83. ShowPreview = 0,
  84. ShowName = 1,
  85. ShowNothing = 2,
  86. };
  87. enum class WorkMode {
  88. WindowAndTray = 0,
  89. TrayOnly = 1,
  90. WindowOnly = 2,
  91. };
  92. enum class CloseBehavior {
  93. Quit = 0,
  94. CloseToTaskbar = 1,
  95. RunInBackground = 2,
  96. };
  97. static constexpr auto kDefaultVolume = 0.9;
  98. Settings();
  99. ~Settings();
  100. [[nodiscard]] rpl::producer<> saveDelayedRequests() const {
  101. return _saveDelayed.events();
  102. }
  103. [[nodiscard]] SettingsProxy &proxy() {
  104. return _proxy;
  105. }
  106. [[nodiscard]] static bool IsLeftCorner(ScreenCorner corner) {
  107. return (corner == ScreenCorner::TopLeft)
  108. || (corner == ScreenCorner::BottomLeft);
  109. }
  110. [[nodiscard]] static bool IsTopCorner(ScreenCorner corner) {
  111. return (corner == ScreenCorner::TopLeft)
  112. || (corner == ScreenCorner::TopRight);
  113. }
  114. [[nodiscard]] QByteArray serialize() const;
  115. void addFromSerialized(const QByteArray &serialized);
  116. [[nodiscard]] bool adaptiveForWide() const {
  117. return _adaptiveForWide.current();
  118. }
  119. [[nodiscard]] rpl::producer<bool> adaptiveForWideValue() const {
  120. return _adaptiveForWide.value();
  121. }
  122. [[nodiscard]] rpl::producer<bool> adaptiveForWideChanges() const {
  123. return _adaptiveForWide.changes();
  124. }
  125. void setAdaptiveForWide(bool value) {
  126. _adaptiveForWide = value;
  127. }
  128. [[nodiscard]] bool moderateModeEnabled() const {
  129. return _moderateModeEnabled;
  130. }
  131. void setModerateModeEnabled(bool value) {
  132. _moderateModeEnabled = value;
  133. }
  134. [[nodiscard]] float64 songVolume() const {
  135. return _songVolume.current();
  136. }
  137. [[nodiscard]] rpl::producer<float64> songVolumeChanges() const {
  138. return _songVolume.changes();
  139. }
  140. void setSongVolume(float64 value) {
  141. _songVolume = value;
  142. }
  143. [[nodiscard]] float64 videoVolume() const {
  144. return _videoVolume.current();
  145. }
  146. [[nodiscard]] rpl::producer<float64> videoVolumeChanges() const {
  147. return _videoVolume.changes();
  148. }
  149. void setVideoVolume(float64 value) {
  150. _videoVolume = value;
  151. }
  152. [[nodiscard]] bool askDownloadPath() const {
  153. return _askDownloadPath;
  154. }
  155. void setAskDownloadPath(bool value) {
  156. _askDownloadPath = value;
  157. }
  158. [[nodiscard]] QString downloadPath() const {
  159. return _downloadPath.current();
  160. }
  161. [[nodiscard]] rpl::producer<QString> downloadPathValue() const {
  162. return _downloadPath.value();
  163. }
  164. void setDownloadPath(const QString &value) {
  165. _downloadPath = value;
  166. }
  167. [[nodiscard]] QByteArray downloadPathBookmark() const {
  168. return _downloadPathBookmark;
  169. }
  170. void setDownloadPathBookmark(const QByteArray &value) {
  171. _downloadPathBookmark = value;
  172. }
  173. [[nodiscard]] bool soundNotify() const {
  174. return _soundNotify;
  175. }
  176. void setSoundNotify(bool value) {
  177. _soundNotify = value;
  178. }
  179. [[nodiscard]] bool desktopNotify() const {
  180. return _desktopNotify;
  181. }
  182. void setDesktopNotify(bool value) {
  183. _desktopNotify = value;
  184. }
  185. [[nodiscard]] bool flashBounceNotify() const {
  186. return _flashBounceNotify;
  187. }
  188. void setFlashBounceNotify(bool value) {
  189. _flashBounceNotify = value;
  190. }
  191. [[nodiscard]] NotifyView notifyView() const {
  192. return _notifyView;
  193. }
  194. void setNotifyView(NotifyView value) {
  195. _notifyView = value;
  196. }
  197. [[nodiscard]] bool nativeNotifications() const;
  198. void setNativeNotifications(bool value);
  199. [[nodiscard]] bool skipToastsInFocus() const;
  200. void setSkipToastsInFocus(bool value);
  201. [[nodiscard]] int notificationsCount() const {
  202. return _notificationsCount;
  203. }
  204. void setNotificationsCount(int value) {
  205. _notificationsCount = value;
  206. }
  207. [[nodiscard]] ScreenCorner notificationsCorner() const {
  208. return _notificationsCorner;
  209. }
  210. void setNotificationsCorner(ScreenCorner corner) {
  211. _notificationsCorner = corner;
  212. }
  213. [[nodiscard]] bool includeMutedCounter() const {
  214. return _includeMutedCounter;
  215. }
  216. void setIncludeMutedCounter(bool value) {
  217. _includeMutedCounter = value;
  218. }
  219. [[nodiscard]] bool includeMutedCounterFolders() const {
  220. return _includeMutedCounterFolders;
  221. }
  222. void setIncludeMutedCounterFolders(bool value) {
  223. _includeMutedCounterFolders = value;
  224. }
  225. [[nodiscard]] bool countUnreadMessages() const {
  226. return _countUnreadMessages;
  227. }
  228. void setCountUnreadMessages(bool value) {
  229. _countUnreadMessages = value;
  230. }
  231. void setNotifyAboutPinned(bool notify) {
  232. _notifyAboutPinned = notify;
  233. }
  234. [[nodiscard]] bool notifyAboutPinned() const {
  235. return _notifyAboutPinned.current();
  236. }
  237. [[nodiscard]] rpl::producer<bool> notifyAboutPinnedChanges() const {
  238. return _notifyAboutPinned.changes();
  239. }
  240. [[nodiscard]] int autoLock() const {
  241. return _autoLock;
  242. }
  243. void setAutoLock(int value) {
  244. _autoLock = value;
  245. }
  246. [[nodiscard]] QString playbackDeviceId() const {
  247. return _playbackDeviceId.current();
  248. }
  249. [[nodiscard]] rpl::producer<QString> playbackDeviceIdChanges() const {
  250. return _playbackDeviceId.changes();
  251. }
  252. [[nodiscard]] rpl::producer<QString> playbackDeviceIdValue() const {
  253. return _playbackDeviceId.value();
  254. }
  255. void setPlaybackDeviceId(const QString &value) {
  256. _playbackDeviceId = value;
  257. }
  258. [[nodiscard]] QString captureDeviceId() const {
  259. return _captureDeviceId.current();
  260. }
  261. [[nodiscard]] rpl::producer<QString> captureDeviceIdChanges() const {
  262. return _captureDeviceId.changes();
  263. }
  264. [[nodiscard]] rpl::producer<QString> captureDeviceIdValue() const {
  265. return _captureDeviceId.value();
  266. }
  267. void setCaptureDeviceId(const QString &value) {
  268. _captureDeviceId = value;
  269. }
  270. [[nodiscard]] QString cameraDeviceId() const {
  271. return _cameraDeviceId.current();
  272. }
  273. [[nodiscard]] rpl::producer<QString> cameraDeviceIdChanges() const {
  274. return _cameraDeviceId.changes();
  275. }
  276. [[nodiscard]] rpl::producer<QString> cameraDeviceIdValue() const {
  277. return _cameraDeviceId.value();
  278. }
  279. void setCameraDeviceId(const QString &value) {
  280. _cameraDeviceId = value;
  281. }
  282. [[nodiscard]] QString callPlaybackDeviceId() const {
  283. return _callPlaybackDeviceId.current();
  284. }
  285. [[nodiscard]] rpl::producer<QString> callPlaybackDeviceIdChanges() const {
  286. return _callPlaybackDeviceId.changes();
  287. }
  288. [[nodiscard]] rpl::producer<QString> callPlaybackDeviceIdValue() const {
  289. return _callPlaybackDeviceId.value();
  290. }
  291. void setCallPlaybackDeviceId(const QString &value) {
  292. _callPlaybackDeviceId = value;
  293. }
  294. [[nodiscard]] QString callCaptureDeviceId() const {
  295. return _callCaptureDeviceId.current();
  296. }
  297. [[nodiscard]] rpl::producer<QString> callCaptureDeviceIdChanges() const {
  298. return _callCaptureDeviceId.changes();
  299. }
  300. [[nodiscard]] rpl::producer<QString> callCaptureDeviceIdValue() const {
  301. return _callCaptureDeviceId.value();
  302. }
  303. void setCallCaptureDeviceId(const QString &value) {
  304. _callCaptureDeviceId = value;
  305. }
  306. [[nodiscard]] int callOutputVolume() const {
  307. return _callOutputVolume;
  308. }
  309. void setCallOutputVolume(int value) {
  310. _callOutputVolume = value;
  311. }
  312. [[nodiscard]] int callInputVolume() const {
  313. return _callInputVolume;
  314. }
  315. void setCallInputVolume(int value) {
  316. _callInputVolume = value;
  317. }
  318. [[nodiscard]] bool callAudioDuckingEnabled() const {
  319. return _callAudioDuckingEnabled;
  320. }
  321. void setCallAudioDuckingEnabled(bool value) {
  322. _callAudioDuckingEnabled = value;
  323. }
  324. [[nodiscard]] bool disableCallsLegacy() const {
  325. return _disableCallsLegacy;
  326. }
  327. [[nodiscard]] bool groupCallPushToTalk() const {
  328. return _groupCallPushToTalk;
  329. }
  330. void setGroupCallPushToTalk(bool value) {
  331. _groupCallPushToTalk = value;
  332. }
  333. [[nodiscard]] QByteArray groupCallPushToTalkShortcut() const {
  334. return _groupCallPushToTalkShortcut;
  335. }
  336. void setGroupCallPushToTalkShortcut(const QByteArray &serialized) {
  337. _groupCallPushToTalkShortcut = serialized;
  338. }
  339. [[nodiscard]] crl::time groupCallPushToTalkDelay() const {
  340. return _groupCallPushToTalkDelay;
  341. }
  342. void setGroupCallPushToTalkDelay(crl::time delay) {
  343. _groupCallPushToTalkDelay = delay;
  344. }
  345. [[nodiscard]] bool groupCallNoiseSuppression() const {
  346. return _groupCallNoiseSuppression;
  347. }
  348. void setGroupCallNoiseSuppression(bool value) {
  349. _groupCallNoiseSuppression = value;
  350. }
  351. [[nodiscard]] Window::Theme::AccentColors &themesAccentColors() {
  352. return _themesAccentColors;
  353. }
  354. void setThemesAccentColors(Window::Theme::AccentColors &&colors) {
  355. _themesAccentColors = std::move(colors);
  356. }
  357. void setLastSeenWarningSeen(bool lastSeenWarningSeen) {
  358. _lastSeenWarningSeen = lastSeenWarningSeen;
  359. }
  360. [[nodiscard]] bool lastSeenWarningSeen() const {
  361. return _lastSeenWarningSeen;
  362. }
  363. void setSendFilesWay(Ui::SendFilesWay way) {
  364. _sendFilesWay = way;
  365. }
  366. [[nodiscard]] Ui::SendFilesWay sendFilesWay() const {
  367. return _sendFilesWay;
  368. }
  369. void setSendSubmitWay(Ui::InputSubmitSettings value) {
  370. _sendSubmitWay = value;
  371. }
  372. [[nodiscard]] Ui::InputSubmitSettings sendSubmitWay() const {
  373. return _sendSubmitWay.current();
  374. }
  375. [[nodiscard]] auto sendSubmitWayValue() const
  376. -> rpl::producer<Ui::InputSubmitSettings> {
  377. return _sendSubmitWay.value();
  378. }
  379. void setSoundOverride(const QString &key, const QString &path) {
  380. _soundOverrides.emplace(key, path);
  381. }
  382. void clearSoundOverrides() {
  383. _soundOverrides.clear();
  384. }
  385. [[nodiscard]] QString getSoundPath(const QString &key) const;
  386. [[nodiscard]] auto noWarningExtensions() const
  387. -> const base::flat_set<QString> & {
  388. return _noWarningExtensions;
  389. }
  390. void setNoWarningExtensions(base::flat_set<QString> extensions) {
  391. _noWarningExtensions = std::move(extensions);
  392. }
  393. [[nodiscard]] bool ipRevealWarning() const {
  394. return _ipRevealWarning;
  395. }
  396. void setIpRevealWarning(bool warning) {
  397. _ipRevealWarning = warning;
  398. }
  399. [[nodiscard]] bool loopAnimatedStickers() const {
  400. return _loopAnimatedStickers;
  401. }
  402. void setLoopAnimatedStickers(bool value) {
  403. _loopAnimatedStickers = value;
  404. }
  405. void setLargeEmoji(bool value) {
  406. _largeEmoji = value;
  407. }
  408. [[nodiscard]] bool largeEmoji() const {
  409. return _largeEmoji.current();
  410. }
  411. [[nodiscard]] rpl::producer<bool> largeEmojiValue() const {
  412. return _largeEmoji.value();
  413. }
  414. [[nodiscard]] rpl::producer<bool> largeEmojiChanges() const {
  415. return _largeEmoji.changes();
  416. }
  417. void setReplaceEmoji(bool value) {
  418. _replaceEmoji = value;
  419. }
  420. [[nodiscard]] bool replaceEmoji() const {
  421. return _replaceEmoji.current();
  422. }
  423. [[nodiscard]] rpl::producer<bool> replaceEmojiValue() const {
  424. return _replaceEmoji.value();
  425. }
  426. [[nodiscard]] rpl::producer<bool> replaceEmojiChanges() const {
  427. return _replaceEmoji.changes();
  428. }
  429. [[nodiscard]] bool suggestEmoji() const {
  430. return _suggestEmoji;
  431. }
  432. void setSuggestEmoji(bool value) {
  433. _suggestEmoji = value;
  434. }
  435. [[nodiscard]] bool suggestStickersByEmoji() const {
  436. return _suggestStickersByEmoji;
  437. }
  438. void setSuggestStickersByEmoji(bool value) {
  439. _suggestStickersByEmoji = value;
  440. }
  441. [[nodiscard]] bool suggestAnimatedEmoji() const {
  442. return _suggestAnimatedEmoji;
  443. }
  444. void setSuggestAnimatedEmoji(bool value) {
  445. _suggestAnimatedEmoji = value;
  446. }
  447. void setCornerReaction(bool value) {
  448. _cornerReaction = value;
  449. }
  450. [[nodiscard]] bool cornerReaction() const {
  451. return _cornerReaction.current();
  452. }
  453. [[nodiscard]] rpl::producer<bool> cornerReactionValue() const {
  454. return _cornerReaction.value();
  455. }
  456. [[nodiscard]] rpl::producer<bool> cornerReactionChanges() const {
  457. return _cornerReaction.changes();
  458. }
  459. void setSpellcheckerEnabled(bool value) {
  460. _spellcheckerEnabled = value;
  461. }
  462. bool spellcheckerEnabled() const {
  463. return _spellcheckerEnabled.current();
  464. }
  465. rpl::producer<bool> spellcheckerEnabledValue() const {
  466. return _spellcheckerEnabled.value();
  467. }
  468. rpl::producer<bool> spellcheckerEnabledChanges() const {
  469. return _spellcheckerEnabled.changes();
  470. }
  471. void setDictionariesEnabled(std::vector<int> dictionaries) {
  472. _dictionariesEnabled = std::move(dictionaries);
  473. }
  474. std::vector<int> dictionariesEnabled() const {
  475. return _dictionariesEnabled.current();
  476. }
  477. rpl::producer<std::vector<int>> dictionariesEnabledChanges() const {
  478. return _dictionariesEnabled.changes();
  479. }
  480. void setAutoDownloadDictionaries(bool value) {
  481. _autoDownloadDictionaries = value;
  482. }
  483. bool autoDownloadDictionaries() const {
  484. return _autoDownloadDictionaries.current();
  485. }
  486. rpl::producer<bool> autoDownloadDictionariesValue() const {
  487. return _autoDownloadDictionaries.value();
  488. }
  489. rpl::producer<bool> autoDownloadDictionariesChanges() const {
  490. return _autoDownloadDictionaries.changes();
  491. }
  492. [[nodiscard]] float64 videoPlaybackSpeed(
  493. bool lastNonDefault = false) const {
  494. return (_videoPlaybackSpeed.enabled || lastNonDefault)
  495. ? _videoPlaybackSpeed.value
  496. : 1.;
  497. }
  498. void setVideoPlaybackSpeed(float64 speed) {
  499. if ((_videoPlaybackSpeed.enabled = !Media::EqualSpeeds(speed, 1.))) {
  500. _videoPlaybackSpeed.value = speed;
  501. }
  502. }
  503. [[nodiscard]] float64 voicePlaybackSpeed(
  504. bool lastNonDefault = false) const {
  505. return (_voicePlaybackSpeed.enabled || lastNonDefault)
  506. ? _voicePlaybackSpeed.value
  507. : 1.;
  508. }
  509. void setVoicePlaybackSpeed(float64 speed) {
  510. if ((_voicePlaybackSpeed.enabled = !Media::EqualSpeeds(speed, 1.0))) {
  511. _voicePlaybackSpeed.value = speed;
  512. }
  513. }
  514. // For legacy values read-write outside of Settings.
  515. [[nodiscard]] qint32 videoPlaybackSpeedSerialized() const {
  516. return SerializePlaybackSpeed(_videoPlaybackSpeed);
  517. }
  518. void setVideoPlaybackSpeedSerialized(qint32 value) {
  519. _videoPlaybackSpeed = DeserializePlaybackSpeed(value);
  520. }
  521. [[nodiscard]] QByteArray videoPipGeometry() const {
  522. return _videoPipGeometry;
  523. }
  524. void setVideoPipGeometry(QByteArray geometry) {
  525. _videoPipGeometry = geometry;
  526. }
  527. [[nodiscard]] QByteArray photoEditorBrush() const {
  528. return _photoEditorBrush;
  529. }
  530. void setPhotoEditorBrush(QByteArray brush) {
  531. _photoEditorBrush = brush;
  532. }
  533. [[nodiscard]] float64 rememberedSongVolume() const {
  534. return _rememberedSongVolume;
  535. }
  536. void setRememberedSongVolume(float64 value) {
  537. _rememberedSongVolume = value;
  538. }
  539. [[nodiscard]] bool rememberedSoundNotifyFromTray() const {
  540. return _rememberedSoundNotifyFromTray;
  541. }
  542. void setRememberedSoundNotifyFromTray(bool value) {
  543. _rememberedSoundNotifyFromTray = value;
  544. }
  545. [[nodiscard]] bool rememberedFlashBounceNotifyFromTray() const {
  546. return _rememberedFlashBounceNotifyFromTray;
  547. }
  548. void setRememberedFlashBounceNotifyFromTray(bool value) {
  549. _rememberedFlashBounceNotifyFromTray = value;
  550. }
  551. [[nodiscard]] bool mainMenuAccountsShown() const {
  552. return _mainMenuAccountsShown.current();
  553. }
  554. [[nodiscard]] rpl::producer<bool> mainMenuAccountsShownValue() const {
  555. return _mainMenuAccountsShown.value();
  556. }
  557. void setMainMenuAccountsShown(bool value) {
  558. _mainMenuAccountsShown = value;
  559. }
  560. [[nodiscard]] bool tabbedSelectorSectionEnabled() const {
  561. return _tabbedSelectorSectionEnabled;
  562. }
  563. void setTabbedSelectorSectionEnabled(bool enabled);
  564. [[nodiscard]] bool thirdSectionInfoEnabled() const {
  565. return _thirdSectionInfoEnabled;
  566. }
  567. void setThirdSectionInfoEnabled(bool enabled);
  568. [[nodiscard]] rpl::producer<bool> thirdSectionInfoEnabledValue() const;
  569. [[nodiscard]] int thirdSectionExtendedBy() const {
  570. return _thirdSectionExtendedBy;
  571. }
  572. void setThirdSectionExtendedBy(int savedValue) {
  573. _thirdSectionExtendedBy = savedValue;
  574. }
  575. [[nodiscard]] bool tabbedReplacedWithInfo() const {
  576. return _tabbedReplacedWithInfo;
  577. }
  578. void setTabbedReplacedWithInfo(bool enabled);
  579. [[nodiscard]] rpl::producer<bool> tabbedReplacedWithInfoValue() const;
  580. void setFloatPlayerColumn(Window::Column column) {
  581. _floatPlayerColumn = column;
  582. }
  583. [[nodiscard]] Window::Column floatPlayerColumn() const {
  584. return _floatPlayerColumn;
  585. }
  586. void setFloatPlayerCorner(RectPart corner) {
  587. _floatPlayerCorner = corner;
  588. }
  589. [[nodiscard]] RectPart floatPlayerCorner() const {
  590. return _floatPlayerCorner;
  591. }
  592. [[nodiscard]] bool recordVideoMessages() const {
  593. return _recordVideoMessages;
  594. }
  595. void setRecordVideoMessages(bool value) {
  596. _recordVideoMessages = value;
  597. }
  598. void updateDialogsWidthRatio(float64 ratio, bool nochat);
  599. [[nodiscard]] float64 dialogsWidthRatio(bool nochat) const;
  600. [[nodiscard]] float64 dialogsWithChatWidthRatio() const;
  601. [[nodiscard]] rpl::producer<float64> dialogsWithChatWidthRatioChanges() const;
  602. [[nodiscard]] float64 dialogsNoChatWidthRatio() const;
  603. [[nodiscard]] rpl::producer<float64> dialogsNoChatWidthRatioChanges() const;
  604. void setThirdColumnWidth(int width);
  605. [[nodiscard]] int thirdColumnWidth() const;
  606. [[nodiscard]] rpl::producer<int> thirdColumnWidthChanges() const;
  607. void setNotifyFromAll(bool value) {
  608. _notifyFromAll = value;
  609. }
  610. [[nodiscard]] bool notifyFromAll() const {
  611. return _notifyFromAll;
  612. }
  613. void setNativeWindowFrame(bool value) {
  614. _nativeWindowFrame = value;
  615. }
  616. [[nodiscard]] bool nativeWindowFrame() const {
  617. return _nativeWindowFrame.current();
  618. }
  619. [[nodiscard]] rpl::producer<bool> nativeWindowFrameChanges() const {
  620. return _nativeWindowFrame.changes();
  621. }
  622. void setSystemDarkMode(std::optional<bool> value) {
  623. _systemDarkMode = value;
  624. }
  625. [[nodiscard]] std::optional<bool> systemDarkMode() const {
  626. return _systemDarkMode.current();
  627. }
  628. [[nodiscard]] rpl::producer<std::optional<bool>> systemDarkModeValue() const {
  629. return _systemDarkMode.value();
  630. }
  631. [[nodiscard]] rpl::producer<std::optional<bool>> systemDarkModeChanges() const {
  632. return _systemDarkMode.changes();
  633. }
  634. void setSystemDarkModeEnabled(bool value) {
  635. _systemDarkModeEnabled = value;
  636. }
  637. [[nodiscard]] bool systemDarkModeEnabled() const {
  638. return _systemDarkModeEnabled.current();
  639. }
  640. [[nodiscard]] rpl::producer<bool> systemDarkModeEnabledValue() const {
  641. return _systemDarkModeEnabled.value();
  642. }
  643. [[nodiscard]] rpl::producer<bool> systemDarkModeEnabledChanges() const {
  644. return _systemDarkModeEnabled.changes();
  645. }
  646. [[nodiscard]] WindowTitleContent windowTitleContent() const {
  647. return _windowTitleContent.current();
  648. }
  649. [[nodiscard]] rpl::producer<WindowTitleContent> windowTitleContentChanges() const {
  650. return _windowTitleContent.changes();
  651. }
  652. void setWindowTitleContent(WindowTitleContent content) {
  653. _windowTitleContent = content;
  654. }
  655. [[nodiscard]] const WindowPosition &windowPosition() const {
  656. return _windowPosition;
  657. }
  658. void setWindowPosition(const WindowPosition &position) {
  659. _windowPosition = position;
  660. }
  661. void setWorkMode(WorkMode value) {
  662. _workMode = value;
  663. }
  664. [[nodiscard]] WorkMode workMode() const {
  665. return _workMode.current();
  666. }
  667. [[nodiscard]] rpl::producer<WorkMode> workModeValue() const {
  668. return _workMode.value();
  669. }
  670. [[nodiscard]] rpl::producer<WorkMode> workModeChanges() const {
  671. return _workMode.changes();
  672. }
  673. [[nodiscard]] const std::vector<RecentEmoji> &recentEmoji() const;
  674. void incrementRecentEmoji(RecentEmojiId id);
  675. void hideRecentEmoji(RecentEmojiId id);
  676. void resetRecentEmoji();
  677. void setLegacyRecentEmojiPreload(QVector<QPair<QString, ushort>> data);
  678. [[nodiscard]] rpl::producer<> recentEmojiUpdated() const {
  679. return _recentEmojiUpdated.events();
  680. }
  681. [[nodiscard]] const base::flat_map<QString, uint8> &emojiVariants() const {
  682. return _emojiVariants;
  683. }
  684. [[nodiscard]] EmojiPtr lookupEmojiVariant(EmojiPtr emoji) const;
  685. [[nodiscard]] bool hasChosenEmojiVariant(EmojiPtr emoji) const;
  686. void saveEmojiVariant(EmojiPtr emoji);
  687. void saveAllEmojiVariants(EmojiPtr emoji);
  688. void setLegacyEmojiVariants(QMap<QString, int> data);
  689. [[nodiscard]] bool disableOpenGL() const {
  690. return _disableOpenGL;
  691. }
  692. void setDisableOpenGL(bool value) {
  693. _disableOpenGL = value;
  694. }
  695. [[nodiscard]] base::flags<Calls::Group::StickedTooltip> hiddenGroupCallTooltips() const {
  696. return _hiddenGroupCallTooltips;
  697. }
  698. void setHiddenGroupCallTooltip(Calls::Group::StickedTooltip value) {
  699. _hiddenGroupCallTooltips |= value;
  700. }
  701. void setCloseBehavior(CloseBehavior value) {
  702. _closeBehavior = value;
  703. }
  704. [[nodiscard]] CloseBehavior closeBehavior() const {
  705. return _closeBehavior;
  706. }
  707. void setTrayIconMonochrome(bool value) {
  708. _trayIconMonochrome = value;
  709. }
  710. [[nodiscard]] bool trayIconMonochrome() const {
  711. return _trayIconMonochrome.current();
  712. }
  713. [[nodiscard]] rpl::producer<bool> trayIconMonochromeChanges() const {
  714. return _trayIconMonochrome.changes();
  715. }
  716. void setCustomDeviceModel(const QString &model) {
  717. _customDeviceModel = model;
  718. }
  719. [[nodiscard]] QString customDeviceModel() const {
  720. return _customDeviceModel.current();
  721. }
  722. [[nodiscard]] rpl::producer<QString> customDeviceModelChanges() const {
  723. return _customDeviceModel.changes();
  724. }
  725. [[nodiscard]] rpl::producer<QString> customDeviceModelValue() const {
  726. return _customDeviceModel.value();
  727. }
  728. [[nodiscard]] QString deviceModel() const;
  729. [[nodiscard]] rpl::producer<QString> deviceModelChanges() const;
  730. [[nodiscard]] rpl::producer<QString> deviceModelValue() const;
  731. void setPlayerRepeatMode(Media::RepeatMode mode) {
  732. _playerRepeatMode = mode;
  733. }
  734. [[nodiscard]] Media::RepeatMode playerRepeatMode() const {
  735. return _playerRepeatMode.current();
  736. }
  737. [[nodiscard]] rpl::producer<Media::RepeatMode> playerRepeatModeValue() const {
  738. return _playerRepeatMode.value();
  739. }
  740. [[nodiscard]] rpl::producer<Media::RepeatMode> playerRepeatModeChanges() const {
  741. return _playerRepeatMode.changes();
  742. }
  743. void setPlayerOrderMode(Media::OrderMode mode) {
  744. _playerOrderMode = mode;
  745. }
  746. [[nodiscard]] Media::OrderMode playerOrderMode() const {
  747. return _playerOrderMode.current();
  748. }
  749. [[nodiscard]] rpl::producer<Media::OrderMode> playerOrderModeValue() const {
  750. return _playerOrderMode.value();
  751. }
  752. [[nodiscard]] rpl::producer<Media::OrderMode> playerOrderModeChanges() const {
  753. return _playerOrderMode.changes();
  754. }
  755. [[nodiscard]] std::vector<uint64> accountsOrder() const {
  756. return _accountsOrder;
  757. }
  758. void setAccountsOrder(const std::vector<uint64> &order) {
  759. _accountsOrder = order;
  760. }
  761. [[nodiscard]] bool hardwareAcceleratedVideo() const {
  762. return _hardwareAcceleratedVideo;
  763. }
  764. void setHardwareAcceleratedVideo(bool value) {
  765. _hardwareAcceleratedVideo = value;
  766. }
  767. void setMacWarnBeforeQuit(bool value) {
  768. _macWarnBeforeQuit = value;
  769. }
  770. [[nodiscard]] bool macWarnBeforeQuit() const {
  771. return _macWarnBeforeQuit;
  772. }
  773. void setChatQuickAction(HistoryView::DoubleClickQuickAction value) {
  774. _chatQuickAction = value;
  775. }
  776. [[nodiscard]] HistoryView::DoubleClickQuickAction chatQuickAction() const {
  777. return _chatQuickAction;
  778. }
  779. void setTranslateButtonEnabled(bool value);
  780. [[nodiscard]] bool translateButtonEnabled() const;
  781. void setTranslateChatEnabled(bool value);
  782. [[nodiscard]] bool translateChatEnabled() const;
  783. [[nodiscard]] rpl::producer<bool> translateChatEnabledValue() const;
  784. void setTranslateTo(LanguageId id);
  785. [[nodiscard]] LanguageId translateTo() const;
  786. [[nodiscard]] rpl::producer<LanguageId> translateToValue() const;
  787. void setSkipTranslationLanguages(std::vector<LanguageId> languages);
  788. [[nodiscard]] std::vector<LanguageId> skipTranslationLanguages() const;
  789. [[nodiscard]] auto skipTranslationLanguagesValue() const
  790. -> rpl::producer<std::vector<LanguageId>>;
  791. void setRememberedDeleteMessageOnlyForYou(bool value);
  792. [[nodiscard]] bool rememberedDeleteMessageOnlyForYou() const;
  793. [[nodiscard]] const WindowPosition &mediaViewPosition() const {
  794. return _mediaViewPosition;
  795. }
  796. void setMediaViewPosition(const WindowPosition &position) {
  797. _mediaViewPosition = position;
  798. }
  799. [[nodiscard]] bool ignoreBatterySaving() const {
  800. return _ignoreBatterySaving.current();
  801. }
  802. [[nodiscard]] rpl::producer<bool> ignoreBatterySavingValue() const {
  803. return _ignoreBatterySaving.value();
  804. }
  805. void setIgnoreBatterySavingValue(bool value) {
  806. _ignoreBatterySaving = value;
  807. }
  808. void setMacRoundIconDigest(std::optional<uint64> value) {
  809. _macRoundIconDigest = value;
  810. }
  811. [[nodiscard]] std::optional<uint64> macRoundIconDigest() const {
  812. return _macRoundIconDigest;
  813. }
  814. [[nodiscard]] bool storiesClickTooltipHidden() const {
  815. return _storiesClickTooltipHidden.current();
  816. }
  817. [[nodiscard]] rpl::producer<bool> storiesClickTooltipHiddenValue() const {
  818. return _storiesClickTooltipHidden.value();
  819. }
  820. void setStoriesClickTooltipHidden(bool value) {
  821. _storiesClickTooltipHidden = value;
  822. }
  823. [[nodiscard]] bool ttlVoiceClickTooltipHidden() const {
  824. return _ttlVoiceClickTooltipHidden.current();
  825. }
  826. [[nodiscard]] rpl::producer<bool> ttlVoiceClickTooltipHiddenValue() const {
  827. return _ttlVoiceClickTooltipHidden.value();
  828. }
  829. void setTtlVoiceClickTooltipHidden(bool value) {
  830. _ttlVoiceClickTooltipHidden = value;
  831. }
  832. [[nodiscard]] const WindowPosition &ivPosition() const {
  833. return _ivPosition;
  834. }
  835. void setIvPosition(const WindowPosition &position) {
  836. _ivPosition = position;
  837. }
  838. [[nodiscard]] QString customFontFamily() const {
  839. return _customFontFamily;
  840. }
  841. void setCustomFontFamily(const QString &value) {
  842. _customFontFamily = value;
  843. }
  844. [[nodiscard]] bool systemUnlockEnabled() const {
  845. return _systemUnlockEnabled;
  846. }
  847. void setSystemUnlockEnabled(bool enabled) {
  848. _systemUnlockEnabled = enabled;
  849. }
  850. [[nodiscard]] std::optional<bool> weatherInCelsius() const {
  851. return _weatherInCelsius;
  852. }
  853. void setWeatherInCelsius(bool value) {
  854. _weatherInCelsius = value;
  855. }
  856. [[nodiscard]] QByteArray tonsiteStorageToken() const {
  857. return _tonsiteStorageToken;
  858. }
  859. void setTonsiteStorageToken(const QByteArray &value) {
  860. _tonsiteStorageToken = value;
  861. }
  862. [[nodiscard]] int ivZoom() const;
  863. [[nodiscard]] rpl::producer<int> ivZoomValue() const;
  864. void setIvZoom(int value);
  865. [[nodiscard]] bool chatFiltersHorizontal() const;
  866. [[nodiscard]] rpl::producer<bool> chatFiltersHorizontalChanges() const;
  867. void setChatFiltersHorizontal(bool value);
  868. [[nodiscard]] Media::VideoQuality videoQuality() const;
  869. void setVideoQuality(Media::VideoQuality quality);
  870. [[nodiscard]] static bool ThirdColumnByDefault();
  871. [[nodiscard]] static float64 DefaultDialogsWidthRatio();
  872. struct PlaybackSpeed {
  873. float64 value = Media::kSpedUpDefault;
  874. bool enabled = false;
  875. };
  876. [[nodiscard]] static qint32 SerializePlaybackSpeed(PlaybackSpeed speed);
  877. [[nodiscard]] static PlaybackSpeed DeserializePlaybackSpeed(
  878. qint32 speed);
  879. [[nodiscard]] Dialogs::Ui::QuickDialogAction quickDialogAction() const;
  880. void setQuickDialogAction(Dialogs::Ui::QuickDialogAction);
  881. void resetOnLastLogout();
  882. private:
  883. void resolveRecentEmoji() const;
  884. static constexpr auto kDefaultThirdColumnWidth = 0;
  885. static constexpr auto kDefaultDialogsWidthRatio = 5. / 14;
  886. static constexpr auto kDefaultBigDialogsWidthRatio = 0.275;
  887. struct RecentEmojiPreload {
  888. QString emoji;
  889. ushort rating = 0;
  890. };
  891. SettingsProxy _proxy;
  892. rpl::variable<bool> _adaptiveForWide = true;
  893. bool _moderateModeEnabled = false;
  894. rpl::variable<float64> _songVolume = kDefaultVolume;
  895. rpl::variable<float64> _videoVolume = kDefaultVolume;
  896. bool _askDownloadPath = false;
  897. rpl::variable<QString> _downloadPath;
  898. QByteArray _downloadPathBookmark;
  899. bool _soundNotify = true;
  900. bool _desktopNotify = true;
  901. bool _flashBounceNotify = true;
  902. NotifyView _notifyView = NotifyView::ShowPreview;
  903. std::optional<bool> _nativeNotifications;
  904. bool _skipToastsInFocus = false;
  905. int _notificationsCount = 3;
  906. ScreenCorner _notificationsCorner = ScreenCorner::BottomRight;
  907. bool _includeMutedCounter = true;
  908. bool _includeMutedCounterFolders = true;
  909. bool _countUnreadMessages = true;
  910. rpl::variable<bool> _notifyAboutPinned = true;
  911. int _autoLock = 3600;
  912. rpl::variable<QString> _playbackDeviceId;
  913. rpl::variable<QString> _captureDeviceId;
  914. rpl::variable<QString> _cameraDeviceId;
  915. rpl::variable<QString> _callPlaybackDeviceId;
  916. rpl::variable<QString> _callCaptureDeviceId;
  917. int _callOutputVolume = 100;
  918. int _callInputVolume = 100;
  919. bool _callAudioDuckingEnabled = true;
  920. bool _disableCallsLegacy = false;
  921. bool _groupCallPushToTalk = false;
  922. bool _groupCallNoiseSuppression = false;
  923. QByteArray _groupCallPushToTalkShortcut;
  924. crl::time _groupCallPushToTalkDelay = 20;
  925. Window::Theme::AccentColors _themesAccentColors;
  926. bool _lastSeenWarningSeen = false;
  927. Ui::SendFilesWay _sendFilesWay = Ui::SendFilesWay();
  928. rpl::variable<Ui::InputSubmitSettings> _sendSubmitWay
  929. = Ui::InputSubmitSettings();
  930. base::flat_map<QString, QString> _soundOverrides;
  931. base::flat_set<QString> _noWarningExtensions;
  932. bool _ipRevealWarning = true;
  933. bool _loopAnimatedStickers = true;
  934. rpl::variable<bool> _largeEmoji = true;
  935. rpl::variable<bool> _replaceEmoji = true;
  936. bool _suggestEmoji = true;
  937. bool _suggestStickersByEmoji = true;
  938. bool _suggestAnimatedEmoji = true;
  939. rpl::variable<bool> _cornerReaction = true;
  940. rpl::variable<bool> _spellcheckerEnabled = true;
  941. PlaybackSpeed _videoPlaybackSpeed;
  942. PlaybackSpeed _voicePlaybackSpeed;
  943. QByteArray _videoPipGeometry;
  944. rpl::variable<std::vector<int>> _dictionariesEnabled;
  945. rpl::variable<bool> _autoDownloadDictionaries = true;
  946. rpl::variable<bool> _mainMenuAccountsShown = true;
  947. mutable std::vector<RecentEmojiPreload> _recentEmojiPreload;
  948. mutable std::vector<RecentEmoji> _recentEmoji;
  949. base::flat_set<QString> _recentEmojiSkip;
  950. mutable bool _recentEmojiResolved = false;
  951. base::flat_map<QString, uint8> _emojiVariants;
  952. rpl::event_stream<> _recentEmojiUpdated;
  953. bool _tabbedSelectorSectionEnabled = false; // per-window
  954. Window::Column _floatPlayerColumn = Window::Column(); // per-window
  955. RectPart _floatPlayerCorner = RectPart(); // per-window
  956. bool _thirdSectionInfoEnabled = true; // per-window
  957. rpl::event_stream<bool> _thirdSectionInfoEnabledValue; // per-window
  958. int _thirdSectionExtendedBy = -1; // per-window
  959. rpl::variable<float64> _dialogsWithChatWidthRatio; // per-window
  960. rpl::variable<float64> _dialogsNoChatWidthRatio; // per-window
  961. rpl::variable<int> _thirdColumnWidth = kDefaultThirdColumnWidth; // p-w
  962. bool _notifyFromAll = true;
  963. rpl::variable<bool> _nativeWindowFrame = false;
  964. rpl::variable<std::optional<bool>> _systemDarkMode = std::nullopt;
  965. rpl::variable<bool> _systemDarkModeEnabled = true;
  966. rpl::variable<WindowTitleContent> _windowTitleContent;
  967. WindowPosition _windowPosition; // per-window
  968. bool _disableOpenGL = false;
  969. rpl::variable<WorkMode> _workMode = WorkMode::WindowAndTray;
  970. base::flags<Calls::Group::StickedTooltip> _hiddenGroupCallTooltips;
  971. CloseBehavior _closeBehavior = CloseBehavior::Quit;
  972. rpl::variable<bool> _trayIconMonochrome = true;
  973. rpl::variable<QString> _customDeviceModel;
  974. rpl::variable<Media::RepeatMode> _playerRepeatMode;
  975. rpl::variable<Media::OrderMode> _playerOrderMode;
  976. bool _macWarnBeforeQuit = true;
  977. std::vector<uint64> _accountsOrder;
  978. #ifdef Q_OS_MAC
  979. bool _hardwareAcceleratedVideo = true;
  980. #else // Q_OS_MAC
  981. bool _hardwareAcceleratedVideo = false;
  982. #endif // Q_OS_MAC
  983. HistoryView::DoubleClickQuickAction _chatQuickAction
  984. = HistoryView::DoubleClickQuickAction();
  985. bool _translateButtonEnabled = false;
  986. rpl::variable<bool> _translateChatEnabled = true;
  987. rpl::variable<int> _translateToRaw = 0;
  988. rpl::variable<std::vector<LanguageId>> _skipTranslationLanguages;
  989. rpl::event_stream<> _skipTranslationLanguagesChanges;
  990. bool _rememberedDeleteMessageOnlyForYou = false;
  991. WindowPosition _mediaViewPosition = { .maximized = 2 };
  992. rpl::variable<bool> _ignoreBatterySaving = false;
  993. std::optional<uint64> _macRoundIconDigest;
  994. rpl::variable<bool> _storiesClickTooltipHidden = false;
  995. rpl::variable<bool> _ttlVoiceClickTooltipHidden = false;
  996. WindowPosition _ivPosition;
  997. QString _customFontFamily;
  998. bool _systemUnlockEnabled = false;
  999. std::optional<bool> _weatherInCelsius;
  1000. QByteArray _tonsiteStorageToken;
  1001. rpl::variable<int> _ivZoom = 100;
  1002. Media::VideoQuality _videoQuality;
  1003. rpl::variable<bool> _chatFiltersHorizontal = false;
  1004. bool _tabbedReplacedWithInfo = false; // per-window
  1005. rpl::event_stream<bool> _tabbedReplacedWithInfoValue; // per-window
  1006. rpl::event_stream<> _saveDelayed;
  1007. float64 _rememberedSongVolume = kDefaultVolume;
  1008. bool _rememberedSoundNotifyFromTray = false;
  1009. bool _rememberedFlashBounceNotifyFromTray = false;
  1010. bool _dialogsWidthSetToZeroWithoutChat = false;
  1011. bool _recordVideoMessages = false;
  1012. Dialogs::Ui::QuickDialogAction _quickDialogAction
  1013. = Dialogs::Ui::QuickDialogAction::Disabled;
  1014. QByteArray _photoEditorBrush;
  1015. };
  1016. } // namespace Core