Add right click menu to accountlist avatar

Adds a right click menu with the following options

![image](/uploads/09a266fb609bb8f94b206eb66f09e06d/image.png)

depends upon frameworks/kirigami!933
This commit is contained in:
James Graham
2023-03-14 23:00:41 +00:00
committed by Carl Schwan
parent bc84ad8d56
commit 64dee7eb12
5 changed files with 66 additions and 1 deletions

View File

@@ -177,6 +177,7 @@ if(ANDROID)
"visibility"
"home"
"preferences-desktop-notification"
"computer-symbolic"
)
else()
target_link_libraries(neochat PUBLIC Qt::Widgets KF${QT_MAJOR_VERSION}::KIOWidgets)

View File

@@ -144,12 +144,17 @@ QQC2.ToolBar {
actions.main: Kirigami.Action {
text: i18n("Edit this account")
icon.name: "document-edit"
onTriggered: pageStack.pushDialogLayer(Qt.resolvedUrl('./AccountEditorPage.qml'), {
onTriggered: pageStack.pushDialogLayer(Qt.resolvedUrl('qrc:/AccountEditorPage.qml'), {
connection: Controller.activeConnection
}, {
title: i18n("Account editor")
});
}
TapHandler {
acceptedButtons: Qt.RightButton
acceptedDevices: PointerDevice.Mouse
onTapped: accountMenu.open()
}
}
}
ColumnLayout {
@@ -214,6 +219,11 @@ QQC2.ToolBar {
Item {
width: 1
}
AccountMenu {
id: accountMenu
y: -height
}
}
}
}

View File

@@ -0,0 +1,44 @@
// SPDX-FileCopyrightText: 2022 James Graham <james.h.graham@protonmail.com>
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
import QtQuick 2.15
import QtQuick.Controls 2.15 as QQC2
import QtQuick.Layouts 1.15
import org.kde.kirigami 2.19 as Kirigami
import org.kde.neochat 1.0
QQC2.Menu {
id: root
margins: Kirigami.Units.smallSpacing
QQC2.MenuItem {
text: i18n("Edit this account")
icon.name: "document-edit"
onTriggered: pageStack.pushDialogLayer("qrc:/AccountEditorPage.qml", {
connection: Controller.activeConnection
}, {
title: i18n("Account editor")
});
}
QQC2.MenuItem {
text: i18n("Notification settings")
icon.name: "notifications"
onTriggered: pageStack.pushDialogLayer("qrc:/SettingsPage.qml", {defaultPage: "notifications"}, { title: i18n("Configure")})
}
QQC2.MenuItem {
text: i18n("Devices")
icon.name: "computer-symbolic"
onTriggered: pageStack.pushDialogLayer("qrc:/SettingsPage.qml", {defaultPage: "devices"}, { title: i18n("Configure")})
}
QQC2.MenuItem {
text: i18n("Logout")
icon.name: "list-remove-user"
onTriggered: confirmLogoutDialog.open()
}
ConfirmLogoutDialog {
id: confirmLogoutDialog
}
}

View File

@@ -9,47 +9,56 @@ Kirigami.CategorizedSettings {
objectName: "settingsPage"
actions: [
Kirigami.SettingAction {
actionName: "general"
text: i18n("General")
icon.name: "org.kde.neochat"
page: Qt.resolvedUrl("GeneralSettingsPage.qml")
},
Kirigami.SettingAction {
actionName: "appearance"
text: i18n("Appearance")
icon.name: "preferences-desktop-theme-global"
page: Qt.resolvedUrl("AppearanceSettingsPage.qml")
},
Kirigami.SettingAction {
actionName: "notifications"
text: i18n("Notifications")
icon.name: "preferences-desktop-notification"
page: Qt.resolvedUrl("GlobalNotificationsPage.qml")
},
Kirigami.SettingAction {
actionName: "accounts"
text: i18n("Accounts")
icon.name: "preferences-system-users"
page: Qt.resolvedUrl("AccountsPage.qml")
},
Kirigami.SettingAction {
actionName: "customEmojis"
text: i18n("Custom Emojis")
icon.name: "preferences-desktop-emoticons"
page: Qt.resolvedUrl("Emoticons.qml")
},
Kirigami.SettingAction {
actionName: "spellChecking"
text: i18n("Spell Checking")
icon.name: "tools-check-spelling"
page: Qt.resolvedUrl("SonnetConfigPage.qml")
visible: Qt.platform.os !== "android"
},
Kirigami.SettingAction {
actionName: "netowrkProxy"
text: i18n("Network Proxy")
icon.name: "network-connect"
page: Qt.resolvedUrl("NetworkProxyPage.qml")
},
Kirigami.SettingAction {
actionName: "devices"
text: i18n("Devices")
icon.name: "computer"
page: Qt.resolvedUrl("DevicesPage.qml")
},
Kirigami.SettingAction {
actionName: "about"
text: i18n("About NeoChat")
icon.name: "help-about"
page: Qt.resolvedUrl("About.qml")

View File

@@ -73,6 +73,7 @@
<file alias="VerificationCanceled.qml">qml/Dialog/KeyVerification/VerificationCanceled.qml</file>
<file alias="GlobalMenu.qml">qml/Menu/GlobalMenu.qml</file>
<file alias="EditMenu.qml">qml/Menu/EditMenu.qml</file>
<file alias="AccountMenu.qml">qml/Menu/AccountMenu.qml</file>
<file alias="MessageDelegateContextMenu.qml">qml/Menu/Timeline/MessageDelegateContextMenu.qml</file>
<file alias="FileDelegateContextMenu.qml">qml/Menu/Timeline/FileDelegateContextMenu.qml</file>
<file alias="MessageSourceSheet.qml">qml/Menu/Timeline/MessageSourceSheet.qml</file>