-
Notifications
You must be signed in to change notification settings - Fork 914
Feature/public links #4175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/public links #4175
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,8 +15,8 @@ import com.nextcloud.desktopclient | |
| AbstractButton { | ||
| id: userLine | ||
|
|
||
| signal showUserStatusSelector(int id) | ||
| signal showUserStatusMessageSelector(int id) | ||
| signal showUserStatusSelector(int id) | ||
| signal showUserStatusMessageSelector(int id) | ||
|
|
||
|
|
||
| Accessible.role: Accessible.MenuItem | ||
|
|
@@ -133,26 +133,31 @@ AbstractButton { | |
| id: userMoreButtonMenu | ||
| closePolicy: Menu.CloseOnPressOutsideParent | Menu.CloseOnEscape | ||
|
|
||
| MenuItem { | ||
| visible: model.isConnected && model.serverHasUserStatus | ||
| height: visible ? implicitHeight : 0 | ||
| text: qsTr("Set status") | ||
| font.pixelSize: Style.topLinePixelSize | ||
| hoverEnabled: true | ||
| onClicked: showUserStatusSelector(index) | ||
| } | ||
|
|
||
| MenuItem { | ||
| visible: model.isConnected && model.serverHasUserStatus | ||
| height: visible ? implicitHeight : 0 | ||
| text: qsTr("Status message") | ||
| font.pixelSize: Style.topLinePixelSize | ||
| hoverEnabled: true | ||
| onClicked: showUserStatusMessageSelector(index) | ||
| } | ||
|
|
||
| MenuItem { | ||
| text: model.isConnected ? qsTr("Log out") : qsTr("Log in") | ||
| <<<<<<< HEAD | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks |
||
| MenuItem { | ||
| visible: model.isConnected && model.serverHasUserStatus | ||
| height: visible ? implicitHeight : 0 | ||
| text: qsTr("Set status") | ||
| font.pixelSize: Style.topLinePixelSize | ||
| hoverEnabled: true | ||
| onClicked: showUserStatusSelector(index) | ||
| } | ||
|
|
||
| MenuItem { | ||
| visible: model.isConnected && model.serverHasUserStatus | ||
| height: visible ? implicitHeight : 0 | ||
| text: qsTr("Status message") | ||
| font.pixelSize: Style.topLinePixelSize | ||
| hoverEnabled: true | ||
| onClicked: showUserStatusMessageSelector(index) | ||
| } | ||
|
|
||
| MenuItem { | ||
| text: model.isConnected ? qsTr("Log out") : qsTr("Log in") | ||
| visible: model.canLogout | ||
| height: visible ? implicitHeight : 0 | ||
mgallien marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| width: parent.width | ||
| text: model.isConnected ? qsTr("Log out") : qsTr("Log in") | ||
| font.pixelSize: Style.topLinePixelSize | ||
| hoverEnabled: true | ||
| onClicked: { | ||
|
|
@@ -175,7 +180,7 @@ AbstractButton { | |
|
|
||
| MenuItem { | ||
| id: removeAccountButton | ||
| text: qsTr("Remove account") | ||
| text: model.removeAccountText | ||
| font.pixelSize: Style.topLinePixelSize | ||
| hoverEnabled: true | ||
| onClicked: { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: GPL-2.0-or-later | ||
|
|
@@ -900,7 +900,17 @@ | |
| return _trayFolderInfos; | ||
| } | ||
|
|
||
| bool User::canLogout() const | ||
| { | ||
| return !isPublicShareLink(); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without really knowing the context, reads very weird, that |
||
| } | ||
|
|
||
| bool User::isPublicShareLink() const | ||
| { | ||
| return _account->account()->isPublicShareLink(); | ||
| } | ||
|
|
||
| void User::slotItemCompleted(const QString &folder, const SyncFileItemPtr &item) | ||
|
Check warning on line 913 in src/gui/tray/usermodel.cpp
|
||
| { | ||
| auto folderInstance = FolderMan::instance()->folder(folder); | ||
|
|
||
|
|
@@ -1004,17 +1014,27 @@ | |
|
|
||
| QString User::name() const | ||
| { | ||
| if (isPublicShareLink()) { | ||
| return tr("Public Share Link"); | ||
| } | ||
|
|
||
| return _account->account()->prettyName(); | ||
| } | ||
|
|
||
| QString User::server(bool shortened) const | ||
| { | ||
| QString serverUrl = _account->account()->url().toString(); | ||
| auto serverUrl = _account->account()->url(); | ||
|
|
||
| if (isPublicShareLink()) { | ||
| serverUrl.setUserName({}); | ||
| } | ||
| QString stringServerUrl = serverUrl.toString(); | ||
| if (shortened) { | ||
| serverUrl.replace(QLatin1String("https://"), QLatin1String("")); | ||
| serverUrl.replace(QLatin1String("http://"), QLatin1String("")); | ||
| stringServerUrl.replace(QLatin1String("https://"), QLatin1String("")); | ||
| stringServerUrl.replace(QLatin1String("http://"), QLatin1String("")); | ||
|
|
||
| } | ||
| return serverUrl; | ||
| return stringServerUrl; | ||
| } | ||
|
|
||
| UserStatus::OnlineStatus User::status() const | ||
|
|
@@ -1579,36 +1599,54 @@ | |
|
|
||
| QVariant UserModel::data(const QModelIndex &index, int role) const | ||
| { | ||
| if (index.row() < 0 || index.row() >= _users.count()) { | ||
| return QVariant(); | ||
| } | ||
|
|
||
| if (role == NameRole) { | ||
| return _users[index.row()]->name(); | ||
| } else if (role == ServerRole) { | ||
| return _users[index.row()]->server(); | ||
| } else if (role == ServerHasUserStatusRole) { | ||
| return _users[index.row()]->serverHasUserStatus(); | ||
| } else if (role == StatusRole) { | ||
| return QVariant::fromValue(_users[index.row()]->status()); | ||
| } else if (role == StatusIconRole) { | ||
| return _users[index.row()]->statusIcon(); | ||
| } else if (role == StatusEmojiRole) { | ||
| return _users[index.row()]->statusEmoji(); | ||
| } else if (role == StatusMessageRole) { | ||
| return _users[index.row()]->statusMessage(); | ||
| } else if (role == DesktopNotificationsAllowedRole) { | ||
| return _users[index.row()]->isDesktopNotificationsAllowed(); | ||
| } else if (role == AvatarRole) { | ||
| return _users[index.row()]->avatarUrl(); | ||
| } else if (role == IsCurrentUserRole) { | ||
| return _users[index.row()]->isCurrentUser(); | ||
| } else if (role == IsConnectedRole) { | ||
| return _users[index.row()]->isConnected(); | ||
| } else if (role == IdRole) { | ||
| return index.row(); | ||
| } | ||
| return QVariant(); | ||
| auto result = QVariant{}; | ||
| switch (static_cast<UserRoles>(role)) | ||
| { | ||
| case NameRole: | ||
| result = _users[index.row()]->name(); | ||
| break; | ||
| case ServerRole: | ||
| result = _users[index.row()]->server(); | ||
| break; | ||
| case ServerHasUserStatusRole: | ||
| result = _users[index.row()]->serverHasUserStatus(); | ||
| break; | ||
| case StatusRole: | ||
| result = QVariant::fromValue(_users[index.row()]->status()); | ||
| break; | ||
| case StatusIconRole: | ||
| result = _users[index.row()]->statusIcon(); | ||
| break; | ||
| case StatusEmojiRole: | ||
| result = _users[index.row()]->statusEmoji(); | ||
| break; | ||
| case StatusMessageRole: | ||
| result = _users[index.row()]->statusMessage(); | ||
| break; | ||
| case DesktopNotificationsAllowedRole: | ||
| result = _users[index.row()]->isDesktopNotificationsAllowed(); | ||
| break; | ||
| case AvatarRole: | ||
| result = _users[index.row()]->avatarUrl(); | ||
| break; | ||
| case IsCurrentUserRole: | ||
| result = _users[index.row()]->isCurrentUser(); | ||
| break; | ||
| case IsConnectedRole: | ||
| result = _users[index.row()]->isConnected(); | ||
| break; | ||
| case IdRole: | ||
| result = index.row(); | ||
| break; | ||
| case CanLogoutRole: | ||
| result = _users[index.row()]->canLogout(); | ||
| break; | ||
| case RemoveAccountTextRole: | ||
| result = _users[index.row()]->isPublicShareLink() ? tr("Leave share") : tr("Remove account"); | ||
| break; | ||
| } | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| QHash<int, QByteArray> UserModel::roleNames() const | ||
|
|
@@ -1626,6 +1664,8 @@ | |
| roles[IsCurrentUserRole] = "isCurrentUser"; | ||
| roles[IsConnectedRole] = "isConnected"; | ||
| roles[IdRole] = "id"; | ||
| roles[CanLogoutRole] = "canLogout"; | ||
| roles[RemoveAccountTextRole] = "removeAccountText"; | ||
| return roles; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.