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