Add a 'Sync now' button to the sync status header in the tray window
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Thu, 20 Oct 2022 11:41:55 +0000 (13:41 +0200)
committerClaudio Cambra <claudio.cambra@gmail.com>
Tue, 25 Oct 2022 17:14:40 +0000 (19:14 +0200)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/gui/tray/SyncStatus.qml
src/gui/tray/usermodel.cpp
src/gui/tray/usermodel.h

index d0361000a4f447bb1e4393e921cbf1b7736b8d11..ea9480528f9d7fdc875221cd9b4461140e71ab02 100644 (file)
@@ -7,7 +7,7 @@ import Style 1.0
 import com.nextcloud.desktopclient 1.0 as NC
 
 RowLayout {
-    id: layout
+    id: root
 
     property alias model: syncStatus
 
@@ -49,7 +49,7 @@ RowLayout {
 
         Text {
             id: syncProgressText
-            
+
             Layout.fillWidth: true
 
             text: syncStatus.syncStatusString
@@ -64,7 +64,7 @@ RowLayout {
 
             active: syncStatus.syncing
             visible: syncStatus.syncing
-            
+
             sourceComponent: ProgressBar {
                 id: syncProgressBar
 
@@ -98,4 +98,30 @@ RowLayout {
             font.pixelSize: Style.subLinePixelSize
         }
     }
+
+    CustomButton {
+        FontMetrics {
+            id: syncNowFm
+            font.bold: true
+        }
+
+        Layout.preferredWidth: syncNowFm.boundingRect(text).width + leftPadding + rightPadding
+        Layout.rightMargin: Style.trayHorizontalMargin
+
+        FontMetrics { font.bold: true }
+
+        text: qsTr("Sync now")
+        textColor: Style.adjustedCurrentUserHeaderColor
+        textColorHovered: Style.currentUserHeaderTextColor
+        bold: true
+        bgColor: Style.currentUserHeaderColor
+
+        visible: !syncStatus.syncing && NC.UserModel.currentUser.hasLocalFolder
+        enabled: visible
+        onClicked: {
+            if(!syncStatus.syncing) {
+                NC.UserModel.currentUser.forceSyncNow();
+            }
+        }
+    }
 }
index 79c75d4eb5c97f65b2990d17fa20f5248ae5da4c..995e2907bc3581b1c78c70c0588bfaa04292942f 100644 (file)
@@ -856,6 +856,11 @@ void User::slotSendReplyMessage(const int activityIndex, const QString &token, c
     });
 }
 
+void User::forceSyncNow() const
+{
+    FolderMan::instance()->forceSyncForFolder(getFolder());
+}
+
 /*-------------------------------------------------------------------------------------*/
 
 UserModel *UserModel::_instance = nullptr;
index 5735eb995db738a8a9b7fabd979f78f6781f843f..62ad1eb2f0607a7460c58cb99a55767c19778e61 100644 (file)
@@ -108,6 +108,7 @@ public slots:
     void setNotificationRefreshInterval(std::chrono::milliseconds interval);
     void slotRebuildNavigationAppList();
     void slotSendReplyMessage(const int activityIndex, const QString &conversationToken, const QString &message, const QString &replyTo);
+    void forceSyncNow() const;
 
 private:
     void slotPushNotificationsReady();