From 94325edc72c0796abadc3d3ae52eac1bfce64f8c Mon Sep 17 00:00:00 2001 From: Hannah von Reth Date: Fri, 22 Jan 2021 17:03:09 +0100 Subject: [PATCH 1/6] Fix typo Fixes: #8379 --- cmake/modules/OCGenerateTheme.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/modules/OCGenerateTheme.cmake b/cmake/modules/OCGenerateTheme.cmake index 4db90609a79..119b11ae4ca 100644 --- a/cmake/modules/OCGenerateTheme.cmake +++ b/cmake/modules/OCGenerateTheme.cmake @@ -7,7 +7,7 @@ function(__addIcon THEME ICON_NAME) if (EXISTS ${OEM_THEME_DIR}/${icon}) file(APPEND "${QRC}" "${OEM_THEME_DIR}/${icon}\n") else() - set(SIZES "16;22,32;48;64;128;256;512;1024") + set(SIZES "16;22;32;48;64;128;256;512;1024") foreach(size ${SIZES}) set(icon "theme/${THEME}/${ICON_NAME}-${size}.png") if (EXISTS ${OEM_THEME_DIR}/${icon}) From 2519a0bd0cf2edc9a0109ea86ded1238d3f48b99 Mon Sep 17 00:00:00 2001 From: Hannah von Reth Date: Mon, 25 Jan 2021 13:53:40 +0100 Subject: [PATCH 2/6] Fix OIDC display (#8391) Fixes: #8390 --- changelog/unreleased/8390 | 5 +++++ src/libsync/creds/oauth.cpp | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 changelog/unreleased/8390 diff --git a/changelog/unreleased/8390 b/changelog/unreleased/8390 new file mode 100644 index 00000000000..fb3044764a8 --- /dev/null +++ b/changelog/unreleased/8390 @@ -0,0 +1,5 @@ +Bugfix: Fix wrong option provided to OIDC + +We fixed a bug where we passed a wrong value to the OIDC display parameter + +https://github.com/owncloud/client/issues/8390 diff --git a/src/libsync/creds/oauth.cpp b/src/libsync/creds/oauth.cpp index 6e009ce311b..698728df6bb 100644 --- a/src/libsync/creds/oauth.cpp +++ b/src/libsync/creds/oauth.cpp @@ -306,8 +306,7 @@ QUrl OAuth::authorisationLink() const { QStringLiteral("code_challenge_method"), QStringLiteral("S256") }, { QStringLiteral("scope"), Theme::instance()->openIdConnectScopes() }, { QStringLiteral("prompt"), Theme::instance()->openIdConnectPrompt() }, - { QStringLiteral("state"), QString::fromUtf8(_state) }, - { QStringLiteral("display"), Theme::instance()->appNameGUI() } }); + { QStringLiteral("state"), QString::fromUtf8(_state) } }); if (!_account->davUser().isNull()) { const QString davUser = _account->davUser().replace(QLatin1Char('+'), QStringLiteral("%2B")); // Issue #7762; From cf9322c2bd4cf5637e2a6d300170014a7704b229 Mon Sep 17 00:00:00 2001 From: Hannah von Reth Date: Fri, 22 Jan 2021 13:42:32 +0100 Subject: [PATCH 3/6] Increase the quality of upscaled icons --- src/libsync/theme.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsync/theme.cpp b/src/libsync/theme.cpp index 0c1a1bb9f99..949571c2535 100644 --- a/src/libsync/theme.cpp +++ b/src/libsync/theme.cpp @@ -189,7 +189,7 @@ QIcon Theme::themeIcon(const QString &name, bool sysTray, bool sysTrayMenuVisibl } else if (size >= 128) { if (!previousIcon.isEmpty()) { qWarning() << "Upsacling:" << previousIcon << "to" << size; - cached.addPixmap(QPixmap(previousIcon).scaled({ size, size }, Qt::KeepAspectRatio)); + cached.addPixmap(QPixmap(previousIcon).scaled({ size, size }, Qt::KeepAspectRatio, Qt::SmoothTransformation)); } } } From d6dc2abef6e90449ead6d37a872a620e90d54298 Mon Sep 17 00:00:00 2001 From: Hannah von Reth Date: Thu, 21 Jan 2021 17:57:14 +0100 Subject: [PATCH 4/6] Fix branding fallback --- src/gui/guiutility.cpp | 2 +- src/libsync/theme.cpp | 72 ++++++++++++++++++++++++++++++++---------- src/libsync/theme.h | 15 ++++++--- 3 files changed, 67 insertions(+), 22 deletions(-) diff --git a/src/gui/guiutility.cpp b/src/gui/guiutility.cpp index ead4a78ad5c..c5a94724ed7 100644 --- a/src/gui/guiutility.cpp +++ b/src/gui/guiutility.cpp @@ -105,7 +105,7 @@ QIcon Utility::getCoreIcon(const QString &icon_name) if (icon_name.isEmpty()) { return {}; } - const QString path = Theme::instance()->isUsingDarkTheme() ? QStringLiteral("dark") : QStringLiteral("light"); + const QString path = (Theme::instance()->isUsingDarkTheme() && Theme::instance()->hasTheme(Theme::IconType::VanillaIcon, QStringLiteral("dark"))) ? QStringLiteral("dark") : QStringLiteral("light"); const QIcon icon(QStringLiteral(":/client/resources/%1/%2").arg(path, icon_name)); Q_ASSERT(!icon.isNull()); return icon; diff --git a/src/libsync/theme.cpp b/src/libsync/theme.cpp index 949571c2535..c7353c00f43 100644 --- a/src/libsync/theme.cpp +++ b/src/libsync/theme.cpp @@ -38,10 +38,41 @@ #endif namespace { +QString vanillaThemePath() +{ + return QStringLiteral(":/client/ownCloud/theme"); +} + +QString brandThemePath() +{ + return QStringLiteral(":/client/" APPLICATION_SHORTNAME "/theme"); +} + +QString darkTheme() +{ + return QStringLiteral("dark"); +} + +QString coloredTheme() +{ + return QStringLiteral("colored"); +} + +QString whiteTheme() +{ + return QStringLiteral("white"); +} + +QString blackTheme() +{ + return QStringLiteral("black"); +} + constexpr bool strings_equal(char const *a, char const *b) { return *a == *b && (*a == '\0' || strings_equal(a + 1, b + 1)); } + constexpr bool isVanilla() { // TODO: c++17 stringview @@ -137,12 +168,11 @@ QIcon Theme::aboutIcon() const return applicationIcon(); } -bool Theme::isUsingDarkTheme(IconType type) const +bool Theme::isUsingDarkTheme() const { - if (!_hasDarkColoredTheme && type != IconType::VanillaIcon) { - return false; - } - return QPalette().base().color().lightnessF() <= 0.5; + //TODO: replace by a command line switch + static bool forceDark = qEnvironmentVariableIsSet("OWNCLOUD_FORCE_DARK_MODE"); + return forceDark || QPalette().base().color().lightnessF() <= 0.5; } /* * helper to load a icon from either the icon theme the desktop provides or from @@ -150,18 +180,19 @@ bool Theme::isUsingDarkTheme(IconType type) const */ QIcon Theme::themeIcon(const QString &name, bool sysTray, bool sysTrayMenuVisible, IconType iconType) const { + // prevent recusion const bool useCoreIcon = (iconType == IconType::VanillaIcon) || isVanilla(); QString flavor; if (sysTray) { - flavor = systrayIconFlavor(_mono, sysTrayMenuVisible); + flavor = systrayIconFlavor(iconType, _mono, sysTrayMenuVisible); } else { - if (isUsingDarkTheme(iconType)) { - flavor = QStringLiteral("dark"); + if (isUsingDarkTheme() && hasTheme(iconType, darkTheme())) { + flavor = darkTheme(); } else { - flavor = QStringLiteral("colored"); + flavor = coloredTheme(); } } - const QString path = useCoreIcon ? QStringLiteral(":/client/ownCloud/theme") : QStringLiteral(":/client/%1/theme").arg(appName()); + const QString path = useCoreIcon ? vanillaThemePath() : brandThemePath(); const QString key = name + QLatin1Char(',') + flavor; QIcon &cached = _iconCache[key]; // Take reference, this will also "set" the cache entry if (cached.isNull()) { @@ -210,17 +241,26 @@ QIcon Theme::themeIcon(const QString &name, bool sysTray, bool sysTrayMenuVisibl return cached; } -bool Theme::hasTheme(const QString &theme) +bool Theme::hasTheme(IconType type, const QString &theme) const { - return QFileInfo(QStringLiteral(":/client/" APPLICATION_SHORTNAME "/theme/%1/").arg(theme)).isDir(); + const auto key = qMakePair(type != IconType::VanillaIcon, theme); + auto it = _themeCache.find(key); + if (it == _themeCache.end()) { + bool found = QFileInfo(QStringLiteral("%1/%2/").arg(type == IconType::VanillaIcon ? vanillaThemePath() : brandThemePath(), theme)).isDir(); + if (!found && type == IconType::BrandedIconWithFallbackToVanillaIcon) { + found = hasTheme(IconType::VanillaIcon, theme); + } + return _themeCache[key] = found; + } + return it.value(); } -QString Theme::systrayIconFlavor(bool mono, bool sysTrayMenuVisible) const +QString Theme::systrayIconFlavor(IconType type, bool mono, bool sysTrayMenuVisible) const { Q_UNUSED(sysTrayMenuVisible) QString flavor; if (mono) { - flavor = Utility::hasDarkSystray() ? QStringLiteral("white") : QStringLiteral("black"); + flavor = Utility::hasDarkSystray() ? whiteTheme() : blackTheme(); #ifdef Q_OS_MAC if (sysTrayMenuVisible) { @@ -229,7 +269,7 @@ QString Theme::systrayIconFlavor(bool mono, bool sysTrayMenuVisible) const #endif } else { // we have a dark sys tray and the theme has support for that - flavor = (Utility::hasDarkSystray() && _hasDarkColoredTheme) ? QStringLiteral("dark") : QStringLiteral("colored"); + flavor = (Utility::hasDarkSystray() && hasTheme(type, darkTheme())) ? darkTheme() : coloredTheme(); } return flavor; } @@ -303,7 +343,7 @@ bool Theme::systrayUseMonoIcons() const bool Theme::monoIconsAvailable() const { - return hasTheme(systrayIconFlavor(true)); + return hasTheme(IconType::BrandedIcon, systrayIconFlavor(IconType::BrandedIcon, true)); } QString Theme::updateCheckUrl() const diff --git a/src/libsync/theme.h b/src/libsync/theme.h index 843f7a4bbe9..ad8feb3fd91 100644 --- a/src/libsync/theme.h +++ b/src/libsync/theme.h @@ -104,6 +104,7 @@ class OWNCLOUDSYNC_EXPORT Theme : public QObject BrandedIconWithFallbackToVanillaIcon, VanillaIcon }; + /** * get an sync state icon */ @@ -118,7 +119,7 @@ class OWNCLOUDSYNC_EXPORT Theme : public QObject * Whether use the dark icon theme * The function also ensures the theme supports the dark theme */ - bool isUsingDarkTheme(IconType fallbackType = IconType::BrandedIcon) const; + bool isUsingDarkTheme() const; #endif virtual QString statusHeaderText(SyncResult::Status) const; @@ -188,7 +189,7 @@ class OWNCLOUDSYNC_EXPORT Theme : public QObject #ifndef TOKEN_AUTH_ONLY /** colored, white or black */ - QString systrayIconFlavor(bool mono, bool sysTrayMenuVisible = false) const; + QString systrayIconFlavor(IconType type, bool mono, bool sysTrayMenuVisible = false) const; /** * Override to use a string or a custom image name. @@ -406,10 +407,12 @@ class OWNCLOUDSYNC_EXPORT Theme : public QObject */ virtual bool enableExperimentalFeatures() const; + // whether or not a theme is available + bool hasTheme(IconType type, const QString &theme) const; + protected: #ifndef TOKEN_AUTH_ONLY QIcon themeIcon(const QString &name, bool sysTray = false, bool sysTrayMenuVisible = false, IconType iconType = IconType::BrandedIconWithFallbackToVanillaIcon) const; - static bool hasTheme(const QString &theme); #endif Theme(); @@ -423,8 +426,10 @@ class OWNCLOUDSYNC_EXPORT Theme : public QObject static Theme *_instance; bool _mono; #ifndef TOKEN_AUTH_ONLY - bool _hasDarkColoredTheme = hasTheme(QStringLiteral("dark")); - mutable QHash _iconCache; + // + mutable QMap, bool> _themeCache; + + mutable QMap _iconCache; #endif }; } From 2e87750c678689c7e843864b6d832a869e651dfa Mon Sep 17 00:00:00 2001 From: Hannah von Reth Date: Fri, 22 Jan 2021 12:42:21 +0100 Subject: [PATCH 5/6] Fix detection of availability of icon branding --- cmake/modules/OCGenerateTheme.cmake | 28 ++++-- core_theme.qrc | 6 +- src/gui/guiutility.cpp | 2 +- src/libsync/owncloudtheme.cpp | 4 +- src/libsync/theme.cpp | 87 +++++++++++-------- src/libsync/theme.h | 28 ++++-- .../{colored => universal}/oc-image-about.svg | 0 .../{colored => universal}/owncloud-icon.svg | 0 theme/{colored => universal}/wizard_logo.svg | 0 9 files changed, 95 insertions(+), 60 deletions(-) rename theme/{colored => universal}/oc-image-about.svg (100%) rename theme/{colored => universal}/owncloud-icon.svg (100%) rename theme/{colored => universal}/wizard_logo.svg (100%) diff --git a/cmake/modules/OCGenerateTheme.cmake b/cmake/modules/OCGenerateTheme.cmake index 119b11ae4ca..86381ad6973 100644 --- a/cmake/modules/OCGenerateTheme.cmake +++ b/cmake/modules/OCGenerateTheme.cmake @@ -1,17 +1,29 @@ function(__addIcon THEME ICON_NAME) - set(icon "theme/${THEME}/${ICON_NAME}.svg") + set(options) + set(oneValueArgs SRC_PATH) + set(multiValueArgs) + cmake_parse_arguments(_ICON "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if(NOT _ICON_SRC_PATH) + set(_ICON_SRC_PATH ${THEME}) + endif() + + set(icon "theme/${_ICON_SRC_PATH}/${ICON_NAME}.svg") + set(iconAlias "theme/${THEME}/${ICON_NAME}.svg") if (EXISTS ${OEM_THEME_DIR}/${icon}) - file(APPEND "${QRC}" "${OEM_THEME_DIR}/${icon}\n") + file(APPEND "${QRC}" "${OEM_THEME_DIR}/${icon}\n") else() - set(icon "theme/${THEME}/${ICON_NAME}.png") + set(icon "theme/${_ICON_SRC_PATH}/${ICON_NAME}.png") + set(iconAlias "theme/${THEME}/${ICON_NAME}.png") if (EXISTS ${OEM_THEME_DIR}/${icon}) - file(APPEND "${QRC}" "${OEM_THEME_DIR}/${icon}\n") + file(APPEND "${QRC}" "${OEM_THEME_DIR}/${icon}\n") else() set(SIZES "16;22;32;48;64;128;256;512;1024") foreach(size ${SIZES}) - set(icon "theme/${THEME}/${ICON_NAME}-${size}.png") + set(icon "theme/${_ICON_SRC_PATH}/${ICON_NAME}-${size}.png") + set(iconAlias "theme/${THEME}/${ICON_NAME}-${size}.png") if (EXISTS ${OEM_THEME_DIR}/${icon}) - file(APPEND "${QRC}" "${OEM_THEME_DIR}/${icon}\n") + file(APPEND "${QRC}" "${OEM_THEME_DIR}/${icon}\n") endif() endforeach() endif() @@ -22,8 +34,8 @@ function(generate_theme TARGET) if(NOT "${OEM_THEME_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}") set(QRC ${CMAKE_BINARY_DIR}/theme.qrc) file(WRITE "${QRC}" "\n\n") - __addIcon("colored" "${APPLICATION_ICON_NAME}-icon") - __addIcon("colored" "wizard_logo") + __addIcon("universal" "${APPLICATION_ICON_NAME}-icon" SRC_PATH "colored") + __addIcon("universal" "wizard_logo" SRC_PATH "colored") set(STATES "ok;error;information;offline;pause;sync") set(THEMES "colored;dark;black;white") diff --git a/core_theme.qrc b/core_theme.qrc index caee1185b0f..1137eaeed63 100644 --- a/core_theme.qrc +++ b/core_theme.qrc @@ -6,21 +6,21 @@ theme/black/ui-light-plain-monochrom-state-offline.svg theme/black/ui-light-plain-monochrom-state-pause.svg theme/black/ui-light-plain-monochrom-state-sync.svg - theme/colored/owncloud-icon.svg - theme/colored/oc-image-about.svg theme/colored/ui-light-plain-color-state-checkmark.svg theme/colored/ui-light-plain-color-state-error.svg theme/colored/ui-light-plain-color-state-info.svg theme/colored/ui-light-plain-color-state-offline.svg theme/colored/ui-light-plain-color-state-pause.svg theme/colored/ui-light-plain-color-state-sync.svg - theme/colored/wizard_logo.svg theme/dark/ui-dark-plain-color-state-checkmark.svg theme/dark/ui-dark-plain-color-state-error.svg theme/dark/ui-dark-plain-color-state-info.svg theme/dark/ui-dark-plain-color-state-offline.svg theme/dark/ui-dark-plain-color-state-pause.svg theme/dark/ui-dark-plain-color-state-sync.svg + theme/universal/oc-image-about.svg + theme/universal/owncloud-icon.svg + theme/universal/wizard_logo.svg theme/white/ui-dark-plain-monochrom-state-checkmark.svg theme/white/ui-dark-plain-monochrom-state-error.svg theme/white/ui-dark-plain-monochrom-state-info.svg diff --git a/src/gui/guiutility.cpp b/src/gui/guiutility.cpp index c5a94724ed7..ead4a78ad5c 100644 --- a/src/gui/guiutility.cpp +++ b/src/gui/guiutility.cpp @@ -105,7 +105,7 @@ QIcon Utility::getCoreIcon(const QString &icon_name) if (icon_name.isEmpty()) { return {}; } - const QString path = (Theme::instance()->isUsingDarkTheme() && Theme::instance()->hasTheme(Theme::IconType::VanillaIcon, QStringLiteral("dark"))) ? QStringLiteral("dark") : QStringLiteral("light"); + const QString path = Theme::instance()->isUsingDarkTheme() ? QStringLiteral("dark") : QStringLiteral("light"); const QIcon icon(QStringLiteral(":/client/resources/%1/%2").arg(path, icon_name)); Q_ASSERT(!icon.isNull()); return icon; diff --git a/src/libsync/owncloudtheme.cpp b/src/libsync/owncloudtheme.cpp index 571d625b1d2..cb5cf96c190 100644 --- a/src/libsync/owncloudtheme.cpp +++ b/src/libsync/owncloudtheme.cpp @@ -58,12 +58,12 @@ QColor ownCloudTheme::wizardHeaderSubTitleColor() const QIcon ownCloudTheme::wizardHeaderLogo() const { - return themeIcon(QStringLiteral("wizard_logo"), false, false, Theme::IconType::BrandedIcon); + return themeUniversalIcon(QStringLiteral("wizard_logo")); } QIcon ownCloudTheme::aboutIcon() const { - return QIcon(QStringLiteral(":/client/ownCloud/theme/colored/oc-image-about.svg")); + return themeUniversalIcon(QStringLiteral("oc-image-about")); } #endif diff --git a/src/libsync/theme.cpp b/src/libsync/theme.cpp index c7353c00f43..f1000026cb8 100644 --- a/src/libsync/theme.cpp +++ b/src/libsync/theme.cpp @@ -87,8 +87,6 @@ Theme *Theme::instance() { if (!_instance) { _instance = new THEME_CLASS; - // some themes may not call the base ctor - _instance->_mono = false; } return _instance; } @@ -160,7 +158,7 @@ QString Theme::configFileName() const QIcon Theme::applicationIcon() const { - return themeIcon(QStringLiteral(APPLICATION_ICON_NAME "-icon")); + return themeUniversalIcon(QStringLiteral(APPLICATION_ICON_NAME "-icon")); } QIcon Theme::aboutIcon() const @@ -171,27 +169,44 @@ QIcon Theme::aboutIcon() const bool Theme::isUsingDarkTheme() const { //TODO: replace by a command line switch - static bool forceDark = qEnvironmentVariableIsSet("OWNCLOUD_FORCE_DARK_MODE"); + static bool forceDark = qEnvironmentVariableIntValue("OWNCLOUD_FORCE_DARK_MODE") != 0; return forceDark || QPalette().base().color().lightnessF() <= 0.5; } + +bool Theme::allowDarkTheme() const +{ + return _hasBrandedColored == _hasBrandedDark; +} + + +QIcon Theme::themeUniversalIcon(const QString &name, Theme::IconType iconType) const +{ + return loadIcon(QStringLiteral("universal"), name, iconType); +} + +QIcon Theme::themeTrayIcon(const QString &name, bool sysTrayMenuVisible, IconType iconType) const +{ + auto icon = loadIcon(systrayIconFlavor(_mono, sysTrayMenuVisible), name, iconType); +#ifdef Q_OS_MAC + // This defines the icon as a template and enables automatic macOS color handling + // See https://bugreports.qt.io/browse/QTBUG-42109 + icon.setIsMask(_mono && !sysTrayMenuVisible); +#endif + return icon; +} + +QIcon Theme::themeIcon(const QString &name, Theme::IconType iconType) const +{ + return loadIcon((isUsingDarkTheme() && allowDarkTheme()) ? darkTheme() : coloredTheme(), name, iconType); +} /* * helper to load a icon from either the icon theme the desktop provides or from * the apps Qt resources. */ -QIcon Theme::themeIcon(const QString &name, bool sysTray, bool sysTrayMenuVisible, IconType iconType) const +QIcon Theme::loadIcon(const QString &flavor, const QString &name, IconType iconType) const { // prevent recusion const bool useCoreIcon = (iconType == IconType::VanillaIcon) || isVanilla(); - QString flavor; - if (sysTray) { - flavor = systrayIconFlavor(iconType, _mono, sysTrayMenuVisible); - } else { - if (isUsingDarkTheme() && hasTheme(iconType, darkTheme())) { - flavor = darkTheme(); - } else { - flavor = coloredTheme(); - } - } const QString path = useCoreIcon ? vanillaThemePath() : brandThemePath(); const QString key = name + QLatin1Char(',') + flavor; QIcon &cached = _iconCache[key]; // Take reference, this will also "set" the cache entry @@ -227,35 +242,24 @@ QIcon Theme::themeIcon(const QString &name, bool sysTray, bool sysTrayMenuVisibl } if (cached.isNull()) { if (!useCoreIcon && iconType == IconType::BrandedIconWithFallbackToVanillaIcon) { - return themeIcon(name, sysTray, sysTrayMenuVisible, IconType::VanillaIcon); + return loadIcon(flavor, name, IconType::VanillaIcon); } qWarning() << "Failed to locate the icon" << name; } - -#ifdef Q_OS_MAC - // This defines the icon as a template and enables automatic macOS color handling - // See https://bugreports.qt.io/browse/QTBUG-42109 - cached.setIsMask(_mono && sysTray && !sysTrayMenuVisible); -#endif - return cached; } bool Theme::hasTheme(IconType type, const QString &theme) const { const auto key = qMakePair(type != IconType::VanillaIcon, theme); - auto it = _themeCache.find(key); - if (it == _themeCache.end()) { - bool found = QFileInfo(QStringLiteral("%1/%2/").arg(type == IconType::VanillaIcon ? vanillaThemePath() : brandThemePath(), theme)).isDir(); - if (!found && type == IconType::BrandedIconWithFallbackToVanillaIcon) { - found = hasTheme(IconType::VanillaIcon, theme); - } - return _themeCache[key] = found; + auto it = _themeCache.constFind(key); + if (it == _themeCache.cend()) { + return _themeCache[key] = QFileInfo(QStringLiteral("%1/%2/").arg(type == IconType::VanillaIcon ? vanillaThemePath() : brandThemePath(), theme)).isDir(); } return it.value(); } -QString Theme::systrayIconFlavor(IconType type, bool mono, bool sysTrayMenuVisible) const +QString Theme::systrayIconFlavor(bool mono, bool sysTrayMenuVisible) const { Q_UNUSED(sysTrayMenuVisible) QString flavor; @@ -269,7 +273,7 @@ QString Theme::systrayIconFlavor(IconType type, bool mono, bool sysTrayMenuVisib #endif } else { // we have a dark sys tray and the theme has support for that - flavor = (Utility::hasDarkSystray() && hasTheme(type, darkTheme())) ? darkTheme() : coloredTheme(); + flavor = (Utility::hasDarkSystray() && allowDarkTheme()) ? darkTheme() : coloredTheme(); } return flavor; } @@ -278,7 +282,6 @@ QString Theme::systrayIconFlavor(IconType type, bool mono, bool sysTrayMenuVisib Theme::Theme() : QObject(nullptr) - , _mono(false) { } @@ -343,7 +346,9 @@ bool Theme::systrayUseMonoIcons() const bool Theme::monoIconsAvailable() const { - return hasTheme(IconType::BrandedIcon, systrayIconFlavor(IconType::BrandedIcon, true)); + // mono icons are only supported in vanilla and if a customer provides them + // no fallback to vanilla + return hasTheme(IconType::BrandedIcon, systrayIconFlavor(true)); } QString Theme::updateCheckUrl() const @@ -511,8 +516,11 @@ QIcon Theme::syncStateIcon(SyncResult::Status status, bool sysTray, bool sysTray default: statusIcon = QStringLiteral("state-error"); } - - return themeIcon(statusIcon, sysTray, sysTrayMenuVisible); + if (sysTray) { + return themeTrayIcon(statusIcon, sysTrayMenuVisible); + } else { + return themeIcon(statusIcon); + } } QIcon Theme::folderDisabledIcon() const @@ -522,7 +530,12 @@ QIcon Theme::folderDisabledIcon() const QIcon Theme::folderOfflineIcon(bool sysTray, bool sysTrayMenuVisible) const { - return themeIcon(QLatin1String("state-offline"), sysTray, sysTrayMenuVisible); + const auto statusIcon = QLatin1String("state-offline"); + if (sysTray) { + return themeTrayIcon(statusIcon, sysTrayMenuVisible); + } else { + return themeIcon(statusIcon); + } } QColor Theme::wizardHeaderTitleColor() const diff --git a/src/libsync/theme.h b/src/libsync/theme.h index ad8feb3fd91..1c7f5221db7 100644 --- a/src/libsync/theme.h +++ b/src/libsync/theme.h @@ -120,6 +120,11 @@ class OWNCLOUDSYNC_EXPORT Theme : public QObject * The function also ensures the theme supports the dark theme */ bool isUsingDarkTheme() const; + + /** + * Whether the branding allows the dark theme + */ + bool allowDarkTheme() const; #endif virtual QString statusHeaderText(SyncResult::Status) const; @@ -189,7 +194,7 @@ class OWNCLOUDSYNC_EXPORT Theme : public QObject #ifndef TOKEN_AUTH_ONLY /** colored, white or black */ - QString systrayIconFlavor(IconType type, bool mono, bool sysTrayMenuVisible = false) const; + QString systrayIconFlavor(bool mono, bool sysTrayMenuVisible = false) const; /** * Override to use a string or a custom image name. @@ -407,12 +412,11 @@ class OWNCLOUDSYNC_EXPORT Theme : public QObject */ virtual bool enableExperimentalFeatures() const; - // whether or not a theme is available - bool hasTheme(IconType type, const QString &theme) const; - protected: #ifndef TOKEN_AUTH_ONLY - QIcon themeIcon(const QString &name, bool sysTray = false, bool sysTrayMenuVisible = false, IconType iconType = IconType::BrandedIconWithFallbackToVanillaIcon) const; + QIcon themeUniversalIcon(const QString &name, IconType iconType = IconType::BrandedIcon) const; + QIcon themeTrayIcon(const QString &name, bool sysTrayMenuVisible = false, IconType iconType = IconType::BrandedIconWithFallbackToVanillaIcon) const; + QIcon themeIcon(const QString &name, IconType iconType = IconType::BrandedIconWithFallbackToVanillaIcon) const; #endif Theme(); @@ -423,13 +427,19 @@ class OWNCLOUDSYNC_EXPORT Theme : public QObject Theme(Theme const &); Theme &operator=(Theme const &); + QIcon loadIcon(const QString &flavor, const QString &name, IconType iconType) const; + // whether or not a theme is available + bool hasTheme(IconType type, const QString &theme) const; + static Theme *_instance; - bool _mono; + bool _mono = false; #ifndef TOKEN_AUTH_ONLY - // - mutable QMap, bool> _themeCache; - mutable QMap _iconCache; + // <, bool + // caches the availability of themes for branded and unbranded themes + mutable QMap, bool> _themeCache; + const bool _hasBrandedColored = hasTheme(IconType::BrandedIcon, QStringLiteral("colored")); + const bool _hasBrandedDark = hasTheme(IconType::BrandedIcon, QStringLiteral("dark")); #endif }; } diff --git a/theme/colored/oc-image-about.svg b/theme/universal/oc-image-about.svg similarity index 100% rename from theme/colored/oc-image-about.svg rename to theme/universal/oc-image-about.svg diff --git a/theme/colored/owncloud-icon.svg b/theme/universal/owncloud-icon.svg similarity index 100% rename from theme/colored/owncloud-icon.svg rename to theme/universal/owncloud-icon.svg diff --git a/theme/colored/wizard_logo.svg b/theme/universal/wizard_logo.svg similarity index 100% rename from theme/colored/wizard_logo.svg rename to theme/universal/wizard_logo.svg From 5d42db289a2dc21d3fc4a6f296687a718d71ca33 Mon Sep 17 00:00:00 2001 From: Hannah von Reth Date: Mon, 25 Jan 2021 17:03:09 +0100 Subject: [PATCH 6/6] v2.7.5-rc4 --- VERSION.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.cmake b/VERSION.cmake index f4893176d9a..e99f5aaed9a 100644 --- a/VERSION.cmake +++ b/VERSION.cmake @@ -5,7 +5,7 @@ set( MIRALL_VERSION_YEAR 2021 ) set( MIRALL_SOVERSION 0 ) if ( NOT DEFINED MIRALL_VERSION_SUFFIX ) - set( MIRALL_VERSION_SUFFIX "rc3") #e.g. beta1, beta2, rc1 + set( MIRALL_VERSION_SUFFIX "rc4") #e.g. beta1, beta2, rc1 endif( NOT DEFINED MIRALL_VERSION_SUFFIX ) if( NOT DEFINED MIRALL_VERSION_BUILD )