diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp index 0dc60e626b8b3..0b2b918eba889 100644 --- a/src/gui/folderman.cpp +++ b/src/gui/folderman.cpp @@ -1610,18 +1610,21 @@ void FolderMan::slotLeaveShare(const QString &localFile, const QByteArray &folde } void FolderMan::trayOverallStatus(const QList &folders, - SyncResult::Status *status, bool *unresolvedConflicts) + SyncResult::Status *status, + bool *unresolvedConflicts, + const ProgressInfo **overallProgressInfo) { *status = SyncResult::Undefined; *unresolvedConflicts = false; const auto cnt = folders.count(); - // if one folder: show the state of the one folder. + // if one folder: show the state of the one folder along with the sync status. // if more folders: // if one of them has an error -> show error // if one is paused, but others ok, show ok // do not show "problem" in the tray + // and do not show sync status // if (cnt == 1) { const auto folder = folders.at(0); @@ -1644,6 +1647,7 @@ void FolderMan::trayOverallStatus(const QList &folders, } } *unresolvedConflicts = syncResult.hasUnresolvedConflicts(); + *overallProgressInfo = &folder->syncEngine().progressInfo(); } } else { auto errorsSeen = false; @@ -1710,8 +1714,7 @@ void FolderMan::trayOverallStatus(const QList &folders, } } -QString FolderMan::trayTooltipStatusString( - SyncResult::Status syncStatus, bool hasUnresolvedConflicts, bool paused) +QString FolderMan::trayTooltipStatusString(SyncResult::Status syncStatus, bool hasUnresolvedConflicts, bool paused, const ProgressInfo &progress) { QString folderMessage; switch (syncStatus) { @@ -1725,6 +1728,28 @@ QString FolderMan::trayTooltipStatusString( folderMessage = tr("Preparing for sync."); break; case SyncResult::SyncRunning: + if (progress.status() == ProgressInfo::Propagation) { + if (progress.totalSize() == 0) { + qint64 currentFile = progress.currentFile(); + qint64 totalFileCount = qMax(progress.totalFiles(), currentFile); + if (progress.trustEta()) { + folderMessage = tr("Syncing %1 of %2 (%3 left)") + .arg(currentFile) + .arg(totalFileCount) + .arg(Utility::durationToDescriptiveString2(progress.totalProgress().estimatedEta)); + } else { + folderMessage = tr("Syncing %1 of %2").arg(currentFile).arg(totalFileCount); + } + } else { + QString totalSizeStr = Utility::octetsToString(progress.totalSize()); + if (progress.trustEta()) { + folderMessage = tr("Syncing %1 (%2 left)").arg(totalSizeStr, Utility::durationToDescriptiveString2(progress.totalProgress().estimatedEta)); + } else { + folderMessage = tr("Syncing %1").arg(totalSizeStr); + } + } + break; + } folderMessage = tr("Sync is running."); break; case SyncResult::Success: diff --git a/src/gui/folderman.h b/src/gui/folderman.h index 0fcffc9fdd16c..2a857513363cd 100644 --- a/src/gui/folderman.h +++ b/src/gui/folderman.h @@ -137,11 +137,11 @@ class FolderMan : public QObject bool startFromScratch(const QString &); /// Produce text for use in the tray tooltip - static QString trayTooltipStatusString(SyncResult::Status syncStatus, bool hasUnresolvedConflicts, bool paused); + static QString trayTooltipStatusString(SyncResult::Status syncStatus, bool hasUnresolvedConflicts, bool paused, const ProgressInfo &progress); /// Compute status summarizing multiple folders - static void trayOverallStatus(const QList &folders, - SyncResult::Status *status, bool *unresolvedConflicts); + static void + trayOverallStatus(const QList &folders, SyncResult::Status *status, bool *unresolvedConflicts, const ProgressInfo **overallProgressInfo); // Escaping of the alias which is used in QSettings AND the file // system, thus need to be escaped. diff --git a/src/gui/owncloudgui.cpp b/src/gui/owncloudgui.cpp index 9cc24ef7ae617..eea6132a68f51 100644 --- a/src/gui/owncloudgui.cpp +++ b/src/gui/owncloudgui.cpp @@ -32,6 +32,7 @@ #include "theme.h" #include "wheelhandler.h" #include "syncconflictsmodel.h" +#include "syncengine.h" #include "filedetails/datefieldbackend.h" #include "filedetails/filedetails.h" #include "filedetails/shareemodel.h" @@ -383,7 +384,8 @@ void ownCloudGui::slotComputeOverallSyncStatus() SyncResult::Status overallStatus = SyncResult::Undefined; bool hasUnresolvedConflicts = false; - FolderMan::trayOverallStatus(map.values(), &overallStatus, &hasUnresolvedConflicts); + const ProgressInfo *overallProgressInfo; + FolderMan::trayOverallStatus(map.values(), &overallStatus, &hasUnresolvedConflicts, &overallProgressInfo); #ifdef BUILD_FILE_PROVIDER_MODULE if (!problemFileProviderAccounts.isEmpty()) { @@ -420,15 +422,15 @@ void ownCloudGui::slotComputeOverallSyncStatus() #endif #ifdef Q_OS_WIN // Windows has a 128-char tray tooltip length limit. - trayMessage = folderMan->trayTooltipStatusString(overallStatus, hasUnresolvedConflicts, false); + trayMessage = folderMan->trayTooltipStatusString(overallStatus, hasUnresolvedConflicts, false, *overallProgressInfo); #else QStringList allStatusStrings; const auto folders = map.values(); for (const auto folder : folders) { - QString folderMessage = FolderMan::trayTooltipStatusString( - folder->syncResult().status(), - folder->syncResult().hasUnresolvedConflicts(), - folder->syncPaused()); + QString folderMessage = FolderMan::trayTooltipStatusString(folder->syncResult().status(), + folder->syncResult().hasUnresolvedConflicts(), + folder->syncPaused(), + folder->syncEngine().progressInfo()); allStatusStrings += tr("Folder %1: %2").arg(folder->shortGuiLocalPath(), folderMessage); } #ifdef BUILD_FILE_PROVIDER_MODULE @@ -502,7 +504,6 @@ void ownCloudGui::slotUpdateProgress(const QString &folder, const ProgressInfo & { Q_UNUSED(folder); - // FIXME: Lots of messages computed for nothing in this method, needs revisiting if (progress.status() == ProgressInfo::Discovery) { #if 0 if (!progress._currentDiscoveredRemoteFolder.isEmpty()) { @@ -520,33 +521,7 @@ void ownCloudGui::slotUpdateProgress(const QString &folder, const ProgressInfo & return; } - if (progress.totalSize() == 0) { - qint64 currentFile = progress.currentFile(); - qint64 totalFileCount = qMax(progress.totalFiles(), currentFile); - QString msg; - if (progress.trustEta()) { - msg = tr("Syncing %1 of %2 (%3 left)") - .arg(currentFile) - .arg(totalFileCount) - .arg(Utility::durationToDescriptiveString2(progress.totalProgress().estimatedEta)); - } else { - msg = tr("Syncing %1 of %2") - .arg(currentFile) - .arg(totalFileCount); - } - //_actionStatus->setText(msg); - } else { - QString totalSizeStr = Utility::octetsToString(progress.totalSize()); - QString msg; - if (progress.trustEta()) { - msg = tr("Syncing %1 (%2 left)") - .arg(totalSizeStr, Utility::durationToDescriptiveString2(progress.totalProgress().estimatedEta)); - } else { - msg = tr("Syncing %1") - .arg(totalSizeStr); - } - //_actionStatus->setText(msg); - } + slotComputeOverallSyncStatus(); if (!progress._lastCompletedItem.isEmpty()) { diff --git a/src/libsync/syncengine.h b/src/libsync/syncengine.h index af234725cf2d8..0d47e57cce2e9 100644 --- a/src/libsync/syncengine.h +++ b/src/libsync/syncengine.h @@ -78,6 +78,11 @@ class OWNCLOUDSYNC_EXPORT SyncEngine : public QObject [[nodiscard]] SyncOptions syncOptions() const { return _syncOptions; } [[nodiscard]] bool ignoreHiddenFiles() const { return _ignore_hidden_files; } + [[nodiscard]] const ProgressInfo &progressInfo() const + { + return *_progressInfo; + } + [[nodiscard]] ExcludedFiles &excludedFiles() const { return *_excludedFiles; } [[nodiscard]] SyncFileStatusTracker &syncFileStatusTracker() const { return *_syncFileStatusTracker; }