From: Claudio Cambra Date: Mon, 15 Jan 2024 08:35:49 +0000 (+0800) Subject: Provide correct sync state icon in file provider domain sync status X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~7^2~140^2~8 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=a469d44123499e12db8f3e0110cd999d101b6b08;p=nextcloud-desktop.git Provide correct sync state icon in file provider domain sync status Signed-off-by: Claudio Cambra --- diff --git a/src/gui/macOS/fileproviderdomainsyncstatus.h b/src/gui/macOS/fileproviderdomainsyncstatus.h index db0f37716..d92c2c553 100644 --- a/src/gui/macOS/fileproviderdomainsyncstatus.h +++ b/src/gui/macOS/fileproviderdomainsyncstatus.h @@ -36,6 +36,7 @@ class FileProviderDomainSyncStatus : public QObject Q_PROPERTY(int uploadFileTotalCount READ uploadFileTotalCount NOTIFY uploadFileTotalCountChanged) Q_PROPERTY(int uploadFileCompletedCount READ uploadFileCompletedCount NOTIFY uploadFileCompletedCountChanged) // TODO: more detailed reporting (time remaining, megabytes, etc.) + Q_PROPERTY(QUrl icon READ icon NOTIFY iconChanged) public: explicit FileProviderDomainSyncStatus(const QString &domainIdentifier, QObject *parent = nullptr); @@ -51,6 +52,7 @@ public: int downloadFileCompletedCount() const; int uploadFileTotalCount() const; int uploadFileCompletedCount() const; + QUrl icon() const; signals: void syncingChanged(bool syncing); @@ -63,6 +65,7 @@ signals: void downloadFileCompletedCountChanged(int downloadFileCompletedCount); void uploadFileTotalCountChanged(int uploadFileTotalCount); void uploadFileCompletedCountChanged(int uploadFileCompletedCount); + void iconChanged(const QUrl &icon); private: void setDownloading(const bool syncing); @@ -73,6 +76,8 @@ private: void setDownloadFileCompletedCount(const int fileCompletedCount); void setUploadFileTotalCount(const int fileTotalCount); void setUploadFileCompletedCount(const int fileCompletedCount); + void setIcon(const QUrl &icon); + void updateIcon(); bool _downloading = false; bool _uploading = false; @@ -82,6 +87,7 @@ private: int _downloadFileCompletedCount = 0; int _uploadFileTotalCount = 0; int _uploadFileCompletedCount = 0; + QUrl _icon; class MacImplementation; std::unique_ptr d; diff --git a/src/gui/macOS/fileproviderdomainsyncstatus_mac.mm b/src/gui/macOS/fileproviderdomainsyncstatus_mac.mm index 1455f93b1..6cc7efd42 100644 --- a/src/gui/macOS/fileproviderdomainsyncstatus_mac.mm +++ b/src/gui/macOS/fileproviderdomainsyncstatus_mac.mm @@ -17,6 +17,7 @@ #include #include "gui/macOS/fileproviderutils.h" +#include "libsync/theme.h" #import @@ -67,6 +68,7 @@ public: q->setDownloadFractionCompleted(progress.fractionCompleted); q->setDownloadFileTotalCount(progress.fileTotalCount.intValue); q->setDownloadFileCompletedCount(progress.fileCompletedCount.intValue); + q->updateIcon(); } void updateUpload(NSProgress *const progress) const @@ -80,6 +82,7 @@ public: q->setUploadFractionCompleted(progress.fractionCompleted); q->setUploadFileTotalCount(progress.fileTotalCount.intValue); q->setUploadFileCompletedCount(progress.fileCompletedCount.intValue); + q->updateIcon(); } private: @@ -95,6 +98,7 @@ FileProviderDomainSyncStatus::FileProviderDomainSyncStatus(const QString &domain , d(std::make_unique(domainIdentifier, this)) { qRegisterMetaType("FileProviderDomainSyncStatus*"); + updateIcon(); } FileProviderDomainSyncStatus::~FileProviderDomainSyncStatus() = default; @@ -149,6 +153,11 @@ int FileProviderDomainSyncStatus::uploadFileCompletedCount() const return _uploadFileCompletedCount; } +QUrl FileProviderDomainSyncStatus::icon() const +{ + return _icon; +} + void FileProviderDomainSyncStatus::setDownloading(const bool downloading) { if (_downloading == downloading) { @@ -233,4 +242,20 @@ void FileProviderDomainSyncStatus::setUploadFileCompletedCount(const int fileCom emit uploadFileCompletedCountChanged(_uploadFileCompletedCount); } +void FileProviderDomainSyncStatus::setIcon(const QUrl &icon) +{ + if (_icon == icon) { + return; + } + + _icon = icon; + emit iconChanged(_icon); +} + +void FileProviderDomainSyncStatus::updateIcon() +{ + const auto iconUrl = syncing() ? Theme::instance()->syncStatusRunning() : Theme::instance()->syncStatusOk(); + setIcon(iconUrl); +} + } // OCC::Mac