From b6d42ab482a99ac390e1253f7df01a0f0fd0f6f3 Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Tue, 8 Feb 2022 23:10:54 +0100 Subject: [PATCH] show leave share menu item to delete an account for public shared folder to delete a normal acount show "Remove account" to delete a public share link account show "Leave share" Signed-off-by: Matthieu Gallien --- src/gui/tray/UserLine.qml | 2 +- src/gui/tray/usermodel.cpp | 9 +++++++++ src/gui/tray/usermodel.h | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/gui/tray/UserLine.qml b/src/gui/tray/UserLine.qml index a6e781d439689..ffcf1be8a71b1 100644 --- a/src/gui/tray/UserLine.qml +++ b/src/gui/tray/UserLine.qml @@ -220,7 +220,7 @@ MenuItem { MenuItem { id: removeAccountButton width: parent.width - text: qsTr("Remove account") + text: model.removeAccountText font.pixelSize: Style.topLinePixelSize palette.windowText: Style.ncTextColor hoverEnabled: true diff --git a/src/gui/tray/usermodel.cpp b/src/gui/tray/usermodel.cpp index ed46a7c700c2c..af92586aaae42 100644 --- a/src/gui/tray/usermodel.cpp +++ b/src/gui/tray/usermodel.cpp @@ -625,6 +625,11 @@ bool User::canLogout() const return !_account->account()->isPublicShareLink(); } +bool User::isPublicShareLink() const +{ + return _account->account()->isPublicShareLink(); +} + void User::slotItemCompleted(const QString &folder, const SyncFileItemPtr &item) { auto folderInstance = FolderMan::instance()->folder(folder); @@ -1093,6 +1098,9 @@ QVariant UserModel::data(const QModelIndex &index, int role) const case CanLogoutRole: result = _users[index.row()]->canLogout(); break; + case RemoveAccountTextRole: + result = _users[index.row()]->isPublicShareLink() ? tr("Leave share") : tr("Remove account"); + break; } return result; @@ -1105,6 +1113,7 @@ QHash UserModel::roleNames() const roles[ServerRole] = "server"; roles[ServerHasUserStatusRole] = "serverHasUserStatus"; roles[CanLogoutRole] = "canLogout"; + roles[RemoveAccountTextRole] = "removeAccountText"; roles[StatusIconRole] = "statusIcon"; roles[StatusEmojiRole] = "statusEmoji"; roles[StatusMessageRole] = "statusMessage"; diff --git a/src/gui/tray/usermodel.h b/src/gui/tray/usermodel.h index 779af633ae110..14c4fd0e9da82 100644 --- a/src/gui/tray/usermodel.h +++ b/src/gui/tray/usermodel.h @@ -76,6 +76,7 @@ class User : public QObject QString statusEmoji() const; void processCompletedSyncItem(const Folder *folder, const SyncFileItemPtr &item); bool canLogout() const; + bool isPublicShareLink() const; signals: void guiLog(const QString &, const QString &); @@ -184,6 +185,7 @@ class UserModel : public QAbstractListModel ServerRole, ServerHasUserStatusRole, CanLogoutRole, + RemoveAccountTextRole, StatusIconRole, StatusEmojiRole, StatusMessageRole,