mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-22 04:55:48 +03:00
Provide correct sync state icon in file provider domain sync status
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
parent
7d8778d12a
commit
a469d44123
2 changed files with 31 additions and 0 deletions
|
@ -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<MacImplementation> d;
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <QLoggingCategory>
|
||||
|
||||
#include "gui/macOS/fileproviderutils.h"
|
||||
#include "libsync/theme.h"
|
||||
|
||||
#import <FileProvider/FileProvider.h>
|
||||
|
||||
|
@ -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<MacImplementation>(domainIdentifier, this))
|
||||
{
|
||||
qRegisterMetaType<FileProviderDomainSyncStatus*>("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
|
||||
|
|
Loading…
Reference in a new issue