This repository has been archived on 2021-06-24. You can view files and clone it, but cannot push or open issues or pull requests.
ui/qml/widgets/MyProfile.qml

154 lines
4.3 KiB
QML

import QtGraphicalEffects 1.0
import QtQuick 2.7
import QtQuick.Controls 2.4
import QtQuick.Controls.Material 2.0
import QtQuick.Controls.Styles 1.4
import QtQuick.Layouts 1.3
import QtQuick.Window 2.11
import QtQuick.Controls 1.4
import "../opaque" as Opaque
import "../opaque/styles"
import "../opaque/theme"
import "../opaque/fonts"
Item {
id: root
anchors.fill: parent
width: parent.width
height: profile.height
implicitHeight: profile.height
property string image
property string nick
property string onion
property string tag
property bool dualPane: false
property real logscale: 4 * Math.log10(gcd.themeScale + 1)
onDualPaneChanged: { realignProfile() }
function realignProfile() {
if (dualPane) {
profile.height = Theme.contactPortraitSize * logscale
portrait.baseWidth = Theme.contactPortraitSize * logscale
portrait.height = Theme.contactPortraitSize * logscale
portrait.anchors.horizontalCenter = undefined
portrait.anchors.left = profile.left
portrait.anchors.leftMargin = 25 * logscale
nameRow.anchors.right = undefined
nameRow.anchors.left = portrait.right
nameRow.anchors.top = undefined
nameRow.anchors.verticalCenter = portrait.verticalCenter
nameCenter.anchors.horizontalCenter = undefined
nameCenter.anchors.left = nameRow.left
} else {
profile.height = (Theme.contactPortraitSize * 2 * logscale)
portrait.size = Theme.contactPortraitSize * 1.5
portrait.anchors.left = undefined
portrait.anchors.leftMargin = undefined
portrait.anchors.horizontalCenter = profile.horizontalCenter
nameRow.anchors.left = profile.left
nameRow.anchors.right = profile.right
nameRow.anchors.verticalCenter = undefined
nameRow.anchors.top = portrait.bottom
nameCenter.anchors.left = undefined
nameCenter.anchors.horizontalCenter = nameRow.horizontalCenter
}
}
Rectangle {
anchors.left: parent.left
anchors.right: parent.right
width: parent.width
id: profile
color: Theme.backgroundMainColor
Opaque.Portrait {
id: portrait
source: root.image
badgeColor: Theme.portraitProfileBadgeColor
portraitBorderColor: Theme.portraitOnlineBorderColor
portraitColor: Theme.portraitOnlineBackgroundColor
badgeContent: Image {// Profle Type
id: profiletype
source: tag == "v1-userPassword" ? gcd.assetPath + "/fontawesome/solid/lock.svg" : gcd.assetPath + "/fontawesome/solid/lock-open.svg"
height: Theme.badgeTextSize * gcd.themeScale
width: height
}
}
Rectangle {
id: nameRow
height: name.height
onWidthChanged: { name.textResize() }
color: Theme.backgroundMainColor
Rectangle {
id: nameCenter
width: name.width + addBtn.width
Opaque.EllipsisLabel {
id: name
color: Theme.portraitOnlineTextColor
size: Theme.usernameSize * gcd.themeScale
weight: Font.Bold
font.family: Fonts.applicationFontExtraBold.name
font.styleName: "ExtraBold"
text: nick
extraPadding: addBtn.width + 30
container: nameRow
}
Opaque.Button { // Add Button
id: addBtn
anchors.left: name.right
anchors.top: name.top
icon: "solid/plus"
height: name.height
width: height
radius: width * 0.3
onClicked: {
}
}
}
}
}
Connections {
target: gcd
onUpdateMyProfile: function(_nick, _onion, _image, _tag, _showBlocked) {
nick = _nick
onion = _onion
image = _image
tag = _tag
}
onResetProfile: { realignProfile() }
}
}