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);
int downloadFileCompletedCount() const;
int uploadFileTotalCount() const;
int uploadFileCompletedCount() const;
+ QUrl icon() const;
signals:
void syncingChanged(bool syncing);
void downloadFileCompletedCountChanged(int downloadFileCompletedCount);
void uploadFileTotalCountChanged(int uploadFileTotalCount);
void uploadFileCompletedCountChanged(int uploadFileCompletedCount);
+ void iconChanged(const QUrl &icon);
private:
void setDownloading(const bool syncing);
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;
int _downloadFileCompletedCount = 0;
int _uploadFileTotalCount = 0;
int _uploadFileCompletedCount = 0;
+ QUrl _icon;
class MacImplementation;
std::unique_ptr<MacImplementation> d;
#include <QLoggingCategory>
#include "gui/macOS/fileproviderutils.h"
+#include "libsync/theme.h"
#import <FileProvider/FileProvider.h>
q->setDownloadFractionCompleted(progress.fractionCompleted);
q->setDownloadFileTotalCount(progress.fileTotalCount.intValue);
q->setDownloadFileCompletedCount(progress.fileCompletedCount.intValue);
+ q->updateIcon();
}
void updateUpload(NSProgress *const progress) const
q->setUploadFractionCompleted(progress.fractionCompleted);
q->setUploadFileTotalCount(progress.fileTotalCount.intValue);
q->setUploadFileCompletedCount(progress.fileCompletedCount.intValue);
+ q->updateIcon();
}
private:
, d(std::make_unique<MacImplementation>(domainIdentifier, this))
{
qRegisterMetaType<FileProviderDomainSyncStatus*>("FileProviderDomainSyncStatus*");
+ updateIcon();
}
FileProviderDomainSyncStatus::~FileProviderDomainSyncStatus() = default;
return _uploadFileCompletedCount;
}
+QUrl FileProviderDomainSyncStatus::icon() const
+{
+ return _icon;
+}
+
void FileProviderDomainSyncStatus::setDownloading(const bool downloading)
{
if (_downloading == downloading) {
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