Skip to content

Commit

Permalink
show profile data in UI, move fallback image to Qt
Browse files Browse the repository at this point in the history
  • Loading branch information
prolic committed Sep 25, 2024
1 parent f952ba1 commit a4e2f93
Show file tree
Hide file tree
Showing 8 changed files with 181 additions and 123 deletions.
11 changes: 7 additions & 4 deletions resources/qml/content/App.qml
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,17 @@ ApplicationWindow {
KeyMgmtScreen {
anchors.margins: 10
anchors.fill: parent

visible: currentScreen == "KeyMgmt"
}

HomeScreen {
anchors.margins: 10
Loader {
id: myHomeScreenLoader
active: currentScreen == "Home"
anchors.fill: parent
visible: currentScreen == "Home"
sourceComponent: HomeScreen {
anchors.margins: 10
anchors.fill: parent
}
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions resources/qml/content/HomeScreen.ui.qml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ Rectangle {
width: 75
height: 75

icon.source: mypicture
icon.width: 65
icon.height: 65
icon.color: "transparent"

Component.onCompleted: {
icon.source = Util.getProfilePicture(mypicture, mynpub)
}

Material.elevation: 10

ToolTip.visible: hovered
Expand All @@ -43,7 +46,6 @@ Rectangle {
}
}


MyProfile {
id: myProfile
visible: false
Expand Down
2 changes: 1 addition & 1 deletion resources/qml/content/KeyMgmtScreen.ui.qml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Rectangle {
spacing: 5

Image {
source: modelData.picture
source: Util.getProfilePicture(modelData.picture, modelData.npub)
width: 50
height: 50
Layout.preferredWidth: 50
Expand Down
214 changes: 126 additions & 88 deletions resources/qml/content/Profile/MyProfile.ui.qml
Original file line number Diff line number Diff line change
Expand Up @@ -11,126 +11,164 @@ Rectangle {
border.color: "#e0e0e0"
radius: 5
width: 400
implicitHeight: content.implicitHeight
implicitHeight: contentLoader.implicitHeight
property var profileData: {}

ColumnLayout {
id: content
Loader {
id: contentLoader
anchors.fill: parent
anchors.margins: 1
spacing: 10

RowLayout {
Layout.fillWidth: true
Layout.alignment: Qt.AlignRight
Layout.rightMargin: 2
Layout.topMargin: 2

CloseButton {
id: closeButton
target: root
}
}
sourceComponent: profileData && profileData !== {} ? contentComponent : null
}

RowLayout {
width: parent.width
Component {
id: contentComponent

ColumnLayout {
spacing: 10
width: parent.width
ColumnLayout {
id: content
anchors.fill: parent
anchors.margins: 1
spacing: 10

Rectangle {
Layout.fillWidth: true
height: 80
visible: profileData.banner !== null
RowLayout {
Layout.fillWidth: true
Layout.alignment: Qt.AlignRight
Layout.rightMargin: 2
Layout.topMargin: 2

Image {
source: profileData.banner ?? ""
width: parent.width
height: 80
fillMode: Image.PreserveAspectCrop
clip: true
}
CloseButton {
id: closeButton
target: root
}
}

RowLayout {
Layout.fillWidth: true
RowLayout {
width: parent.width

ColumnLayout {
spacing: 10
width: parent.width

Rectangle {
width: 60
height: 60
Layout.leftMargin: 10
Layout.fillHeight: true
Layout.fillWidth: true
height: 80
visible: profileData.banner !== null && profileData.banner !== ""

Image {
source: profileData.picture ?? ""
width: 60
height: 60
source: profileData.banner ?? ""
width: parent.width
height: 80
fillMode: Image.PreserveAspectCrop
clip: true
}
}

ColumnLayout {
spacing: 10
RowLayout {
Layout.fillWidth: true
spacing: 10

Text {
text: profileData.display_name ?? ""
font.bold: true
}

Text {
text: profileData.name ?? ""
}

Text {
text: profileData.about ?? ""
Layout.fillWidth: true
wrapMode: Text.Wrap
}

ExternalIdentity {
Layout.fillWidth: true
icon: ExternalIdentityIcons.github
link: profileData.githubLink ?? ""
proof: profileData.githubProof ?? ""
value: profileData.githubUsername ?? ""
Rectangle {
width: 60
height: 60
Layout.leftMargin: 10
Layout.fillHeight: true

Image {
width: 60
height: 60
fillMode: Image.PreserveAspectCrop
clip: true

Component.onCompleted: {
source = Util.getProfilePicture(profileData.picture, mynpub)
}
}
}

ExternalIdentity {
ColumnLayout {
spacing: 10
Layout.fillWidth: true
icon: ExternalIdentityIcons.telegram
link: profileData.telegramLink ?? ""
proof: profileData.telegramProof ?? ""
value: profileData.telegramUsername ?? ""
}

ExternalIdentity {
Layout.fillWidth: true
icon: ExternalIdentityIcons.x_twitter
link: profileData.twitterLink ?? ""
proof: profileData.twitterProof ?? ""
value: profileData.twitterUsername ?? ""
Text {
text: profileData.display_name ?? ""
font.bold: true
}

Text {
text: profileData.name ?? ""
}

RowLayout {
Text {
text: mynpub
elide: Text.ElideRight
Layout.fillWidth: true
Layout.maximumWidth: parent.width - copyButton.width - parent.spacing
}

Button {
id: copyButton
icon.source: "qrc:/icons/content_copy.svg"
flat: true
Layout.preferredWidth: 50
Layout.preferredHeight: 50
Layout.rightMargin: 10

ToolTip.visible: hovered
ToolTip.text: qsTr("Copy to clipboard")

onClicked: {
clipboard.copyText(mynpub)
}
}
}

Text {
text: profileData.about ?? ""
Layout.fillWidth: true
wrapMode: Text.Wrap
}

ExternalIdentity {
Layout.fillWidth: true
icon: ExternalIdentityIcons.github
link: profileData.githubLink ?? ""
proof: profileData.githubProof ?? ""
value: profileData.githubUsername ?? ""
}

ExternalIdentity {
Layout.fillWidth: true
icon: ExternalIdentityIcons.telegram
link: profileData.telegramLink ?? ""
proof: profileData.telegramProof ?? ""
value: profileData.telegramUsername ?? ""
}

ExternalIdentity {
Layout.fillWidth: true
icon: ExternalIdentityIcons.x_twitter
link: profileData.twitterLink ?? ""
proof: profileData.twitterProof ?? ""
value: profileData.twitterUsername ?? ""
}
}
}
}
}
}

RowLayout {
width: parent.width
Layout.alignment: Qt.AlignRight
Layout.rightMargin: 10
Layout.bottomMargin: 10
RowLayout {
width: parent.width
Layout.alignment: Qt.AlignRight
Layout.rightMargin: 10
Layout.bottomMargin: 10

EditButton {
id: editButton
EditButton {
id: editButton

onClicked: {
root.visible = false;
editMyProfile.visible = true;
onClicked: {
root.visible = false;
editMyProfile.visible = true;
}
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions resources/qml/imports/Futr/Util.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
pragma Singleton
import QtQuick 2.15

QtObject {
function getProfilePicture(picture, npub) {
return picture ? picture : "https://robohash.org/" + npub + ".png?size=50x50";
}
}
1 change: 1 addition & 0 deletions resources/qml/imports/Futr/qmldir
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Module Futr
singleton Constants 1.0 Constants.qml
singleton ExternalIdentityIcons 1.0 ExternalIdentityIcons.qml
singleton Util 1.0 Util.qml
Loading

0 comments on commit a4e2f93

Please sign in to comment.