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] var chatAccount = parseJSON(accounts)[1]
self.view.username = chatAccount["name"].str self.view.username = chatAccount["name"].str
self.view.identicon = chatAccount["photo-path"].str

View File

@ -3,6 +3,7 @@ import NimQml
QtObject: QtObject:
type ProfileView* = ref object of QObject type ProfileView* = ref object of QObject
username*: string username*: string
identicon*: string
proc setup(self: ProfileView) = proc setup(self: ProfileView) =
self.QObject.setup self.QObject.setup
@ -10,6 +11,7 @@ QtObject:
proc newProfileView*(): ProfileView = proc newProfileView*(): ProfileView =
new(result) new(result)
result.username = "" result.username = ""
result.identicon = ""
result.setup result.setup
proc delete*(self: ProfileView) = proc delete*(self: ProfileView) =
@ -28,3 +30,17 @@ QtObject:
read = username read = username
write = setUsername write = setUsername
notify = receivedUsername 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) engine.setRootContextProperty("nodeModel", node.variant)
var profile = profile.newController() var profile = profile.newController()
profile.init(accounts) profile.init(accounts) # TODO: use correct account
engine.setRootContextProperty("profileModel", profile.variant) engine.setRootContextProperty("profileModel", profile.variant)
signalController.init() signalController.init()

View File

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