refactor(ProfileView): use StatusQ components to render profile menu

This commit is contained in:
Pascal Precht 2021-08-27 12:44:39 +02:00 committed by Pascal Precht
parent 414637a260
commit 5b674cee5a
5 changed files with 48 additions and 155 deletions

View File

@ -1,23 +1,20 @@
import QtQuick 2.13 import QtQuick 2.13
import StatusQ.Components 0.1
import "../../../imports" import "../../../imports"
import "../../../shared"
import "./LeftTab" import "./LeftTab"
Rectangle { Item {
property alias changeProfileSection: profileMenu.changeProfileSection property alias changeProfileSection: profileMenu.changeProfileSection
id: profileInfoContainer id: profileInfoContainer
color: Style.current.secondaryMenuBackground
StyledText { StatusNavigationPanelHeadline {
id: title id: title
//% "Profile" text: qsTr("Profile")
text: qsTrId("profile")
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: Style.current.padding anchors.topMargin: Style.current.padding
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
font.weight: Font.Bold
font.pixelSize: 17
} }
Menu { Menu {

View File

@ -1,17 +1,17 @@
import QtQuick 2.13 import QtQuick 2.13
import QtQuick.Controls 2.13 import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13 import QtQuick.Layouts 1.13
import StatusQ.Components 0.1
import "../../../../imports" import "../../../../imports"
import "../../../../shared"
import "./components"
import "./constants.js" as ProfileConstants import "./constants.js" as ProfileConstants
ScrollView { ScrollView {
readonly property int btnheight: 42
readonly property int w: 340
property var changeProfileSection: function (sectionId) { property var changeProfileSection: function (sectionId) {
Config.currentMenuTab = sectionId Config.currentMenuTab = sectionId
} }
ScrollBar.horizontal.policy: Qt.ScrollBarAlwaysOff
contentHeight: menuItems.height + 24 contentHeight: menuItems.height + 24
id: profileMenu id: profileMenu
@ -19,59 +19,47 @@ ScrollView {
Column { Column {
id: menuItems id: menuItems
spacing: 8 spacing: 4
Repeater { Repeater {
model: ProfileConstants.mainMenuButtons model: ProfileConstants.mainMenuButtons
delegate: MenuButton { delegate: StatusNavigationListItem {
menuItemId: modelData.id itemId: modelData.id
text: modelData .text title: modelData.text
source: "../../../img/profile/" + modelData.filename icon.name: modelData.icon
active: Config.currentMenuTab === modelData.id selected: Config.currentMenuTab === modelData.id
Layout.fillWidth: true onClicked: Config.currentMenuTab = modelData.id
width: profileMenu.width
onClicked: {
Config.currentMenuTab = modelData.id
}
} }
} }
StyledText { StatusListSectionHeadline { text: "Settings" }
topPadding: 10
leftPadding: 20
text: "Settings"
color: Style.current.secondaryText
}
Repeater { Repeater {
model: ProfileConstants.settingsMenuButtons model: ProfileConstants.settingsMenuButtons
delegate: MenuButton { delegate: StatusNavigationListItem {
menuItemId: modelData.id itemId: modelData.id
text: modelData .text title: modelData.text
source: "../../../img/profile/" + modelData.filename icon.name: modelData.icon
active: Config.currentMenuTab === modelData.id selected: Config.currentMenuTab === modelData.id
onClicked: Config.currentMenuTab = modelData.id
visible: modelData.ifEnabled !== "browser" || appSettings.isBrowserEnabled visible: modelData.ifEnabled !== "browser" || appSettings.isBrowserEnabled
Layout.fillWidth: true
width: profileMenu.width
onClicked: function () {
Config.currentMenuTab = modelData.id
}
} }
} }
StyledText { Item {
text: " " id: invisibleSeparator
height: 16
width: parent.width
} }
Repeater { Repeater {
model: ProfileConstants.extraMenuButtons model: ProfileConstants.extraMenuButtons
delegate: MenuButton { delegate: StatusNavigationListItem {
menuItemId: modelData.id itemId: modelData.id
text: modelData.text title: modelData.text
source: "../../../img/profile/" + modelData.filename icon.name: modelData.icon
active: Config.currentMenuTab === modelData.id selected: Config.currentMenuTab === modelData.id
Layout.fillWidth: true visible: modelData.ifEnabled !== "browser" || appSettings.isBrowserEnabled
width: profileMenu.width
onClicked: function () { onClicked: function () {
if (modelData.function === "exit") { if (modelData.function === "exit") {
return Qt.quit() return Qt.quit()

View File

@ -1,91 +0,0 @@
import QtQuick 2.13
import QtGraphicalEffects 1.13
import "../../../../../imports"
import "../../../../../shared"
import "../constants.js" as ProfileConstants
Rectangle {
property int menuItemId: -1
property bool hovered: false
property bool active: false
property url source: "../../../../img/eye.svg"
property string text: "My Profile"
signal clicked()
id: menuButton
color: {
if (active) {
return Style.current.menuBackgroundActive
}
if (hovered) {
return Style.current.menuBackgroundHover
}
return Style.current.transparent
}
border.width: 0
height: 48
width: parent.width
radius: Style.current.radius
SVGImage {
id: iconImage
height: 24
width: 24
anchors.left: parent.left
anchors.leftMargin: Style.current.padding
anchors.verticalCenter: parent.verticalCenter
source: menuButton.source
ColorOverlay {
anchors.fill: parent
source: parent
color: Style.current.blue
}
}
StyledText {
text: menuButton.text
anchors.left: iconImage.right
anchors.leftMargin: Style.current.padding
anchors.verticalCenter: parent.verticalCenter
}
Rectangle {
visible: !profileModel.mnemonic.isBackedUp && !active && ProfileConstants.PRIVACY_AND_SECURITY === menuItemId
anchors.verticalCenter: parent.verticalCenter
anchors.right: menuButton.right
anchors.rightMargin: 10
radius: 9
color: Style.current.blue
width: 18
height: 18
Text {
font.pixelSize: 12
color: Style.current.white
anchors.centerIn: parent
text: "1"
}
}
MouseArea {
cursorShape: Qt.PointingHandCursor
anchors.fill: parent
hoverEnabled: true
onEntered: {
menuButton.hovered = true
}
onExited: {
menuButton.hovered = false
}
onClicked: function () {
menuButton.clicked()
}
}
}
/*##^##
Designer {
D{i:0;formeditorColor:"#ffffff";height:48;width:300}
}
##^##*/

View File

@ -17,67 +17,67 @@ var SIGNOUT = 14
var mainMenuButtons = [{ var mainMenuButtons = [{
"id": PROFILE, "id": PROFILE,
"text": qsTr("My Profile"), "text": qsTr("My Profile"),
"filename": "myProfile.svg" "icon": "profile"
}, { }, {
"id": CONTACTS, "id": CONTACTS,
"text": qsTr("Contacts"), "text": qsTr("Contacts"),
"filename": "contacts.svg" "icon": "contact"
}, { }, {
"id": ENS, "id": ENS,
"text": qsTr("ENS usernames"), "text": qsTr("ENS usernames"),
"filename": "ensUsernames.svg" "icon": "username"
}] }]
var settingsMenuButtons = [{ var settingsMenuButtons = [{
"id": PRIVACY_AND_SECURITY, "id": PRIVACY_AND_SECURITY,
"text": qsTr("Privacy and security"), "text": qsTr("Privacy and security"),
"filename": "security.svg" "icon": "security"
}, { }, {
"id": APPEARANCE, "id": APPEARANCE,
"text": qsTr("Appearance"), "text": qsTr("Appearance"),
"filename": "appearance.svg" "icon": "appearance"
}, { }, {
"id": SOUND, "id": SOUND,
"text": qsTr("Sound"), "text": qsTr("Sound"),
"filename": "sound.svg" "icon": "sound"
}, { }, {
"id": LANGUAGE, "id": LANGUAGE,
"text": qsTr("Language"), "text": qsTr("Language"),
"filename": "globe.svg" "icon": "language"
}, { }, {
"id": NOTIFICATIONS, "id": NOTIFICATIONS,
"text": qsTr("Notifications"), "text": qsTr("Notifications"),
"filename": "notifications.svg" "icon": "notification"
}, { }, {
"id": SYNC_SETTINGS, "id": SYNC_SETTINGS,
"text": qsTr("Sync settings"), "text": qsTr("Sync settings"),
"filename": "sync.svg" "icon": "mobile"
}, { }, {
"id": DEVICES_SETTINGS, "id": DEVICES_SETTINGS,
"text": qsTr("Devices settings"), "text": qsTr("Devices settings"),
"filename": "sync.svg" "icon": "mobile"
}, { }, {
"id": BROWSER_SETTINGS, "id": BROWSER_SETTINGS,
"text": qsTr("Browser settings"), "text": qsTr("Browser settings"),
"filename": "../compassActive.svg", "icon": "browser",
"ifEnabled": "browser" "ifEnabled": "browser"
}, { }, {
"id": ADVANCED, "id": ADVANCED,
"text": qsTr("Advanced"), "text": qsTr("Advanced"),
"filename": "advanced.svg" "icon": "settings"
}] }]
var extraMenuButtons = [{ var extraMenuButtons = [{
"id": NEED_HELP, "id": NEED_HELP,
"text": qsTr("Need help?"), "text": qsTr("Need help?"),
"filename": "help.svg" "icon": "help"
}, { }, {
"id": ABOUT, "id": ABOUT,
"text": qsTr("About"), "text": qsTr("About"),
"filename": "about.svg" "icon": "info"
}, { }, {
"id": SIGNOUT, "id": SIGNOUT,
"function": "exit", "function": "exit",
"text": qsTr("Sign out & Quit"), "text": qsTr("Sign out & Quit"),
"filename": "signout.svg" "icon": "logout"
}] }]

View File

@ -179,7 +179,6 @@ DISTFILES += \
app/AppLayouts/Chat/components/GroupInfoPopup.qml \ app/AppLayouts/Chat/components/GroupInfoPopup.qml \
app/AppLayouts/Chat/data/channelList.js \ app/AppLayouts/Chat/data/channelList.js \
app/AppLayouts/Profile/LeftTab/Constants.js \ app/AppLayouts/Profile/LeftTab/Constants.js \
app/AppLayouts/Profile/LeftTab/components/MenuButton.qml \
app/AppLayouts/Chat/data/EmojiReactions.qml \ app/AppLayouts/Chat/data/EmojiReactions.qml \
app/AppLayouts/Profile/Sections/AppearanceContainer.qml \ app/AppLayouts/Profile/Sections/AppearanceContainer.qml \
app/AppLayouts/Profile/Sections/NetworksModal.qml \ app/AppLayouts/Profile/Sections/NetworksModal.qml \