1 /* 2 * Copyright (C) by Felix Weilbach <felix.weilbach@nextcloud.com> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, but 10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * for more details. 13 */ 14 15 #pragma once 16 17 #include "account.h" 18 #include "accountfwd.h" 19 #include "accountstate.h" 20 #include "folderman.h" 21 22 #include <theme.h> 23 #include <folder.h> 24 25 #include <QObject> 26 27 namespace OCC { 28 29 class SyncStatusSummary : public QObject 30 { 31 Q_OBJECT 32 33 Q_PROPERTY(double syncProgress READ syncProgress NOTIFY syncProgressChanged) 34 Q_PROPERTY(QUrl syncIcon READ syncIcon NOTIFY syncIconChanged) 35 Q_PROPERTY(bool syncing READ syncing NOTIFY syncingChanged) 36 Q_PROPERTY(QString syncStatusString READ syncStatusString NOTIFY syncStatusStringChanged) 37 Q_PROPERTY(QString syncStatusDetailString READ syncStatusDetailString NOTIFY syncStatusDetailStringChanged) 38 39 public: 40 explicit SyncStatusSummary(QObject *parent = nullptr); 41 42 double syncProgress() const; 43 QUrl syncIcon() const; 44 bool syncing() const; 45 QString syncStatusString() const; 46 QString syncStatusDetailString() const; 47 48 signals: 49 void syncProgressChanged(); 50 void syncIconChanged(); 51 void syncingChanged(); 52 void syncStatusStringChanged(); 53 void syncStatusDetailStringChanged(); 54 55 public slots: 56 void load(); 57 58 private: 59 void connectToFoldersProgress(const Folder::Map &map); 60 61 void onFolderListChanged(const OCC::Folder::Map &folderMap); 62 void onFolderProgressInfo(const ProgressInfo &progress); 63 void onFolderSyncStateChanged(const Folder *folder); 64 void onIsConnectedChanged(); 65 66 void setSyncStateForFolder(const Folder *folder); 67 void markFolderAsError(const Folder *folder); 68 void markFolderAsSuccess(const Folder *folder); 69 bool folderErrors() const; 70 bool folderError(const Folder *folder) const; 71 void clearFolderErrors(); 72 void setSyncStateToConnectedState(); 73 bool reloadNeeded(AccountState *accountState) const; 74 void initSyncState(); 75 76 void setSyncProgress(double value); 77 void setSyncing(bool value); 78 void setSyncStatusString(const QString &value); 79 void setSyncStatusDetailString(const QString &value); 80 void setSyncIcon(const QUrl &value); 81 void setAccountState(AccountStatePtr accountState); 82 83 AccountStatePtr _accountState; 84 std::set<QString> _foldersWithErrors; 85 86 QUrl _syncIcon = Theme::instance()->syncStatusOk(); 87 double _progress = 1.0; 88 bool _isSyncing = false; 89 QString _syncStatusString = tr("All synced!"); 90 QString _syncStatusDetailString; 91 }; 92 } 93