gui: add some extra syncing details to the tray tooltips

There was some unused code that updated some status bar text -- this is
now part of the tooltip during syncing.

Signed-off-by: Jyrki Gadinger <nilsding@nilsding.org>
This commit is contained in:
Jyrki Gadinger 2024-08-29 17:31:04 +02:00 committed by Matthieu Gallien
parent b6c439ffc8
commit 45fa561e64
4 changed files with 53 additions and 42 deletions

View file

@ -1610,18 +1610,21 @@ void FolderMan::slotLeaveShare(const QString &localFile, const QByteArray &folde
} }
void FolderMan::trayOverallStatus(const QList<Folder *> &folders, void FolderMan::trayOverallStatus(const QList<Folder *> &folders,
SyncResult::Status *status, bool *unresolvedConflicts) SyncResult::Status *status,
bool *unresolvedConflicts,
ProgressInfo **const overallProgressInfo)
{ {
*status = SyncResult::Undefined; *status = SyncResult::Undefined;
*unresolvedConflicts = false; *unresolvedConflicts = false;
const auto cnt = folders.count(); 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 more folders:
// if one of them has an error -> show error // if one of them has an error -> show error
// if one is paused, but others ok, show ok // if one is paused, but others ok, show ok
// do not show "problem" in the tray // do not show "problem" in the tray
// and do not show sync status
// //
if (cnt == 1) { if (cnt == 1) {
const auto folder = folders.at(0); const auto folder = folders.at(0);
@ -1644,6 +1647,7 @@ void FolderMan::trayOverallStatus(const QList<Folder *> &folders,
} }
} }
*unresolvedConflicts = syncResult.hasUnresolvedConflicts(); *unresolvedConflicts = syncResult.hasUnresolvedConflicts();
*overallProgressInfo = folder->syncEngine().progressInfo();
} }
} else { } else {
auto errorsSeen = false; auto errorsSeen = false;
@ -1710,8 +1714,7 @@ void FolderMan::trayOverallStatus(const QList<Folder *> &folders,
} }
} }
QString FolderMan::trayTooltipStatusString( QString FolderMan::trayTooltipStatusString(SyncResult::Status syncStatus, bool hasUnresolvedConflicts, bool paused, ProgressInfo *const progress)
SyncResult::Status syncStatus, bool hasUnresolvedConflicts, bool paused)
{ {
QString folderMessage; QString folderMessage;
switch (syncStatus) { switch (syncStatus) {
@ -1725,6 +1728,35 @@ QString FolderMan::trayTooltipStatusString(
folderMessage = tr("Preparing for sync."); folderMessage = tr("Preparing for sync.");
break; break;
case SyncResult::SyncRunning: case SyncResult::SyncRunning:
if (progress && progress->status() == ProgressInfo::Propagation) {
const auto estimatedEta = progress->totalProgress().estimatedEta;
if (progress->totalSize() == 0) {
qint64 currentFile = progress->currentFile();
qint64 totalFileCount = qMax(progress->totalFiles(), currentFile);
if (progress->trustEta()) {
if (estimatedEta == 0) {
folderMessage = tr("Syncing %1 of %2 (A few seconds left)").arg(currentFile).arg(totalFileCount);
} else {
folderMessage =
tr("Syncing %1 of %2 (%3 left)").arg(currentFile).arg(totalFileCount).arg(Utility::durationToDescriptiveString1(estimatedEta));
}
} else {
folderMessage = tr("Syncing %1 of %2").arg(currentFile).arg(totalFileCount);
}
} else {
QString totalSizeStr = Utility::octetsToString(progress->totalSize());
if (progress->trustEta()) {
if (estimatedEta == 0) {
folderMessage = tr("Syncing %1 (A few seconds left)").arg(totalSizeStr, Utility::durationToDescriptiveString1(estimatedEta));
} else {
folderMessage = tr("Syncing %1 (%2 left)").arg(totalSizeStr, Utility::durationToDescriptiveString1(estimatedEta));
}
} else {
folderMessage = tr("Syncing %1").arg(totalSizeStr);
}
}
break;
}
folderMessage = tr("Sync is running."); folderMessage = tr("Sync is running.");
break; break;
case SyncResult::Success: case SyncResult::Success:

View file

@ -137,11 +137,10 @@ public:
bool startFromScratch(const QString &); bool startFromScratch(const QString &);
/// Produce text for use in the tray tooltip /// 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, ProgressInfo *progress);
/// Compute status summarizing multiple folders /// Compute status summarizing multiple folders
static void trayOverallStatus(const QList<Folder *> &folders, static void trayOverallStatus(const QList<Folder *> &folders, SyncResult::Status *status, bool *unresolvedConflicts, ProgressInfo **overallProgressInfo);
SyncResult::Status *status, bool *unresolvedConflicts);
// Escaping of the alias which is used in QSettings AND the file // Escaping of the alias which is used in QSettings AND the file
// system, thus need to be escaped. // system, thus need to be escaped.

View file

@ -32,6 +32,7 @@
#include "theme.h" #include "theme.h"
#include "wheelhandler.h" #include "wheelhandler.h"
#include "syncconflictsmodel.h" #include "syncconflictsmodel.h"
#include "syncengine.h"
#include "filedetails/datefieldbackend.h" #include "filedetails/datefieldbackend.h"
#include "filedetails/filedetails.h" #include "filedetails/filedetails.h"
#include "filedetails/shareemodel.h" #include "filedetails/shareemodel.h"
@ -383,7 +384,8 @@ void ownCloudGui::slotComputeOverallSyncStatus()
SyncResult::Status overallStatus = SyncResult::Undefined; SyncResult::Status overallStatus = SyncResult::Undefined;
bool hasUnresolvedConflicts = false; bool hasUnresolvedConflicts = false;
FolderMan::trayOverallStatus(map.values(), &overallStatus, &hasUnresolvedConflicts); ProgressInfo *overallProgressInfo = nullptr;
FolderMan::trayOverallStatus(map.values(), &overallStatus, &hasUnresolvedConflicts, &overallProgressInfo);
#ifdef BUILD_FILE_PROVIDER_MODULE #ifdef BUILD_FILE_PROVIDER_MODULE
if (!problemFileProviderAccounts.isEmpty()) { if (!problemFileProviderAccounts.isEmpty()) {
@ -420,16 +422,16 @@ void ownCloudGui::slotComputeOverallSyncStatus()
#endif #endif
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
// Windows has a 128-char tray tooltip length limit. // Windows has a 128-char tray tooltip length limit.
trayMessage = folderMan->trayTooltipStatusString(overallStatus, hasUnresolvedConflicts, false); trayMessage = folderMan->trayTooltipStatusString(overallStatus, hasUnresolvedConflicts, false, overallProgressInfo);
#else #else
QStringList allStatusStrings; QStringList allStatusStrings;
const auto folders = map.values(); const auto folders = map.values();
for (const auto folder : folders) { for (const auto folder : folders) {
QString folderMessage = FolderMan::trayTooltipStatusString( QString folderMessage = FolderMan::trayTooltipStatusString(folder->syncResult().status(),
folder->syncResult().status(), folder->syncResult().hasUnresolvedConflicts(),
folder->syncResult().hasUnresolvedConflicts(), folder->syncPaused(),
folder->syncPaused()); folder->syncEngine().progressInfo());
allStatusStrings += tr("Folder %1: %2").arg(folder->shortGuiLocalPath(), folderMessage); allStatusStrings += tr("%1: %2").arg(folder->shortGuiLocalPath(), folderMessage);
} }
#ifdef BUILD_FILE_PROVIDER_MODULE #ifdef BUILD_FILE_PROVIDER_MODULE
for (const auto &accountId : syncingFileProviderAccounts) { for (const auto &accountId : syncingFileProviderAccounts) {
@ -502,7 +504,6 @@ void ownCloudGui::slotUpdateProgress(const QString &folder, const ProgressInfo &
{ {
Q_UNUSED(folder); Q_UNUSED(folder);
// FIXME: Lots of messages computed for nothing in this method, needs revisiting
if (progress.status() == ProgressInfo::Discovery) { if (progress.status() == ProgressInfo::Discovery) {
#if 0 #if 0
if (!progress._currentDiscoveredRemoteFolder.isEmpty()) { if (!progress._currentDiscoveredRemoteFolder.isEmpty()) {
@ -520,33 +521,7 @@ void ownCloudGui::slotUpdateProgress(const QString &folder, const ProgressInfo &
return; return;
} }
if (progress.totalSize() == 0) { slotComputeOverallSyncStatus();
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);
}
if (!progress._lastCompletedItem.isEmpty()) { if (!progress._lastCompletedItem.isEmpty()) {

View file

@ -78,6 +78,11 @@ public:
[[nodiscard]] SyncOptions syncOptions() const { return _syncOptions; } [[nodiscard]] SyncOptions syncOptions() const { return _syncOptions; }
[[nodiscard]] bool ignoreHiddenFiles() const { return _ignore_hidden_files; } [[nodiscard]] bool ignoreHiddenFiles() const { return _ignore_hidden_files; }
[[nodiscard]] ProgressInfo *progressInfo() const
{
return _progressInfo.get();
}
[[nodiscard]] ExcludedFiles &excludedFiles() const { return *_excludedFiles; } [[nodiscard]] ExcludedFiles &excludedFiles() const { return *_excludedFiles; }
[[nodiscard]] SyncFileStatusTracker &syncFileStatusTracker() const { return *_syncFileStatusTracker; } [[nodiscard]] SyncFileStatusTracker &syncFileStatusTracker() const { return *_syncFileStatusTracker; }