mirror of
https://github.com/chylex/Nextcloud-Desktop.git
synced 2025-05-29 19:34:08 +02:00
Tray: Try to establish tray after 10s if failed initially #6518
When owncloud is started during desktop startup the tray may not yet be running when the client starts. This will make the client attempt to create a tray icon again after 10 seconds if there's no tray during initial startup.
This commit is contained in:
parent
4bd062f5be
commit
2f7cdb81cf
@ -804,6 +804,12 @@ void Application::openVirtualFile(const QString &filename)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::tryTrayAgain()
|
||||||
|
{
|
||||||
|
qCInfo(lcApplication) << "Trying tray icon, tray available:" << QSystemTrayIcon::isSystemTrayAvailable();
|
||||||
|
_gui->hideAndShowTray();
|
||||||
|
}
|
||||||
|
|
||||||
bool Application::event(QEvent *event)
|
bool Application::event(QEvent *event)
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
|
@ -79,6 +79,9 @@ public slots:
|
|||||||
*/
|
*/
|
||||||
void openVirtualFile(const QString &filename);
|
void openVirtualFile(const QString &filename);
|
||||||
|
|
||||||
|
/// Attempt to show() the tray icon again. Used if no systray was available initially.
|
||||||
|
void tryTrayAgain();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void parseOptions(const QStringList &);
|
void parseOptions(const QStringList &);
|
||||||
void setupTranslations();
|
void setupTranslations();
|
||||||
|
@ -154,6 +154,7 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We can't call isSystemTrayAvailable with appmenu-qt5 begause it hides the systemtray
|
// We can't call isSystemTrayAvailable with appmenu-qt5 begause it hides the systemtray
|
||||||
// (issue #4693)
|
// (issue #4693)
|
||||||
if (qgetenv("QT_QPA_PLATFORMTHEME") != "appmenu-qt5")
|
if (qgetenv("QT_QPA_PLATFORMTHEME") != "appmenu-qt5")
|
||||||
@ -162,27 +163,36 @@ int main(int argc, char **argv)
|
|||||||
// If the systemtray is not there, we will wait one second for it to maybe start
|
// If the systemtray is not there, we will wait one second for it to maybe start
|
||||||
// (eg boot time) then we show the settings dialog if there is still no systemtray.
|
// (eg boot time) then we show the settings dialog if there is still no systemtray.
|
||||||
// On XFCE however, we show a message box with explainaition how to install a systemtray.
|
// On XFCE however, we show a message box with explainaition how to install a systemtray.
|
||||||
|
qCInfo(lcApplication) << "System tray is not available, waiting...";
|
||||||
Utility::sleep(1);
|
Utility::sleep(1);
|
||||||
|
|
||||||
auto desktopSession = qgetenv("XDG_CURRENT_DESKTOP").toLower();
|
auto desktopSession = qgetenv("XDG_CURRENT_DESKTOP").toLower();
|
||||||
if (desktopSession.isEmpty()) {
|
if (desktopSession.isEmpty()) {
|
||||||
desktopSession = qgetenv("DESKTOP_SESSION").toLower();
|
desktopSession = qgetenv("DESKTOP_SESSION").toLower();
|
||||||
}
|
}
|
||||||
if (desktopSession == "xfce") {
|
if (desktopSession == "xfce") {
|
||||||
int attempts = 0;
|
int attempts = 0;
|
||||||
forever {
|
while (!QSystemTrayIcon::isSystemTrayAvailable()) {
|
||||||
if (!QSystemTrayIcon::isSystemTrayAvailable()) {
|
attempts++;
|
||||||
Utility::sleep(1);
|
if (attempts >= 30) {
|
||||||
attempts++;
|
qCWarning(lcApplication) << "System tray unavailable (xfce)";
|
||||||
if (attempts < 30)
|
warnSystray();
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
warnSystray();
|
Utility::sleep(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!app.backgroundMode() && !QSystemTrayIcon::isSystemTrayAvailable() && desktopSession != "ubuntu") {
|
|
||||||
app.showMainDialog();
|
if (QSystemTrayIcon::isSystemTrayAvailable()) {
|
||||||
|
app.tryTrayAgain();
|
||||||
|
} else if (!app.backgroundMode()) {
|
||||||
|
if (desktopSession != "ubuntu") {
|
||||||
|
qCInfo(lcApplication) << "System tray still not available, showing window and trying again later";
|
||||||
|
app.showMainDialog();
|
||||||
|
QTimer::singleShot(10000, &app, &Application::tryTrayAgain);
|
||||||
|
} else {
|
||||||
|
qCInfo(lcApplication) << "System tray still not available, but assuming it's fine on 'ubuntu' desktop";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -367,6 +367,12 @@ void ownCloudGui::slotComputeOverallSyncStatus()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ownCloudGui::hideAndShowTray()
|
||||||
|
{
|
||||||
|
_tray->hide();
|
||||||
|
_tray->show();
|
||||||
|
}
|
||||||
|
|
||||||
void ownCloudGui::slotShowTrayMessage(const QString &title, const QString &msg)
|
void ownCloudGui::slotShowTrayMessage(const QString &title, const QString &msg)
|
||||||
{
|
{
|
||||||
if (_tray)
|
if (_tray)
|
||||||
|
@ -65,6 +65,8 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
void createTray();
|
void createTray();
|
||||||
|
|
||||||
|
void hideAndShowTray();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void setupProxy();
|
void setupProxy();
|
||||||
void serverError(int code, const QString &message);
|
void serverError(int code, const QString &message);
|
||||||
|
Loading…
Reference in New Issue
Block a user