ui/qml/widgets/MyProfile.qml

239 lines
4.8 KiB
QML
Raw Permalink Normal View History

2018-10-23 18:52:13 +00:00
import QtGraphicalEffects 1.0
import QtQuick 2.7
import QtQuick.Controls 2.4
import QtQuick.Controls.Material 2.0
2018-10-29 18:00:21 +00:00
import QtQuick.Controls.Styles 1.4
2018-10-23 18:52:13 +00:00
import QtQuick.Layouts 1.3
2018-10-30 19:48:37 +00:00
import QtQuick.Window 2.11
2019-02-22 23:53:58 +00:00
import QtQuick.Controls 1.4
import "../styles"
2018-10-23 18:52:13 +00:00
ColumnLayout {
id: root
anchors.fill: parent
width: parent.width
property alias image: imgProfileImg.source
2018-10-29 18:00:21 +00:00
property string nick
property string onion
2018-10-23 18:52:13 +00:00
Item{ height: 6 }
Item { // PROFILE IMAGE
id: imgProfile
implicitWidth: 96
implicitHeight: 96
anchors.horizontalCenter: parent.horizontalCenter
2018-10-25 00:13:03 +00:00
Rectangle { // WHITE CIRCLE BORDER
width: 96
height: 96
color: "#FFFFFF"
radius: width / 2
Image { // ACTUAL IMAGE
id: imgProfileImg
anchors.fill: parent
fillMode: Image.PreserveAspectFit
visible: false
}
Image { // INNER CIRCLE MASK
id: mask
fillMode: Image.PreserveAspectFit
visible: false
source: "qrc:/qml/images/extra/clipcircle.png"
}
OpacityMask { // WE PUT IT ALL TOGETHER ANNND
anchors.fill: imgProfileImg
source: imgProfileImg
maskSource: mask
}
Rectangle { // TOR STATUS INDICATOR
color: "#FFFFFF"
width: 12
height: 12
radius: 3
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.margins: 8
Rectangle { //0: no tor, 1: progress 0%, 2: progress 1-99%, 3: DONE
id: rectTorStatus
color: code == 3 ? "green": code == 2 ? "orange" : code == 1 ? "yellow" : "red"
width: 8
height: 8
radius: 2
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.margins: 2
property int code
property string message
property bool hovered
2018-10-23 18:52:13 +00:00
2018-10-25 00:13:03 +00:00
MouseArea {
anchors.fill: parent
hoverEnabled: true
onEntered: rectTorStatus.hovered = true
onExited: rectTorStatus.hovered = false
}
ToolTip.visible: hovered
ToolTip.delay: 400
ToolTip.timeout: 5000
ToolTip.text: message
}
}
2018-10-23 18:52:13 +00:00
}
}
2019-02-04 23:00:12 +00:00
InplaceEditText { // USER NICKNAME
id: lblNick
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width
onUpdated: {
2019-02-11 21:33:07 +00:00
nick = lblNick.text
2019-02-04 23:00:12 +00:00
gcd.updateNick(lblNick.text)
}
}
2018-10-29 18:00:21 +00:00
2019-02-04 23:00:12 +00:00
/*
2018-10-29 18:00:21 +00:00
Text {
id: txtNick
fontSizeMode: Text.HorizontalFit
minimumPixelSize: 10
font.pixelSize: 20
width: 195
2018-10-23 18:52:13 +00:00
anchors.horizontalCenter: parent.horizontalCenter
2018-10-29 18:00:21 +00:00
text: cbNick.editText
2018-10-23 18:52:13 +00:00
2018-10-29 18:00:21 +00:00
MouseArea {
anchors.fill: parent
onClicked: {
parent.visible = false
cbNick.visible = true
}
}
}
ComboBox { // USER NICKNAME
id: cbNick
anchors.horizontalCenter: parent.horizontalCenter
popup.font.pixelSize: 12
width: 200
font.pixelSize: 20
model: ["erinn", "erinn (open privacy)", "supergirl", "add new profile..."]
visible: false
onCurrentTextChanged: {
visible = false
txtNick.visible = true
2018-10-23 18:52:13 +00:00
}
}
2019-02-04 23:00:12 +00:00
*/
2018-10-23 18:52:13 +00:00
ScalingLabel { // ONION ADDRESS
2018-10-23 18:52:13 +00:00
id: lblOnion
//font.pixelSize: 6
2018-10-23 18:52:13 +00:00
Layout.fillWidth: true
padding: 3
horizontalAlignment: Text.AlignHCenter
2019-02-12 21:22:14 +00:00
text:onion
2018-10-23 18:52:13 +00:00
}
2018-10-30 19:48:37 +00:00
Row { // TOOLS FOR EDITING PROFILE
2018-10-23 18:52:13 +00:00
anchors.horizontalCenter: parent.horizontalCenter
2018-11-22 00:01:17 +00:00
spacing: gcd.themeScale * 2
2018-10-23 18:52:13 +00:00
TextEdit { // USED TO POWER THE COPY/PASTE BUTTON
id: txtHidden
visible: false
}
2018-10-30 19:48:37 +00:00
SimpleButton { // COPY ONION ADDRESS BUTTON
icon: "regular/clipboard"
//: Button for copying profile onion address to clipboard
text: qsTr("copy-btn")
2018-10-23 18:52:13 +00:00
onClicked: {
//: Copied to clipboard
gcd.popup(qsTr("copied-clipboard-notification"))
2018-10-23 18:52:13 +00:00
txtHidden.text = nick.replace(" ", "~") + "~" + onion
2018-11-22 00:01:17 +00:00
txtHidden.selectAll()
txtHidden.copy()
2018-10-23 18:52:13 +00:00
}
}
2018-10-30 19:48:37 +00:00
SimpleButton { // SETTINGS BUTTON
icon: "solid/cog"
2018-10-23 18:52:13 +00:00
2018-10-29 18:00:21 +00:00
onClicked: theStack.pane = theStack.settingsPane
2018-10-23 18:52:13 +00:00
}
2018-10-30 19:48:37 +00:00
SimpleButton { // SIGN OUT BUTTON
icon: "solid/sign-out-alt"
2018-10-23 18:52:13 +00:00
2018-10-28 02:49:14 +00:00
onClicked: {
gcd.popup("not yet implemented, sorry :(")
}
2018-10-23 18:52:13 +00:00
}
}
2018-11-22 00:01:17 +00:00
Row {
anchors.horizontalCenter: parent.horizontalCenter
spacing: gcd.themeScale * 2
SimpleButton { // CREATE GROUP BUTTON
icon: "regular/clipboard"
//: create new group button
text: qsTr("new-group-btn")
2018-11-22 00:01:17 +00:00
onClicked: theStack.pane = theStack.addGroupPane
}
}
2019-02-22 23:53:58 +00:00
TextField {
anchors.horizontalCenter: parent.horizontalCenter
style: CwtchTextFieldStyle{ width: 400 }
//: ex: "... paste an address here to add a contact ..."
placeholderText: qsTr("paste-address-to-add-contact")
2019-02-22 23:53:58 +00:00
horizontalAlignment: TextInput.AlignHCenter
onTextChanged: {
if (text != "") {
gcd.importString(text)
text = ""
}
}
}
2018-10-23 18:52:13 +00:00
Connections {
target: gcd
onUpdateMyProfile: function(_nick, _onion, _image) {
nick = _nick
2019-02-04 23:00:12 +00:00
lblNick.text = _nick
2018-10-29 18:00:21 +00:00
onion = _onion
2018-10-23 18:52:13 +00:00
image = _image
}
2018-10-25 00:13:03 +00:00
onTorStatus: function(code, str) {
rectTorStatus.code = code
rectTorStatus.message = str
}
2018-10-23 18:52:13 +00:00
}
}