diff --git a/App/Client/Resource/icons/rabbit-black/svg/app-invert.svg b/App/Client/Resource/icons/rabbit-black/svg/app-invert.svg new file mode 100644 index 000000000..701e169b2 --- /dev/null +++ b/App/Client/Resource/icons/rabbit-black/svg/app-invert.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/App/Client/mainwindow.cpp b/App/Client/mainwindow.cpp index b604c2edf..e27e56dc6 100644 --- a/App/Client/mainwindow.cpp +++ b/App/Client/mainwindow.cpp @@ -45,6 +45,9 @@ #include #include #include +#include +#include +#include static Q_LOGGING_CATEGORY(log, "App.MainWindow") static Q_LOGGING_CATEGORY(logRecord, "App.MainWindow.Record") @@ -1498,7 +1501,35 @@ void MainWindow::slotSystemTrayIconTypeChanged() 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 + 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