From adc08d4ee9bd761f7b244c641a3f87f776cd5ba3 Mon Sep 17 00:00:00 2001 From: allexzander Date: Fri, 11 Jun 2021 12:12:05 +0300 Subject: [PATCH] Improved error message. Added proper subject. Removed folder name from a message text. Signed-off-by: allexzander --- src/gui/folder.cpp | 4 ++-- src/gui/folder.h | 2 +- src/gui/tray/UserModel.cpp | 7 ++++--- src/gui/tray/UserModel.h | 2 +- src/libsync/discovery.cpp | 4 ++-- src/libsync/discoveryphase.h | 2 +- src/libsync/progressdispatcher.h | 3 ++- src/libsync/syncengine.h | 2 +- 8 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index 38b5abfbbdcd8..475c313d02695 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -938,9 +938,9 @@ void Folder::slotSyncError(const QString &message, ErrorCategory category) emit ProgressDispatcher::instance()->syncError(alias(), message, category); } -void Folder::slotAddErrorToGui(SyncFileItem::Status status, const QString &errorMessage) +void Folder::slotAddErrorToGui(SyncFileItem::Status status, const QString &errorMessage, const QString &subject) { - emit ProgressDispatcher::instance()->addErrorToGui(alias() , status, errorMessage); + emit ProgressDispatcher::instance()->addErrorToGui(alias(), status, errorMessage, subject); } void Folder::slotSyncStarted() diff --git a/src/gui/folder.h b/src/gui/folder.h index f7b3eefa5112d..809ca85e79605 100644 --- a/src/gui/folder.h +++ b/src/gui/folder.h @@ -370,7 +370,7 @@ private slots: */ void slotSyncError(const QString &message, ErrorCategory category = ErrorCategory::Normal); - void slotAddErrorToGui(SyncFileItem::Status status, const QString &errorMessage); + void slotAddErrorToGui(SyncFileItem::Status status, const QString &errorMessage, const QString &subject = {}); void slotTransmissionProgress(const ProgressInfo &pi); void slotItemCompleted(const SyncFileItemPtr &); diff --git a/src/gui/tray/UserModel.cpp b/src/gui/tray/UserModel.cpp index b35d0dd418cfb..4a23d01915469 100644 --- a/src/gui/tray/UserModel.cpp +++ b/src/gui/tray/UserModel.cpp @@ -26,6 +26,7 @@ namespace { constexpr qint64 expiredActivitiesCheckIntervalMs = 1000 * 60; + constexpr qint64 activityDefaultExpirationTimeMs = 1000 * 60 * 2; } namespace OCC { @@ -443,7 +444,7 @@ void User::slotAddError(const QString &folderAlias, const QString &message, Erro } } -void User::slotAddErrorToGui(const QString &folderAlias, SyncFileItem::Status status, const QString &errorMessage) +void User::slotAddErrorToGui(const QString &folderAlias, SyncFileItem::Status status, const QString &errorMessage, const QString &subject) { const auto folderInstance = FolderMan::instance()->folder(folderAlias); if (!folderInstance) @@ -457,8 +458,8 @@ void User::slotAddErrorToGui(const QString &folderAlias, SyncFileItem::Status st activity._status = status; const auto currentDateTime = QDateTime::currentDateTime(); activity._dateTime = QDateTime::fromString(currentDateTime.toString(), Qt::ISODate); - activity._expireAtMsecs = currentDateTime.addSecs(60 * 1).toMSecsSinceEpoch(); - activity._subject = folderInstance->shortGuiLocalPath(); + activity._expireAtMsecs = currentDateTime.addMSecs(activityDefaultExpirationTimeMs).toMSecsSinceEpoch(); + activity._subject = !subject.isEmpty() ? subject : folderInstance->shortGuiLocalPath(); activity._message = errorMessage; activity._link = folderInstance->shortGuiLocalPath(); activity._accName = folderInstance->accountState()->account()->displayName(); diff --git a/src/gui/tray/UserModel.h b/src/gui/tray/UserModel.h index c9a81e12ac2f4..2e57d0844f7e8 100644 --- a/src/gui/tray/UserModel.h +++ b/src/gui/tray/UserModel.h @@ -75,7 +75,7 @@ public slots: void slotItemCompleted(const QString &folder, const SyncFileItemPtr &item); void slotProgressInfo(const QString &folder, const ProgressInfo &progress); void slotAddError(const QString &folderAlias, const QString &message, ErrorCategory category); - void slotAddErrorToGui(const QString &folderAlias, SyncFileItem::Status status, const QString &errorMessage); + void slotAddErrorToGui(const QString &folderAlias, SyncFileItem::Status status, const QString &errorMessage, const QString &subject = {}); void slotNotificationRequestFinished(int statusCode); void slotNotifyNetworkError(QNetworkReply *reply); void slotEndNotificationRequest(int replyCode); diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index 68f762c551ae4..7bfdeb3ddca0b 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -921,13 +921,13 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo( // this flag needs to be unset, otherwise a folder would get marked as new in the processSubJobs _childModified = false; if (isFolderPlaceholder && _discoveryData) { - emit _discoveryData->addErrorToGui(SyncFileItem::SoftError, tr("Conflict when uploading a folder %1. It's going to get wiped!").arg(path._local)); + emit _discoveryData->addErrorToGui(SyncFileItem::SoftError, tr("Conflict when uploading a folder. It's going to get wiped!"), path._local); } } else { if (localEntry.isDirectory && !isFolderPlaceholder) { qCInfo(lcDisco) << "Virtual directory without db entry for" << path._local << "but it contains hydrated file(s), so let's keep it and reupload."; if (_discoveryData) { - emit _discoveryData->addErrorToGui(SyncFileItem::SoftError, tr("Conflict when uploading some files to a folder %1. Those, conflicted, are going to get wiped!").arg(path._local)); + emit _discoveryData->addErrorToGui(SyncFileItem::SoftError, tr("Conflict when uploading some files to a folder. Those, conflicted, are going to get wiped!"), path._local); } return; } diff --git a/src/libsync/discoveryphase.h b/src/libsync/discoveryphase.h index 03164f6e8be8f..9868e3ec66c10 100644 --- a/src/libsync/discoveryphase.h +++ b/src/libsync/discoveryphase.h @@ -280,7 +280,7 @@ class DiscoveryPhase : public QObject */ void silentlyExcluded(const QString &folderPath); - void addErrorToGui(SyncFileItem::Status status, const QString &errorMessage); + void addErrorToGui(SyncFileItem::Status status, const QString &errorMessage, const QString &subject); }; /// Implementation of DiscoveryPhase::adjustRenamedPath diff --git a/src/libsync/progressdispatcher.h b/src/libsync/progressdispatcher.h index 7dc75b2e408f0..99415d544defc 100644 --- a/src/libsync/progressdispatcher.h +++ b/src/libsync/progressdispatcher.h @@ -295,8 +295,9 @@ class OWNCLOUDSYNC_EXPORT ProgressDispatcher : public QObject * @param[out] folder The folder which is being processed * @param[out] status of the error * @param[out] full error message + * @param[out] subject (optional) */ - void addErrorToGui(const QString &folder, SyncFileItem::Status status, const QString &errorMessage); + void addErrorToGui(const QString &folder, SyncFileItem::Status status, const QString &errorMessage, const QString &subject); /** * @brief Emitted for a folder when a sync is done, listing all pending conflicts diff --git a/src/libsync/syncengine.h b/src/libsync/syncengine.h index cd69c787a889b..a9e50a19798df 100644 --- a/src/libsync/syncengine.h +++ b/src/libsync/syncengine.h @@ -151,7 +151,7 @@ class OWNCLOUDSYNC_EXPORT SyncEngine : public QObject /// We've produced a new sync error of a type. void syncError(const QString &message, ErrorCategory category = ErrorCategory::Normal); - void addErrorToGui(SyncFileItem::Status status, const QString &errorMessage); + void addErrorToGui(SyncFileItem::Status status, const QString &errorMessage, const QString &subject); void finished(bool success); void started();