Skip to content

Commit 2bdd4ba

Browse files
committed
only show login/logout menu entry for real account not shared folders
Signed-off-by: Matthieu Gallien <[email protected]>
1 parent 11bcbca commit 2bdd4ba

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

src/gui/tray/UserLine.qml

+2
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ MenuItem {
191191
}
192192

193193
MenuItem {
194+
visible: model.canLogout
195+
height: visible ? implicitHeight : 0
194196
width: parent.width
195197
text: model.isConnected ? qsTr("Log out") : qsTr("Log in")
196198
font.pixelSize: Style.topLinePixelSize

src/gui/tray/usermodel.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,11 @@ void User::processCompletedSyncItem(const Folder *folder, const SyncFileItemPtr
551551
}
552552
}
553553

554+
bool User::canLogout() const
555+
{
556+
return !_account->account()->isPublicShareLink();
557+
}
558+
554559
void User::slotItemCompleted(const QString &folder, const SyncFileItemPtr &item)
555560
{
556561
auto folderInstance = FolderMan::instance()->folder(folder);
@@ -992,6 +997,9 @@ QVariant UserModel::data(const QModelIndex &index, int role) const
992997
case IdRole:
993998
result = index.row();
994999
break;
1000+
case CanLogoutRole:
1001+
result = _users[index.row()]->canLogout();
1002+
break;
9951003
}
9961004

9971005
return result;
@@ -1003,6 +1011,7 @@ QHash<int, QByteArray> UserModel::roleNames() const
10031011
roles[NameRole] = "name";
10041012
roles[ServerRole] = "server";
10051013
roles[ServerHasUserStatusRole] = "serverHasUserStatus";
1014+
roles[CanLogoutRole] = "canLogout";
10061015
roles[StatusIconRole] = "statusIcon";
10071016
roles[StatusEmojiRole] = "statusEmoji";
10081017
roles[StatusMessageRole] = "statusMessage";

src/gui/tray/usermodel.h

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class User : public QObject
3535
Q_PROPERTY(QString avatar READ avatarUrl NOTIFY avatarChanged)
3636
Q_PROPERTY(bool isConnected READ isConnected NOTIFY accountStateChanged)
3737
Q_PROPERTY(UnifiedSearchResultsListModel* unifiedSearchResultsListModel READ getUnifiedSearchResultsListModel CONSTANT)
38+
Q_PROPERTY(bool canLogout READ canLogout CONSTANT)
3839
public:
3940
User(AccountStatePtr &account, const bool &isCurrent = false, QObject *parent = nullptr);
4041

@@ -67,6 +68,7 @@ class User : public QObject
6768
QUrl statusIcon() const;
6869
QString statusEmoji() const;
6970
void processCompletedSyncItem(const Folder *folder, const SyncFileItemPtr &item);
71+
bool canLogout() const;
7072

7173
signals:
7274
void guiLog(const QString &, const QString &);
@@ -174,6 +176,7 @@ class UserModel : public QAbstractListModel
174176
NameRole = Qt::UserRole + 1,
175177
ServerRole,
176178
ServerHasUserStatusRole,
179+
CanLogoutRole,
177180
StatusIconRole,
178181
StatusEmojiRole,
179182
StatusMessageRole,

0 commit comments

Comments
 (0)