From 85a202098268f633f159033fcc838e1bd23cf945 Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Thu, 16 Mar 2023 20:39:39 +0100 Subject: [PATCH] tidy up code in Theme class Signed-off-by: Matthieu Gallien --- src/libsync/nextcloudtheme.h | 2 +- src/libsync/theme.h | 149 ++++++++++++++++++----------------- 2 files changed, 77 insertions(+), 74 deletions(-) diff --git a/src/libsync/nextcloudtheme.h b/src/libsync/nextcloudtheme.h index f7c215b8f..6ad138615 100644 --- a/src/libsync/nextcloudtheme.h +++ b/src/libsync/nextcloudtheme.h @@ -29,7 +29,7 @@ class NextcloudTheme : public Theme public: NextcloudTheme(); - QString wizardUrlHint() const override; + [[nodiscard]] QString wizardUrlHint() const override; }; } #endif // NEXTCLOUD_THEME_H diff --git a/src/libsync/theme.h b/src/libsync/theme.h index 5c805fd8f..a936ebc93 100644 --- a/src/libsync/theme.h +++ b/src/libsync/theme.h @@ -90,7 +90,7 @@ public: * * @return true if branded, false otherwise */ - virtual bool isBranded() const; + [[nodiscard]] bool isBranded() const; /** * @brief appNameGUI - Human readable application name. @@ -103,7 +103,7 @@ public: * * @return QString with human readable app name. */ - virtual QString appNameGUI() const; + [[nodiscard]] QString appNameGUI() const; /** * @brief appName - Application name (short) @@ -121,61 +121,61 @@ public: * * @return QString with app name. */ - virtual QString appName() const; + [[nodiscard]] QString appName() const; /** * @brief Returns full path to an online state icon * @return QUrl full path to an icon */ - QUrl stateOnlineImageSource() const; + [[nodiscard]] QUrl stateOnlineImageSource() const; /** * @brief Returns full path to an offline state icon * @return QUrl full path to an icon */ - QUrl stateOfflineImageSource() const; + [[nodiscard]] QUrl stateOfflineImageSource() const; /** * @brief Returns full path to an online user status icon * @return QUrl full path to an icon */ - QUrl statusOnlineImageSource() const; + [[nodiscard]] QUrl statusOnlineImageSource() const; /** * @brief Returns full path to an do not disturb user status icon * @return QUrl full path to an icon */ - QUrl statusDoNotDisturbImageSource() const; + [[nodiscard]] QUrl statusDoNotDisturbImageSource() const; /** * @brief Returns full path to an away user status icon * @return QUrl full path to an icon */ - QUrl statusAwayImageSource() const; + [[nodiscard]] QUrl statusAwayImageSource() const; /** * @brief Returns full path to an invisible user status icon * @return QUrl full path to an icon */ - QUrl statusInvisibleImageSource() const; + [[nodiscard]] QUrl statusInvisibleImageSource() const; - QUrl syncStatusOk() const; + [[nodiscard]] QUrl syncStatusOk() const; - QUrl syncStatusError() const; + [[nodiscard]] QUrl syncStatusError() const; - QUrl syncStatusRunning() const; + [[nodiscard]] QUrl syncStatusRunning() const; - QUrl syncStatusPause() const; + [[nodiscard]] QUrl syncStatusPause() const; - QUrl syncStatusWarning() const; + [[nodiscard]] QUrl syncStatusWarning() const; - QUrl folderOffline() const; + [[nodiscard]] QUrl folderOffline() const; /** * @brief configFileName * @return the name of the config file. */ - virtual QString configFileName() const; + [[nodiscard]] QString configFileName() const; #ifndef TOKEN_AUTH_ONLY static QString hidpiFileName(const QString &fileName, QPaintDevice *dev = nullptr); @@ -187,25 +187,25 @@ public: /** * get an sync state icon */ - virtual QIcon syncStateIcon(SyncResult::Status, bool sysTray = false) const; + [[nodiscard]] QIcon syncStateIcon(SyncResult::Status, bool sysTray = false) const; - virtual QIcon folderDisabledIcon() const; - virtual QIcon folderOfflineIcon(bool sysTray = false) const; - virtual QIcon applicationIcon() const; + [[nodiscard]] QIcon folderDisabledIcon() const; + [[nodiscard]] QIcon folderOfflineIcon(bool sysTray = false) const; + [[nodiscard]] QIcon applicationIcon() const; #endif - virtual QString statusHeaderText(SyncResult::Status) const; - virtual QString version() const; + [[nodiscard]] QString statusHeaderText(SyncResult::Status) const; + [[nodiscard]] QString version() const; /** * Characteristics: bool if more than one sync folder is allowed */ - virtual bool singleSyncFolder() const; + [[nodiscard]] bool singleSyncFolder() const; /** * When true, client works with multiple accounts. */ - virtual bool multiAccount() const; + [[nodiscard]] bool multiAccount() const; /** * URL to documentation. @@ -217,7 +217,7 @@ public: * * Defaults to Nextclouds client documentation website. */ - virtual QString helpUrl() const; + [[nodiscard]] QString helpUrl() const; /** * The url to use for showing help on conflicts. @@ -228,76 +228,79 @@ public: * documentation website. If helpUrl() is empty, this function will also return the * empty string. */ - virtual QString conflictHelpUrl() const; + [[nodiscard]] QString conflictHelpUrl() const; /** * Setting a value here will pre-define the server url. * * The respective UI controls will be disabled only if forceOverrideServerUrl() is true */ - virtual QString overrideServerUrl() const; + [[nodiscard]] QString overrideServerUrl() const; /** * Enforce a pre-defined server url. * * When true, the respective UI controls will be disabled */ - virtual bool forceOverrideServerUrl() const; + [[nodiscard]] bool forceOverrideServerUrl() const; - virtual bool isVfsEnabled() const; + /** + * Enforce use of virtual files whenever possible. + */ + [[nodiscard]] bool isVfsEnabled() const; /** * Automatically start login flow * * When true, the browser will get opened automatically */ - virtual bool startLoginFlowAutomatically() const; + [[nodiscard]] bool startLoginFlowAutomatically() const; /** * Enable OCSP stapling for SSL handshakes * * When true, peer will be requested for Online Certificate Status Protocol response */ - virtual bool enableStaplingOCSP() const; + [[nodiscard]] bool enableStaplingOCSP() const; /** * Enforce SSL validity * * When true, trusting the untrusted certificate is not allowed */ - virtual bool forbidBadSSL() const; + [[nodiscard]] bool forbidBadSSL() const; /** * Forbid use of proxy * * When true, the app always connects to the server directly */ - virtual bool doNotUseProxy() const; + [[nodiscard]] bool doNotUseProxy() const; /** * This is only usefull when previous version had a different overrideServerUrl * with a different auth type in that case You should then specify "http" or "shibboleth". * Normaly this should be left empty. */ - virtual QString forceConfigAuthType() const; + [[nodiscard]] QString forceConfigAuthType() const; /** * The default folder name without path on the server at setup time. */ - virtual QString defaultServerFolder() const; + [[nodiscard]] QString defaultServerFolder() const; /** * The default folder name without path on the client side at setup time. */ - virtual QString defaultClientFolder() const; + [[nodiscard]] QString defaultClientFolder() const; /** * Override to encforce a particular locale, i.e. "de" or "pt_BR" */ - virtual QString enforcedLocale() const { return QString(); } + [[nodiscard]] QString enforcedLocale() const { return QString(); } /** colored, white or black */ - QString systrayIconFlavor(bool mono) const; + [[nodiscard]] QString systrayIconFlavor(bool mono) const; #ifndef TOKEN_AUTH_ONLY /** @@ -305,18 +308,18 @@ public: * The default implementation will try to look up * :/client/theme/.png */ - virtual QVariant customMedia(CustomMediaType type); + [[nodiscard]] QVariant customMedia(CustomMediaType type); /** @return color for the setup wizard */ - virtual QColor wizardHeaderTitleColor() const; + [[nodiscard]] QColor wizardHeaderTitleColor() const; /** @return color for the setup wizard. */ - virtual QColor wizardHeaderBackgroundColor() const; + [[nodiscard]] QColor wizardHeaderBackgroundColor() const; - virtual QPixmap wizardApplicationLogo() const; + [[nodiscard]] QPixmap wizardApplicationLogo() const; /** @return logo for the setup wizard. */ - virtual QPixmap wizardHeaderLogo() const; + [[nodiscard]] QPixmap wizardHeaderLogo() const; /** * The default implementation creates a @@ -325,23 +328,23 @@ public: * * @return banner for the setup wizard. */ - virtual QPixmap wizardHeaderBanner() const; + [[nodiscard]] QPixmap wizardHeaderBanner() const; #endif /** * The SHA sum of the released git commit */ - QString gitSHA1() const; + [[nodiscard]] QString gitSHA1() const; /** * About dialog contents */ - virtual QString about() const; + [[nodiscard]] QString about() const; /** * Legal notice dialog version detail contents */ - virtual QString aboutDetails() const; + [[nodiscard]] QString aboutDetails() const; /** * Define if the systray icons should be using mono design @@ -351,56 +354,56 @@ public: /** * Retrieve wether to use mono icons for systray */ - bool systrayUseMonoIcons() const; + [[nodiscard]] bool systrayUseMonoIcons() const; /** * Check if mono icons are available */ - bool monoIconsAvailable() const; + [[nodiscard]] bool monoIconsAvailable() const; /** * @brief Where to check for new Updates. */ - virtual QString updateCheckUrl() const; + [[nodiscard]] QString updateCheckUrl() const; /** * When true, the setup wizard will show the selective sync dialog by default and default * to nothing selected */ - virtual bool wizardSelectiveSyncDefaultNothing() const; + [[nodiscard]] bool wizardSelectiveSyncDefaultNothing() const; /** * Default option for the newBigFolderSizeLimit. * Size in MB of the maximum size of folder before we ask the confirmation. * Set -1 to never ask confirmation. 0 to ask confirmation for every folder. **/ - virtual qint64 newBigFolderSizeLimit() const; + [[nodiscard]] qint64 newBigFolderSizeLimit() const; /** * Hide the checkbox that says "Ask for confirmation before synchronizing folders larger than X MB" * in the account wizard */ - virtual bool wizardHideFolderSizeLimitCheckbox() const; + [[nodiscard]] bool wizardHideFolderSizeLimitCheckbox() const; /** * Hide the checkbox that says "Ask for confirmation before synchronizing external storages" * in the account wizard */ - virtual bool wizardHideExternalStorageConfirmationCheckbox() const; + [[nodiscard]] bool wizardHideExternalStorageConfirmationCheckbox() const; /** * @brief Sharing options * * Allow link sharing and or user/group sharing */ - virtual bool linkSharing() const; - virtual bool userGroupSharing() const; + [[nodiscard]] bool linkSharing() const; + [[nodiscard]] bool userGroupSharing() const; /** * If this returns true, the user cannot configure the proxy in the network settings. * The proxy settings will be disabled in the configuration dialog. * Default returns false. */ - virtual bool forceSystemNetworkProxy() const; + [[nodiscard]] bool forceSystemNetworkProxy() const; /** * @brief How to handle the userID @@ -417,7 +420,7 @@ public: * * @return UserIDType::UserIDUserName, unless reimplemented */ - virtual UserIDType userIDType() const; + [[nodiscard]] UserIDType userIDType() const; /** * @brief Allows to customize the type of user ID (e.g. user name, email) @@ -427,7 +430,7 @@ public: * * @return An empty string, unless reimplemented */ - virtual QString customUserID() const; + [[nodiscard]] QString customUserID() const; /** * @brief Demo string to be displayed when no text has been @@ -435,7 +438,7 @@ public: * * @return An empty string, unless reimplemented */ - virtual QString userIDHint() const; + [[nodiscard]] QString userIDHint() const; /** * @brief Postfix that will be enforced in a URL. e.g. @@ -443,14 +446,14 @@ public: * * @return An empty string, unless reimplemented */ - virtual QString wizardUrlPostfix() const; + [[nodiscard]] QString wizardUrlPostfix() const; /** * @brief String that will be shown as long as no text has been entered by the user. * * @return An empty string, unless reimplemented */ - virtual QString wizardUrlHint() const; + [[nodiscard]] virtual QString wizardUrlHint() const; /** * @brief the server folder that should be queried for the quota information @@ -461,14 +464,14 @@ public: * * Defaults: "/" */ - virtual QString quotaBaseFolder() const; + [[nodiscard]] QString quotaBaseFolder() const; /** * The OAuth client_id, secret pair. * Note that client that change these value cannot connect to un-branded owncloud servers. */ - virtual QString oauthClientId() const; - virtual QString oauthClientSecret() const; + [[nodiscard]] QString oauthClientId() const; + [[nodiscard]] QString oauthClientSecret() const; /** * @brief What should be output for the --version command line switch. @@ -476,7 +479,7 @@ public: * By default, it's a combination of appName(), version(), the GIT SHA1 and some * important dependency versions. */ - virtual QString versionSwitchOutput() const; + [[nodiscard]] QString versionSwitchOutput() const; /** * @brief Request suitable QIcon resource depending on the background colour of the parent widget. @@ -484,7 +487,7 @@ public: * This should be replaced (TODO) by a real theming implementation for the client UI * (actually 2019/09/13 only systray theming). */ - virtual QIcon uiThemeIcon(const QString &iconName, bool uiHasDarkBg) const; + [[nodiscard]] QIcon uiThemeIcon(const QString &iconName, bool uiHasDarkBg) const; Q_INVOKABLE static double getColorDarkness(const QColor &color); @@ -584,9 +587,9 @@ public: * By default, the options are not shown unless experimental options are * manually enabled in the configuration file. */ - virtual bool showVirtualFilesOption() const; + [[nodiscard]] bool showVirtualFilesOption() const; - virtual bool enforceVirtualFilesSyncFolder() const; + [[nodiscard]] bool enforceVirtualFilesSyncFolder() const; static QColor defaultColor(); @@ -596,10 +599,10 @@ public: bool darkMode(); public slots: - virtual void setOverrideServerUrl(const QString &overrideServerUrl); - virtual void setForceOverrideServerUrl(bool forceOverride); - virtual void setVfsEnabled(bool enabled); - virtual void setStartLoginFlowAutomatically(bool startLoginFlowAuto); + void setOverrideServerUrl(const QString &overrideServerUrl); + void setForceOverrideServerUrl(bool forceOverride); + void setVfsEnabled(bool enabled); + void setStartLoginFlowAutomatically(bool startLoginFlowAuto); protected: #ifndef TOKEN_AUTH_ONLY