Skip to content

Commit

Permalink
Expose Resources::isVanillaTheme
Browse files Browse the repository at this point in the history
  • Loading branch information
TheOneRing committed Jul 25, 2024
1 parent bd8f59f commit 3522a8d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
9 changes: 2 additions & 7 deletions src/libsync/theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ QString coloredTheme()
{
return QStringLiteral("colored");
}

constexpr bool isVanilla()
{
return std::string_view(APPLICATION_SHORTNAME) == "ownCloud";
}
}
namespace OCC {

Expand Down Expand Up @@ -313,7 +308,7 @@ QString Theme::about() const
{
// Ideally, the vendor should be "ownCloud GmbH", but it cannot be changed without
// changing the location of the settings and other registery keys.
const QString vendor = isVanilla() ? QStringLiteral("ownCloud GmbH") : QStringLiteral(APPLICATION_VENDOR);
const QString vendor = Resources::isVanillaTheme() ? QStringLiteral("ownCloud GmbH") : QStringLiteral(APPLICATION_VENDOR);
return tr("<p>Version %1. For more information visit <a href=\"%2\">https://%3</a></p>"
"<p>For known issues and help, please visit: <a href=\"https://central.owncloud.com/c/desktop-client\">https://central.owncloud.com</a></p>"
"<p><small>By Klaas Freitag, Daniel Molkentin, Olivier Goffart, Markus Götz, "
Expand Down Expand Up @@ -502,7 +497,7 @@ bool Theme::enableSocketApiIconSupport() const

bool Theme::warnOnMultipleDb() const
{
return isVanilla();
return Resources::isVanillaTheme();
}

bool Theme::allowDuplicatedFolderSyncPair() const
Expand Down
14 changes: 7 additions & 7 deletions src/resources/resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ QString whiteTheme()
return QStringLiteral("white");
}

constexpr bool isVanilla()
{
return std::string_view(APPLICATION_SHORTNAME) == "ownCloud";
}

bool hasTheme(IconType type, const QString &theme)
{
// <<is vanilla, theme name>, bool
Expand Down Expand Up @@ -87,6 +82,11 @@ bool Resources::hasMonoTheme()
return hasTheme(Resources::IconType::BrandedIcon, whiteTheme());
}

bool Resources::isVanillaTheme()
{
return std::string_view(APPLICATION_SHORTNAME) == "ownCloud";
}

bool OCC::Resources::isUsingDarkTheme()
{
// TODO: replace by a command line switch
Expand Down Expand Up @@ -124,12 +124,12 @@ QIcon OCC::Resources::loadIcon(const QString &flavor, const QString &name, IconT
{
static QMap<QString, QIcon> _iconCache;
// prevent recusion
const bool useCoreIcon = (iconType == IconType::VanillaIcon) || isVanilla();
const bool useCoreIcon = (iconType == IconType::VanillaIcon) || isVanillaTheme();
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()) {
if (isVanilla() && QIcon::hasThemeIcon(name)) {
if (isVanillaTheme() && QIcon::hasThemeIcon(name)) {
// use from theme
return cached = QIcon::fromTheme(name);
}
Expand Down
7 changes: 7 additions & 0 deletions src/resources/resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ Q_NAMESPACE
enum class IconType { BrandedIcon, BrandedIconWithFallbackToVanillaIcon, VanillaIcon };
Q_ENUM_NS(IconType);


/**
*
* @return Whether we are using the vanilla theme
*/
bool OWNCLOUDRESOURCES_EXPORT isVanillaTheme();

/**
* Whether use the dark icon theme
* The function also ensures the theme supports the dark theme
Expand Down

0 comments on commit 3522a8d

Please sign in to comment.