- Use a white icon if the context menu is visible.
- Enable `QIcon::setIsMask` if compiled on Qt >= 5.6 to allow automatic
macOS color handling.
- No changes if the colored icons are used.
_tray->setParent(this);
// for the beginning, set the offline icon until the account was verified
- _tray->setIcon( Theme::instance()->folderOfflineIcon(true));
+ _tray->setIcon( Theme::instance()->folderOfflineIcon(true, contextMenuVisible()));
connect(_tray.data(), SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
SLOT(slotTrayClicked(QSystemTrayIcon::ActivationReason)));
}
if (!problemAccounts.empty()) {
- _tray->setIcon(Theme::instance()->folderOfflineIcon(true));
+ _tray->setIcon(Theme::instance()->folderOfflineIcon(true, contextMenuVisible()));
#ifdef Q_OS_WIN
// Windows has a 128-char tray tooltip length limit.
QStringList accountNames;
}
if (allSignedOut) {
- _tray->setIcon(Theme::instance()->folderOfflineIcon(true));
+ _tray->setIcon(Theme::instance()->folderOfflineIcon(true, contextMenuVisible()));
_tray->setToolTip(tr("Please sign in"));
return;
} else if (allPaused) {
- _tray->setIcon(Theme::instance()->syncStateIcon(SyncResult::Paused, true));
+ _tray->setIcon(Theme::instance()->syncStateIcon(SyncResult::Paused, true, contextMenuVisible()));
_tray->setToolTip(tr("Account synchronization is disabled"));
return;
}
trayMessage = tr("No sync folders configured.");
}
- QIcon statusIcon = Theme::instance()->syncStateIcon( overallResult.status(), true);
+ QIcon statusIcon = Theme::instance()->syncStateIcon( overallResult.status(), true, contextMenuVisible());
_tray->setIcon( statusIcon );
_tray->setToolTip(trayMessage);
} else {
// undefined because there are no folders.
- QIcon icon = Theme::instance()->syncStateIcon(SyncResult::Problem, true);
+ QIcon icon = Theme::instance()->syncStateIcon(SyncResult::Problem, true, contextMenuVisible());
_tray->setIcon( icon );
_tray->setToolTip(tr("There are no sync folders configured."));
}
// For some reason on OS X _contextMenu->isVisible returns always false
qDebug() << "";
_contextMenuVisibleOsx = true;
+
+ // Update icon in sys tray, as it might change depending on the context menu state
+ slotComputeOverallSyncStatus();
}
void ownCloudGui::slotContextMenuAboutToHide()
// For some reason on OS X _contextMenu->isVisible returns always false
qDebug() << "";
_contextMenuVisibleOsx = false;
+
+ // Update icon in sys tray, as it might change depending on the context menu state
+ slotComputeOverallSyncStatus();
}
bool ownCloudGui::contextMenuVisible() const
* 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 ) const
+QIcon Theme::themeIcon( const QString& name, bool sysTray, bool sysTrayMenuVisible ) const
{
QString flavor;
if (sysTray) {
- flavor = systrayIconFlavor(_mono);
+ flavor = systrayIconFlavor(_mono, sysTrayMenuVisible);
} else {
flavor = QLatin1String("colored");
}
}
}
+ #ifdef Q_OS_MAC
+ #if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
+ // 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
+ #endif
+
return cached;
}
return appName();
}
-QString Theme::systrayIconFlavor(bool mono) const
+QString Theme::systrayIconFlavor(bool mono, bool sysTrayMenuVisible ) const
{
QString flavor;
if (mono) {
flavor = Utility::hasDarkSystray() ? QLatin1String("white") : QLatin1String("black");
+
+ #ifdef Q_OS_MAC
+ if (sysTrayMenuVisible) {
+ flavor = QLatin1String("white");
+ }
+ #endif
} else {
flavor = QLatin1String("colored");
}
return re;
}
-QIcon Theme::syncStateIcon( SyncResult::Status status, bool sysTray ) const
+QIcon Theme::syncStateIcon( SyncResult::Status status, bool sysTray, bool sysTrayMenuVisible ) const
{
// FIXME: Mind the size!
QString statusIcon;
statusIcon = QLatin1String("state-error");
}
- return themeIcon( statusIcon, sysTray );
+ return themeIcon( statusIcon, sysTray, sysTrayMenuVisible );
}
QIcon Theme::folderDisabledIcon( ) const
return themeIcon( QLatin1String("state-pause") );
}
-QIcon Theme::folderOfflineIcon(bool systray) const
+QIcon Theme::folderOfflineIcon(bool sysTray, bool sysTrayMenuVisible ) const
{
- return themeIcon( QLatin1String("state-offline"), systray );
+ return themeIcon( QLatin1String("state-offline"), sysTray, sysTrayMenuVisible );
}
QColor Theme::wizardHeaderTitleColor() const
/**
* get an sync state icon
*/
- virtual QIcon syncStateIcon( SyncResult::Status, bool sysTray = false ) const;
+ virtual QIcon syncStateIcon( SyncResult::Status, bool sysTray = false, bool sysTrayMenuVisible = false) const;
virtual QIcon folderDisabledIcon() const;
- virtual QIcon folderOfflineIcon(bool systray = false) const;
+ virtual QIcon folderOfflineIcon(bool sysTray = false, bool sysTrayMenuVisible = false) const;
virtual QIcon applicationIcon() const = 0;
#endif
virtual QString enforcedLocale() const { return QString::null; }
/** colored, white or black */
- QString systrayIconFlavor(bool mono) const;
+ QString systrayIconFlavor(bool mono, bool sysTrayMenuVisible = false) const;
#ifndef TOKEN_AUTH_ONLY
/**
protected:
#ifndef TOKEN_AUTH_ONLY
- QIcon themeIcon(const QString& name, bool sysTray = false) const;
+ QIcon themeIcon(const QString& name, bool sysTray = false, bool sysTrayMenuVisible = false) const;
#endif
Theme();