display users identicon in the profile instead of an hardcoded one
This commit is contained in:
parent
24bb268934
commit
51ced8bc2d
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -41,7 +41,7 @@ ColumnLayout {
|
|||
|
||||
Image {
|
||||
id: profileImg
|
||||
source: "../../img/placeholder-profile-large.jpg"
|
||||
source: profileModel.identicon
|
||||
width: 80
|
||||
height: 80
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
|
|
Loading…
Reference in New Issue