mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 23:28:14 +03:00
Context menu: More detailed status messages
Previously it could only display synchronization progress or "up to date". Now it also communicates the same overall state that the icon shows. See owncloud/enterprise#2134
This commit is contained in:
parent
3eb2642b11
commit
92e90f9c55
2 changed files with 45 additions and 26 deletions
|
@ -207,13 +207,23 @@ void ownCloudGui::slotComputeOverallSyncStatus()
|
|||
{
|
||||
bool allSignedOut = true;
|
||||
bool allPaused = true;
|
||||
bool allDisconnected = true;
|
||||
QVector<AccountStatePtr> problemAccounts;
|
||||
auto setStatusText = [&](const QString &text) {
|
||||
// Don't overwrite the status if we're currently syncing
|
||||
if (FolderMan::instance()->currentSyncFolder())
|
||||
return;
|
||||
_actionStatus->setText(text);
|
||||
};
|
||||
|
||||
foreach (auto a, AccountManager::instance()->accounts()) {
|
||||
if (!a->isSignedOut()) {
|
||||
allSignedOut = false;
|
||||
}
|
||||
if (!a->isConnected()) {
|
||||
problemAccounts.append(a);
|
||||
} else {
|
||||
allDisconnected = false;
|
||||
}
|
||||
}
|
||||
foreach (Folder *f, FolderMan::instance()->map()) {
|
||||
|
@ -224,6 +234,11 @@ void ownCloudGui::slotComputeOverallSyncStatus()
|
|||
|
||||
if (!problemAccounts.empty()) {
|
||||
_tray->setIcon(Theme::instance()->folderOfflineIcon(true, contextMenuVisible()));
|
||||
if (allDisconnected) {
|
||||
setStatusText(tr("Disconnected"));
|
||||
} else {
|
||||
setStatusText(tr("Disconnected from some accounts"));
|
||||
}
|
||||
#ifdef Q_OS_WIN
|
||||
// Windows has a 128-char tray tooltip length limit.
|
||||
QStringList accountNames;
|
||||
|
@ -250,10 +265,12 @@ void ownCloudGui::slotComputeOverallSyncStatus()
|
|||
if (allSignedOut) {
|
||||
_tray->setIcon(Theme::instance()->folderOfflineIcon(true, contextMenuVisible()));
|
||||
_tray->setToolTip(tr("Please sign in"));
|
||||
setStatusText(tr("Signed out"));
|
||||
return;
|
||||
} else if (allPaused) {
|
||||
_tray->setIcon(Theme::instance()->syncStateIcon(SyncResult::Paused, true, contextMenuVisible()));
|
||||
_tray->setToolTip(tr("Account synchronization is disabled"));
|
||||
setStatusText(tr("Synchronization is paused"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -261,14 +278,13 @@ void ownCloudGui::slotComputeOverallSyncStatus()
|
|||
QString trayMessage;
|
||||
FolderMan *folderMan = FolderMan::instance();
|
||||
Folder::Map map = folderMan->map();
|
||||
SyncResult overallResult = FolderMan::accountStatus(map.values());
|
||||
SyncResult::Status overallResult = FolderMan::accountStatus(map.values()).status();
|
||||
|
||||
// create the tray blob message, check if we have an defined state
|
||||
if (overallResult.status() != SyncResult::Undefined) {
|
||||
if (map.count() > 0) {
|
||||
if (overallResult != SyncResult::Undefined && map.count() > 0) {
|
||||
#ifdef Q_OS_WIN
|
||||
// Windows has a 128-char tray tooltip length limit.
|
||||
trayMessage = folderMan->statusToString(overallResult.status(), false);
|
||||
trayMessage = folderMan->statusToString(overallResult, false);
|
||||
#else
|
||||
QStringList allStatusStrings;
|
||||
foreach (Folder *folder, map.values()) {
|
||||
|
@ -277,18 +293,25 @@ void ownCloudGui::slotComputeOverallSyncStatus()
|
|||
}
|
||||
trayMessage = allStatusStrings.join(QLatin1String("\n"));
|
||||
#endif
|
||||
} else {
|
||||
trayMessage = tr("No sync folders configured.");
|
||||
}
|
||||
|
||||
QIcon statusIcon = Theme::instance()->syncStateIcon(overallResult.status(), true, contextMenuVisible());
|
||||
QIcon statusIcon = Theme::instance()->syncStateIcon(overallResult, true, contextMenuVisible());
|
||||
_tray->setIcon(statusIcon);
|
||||
_tray->setToolTip(trayMessage);
|
||||
|
||||
if (overallResult == SyncResult::Success || overallResult == SyncResult::Problem) {
|
||||
setStatusText(tr("Up to date"));
|
||||
} else if (overallResult == SyncResult::Paused) {
|
||||
setStatusText(tr("Synchronization is paused"));
|
||||
} else {
|
||||
// undefined because there are no folders.
|
||||
QIcon icon = Theme::instance()->syncStateIcon(SyncResult::Problem, true, contextMenuVisible());
|
||||
setStatusText(tr("Error during synchronization"));
|
||||
}
|
||||
} else {
|
||||
if (overallResult == SyncResult::Undefined)
|
||||
overallResult = SyncResult::Problem;
|
||||
QIcon icon = Theme::instance()->syncStateIcon(overallResult, true, contextMenuVisible());
|
||||
_tray->setIcon(icon);
|
||||
_tray->setToolTip(tr("There are no sync folders configured."));
|
||||
setStatusText(tr("No sync folders configured"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -550,11 +573,13 @@ void ownCloudGui::updateContextMenu()
|
|||
|
||||
_contextMenu->addSeparator();
|
||||
|
||||
if (isConfigured && atLeastOneConnected) {
|
||||
_contextMenu->addAction(_actionStatus);
|
||||
if (isConfigured && atLeastOneConnected) {
|
||||
_contextMenu->addMenu(_recentActionsMenu);
|
||||
_contextMenu->addSeparator();
|
||||
}
|
||||
|
||||
_contextMenu->addSeparator();
|
||||
|
||||
if (accountList.isEmpty()) {
|
||||
_contextMenu->addAction(_actionNewAccountWizard);
|
||||
}
|
||||
|
@ -742,7 +767,7 @@ void ownCloudGui::slotUpdateProgress(const QString &folder, const ProgressInfo &
|
|||
.arg(progress._currentDiscoveredFolder));
|
||||
}
|
||||
} else if (progress.status() == ProgressInfo::Done) {
|
||||
QTimer::singleShot(2000, this, &ownCloudGui::slotDisplayIdle);
|
||||
QTimer::singleShot(2000, this, &ownCloudGui::slotComputeOverallSyncStatus);
|
||||
}
|
||||
if (progress.status() != ProgressInfo::Propagation) {
|
||||
return;
|
||||
|
@ -812,11 +837,6 @@ void ownCloudGui::slotUpdateProgress(const QString &folder, const ProgressInfo &
|
|||
}
|
||||
}
|
||||
|
||||
void ownCloudGui::slotDisplayIdle()
|
||||
{
|
||||
_actionStatus->setText(tr("Up to date"));
|
||||
}
|
||||
|
||||
void ownCloudGui::slotLogin()
|
||||
{
|
||||
if (auto account = qvariant_cast<AccountStatePtr>(sender()->property(propertyAccountC))) {
|
||||
|
|
|
@ -98,7 +98,6 @@ public slots:
|
|||
void slotRemoveDestroyedShareDialogs();
|
||||
|
||||
private slots:
|
||||
void slotDisplayIdle();
|
||||
void slotLogin();
|
||||
void slotLogout();
|
||||
void slotUnpauseAllFolders();
|
||||
|
|
Loading…
Reference in a new issue