Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions App/Client/Resource/icons/rabbit-black/svg/app-invert.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 32 additions & 1 deletion App/Client/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
#include <QFileDialog>
#include <QLoggingCategory>
#include <QThread>
#include <QGuiApplication>
#include <QPalette>
#include <QStyleHints>

static Q_LOGGING_CATEGORY(log, "App.MainWindow")
static Q_LOGGING_CATEGORY(logRecord, "App.MainWindow.Record")
Expand Down Expand Up @@ -1498,7 +1501,35 @@
this,
SLOT(slotSystemTrayIconActivated(QSystemTrayIcon::ActivationReason)));
Q_ASSERT(check);
m_TrayIcon->setIcon(this->windowIcon());

QSettings set(RabbitCommon::CDir::Instance()->GetFileUserConfigure(),
QSettings::IniFormat);
QString szThemeName = set.value("Style/Icon/Theme").toString();

#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
const auto scheme = QGuiApplication::styleHints()->colorScheme();
bool isDarkMode = scheme == Qt::ColorScheme::Dark;
#else
const QPalette defaultPalette;
const auto text = defaultPalette.color(QPalette::WindowText);
const auto window = defaultPalette.color(QPalette::Window);
bool isDarkMode = text.lightness() > window.lightness();
#endif // QT_VERSION

#ifdef Q_OS_MACOS
// Load white icon on macOS
if (szThemeName == "rabbit-black") {
m_TrayIcon->setIcon(QIcon::fromTheme("app-invert"));
}
#elif

Check failure on line 1524 in App/Client/mainwindow.cpp

View workflow job for this annotation

GitHub Actions / android / build_android (Release, android_x86_64, 6.8.1)

expected value in expression
if (isDarkMode && szThemeName == "rabbit-black") {
// Load white icon on dark system themes
m_TrayIcon->setIcon(QIcon::fromTheme("app-invert"));
} else {
m_TrayIcon->setIcon(this->windowIcon());
}
#endif

m_TrayIcon->setToolTip(windowTitle());
m_TrayIcon->show();
} else
Expand Down
Loading