Skip to content

Commit

Permalink
show leave share menu item to delete an account for public shared folder
Browse files Browse the repository at this point in the history
to delete a normal acount show "Remove account"
to delete a public share link account show "Leave share"

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
  • Loading branch information
mgallien committed May 4, 2022
1 parent edd73ed commit b6d42ab
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/gui/tray/UserLine.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions src/gui/tray/usermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -1105,6 +1113,7 @@ QHash<int, QByteArray> UserModel::roleNames() const
roles[ServerRole] = "server";
roles[ServerHasUserStatusRole] = "serverHasUserStatus";
roles[CanLogoutRole] = "canLogout";
roles[RemoveAccountTextRole] = "removeAccountText";
roles[StatusIconRole] = "statusIcon";
roles[StatusEmojiRole] = "statusEmoji";
roles[StatusMessageRole] = "statusMessage";
Expand Down
2 changes: 2 additions & 0 deletions src/gui/tray/usermodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 &);
Expand Down Expand Up @@ -184,6 +185,7 @@ class UserModel : public QAbstractListModel
ServerRole,
ServerHasUserStatusRole,
CanLogoutRole,
RemoveAccountTextRole,
StatusIconRole,
StatusEmojiRole,
StatusMessageRole,
Expand Down

0 comments on commit b6d42ab

Please sign in to comment.