theme.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  1. /*
  2. * Copyright (C) by Klaas Freitag <freitag@owncloud.com>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  11. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  12. * for more details.
  13. */
  14. #ifndef _THEME_H
  15. #define _THEME_H
  16. #include <QIcon>
  17. #include <QObject>
  18. #include <QPalette>
  19. #include <QGuiApplication>
  20. #include "syncresult.h"
  21. class QString;
  22. class QObject;
  23. class QPixmap;
  24. class QColor;
  25. class QPaintDevice;
  26. namespace OCC {
  27. class SyncResult;
  28. /**
  29. * @brief The Theme class
  30. * @ingroup libsync
  31. */
  32. class OWNCLOUDSYNC_EXPORT Theme : public QObject
  33. {
  34. Q_OBJECT
  35. Q_PROPERTY(bool branded READ isBranded CONSTANT)
  36. Q_PROPERTY(QString appNameGUI READ appNameGUI CONSTANT)
  37. Q_PROPERTY(QString appName READ appName CONSTANT)
  38. Q_PROPERTY(QUrl stateOnlineImageSource READ stateOnlineImageSource CONSTANT)
  39. Q_PROPERTY(QUrl stateOfflineImageSource READ stateOfflineImageSource CONSTANT)
  40. Q_PROPERTY(QUrl statusOnlineImageSource READ statusOnlineImageSource CONSTANT)
  41. Q_PROPERTY(QUrl statusDoNotDisturbImageSource READ statusDoNotDisturbImageSource CONSTANT)
  42. Q_PROPERTY(QUrl statusAwayImageSource READ statusAwayImageSource CONSTANT)
  43. Q_PROPERTY(QUrl statusInvisibleImageSource READ statusInvisibleImageSource CONSTANT)
  44. #ifndef TOKEN_AUTH_ONLY
  45. Q_PROPERTY(QIcon folderDisabledIcon READ folderDisabledIcon CONSTANT)
  46. Q_PROPERTY(QIcon folderOfflineIcon READ folderOfflineIcon CONSTANT)
  47. Q_PROPERTY(QIcon applicationIcon READ applicationIcon CONSTANT)
  48. #endif
  49. Q_PROPERTY(QString version READ version CONSTANT)
  50. Q_PROPERTY(QString helpUrl READ helpUrl CONSTANT)
  51. Q_PROPERTY(QString conflictHelpUrl READ conflictHelpUrl CONSTANT)
  52. Q_PROPERTY(QString overrideServerUrl READ overrideServerUrl WRITE setOverrideServerUrl NOTIFY overrideServerUrlChanged)
  53. Q_PROPERTY(bool forceOverrideServerUrl READ forceOverrideServerUrl WRITE setForceOverrideServerUrl NOTIFY forceOverrideServerUrlChanged)
  54. Q_PROPERTY(bool isVfsEnabled READ isVfsEnabled WRITE setVfsEnabled NOTIFY vfsEnabledChanged)
  55. Q_PROPERTY(bool startLoginFlowAutomatically READ startLoginFlowAutomatically WRITE setStartLoginFlowAutomatically NOTIFY startLoginFlowAutomaticallyChanged)
  56. #ifndef TOKEN_AUTH_ONLY
  57. Q_PROPERTY(QColor wizardHeaderTitleColor READ wizardHeaderTitleColor CONSTANT)
  58. Q_PROPERTY(QColor wizardHeaderBackgroundColor READ wizardHeaderBackgroundColor CONSTANT)
  59. #endif
  60. Q_PROPERTY(QString updateCheckUrl READ updateCheckUrl CONSTANT)
  61. Q_PROPERTY(QColor defaultColor READ defaultColor CONSTANT)
  62. Q_PROPERTY(QPalette systemPalette READ systemPalette NOTIFY systemPaletteChanged)
  63. Q_PROPERTY(bool darkMode READ darkMode NOTIFY darkModeChanged)
  64. public:
  65. enum CustomMediaType {
  66. oCSetupTop, // ownCloud connect page
  67. oCSetupSide,
  68. oCSetupBottom,
  69. oCSetupResultTop // ownCloud connect result page
  70. };
  71. /* returns a singleton instance. */
  72. static Theme *instance();
  73. ~Theme() override;
  74. /**
  75. * @brief isBranded indicates if the current application is branded
  76. *
  77. * By default, it is considered branded if the APPLICATION_NAME is
  78. * different from "Nextcloud".
  79. *
  80. * @return true if branded, false otherwise
  81. */
  82. [[nodiscard]] bool isBranded() const;
  83. /**
  84. * @brief appNameGUI - Human readable application name.
  85. *
  86. * Use and redefine this if the human readable name contains spaces,
  87. * special chars and such.
  88. *
  89. * By default, the name is derived from the APPLICATION_NAME
  90. * cmake variable.
  91. *
  92. * @return QString with human readable app name.
  93. */
  94. [[nodiscard]] QString appNameGUI() const;
  95. /**
  96. * @brief appName - Application name (short)
  97. *
  98. * Use and redefine this as an application name. Keep it straight as
  99. * it is used for config files etc. If you need a more sophisticated
  100. * name in the GUI, redefine appNameGUI.
  101. *
  102. * By default, the name is derived from the APPLICATION_SHORTNAME
  103. * cmake variable, and should be the same. This method is only
  104. * reimplementable for legacy reasons.
  105. *
  106. * Warning: Do not modify this value, as many things, e.g. settings
  107. * depend on it! You most likely want to modify \ref appNameGUI().
  108. *
  109. * @return QString with app name.
  110. */
  111. [[nodiscard]] QString appName() const;
  112. /**
  113. * @brief Returns full path to an online state icon
  114. * @return QUrl full path to an icon
  115. */
  116. [[nodiscard]] QUrl stateOnlineImageSource() const;
  117. /**
  118. * @brief Returns full path to an offline state icon
  119. * @return QUrl full path to an icon
  120. */
  121. [[nodiscard]] QUrl stateOfflineImageSource() const;
  122. /**
  123. * @brief Returns full path to an online user status icon
  124. * @return QUrl full path to an icon
  125. */
  126. [[nodiscard]] QUrl statusOnlineImageSource() const;
  127. /**
  128. * @brief Returns full path to an do not disturb user status icon
  129. * @return QUrl full path to an icon
  130. */
  131. [[nodiscard]] QUrl statusDoNotDisturbImageSource() const;
  132. /**
  133. * @brief Returns full path to an away user status icon
  134. * @return QUrl full path to an icon
  135. */
  136. [[nodiscard]] QUrl statusAwayImageSource() const;
  137. /**
  138. * @brief Returns full path to an invisible user status icon
  139. * @return QUrl full path to an icon
  140. */
  141. [[nodiscard]] QUrl statusInvisibleImageSource() const;
  142. [[nodiscard]] QUrl syncStatusOk() const;
  143. [[nodiscard]] QUrl syncStatusError() const;
  144. [[nodiscard]] QUrl syncStatusRunning() const;
  145. [[nodiscard]] QUrl syncStatusPause() const;
  146. [[nodiscard]] QUrl syncStatusWarning() const;
  147. [[nodiscard]] QUrl folderOffline() const;
  148. /**
  149. * @brief configFileName
  150. * @return the name of the config file.
  151. */
  152. [[nodiscard]] QString configFileName() const;
  153. #ifndef TOKEN_AUTH_ONLY
  154. static QString hidpiFileName(const QString &fileName, QPaintDevice *dev = nullptr);
  155. static QString hidpiFileName(const QString &iconName, const QColor &backgroundColor, QPaintDevice *dev = nullptr);
  156. static bool isHidpi(QPaintDevice *dev = nullptr);
  157. /**
  158. * get an sync state icon
  159. */
  160. [[nodiscard]] QIcon syncStateIcon(SyncResult::Status, bool sysTray = false) const;
  161. [[nodiscard]] QIcon folderDisabledIcon() const;
  162. [[nodiscard]] QIcon folderOfflineIcon(bool sysTray = false) const;
  163. [[nodiscard]] QIcon applicationIcon() const;
  164. #endif
  165. [[nodiscard]] QString statusHeaderText(SyncResult::Status) const;
  166. [[nodiscard]] QString version() const;
  167. /**
  168. * Characteristics: bool if more than one sync folder is allowed
  169. */
  170. [[nodiscard]] bool singleSyncFolder() const;
  171. /**
  172. * When true, client works with multiple accounts.
  173. */
  174. [[nodiscard]] bool multiAccount() const;
  175. /**
  176. * URL to documentation.
  177. *
  178. * This is opened in the browser when the "Help" action is selected from the tray menu.
  179. *
  180. * If the function is overridden to return an empty string the action is removed from
  181. * the menu.
  182. *
  183. * Defaults to Nextclouds client documentation website.
  184. */
  185. [[nodiscard]] QString helpUrl() const;
  186. /**
  187. * The url to use for showing help on conflicts.
  188. *
  189. * If the function is overridden to return an empty string no help link will be shown.
  190. *
  191. * Defaults to helpUrl() + "conflicts.html", which is a page in ownCloud's client
  192. * documentation website. If helpUrl() is empty, this function will also return the
  193. * empty string.
  194. */
  195. [[nodiscard]] QString conflictHelpUrl() const;
  196. /**
  197. * Setting a value here will pre-define the server url.
  198. *
  199. * The respective UI controls will be disabled only if forceOverrideServerUrl() is true
  200. */
  201. [[nodiscard]] QString overrideServerUrl() const;
  202. /**
  203. * Enforce a pre-defined server url.
  204. *
  205. * When true, the respective UI controls will be disabled
  206. */
  207. [[nodiscard]] bool forceOverrideServerUrl() const;
  208. /**
  209. * Enforce use of virtual files whenever possible.
  210. */
  211. [[nodiscard]] bool isVfsEnabled() const;
  212. /**
  213. * Automatically start login flow
  214. *
  215. * When true, the browser will get opened automatically
  216. */
  217. [[nodiscard]] bool startLoginFlowAutomatically() const;
  218. /**
  219. * Enable OCSP stapling for SSL handshakes
  220. *
  221. * When true, peer will be requested for Online Certificate Status Protocol response
  222. */
  223. [[nodiscard]] bool enableStaplingOCSP() const;
  224. /**
  225. * Enforce SSL validity
  226. *
  227. * When true, trusting the untrusted certificate is not allowed
  228. */
  229. [[nodiscard]] bool forbidBadSSL() const;
  230. /**
  231. * Forbid use of proxy
  232. *
  233. * When true, the app always connects to the server directly
  234. */
  235. [[nodiscard]] bool doNotUseProxy() const;
  236. /**
  237. * This is only usefull when previous version had a different overrideServerUrl
  238. * with a different auth type in that case You should then specify "http" or "shibboleth".
  239. * Normaly this should be left empty.
  240. */
  241. [[nodiscard]] QString forceConfigAuthType() const;
  242. /**
  243. * The default folder name without path on the server at setup time.
  244. */
  245. [[nodiscard]] QString defaultServerFolder() const;
  246. /**
  247. * The default folder name without path on the client side at setup time.
  248. */
  249. [[nodiscard]] QString defaultClientFolder() const;
  250. /**
  251. * Override to encforce a particular locale, i.e. "de" or "pt_BR"
  252. */
  253. [[nodiscard]] QString enforcedLocale() const { return QString(); }
  254. /** colored, white or black */
  255. [[nodiscard]] QString systrayIconFlavor(bool mono) const;
  256. #ifndef TOKEN_AUTH_ONLY
  257. /**
  258. * Override to use a string or a custom image name.
  259. * The default implementation will try to look up
  260. * :/client/theme/<type>.png
  261. */
  262. [[nodiscard]] QVariant customMedia(CustomMediaType type);
  263. /** @return color for the setup wizard */
  264. [[nodiscard]] QColor wizardHeaderTitleColor() const;
  265. /** @return color for the setup wizard. */
  266. [[nodiscard]] QColor wizardHeaderBackgroundColor() const;
  267. [[nodiscard]] QPixmap wizardApplicationLogo() const;
  268. /** @return logo for the setup wizard. */
  269. [[nodiscard]] QPixmap wizardHeaderLogo() const;
  270. /**
  271. * The default implementation creates a
  272. * background based on
  273. * \ref wizardHeaderTitleColor().
  274. *
  275. * @return banner for the setup wizard.
  276. */
  277. [[nodiscard]] QPixmap wizardHeaderBanner() const;
  278. #endif
  279. /**
  280. * The SHA sum of the released git commit
  281. */
  282. [[nodiscard]] QString gitSHA1() const;
  283. /**
  284. * About dialog contents
  285. */
  286. [[nodiscard]] QString about() const;
  287. /**
  288. * Legal notice dialog version detail contents
  289. */
  290. [[nodiscard]] QString aboutDetails() const;
  291. /**
  292. * Define if the systray icons should be using mono design
  293. */
  294. void setSystrayUseMonoIcons(bool mono);
  295. /**
  296. * Retrieve wether to use mono icons for systray
  297. */
  298. [[nodiscard]] bool systrayUseMonoIcons() const;
  299. /**
  300. * Check if mono icons are available
  301. */
  302. [[nodiscard]] bool monoIconsAvailable() const;
  303. /**
  304. * @brief Where to check for new Updates.
  305. */
  306. [[nodiscard]] QString updateCheckUrl() const;
  307. /**
  308. * When true, the setup wizard will show the selective sync dialog by default and default
  309. * to nothing selected
  310. */
  311. [[nodiscard]] bool wizardSelectiveSyncDefaultNothing() const;
  312. /**
  313. * Default option for the newBigFolderSizeLimit.
  314. * Size in MB of the maximum size of folder before we ask the confirmation.
  315. * Set -1 to never ask confirmation. 0 to ask confirmation for every folder.
  316. **/
  317. [[nodiscard]] qint64 newBigFolderSizeLimit() const;
  318. /**
  319. * Hide the checkbox that says "Ask for confirmation before synchronizing folders larger than X MB"
  320. * in the account wizard
  321. */
  322. [[nodiscard]] bool wizardHideFolderSizeLimitCheckbox() const;
  323. /**
  324. * Hide the checkbox that says "Ask for confirmation before synchronizing external storages"
  325. * in the account wizard
  326. */
  327. [[nodiscard]] bool wizardHideExternalStorageConfirmationCheckbox() const;
  328. /**
  329. * @brief Sharing options
  330. *
  331. * Allow link sharing and or user/group sharing
  332. */
  333. [[nodiscard]] bool linkSharing() const;
  334. [[nodiscard]] bool userGroupSharing() const;
  335. /**
  336. * If this returns true, the user cannot configure the proxy in the network settings.
  337. * The proxy settings will be disabled in the configuration dialog.
  338. * Default returns false.
  339. */
  340. [[nodiscard]] bool forceSystemNetworkProxy() const;
  341. /**
  342. * @brief How to handle the userID
  343. *
  344. * @value UserIDUserName Wizard asks for username as ID
  345. * @value UserIDEmail Wizard asks for an email as ID
  346. * @value UserIDCustom Specify string in \ref customUserID
  347. */
  348. enum UserIDType { UserIDUserName = 0,
  349. UserIDEmail,
  350. UserIDCustom };
  351. /** @brief What to display as the userID (e.g. in the wizards)
  352. *
  353. * @return UserIDType::UserIDUserName, unless reimplemented
  354. */
  355. [[nodiscard]] UserIDType userIDType() const;
  356. /**
  357. * @brief Allows to customize the type of user ID (e.g. user name, email)
  358. *
  359. * @note This string cannot be translated, but is still useful for
  360. * referencing brand name IDs (e.g. "ACME ID", when using ACME.)
  361. *
  362. * @return An empty string, unless reimplemented
  363. */
  364. [[nodiscard]] QString customUserID() const;
  365. /**
  366. * @brief Demo string to be displayed when no text has been
  367. * entered for the user id (e.g. mylogin@company.com)
  368. *
  369. * @return An empty string, unless reimplemented
  370. */
  371. [[nodiscard]] QString userIDHint() const;
  372. /**
  373. * @brief Postfix that will be enforced in a URL. e.g.
  374. * ".myhosting.com".
  375. *
  376. * @return An empty string, unless reimplemented
  377. */
  378. [[nodiscard]] QString wizardUrlPostfix() const;
  379. /**
  380. * @brief String that will be shown as long as no text has been entered by the user.
  381. *
  382. * @return An empty string, unless reimplemented
  383. */
  384. [[nodiscard]] virtual QString wizardUrlHint() const;
  385. /**
  386. * @brief the server folder that should be queried for the quota information
  387. *
  388. * This can be configured to show the quota infromation for a different
  389. * folder than the root. This is the folder on which the client will do
  390. * PROPFIND calls to get "quota-available-bytes" and "quota-used-bytes"
  391. *
  392. * Defaults: "/"
  393. */
  394. [[nodiscard]] QString quotaBaseFolder() const;
  395. /**
  396. * The OAuth client_id, secret pair.
  397. * Note that client that change these value cannot connect to un-branded owncloud servers.
  398. */
  399. [[nodiscard]] QString oauthClientId() const;
  400. [[nodiscard]] QString oauthClientSecret() const;
  401. /**
  402. * @brief What should be output for the --version command line switch.
  403. *
  404. * By default, it's a combination of appName(), version(), the GIT SHA1 and some
  405. * important dependency versions.
  406. */
  407. [[nodiscard]] QString versionSwitchOutput() const;
  408. /**
  409. * @brief Request suitable QIcon resource depending on the background colour of the parent widget.
  410. *
  411. * This should be replaced (TODO) by a real theming implementation for the client UI
  412. * (actually 2019/09/13 only systray theming).
  413. */
  414. [[nodiscard]] QIcon uiThemeIcon(const QString &iconName, bool uiHasDarkBg) const;
  415. Q_INVOKABLE static double getColorDarkness(const QColor &color);
  416. /**
  417. * @brief Perform a calculation to check if a colour is dark or light and accounts for different sensitivity of the human eye.
  418. *
  419. * @return True if the specified colour is dark.
  420. *
  421. * 2019/12/08: Moved here from SettingsDialog.
  422. */
  423. Q_INVOKABLE static bool isDarkColor(const QColor &color);
  424. /**
  425. * @brief Return the colour to be used for HTML links (e.g. used in QLabel), based on the current app palette or given colour (Dark-/Light-Mode switching).
  426. *
  427. * @return Background-aware colour for HTML links, based on the current app palette or given colour.
  428. *
  429. * 2019/12/08: Implemented for the Dark Mode on macOS, because the app palette can not account for that (Qt 5.12.5).
  430. */
  431. static QColor getBackgroundAwareLinkColor(const QColor &backgroundColor);
  432. /**
  433. * @brief Return the colour to be used for HTML links (e.g. used in QLabel), based on the current app palette (Dark-/Light-Mode switching).
  434. *
  435. * @return Background-aware colour for HTML links, based on the current app palette.
  436. *
  437. * 2019/12/08: Implemented for the Dark Mode on macOS, because the app palette can not account for that (Qt 5.12.5).
  438. */
  439. static QColor getBackgroundAwareLinkColor();
  440. /**
  441. * @brief Appends a CSS-style colour value to all HTML link tags in a given string, based on the current app palette or given colour (Dark-/Light-Mode switching).
  442. *
  443. * 2019/12/08: Implemented for the Dark Mode on macOS, because the app palette can not account for that (Qt 5.12.5).
  444. *
  445. * This way we also avoid having certain strings re-translated on Transifex.
  446. */
  447. static void replaceLinkColorStringBackgroundAware(QString &linkString, const QColor &backgroundColor);
  448. /**
  449. * @brief Appends a CSS-style colour value to all HTML link tags in a given string, based on the current app palette (Dark-/Light-Mode switching).
  450. *
  451. * 2019/12/08: Implemented for the Dark Mode on macOS, because the app palette can not account for that (Qt 5.12.5).
  452. *
  453. * This way we also avoid having certain strings re-translated on Transifex.
  454. */
  455. static void replaceLinkColorStringBackgroundAware(QString &linkString);
  456. /**
  457. * @brief Appends a CSS-style colour value to all HTML link tags in a given string, as specified by newColor.
  458. *
  459. * 2019/12/19: Implemented for the Dark Mode on macOS, because the app palette can not account for that (Qt 5.12.5).
  460. *
  461. * This way we also avoid having certain strings re-translated on Transifex.
  462. */
  463. static void replaceLinkColorString(QString &linkString, const QColor &newColor);
  464. /**
  465. * @brief Creates a colour-aware icon based on the specified palette's base colour.
  466. *
  467. * @return QIcon, colour-aware (inverted on dark backgrounds).
  468. *
  469. * 2019/12/09: Moved here from SettingsDialog.
  470. */
  471. static QIcon createColorAwareIcon(const QString &name, const QPalette &palette);
  472. /**
  473. * @brief Creates a colour-aware icon based on the app palette's base colour (Dark-/Light-Mode switching).
  474. *
  475. * @return QIcon, colour-aware (inverted on dark backgrounds).
  476. *
  477. * 2019/12/09: Moved here from SettingsDialog.
  478. */
  479. static QIcon createColorAwareIcon(const QString &name);
  480. /**
  481. * @brief Creates a colour-aware pixmap based on the specified palette's base colour.
  482. *
  483. * @return QPixmap, colour-aware (inverted on dark backgrounds).
  484. *
  485. * 2019/12/09: Adapted from createColorAwareIcon.
  486. */
  487. static QPixmap createColorAwarePixmap(const QString &name, const QPalette &palette);
  488. /**
  489. * @brief Creates a colour-aware pixmap based on the app palette's base colour (Dark-/Light-Mode switching).
  490. *
  491. * @return QPixmap, colour-aware (inverted on dark backgrounds).
  492. *
  493. * 2019/12/09: Adapted from createColorAwareIcon.
  494. */
  495. static QPixmap createColorAwarePixmap(const QString &name);
  496. /**
  497. * @brief Whether to show the option to create folders using "virtual files".
  498. *
  499. * By default, the options are not shown unless experimental options are
  500. * manually enabled in the configuration file.
  501. */
  502. [[nodiscard]] bool showVirtualFilesOption() const;
  503. [[nodiscard]] bool enforceVirtualFilesSyncFolder() const;
  504. static QColor defaultColor();
  505. static constexpr const char *themePrefix = ":/client/theme/";
  506. QPalette systemPalette();
  507. bool darkMode();
  508. public slots:
  509. void setOverrideServerUrl(const QString &overrideServerUrl);
  510. void setForceOverrideServerUrl(bool forceOverride);
  511. void setVfsEnabled(bool enabled);
  512. void setStartLoginFlowAutomatically(bool startLoginFlowAuto);
  513. protected:
  514. #ifndef TOKEN_AUTH_ONLY
  515. QIcon themeIcon(const QString &name, bool sysTray = false) const;
  516. #endif
  517. /**
  518. * @brief Generates image path in the resources
  519. * @param name Name of the image file
  520. * @param size Size in the power of two (16, 32, 64, etc.)
  521. * @param sysTray Whether the image requested is for Systray or not
  522. * @return QString image path in the resources
  523. **/
  524. QString themeImagePath(const QString &name, int size = -1, bool sysTray = false) const;
  525. Theme();
  526. signals:
  527. void systrayUseMonoIconsChanged(bool);
  528. void systemPaletteChanged(const QPalette &palette);
  529. void darkModeChanged();
  530. void overrideServerUrlChanged();
  531. void forceOverrideServerUrlChanged();
  532. void vfsEnabledChanged();
  533. void startLoginFlowAutomaticallyChanged();
  534. private:
  535. Theme(Theme const &);
  536. Theme &operator=(Theme const &);
  537. void connectToPaletteSignal();
  538. #if defined(Q_OS_WIN)
  539. QPalette reserveDarkPalette; // Windows 11 button and window dark colours
  540. #endif
  541. static Theme *_instance;
  542. bool _mono = false;
  543. bool _paletteSignalsConnected = false;
  544. QString _overrideServerUrl;
  545. bool _forceOverrideServerUrl = false;
  546. bool _isVfsEnabled = false;
  547. bool _startLoginFlowAutomatically = false;
  548. #ifndef TOKEN_AUTH_ONLY
  549. mutable QHash<QString, QIcon> _iconCache;
  550. #endif
  551. };
  552. }
  553. #endif // _THEME_H