From 194a5194a895749df40cde70a8bbde97513cf4de Mon Sep 17 00:00:00 2001 From: miruka Date: Fri, 1 May 2020 05:21:50 -0400 Subject: [PATCH] Better account context menu, add it in AccountsBar --- src/gui/MainPane/Account.qml | 18 +----------- src/gui/MainPane/AccountContextMenu.qml | 39 +++++++++++++++++++++++++ src/gui/MainPane/AccountsBar.qml | 2 ++ src/icons/thin/account-settings.svg | 3 ++ src/icons/thin/menu-add-chat.svg | 5 ++++ 5 files changed, 50 insertions(+), 17 deletions(-) create mode 100644 src/gui/MainPane/AccountContextMenu.qml create mode 100644 src/icons/thin/account-settings.svg create mode 100644 src/icons/thin/menu-add-chat.svg diff --git a/src/gui/MainPane/Account.qml b/src/gui/MainPane/Account.qml index 8d0924b8..51298d14 100644 --- a/src/gui/MainPane/Account.qml +++ b/src/gui/MainPane/Account.qml @@ -2,7 +2,6 @@ import QtQuick 2.12 import QtQuick.Layouts 1.12 -import Clipboard 0.1 import "../Base" import "../Base/HTile" @@ -58,22 +57,7 @@ HTile { } } - contextMenu: HMenu { - HMenuItem { - icon.name: "copy-user-id" - text: qsTr("Copy user ID") - onTriggered: Clipboard.text = accountModel.id - } - - HMenuItemPopupSpawner { - icon.name: "sign-out" - icon.color: theme.colors.negativeBackground - text: qsTr("Sign out") - - popup: "Popups/SignOutPopup.qml" - properties: { "userId": accountModel.id } - } - } + contextMenu: AccountContextMenu { userId: accountModel.id } onLeftClicked: { pageLoader.showPage( diff --git a/src/gui/MainPane/AccountContextMenu.qml b/src/gui/MainPane/AccountContextMenu.qml new file mode 100644 index 00000000..5102f685 --- /dev/null +++ b/src/gui/MainPane/AccountContextMenu.qml @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later + +import QtQuick 2.12 +import Clipboard 0.1 +import "../Base" + +HMenu { + property string userId + + + HMenuItem { + icon.name: "account-settings" + text: qsTr("Account settings") + onClicked: pageLoader.showPage( + "AccountSettings/AccountSettings", { "userId": userId }, + ) + } + + HMenuItem { + icon.name: "menu-add-chat" + text: qsTr("Add new chat") + onClicked: pageLoader.showPage("AddChat/AddChat", {userId: userId}) + } + + HMenuItem { + icon.name: "copy-user-id" + text: qsTr("Copy user ID") + onTriggered: Clipboard.text = userId + } + + HMenuItemPopupSpawner { + icon.name: "sign-out" + icon.color: theme.colors.negativeBackground + text: qsTr("Sign out") + + popup: "Popups/SignOutPopup.qml" + properties: { "userId": userId } + } +} diff --git a/src/gui/MainPane/AccountsBar.qml b/src/gui/MainPane/AccountsBar.qml index f55ed13b..f18f7a36 100644 --- a/src/gui/MainPane/AccountsBar.qml +++ b/src/gui/MainPane/AccountsBar.qml @@ -90,6 +90,8 @@ HColumnLayout { } } + contextMenu: AccountContextMenu { userId: model.id } + onLeftClicked: roomList.goToAccount(model.id) } diff --git a/src/icons/thin/account-settings.svg b/src/icons/thin/account-settings.svg new file mode 100644 index 00000000..bd8786c6 --- /dev/null +++ b/src/icons/thin/account-settings.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/icons/thin/menu-add-chat.svg b/src/icons/thin/menu-add-chat.svg new file mode 100644 index 00000000..bf15a604 --- /dev/null +++ b/src/icons/thin/menu-add-chat.svg @@ -0,0 +1,5 @@ + + + + +