try to fix problems with wrong detections of tray icon state

This commit is contained in:
Martin Rotter 2022-01-07 08:15:47 +01:00
parent 7b48ef358f
commit 682489a233
2 changed files with 22 additions and 14 deletions

View File

@ -87,15 +87,9 @@ void SystemTrayIcon::showPrivate() {
}
void SystemTrayIcon::show() {
#if defined(Q_OS_WIN)
// Show immediately.
qDebugNN << LOGSEC_GUI << "Showing tray icon immediately.";
showPrivate();
#else
// Delay avoids race conditions and tray icon is properly displayed.
qDebugNN << LOGSEC_GUI << "Showing tray icon with 3000 ms delay.";
QTimer::singleShot(3000, this, &SystemTrayIcon::showPrivate);
#endif
}
void SystemTrayIcon::setNumber(int number, bool any_new_message) {

View File

@ -465,15 +465,29 @@ QIcon Application::desktopAwareIcon() const {
void Application::showTrayIcon() {
// Display tray icon if it is enabled and available.
if (SystemTrayIcon::isSystemTrayDesired()) {
#if !defined(Q_OS_LINUX)
if (!SystemTrayIcon::isSystemTrayAreaAvailable()) {
qWarningNN << LOGSEC_GUI << "Tray icon area is not available.";
return;
}
#endif
qDebugNN << LOGSEC_GUI << "User wants to have tray icon.";
qDebugNN << LOGSEC_GUI << "Showing tray icon.";
trayIcon()->show();
#if defined(Q_OS_WIN)
if (SystemTrayIcon::isSystemTrayAreaAvailable()) {
qDebugNN << LOGSEC_GUI << "Tray icon is available, showing now.";
trayIcon()->show();
}
else {
m_feedReader->feedsModel()->notifyWithCounts();
}
#else
// Delay avoids race conditions and tray icon is properly displayed.
qWarningNN << LOGSEC_GUI << "Showing tray icon with 3000 ms delay.";
QTimer::singleShot(3000, this, [=]() {
if (SystemTrayIcon::isSystemTrayAreaAvailable()) {
qWarningNN << LOGSEC_GUI << "Tray icon is available, showing now.";
trayIcon()->show();
}
else {
m_feedReader->feedsModel()->notifyWithCounts();
}
});
#endif
}
else {
m_feedReader->feedsModel()->notifyWithCounts();