Streamlining local sync notification/activity icons with server ones. Added fileActio...
authorDominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
Thu, 16 Jan 2020 16:09:34 +0000 (17:09 +0100)
committerDominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
Thu, 16 Jan 2020 16:09:34 +0000 (17:09 +0100)
Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
client.qrc
resources/add-color.svg [new file with mode: 0644]
resources/change.svg [new file with mode: 0644]
resources/delete-color.svg [new file with mode: 0644]
src/gui/tray/ActivityListModel.cpp
src/gui/tray/UserModel.cpp

index de385dfb20ac798d0c81b9e401881748bb9a8478..bb284644a91f212b25f3033fea8abf235c3a3eb5 100644 (file)
         <file>resources/copy.svg</file>
         <file>resources/state-sync.svg</file>
         <file>resources/add.png</file>
+        <file>resources/add-color.svg</file>
         <file>resources/state-info.svg</file>
+        <file>resources/change.svg</file>
+        <file>resources/delete-color.svg</file>
     </qresource>
     <qresource prefix="/"/>
     <qresource prefix="/qml">
diff --git a/resources/add-color.svg b/resources/add-color.svg
new file mode 100644 (file)
index 0000000..cb4596a
--- /dev/null
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" version="1.1" viewbox="0 0 16 16"><path fill="#00d400" d="M9.02 13.98h-2v-5h-5v-2h5v-5h2v5l5-.028V8.98h-5z"/></svg>
diff --git a/resources/change.svg b/resources/change.svg
new file mode 100644 (file)
index 0000000..1207142
--- /dev/null
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" version="1.1" height="16"><path d="m8 2c-2.142 0-4.125 1.145-5.196 3l1.948 1.125c0.671-1.162 1.906-1.875 3.2476-1.875 1.1906 0 2.297 0.56157 3 1.5l-1.5 1.5h4.5v-4.5l-1.406 1.406c-1.129-1.348-2.802-2.1563-4.594-2.1563z"/><path d="m2 8.75v4.5l1.408-1.41c1.116 1.334 2.817 2.145 4.592 2.16 2.16 0.01827 4.116-1.132 5.196-3.002l-1.948-1.125c-0.677 1.171-1.9005 1.886-3.248 1.875-1.18-0.01-2.3047-0.572-3-1.5l1.5-1.5z"/></svg>
diff --git a/resources/delete-color.svg b/resources/delete-color.svg
new file mode 100644 (file)
index 0000000..72aed6b
--- /dev/null
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" version="1.1" viewBox="0 0 16 16"><path d="m3.0503 4.4645 3.5355 3.5355-3.5355 3.536 1.4142 1.414 3.5355-3.5358 3.536 3.5358 1.414-1.414-3.5358-3.536 3.5358-3.5355-1.414-1.4142-3.536 3.5355-3.5355-3.5355-1.4142 1.4142z" fill="#d40000"/></svg>
index 88f967f6df8ed5a2486ca29c2a6e959d466e6ad0..dd724acb0ed6cc769fcddad6bf41eeea76cc8d6b 100644 (file)
@@ -133,7 +133,14 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const
             } else if (a._status == SyncFileItem::FileIgnored) {
                 return "qrc:///client/theme/black/state-info.svg";
             } else {
-                return "qrc:///client/theme/black/state-sync.svg";
+                // File sync successful
+                if (a._fileAction == "file_created") {
+                    return "qrc:///client/resources/add-color.svg";
+                } else if (a._fileAction == "file_deleted") {
+                    return "qrc:///client/resources/delete-color.svg";
+                } else {
+                    return "qrc:///client/resources/change.svg";
+                }
             }
         } else {
             // We have an activity
@@ -209,7 +216,6 @@ void ActivityListModel::startFetchJob()
     if (!_accountState->isConnected()) {
         return;
     }
-    //JsonApiJob *job = new JsonApiJob(_accountState->account(), QLatin1String("ocs/v2.php/cloud/activity"), this);
     JsonApiJob *job = new JsonApiJob(_accountState->account(), QLatin1String("ocs/v2.php/apps/activity/api/v2/activity"), this);
     QObject::connect(job, &JsonApiJob::jsonReceived,
         this, &ActivityListModel::slotActivitiesReceived);
index ae9b42653f58782b3a17f94478ca59b6d7e92e58..c0163876ce615200581f8ab0823c0a0c9fd71cca 100644 (file)
@@ -341,11 +341,32 @@ void User::slotItemCompleted(const QString &folder, const SyncFileItemPtr &item)
         activity._accName = folderInstance->accountState()->account()->displayName();
         activity._file = item->_file;
         activity._folder = folder;
+        activity._fileAction = "";
+
+        if (item->_instruction == CSYNC_INSTRUCTION_REMOVE) {
+            activity._fileAction = "file_deleted";
+        } else if (item->_instruction == CSYNC_INSTRUCTION_NEW) {
+            activity._fileAction = "file_created";
+        } else if (item->_instruction == CSYNC_INSTRUCTION_RENAME) {
+            activity._fileAction = "file_renamed";
+        } else {
+            activity._fileAction = "file_changed";
+        }
+
 
         if (item->_status == SyncFileItem::NoStatus || item->_status == SyncFileItem::Success) {
             qCWarning(lcActivity) << "Item " << item->_file << " retrieved successfully.";
-            activity._message.prepend(" ");
-            activity._message.prepend(tr("Synced"));
+            
+            if (activity._fileAction == "file_renamed") {
+                activity._message.prepend(tr("You renamed") + " ");
+            } else if (activity._fileAction == "file_deleted") {
+                activity._message.prepend(tr("You deleted") + " ");
+            } else if (activity._fileAction == "file_created") {
+                activity._message.prepend(tr("You created") + " ");
+            } else {
+                activity._message.prepend(tr("You changed") + " ");
+            }
+
             _activityModel->addSyncFileItemToActivityList(activity);
         } else {
             qCWarning(lcActivity) << "Item " << item->_file << " retrieved resulted in error " << item->_errorString;