Skip to content

Commit dc972cc

Browse files
committed
Add new systray icons
1 parent 523db46 commit dc972cc

24 files changed

+47
-80
lines changed

src/gui/owncloudgui.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ void ownCloudGui::slotTrayMessageIfServerUnsupported(Account *account)
215215

216216
void ownCloudGui::slotComputeOverallSyncStatus()
217217
{
218-
auto getIcon = [this](const SyncResult &result) { return Theme::instance()->themeTrayIcon(result, contextMenuVisible()); };
218+
auto getIcon = [](const SyncResult &result) { return Theme::instance()->themeTrayIcon(result); };
219219
auto getIconFromStatus = [getIcon](const SyncResult::Status &status) { return getIcon(SyncResult{status}); };
220220
bool allSignedOut = true;
221221
bool allPaused = true;
@@ -291,7 +291,6 @@ void ownCloudGui::slotComputeOverallSyncStatus()
291291
QString trayMessage;
292292

293293
auto trayOverallStatusResult = FolderMan::trayOverallStatus(map);
294-
295294
const QIcon statusIcon = getIcon(trayOverallStatusResult.overallStatus());
296295
_tray->setIcon(statusIcon);
297296

src/libsync/theme.cpp

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,6 @@
3434
#include THEME_INCLUDE
3535
#endif
3636

37-
namespace {
38-
QString darkTheme()
39-
{
40-
return QStringLiteral("dark");
41-
}
42-
43-
QString coloredTheme()
44-
{
45-
return QStringLiteral("colored");
46-
}
47-
}
4837
namespace OCC {
4938

5039
Theme *Theme::_instance = nullptr;
@@ -124,14 +113,15 @@ QIcon Theme::aboutIcon() const
124113
return applicationIcon();
125114
}
126115

127-
QIcon Theme::themeTrayIcon(const SyncResult &result, [[maybe_unused]] bool sysTrayMenuVisible, Resources::IconType iconType) const
116+
QIcon Theme::themeTrayIcon(const SyncResult &result, Resources::IconType iconType) const
128117
{
118+
#ifndef Q_OS_MAC
129119
// we have a dark sys tray and the theme has support for that
130-
const QString flavor = (Utility::hasDarkSystray() && Resources::hasDarkTheme()) ? darkTheme() : coloredTheme();
131-
auto icon = Resources::loadIcon(flavor, QStringLiteral("state-%1").arg(syncStateIconName(result)), iconType);
132-
#ifdef Q_OS_MAC
120+
auto icon =
121+
Resources::loadIcon(Utility::hasDarkSystray() ? QStringLiteral("dark-systray") : QStringLiteral("light-systray"), syncStateIconName(result), iconType);
122+
#else
133123
// This defines the icon as a template and enables automatic macOS color handling
134-
// See https://bugreports.qt.io/browse/QTBUG-42109
124+
auto icon = Resources::loadIcon(QStringLiteral("mask-systray"), syncStateIconName(result), iconType);
135125
icon.setIsMask(true);
136126
#endif
137127
return icon;

src/libsync/theme.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,7 @@ class OPENCLOUD_SYNC_EXPORT Theme : public QObject
140140
* get an sync state icon
141141
*/
142142

143-
QIcon themeTrayIcon(const SyncResult &result, bool sysTrayMenuVisible = false,
144-
Resources::IconType iconType = Resources::IconType::BrandedIconWithFallbackToVanillaIcon) const;
143+
QIcon themeTrayIcon(const SyncResult &result, Resources::IconType iconType = Resources::IconType::BrandedIconWithFallbackToVanillaIcon) const;
145144

146145
QString syncStateIconName(const SyncResult &result) const;
147146

src/resources/core_theme.qrc

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
<RCC>
22
<qresource prefix="/client/OpenCloud">
3-
<file alias="theme/colored/state-ok.svg">theme/universal/opencloud-icon.svg</file>
4-
<file alias="theme/colored/state-error.svg">theme/universal/opencloud-icon.svg</file>
5-
<file alias="theme/colored/state-information.svg">theme/universal/opencloud-icon.svg</file>
6-
<file alias="theme/colored/state-offline.svg">theme/universal/opencloud-icon.svg</file>
7-
<file alias="theme/colored/state-pause.svg">theme/universal/opencloud-icon.svg</file>
8-
<file alias="theme/colored/state-sync.svg">theme/universal/opencloud-icon.svg</file>
9-
<file alias="theme/dark/state-ok.svg">theme/universal/opencloud-icon.svg</file>
10-
<file alias="theme/dark/state-error.svg">theme/universal/opencloud-icon.svg</file>
11-
<file alias="theme/dark/state-information.svg">theme/universal/opencloud-icon.svg</file>
12-
<file alias="theme/dark/state-offline.svg">theme/universal/opencloud-icon.svg</file>
13-
<file alias="theme/dark/state-pause.svg">theme/universal/opencloud-icon.svg</file>
14-
<file alias="theme/dark/state-sync.svg">theme/universal/opencloud-icon.svg</file>
15-
<file>theme/universal/opencloud-icon.svg</file>
16-
<file>theme/universal/wizard_logo.svg</file>
173
<file>theme/OpenCloud500-Regular.otf</file>
18-
<file>theme/OpenCloud750-Bold.otf</file>
194
<file>theme/OpenCloud500-Regular.woff2</file>
5+
<file>theme/OpenCloud750-Bold.otf</file>
6+
<file alias="theme/dark-systray/error.svg">theme/dark-systray/ocl-ui_error-flieder-colour.svg</file>
7+
<file alias="theme/dark-systray/information.svg">theme/dark-systray/ocl-ui_info-flieder-colour.svg</file>
8+
<file alias="theme/dark-systray/ok.svg">theme/dark-systray/ocl-ui_logo-flieder.svg</file>
9+
<file alias="theme/dark-systray/offline.svg">theme/dark-systray/ocl-ui_offline-flieder-colour.svg</file>
10+
<file alias="theme/dark-systray/pause.svg">theme/dark-systray/ocl-ui_pause-flieder-colour.svg</file>
11+
<file alias="theme/dark-systray/sync.svg">theme/dark-systray/ocl-ui_sync-flieder-colour.svg</file>
12+
<file alias="theme/light-systray/error.svg">theme/light-systray/ocl-ui_error-petrol-colour.svg</file>
13+
<file alias="theme/light-systray/information.svg">theme/light-systray/ocl-ui_info-petrol-colour.svg</file>
14+
<file alias="theme/light-systray/ok.svg">theme/light-systray/ocl-ui_logo-petrol.svg</file>
15+
<file alias="theme/light-systray/offline.svg">theme/light-systray/ocl-ui_offline-petrol-colour.svg</file>
16+
<file alias="theme/light-systray/pause.svg">theme/light-systray/ocl-ui_pause-petrol-colour.svg</file>
17+
<file alias="theme/light-systray/sync.svg">theme/light-systray/ocl-ui_sync-petrol-colour.svg</file>
18+
<file alias="theme/mask-systray/error.svg">theme/mask-systray/ocl-ui_error-hex#000.svg</file>
19+
<file alias="theme/mask-systray/information.svg">theme/mask-systray/ocl-ui_info-hex#000.svg</file>
20+
<file alias="theme/mask-systray/ok.svg">theme/mask-systray/ocl-ui_logo-hex#000.svg</file>
21+
<file alias="theme/mask-systray/offline.svg">theme/mask-systray/ocl-ui_offline-hex#000.svg</file>
22+
<file alias="theme/mask-systray/pause.svg">theme/mask-systray/ocl-ui_pause-hex#000.svg</file>
23+
<file alias="theme/mask-systray/sync.svg">theme/mask-systray/ocl-ui_sync-hex#000.svg</file>
24+
<file>theme/universal/opencloud-icon.svg</file>
25+
<file>theme/universal/wizard_logo.svg</file>
2026
</qresource>
2127
</RCC>

src/resources/resources.cpp

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -52,37 +52,6 @@ QString brandThemePath()
5252
{
5353
return QStringLiteral(":/client/" APPLICATION_SHORTNAME "/theme");
5454
}
55-
56-
QString darkTheme()
57-
{
58-
return QStringLiteral("dark");
59-
}
60-
61-
QString coloredTheme()
62-
{
63-
return QStringLiteral("colored");
64-
}
65-
66-
bool hasTheme(IconType type, const QString &theme)
67-
{
68-
// <<is vanilla, theme name>, bool
69-
// caches the availability of themes for branded and unbranded themes
70-
static QMap<QPair<bool, QString>, bool> _themeCache;
71-
const auto key = qMakePair(type != IconType::VanillaIcon, theme);
72-
auto it = _themeCache.constFind(key);
73-
if (it == _themeCache.cend()) {
74-
return _themeCache[key] = QFileInfo(QStringLiteral("%1/%2/").arg(type == IconType::VanillaIcon ? vanillaThemePath() : brandThemePath(), theme)).isDir();
75-
}
76-
return it.value();
77-
}
78-
79-
}
80-
81-
bool OCC::Resources::hasDarkTheme()
82-
{
83-
static bool _hasBrandedColored = hasTheme(IconType::BrandedIcon, coloredTheme());
84-
static bool _hasBrandedDark = hasTheme(IconType::BrandedIcon, darkTheme());
85-
return _hasBrandedColored == _hasBrandedDark;
8655
}
8756

8857
bool Resources::isVanillaTheme()
@@ -125,10 +94,6 @@ QIcon OCC::Resources::loadIcon(const QString &flavor, const QString &name, IconT
12594
const QString path = QStringLiteral("%1/%2/%3").arg(useCoreIcon ? vanillaThemePath() : brandThemePath(), flavor, name);
12695
QIcon &cached = iconCache->_cache[path]; // Take reference, this will also "set" the cache entry
12796
if (cached.isNull()) {
128-
if (isVanillaTheme() && QIcon::hasThemeIcon(name)) {
129-
// use from theme
130-
return cached = QIcon::fromTheme(name);
131-
}
13297
const QString svg = QStringLiteral("%1.svg").arg(path);
13398
if (QFile::exists(svg)) {
13499
return cached = QIcon(svg);
@@ -164,11 +129,6 @@ QIcon OCC::Resources::loadIcon(const QString &flavor, const QString &name, IconT
164129
return cached;
165130
}
166131

167-
QIcon OCC::Resources::themeIcon(const QString &name, IconType iconType)
168-
{
169-
return loadIcon((Resources::isUsingDarkTheme() && hasDarkTheme()) ? darkTheme() : coloredTheme(), name, iconType);
170-
}
171-
172132
QIcon OCC::Resources::themeUniversalIcon(const QString &name, IconType iconType)
173133
{
174134
return loadIcon(QStringLiteral("universal"), name, iconType);
@@ -187,8 +147,6 @@ QPixmap CoreImageProvider::requestPixmap(const QString &id, QSize *size, const Q
187147
icon = getCoreIcon(qmlIcon.iconName);
188148
} else if (qmlIcon.theme == QLatin1String("universal")) {
189149
icon = themeUniversalIcon(qmlIcon.iconName);
190-
} else {
191-
icon = themeIcon(qmlIcon.iconName);
192150
}
193151
return Resources::pixmap(requestedSize, icon, qmlIcon.enabled ? QIcon::Normal : QIcon::Disabled, size);
194152
}

src/resources/resources.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,9 @@ bool OPENCLOUD_RESOURCES_EXPORT isVanillaTheme();
4040
*/
4141
bool OPENCLOUD_RESOURCES_EXPORT isUsingDarkTheme();
4242

43-
bool OPENCLOUD_RESOURCES_EXPORT hasDarkTheme();
44-
4543
QIcon OPENCLOUD_RESOURCES_EXPORT getCoreIcon(const QString &icon_name);
4644

4745
QIcon OPENCLOUD_RESOURCES_EXPORT loadIcon(const QString &flavor, const QString &name, IconType iconType);
48-
QIcon OPENCLOUD_RESOURCES_EXPORT themeIcon(const QString &name, IconType iconType = IconType::BrandedIconWithFallbackToVanillaIcon);
4946

5047
/**
5148
* Returns a universal (non color schema aware) icon.
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)