display users identicon in the profile instead of an hardcoded one

This commit is contained in:
Iuri Matias 2020-05-19 22:02:38 -04:00
parent 24bb268934
commit 51ced8bc2d
4 changed files with 19 additions and 2 deletions

View File

@ -21,3 +21,4 @@ proc init*(self: ProfileController, accounts: string) =
var chatAccount = parseJSON(accounts)[1]
self.view.username = chatAccount["name"].str
self.view.identicon = chatAccount["photo-path"].str

View File

@ -3,6 +3,7 @@ import NimQml
QtObject:
type ProfileView* = ref object of QObject
username*: string
identicon*: string
proc setup(self: ProfileView) =
self.QObject.setup
@ -10,6 +11,7 @@ QtObject:
proc newProfileView*(): ProfileView =
new(result)
result.username = ""
result.identicon = ""
result.setup
proc delete*(self: ProfileView) =
@ -28,3 +30,17 @@ QtObject:
read = username
write = setUsername
notify = receivedUsername
proc identicon*(self: ProfileView): string {.slot.} =
result = self.identicon
proc receivedIdenticon*(self: ProfileView, identicon: string) {.signal.}
proc setIdenticon*(self: ProfileView, identicon: string) {.slot.} =
self.identicon = identicon
self.receivedIdenticon(identicon)
QtProperty[string] identicon:
read = identicon
write = setIdenticon
notify = receivedIdenticon

View File

@ -56,7 +56,7 @@ proc mainProc() =
engine.setRootContextProperty("nodeModel", node.variant)
var profile = profile.newController()
profile.init(accounts)
profile.init(accounts) # TODO: use correct account
engine.setRootContextProperty("profileModel", profile.variant)
signalController.init()

View File

@ -41,7 +41,7 @@ ColumnLayout {
Image {
id: profileImg
source: "../../img/placeholder-profile-large.jpg"
source: profileModel.identicon
width: 80
height: 80
fillMode: Image.PreserveAspectCrop