From c0baf5c93cdc31349fcb8c4dd339784936faa92b Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 20 Oct 2022 13:41:55 +0200 Subject: [PATCH] Add a 'Sync now' button to the sync status header in the tray window Signed-off-by: Claudio Cambra --- src/gui/tray/SyncStatus.qml | 32 +++++++++++++++++++++++++++++--- src/gui/tray/usermodel.cpp | 5 +++++ src/gui/tray/usermodel.h | 1 + 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/gui/tray/SyncStatus.qml b/src/gui/tray/SyncStatus.qml index d0361000a..ea9480528 100644 --- a/src/gui/tray/SyncStatus.qml +++ b/src/gui/tray/SyncStatus.qml @@ -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(); + } + } + } } diff --git a/src/gui/tray/usermodel.cpp b/src/gui/tray/usermodel.cpp index 79c75d4eb..995e2907b 100644 --- a/src/gui/tray/usermodel.cpp +++ b/src/gui/tray/usermodel.cpp @@ -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; diff --git a/src/gui/tray/usermodel.h b/src/gui/tray/usermodel.h index 5735eb995..62ad1eb2f 100644 --- a/src/gui/tray/usermodel.h +++ b/src/gui/tray/usermodel.h @@ -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();