From 51ced8bc2dede0e907812c9a7fa188f55adc06dd Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 19 May 2020 22:02:38 -0400 Subject: [PATCH] display users identicon in the profile instead of an hardcoded one --- src/app/profile/core.nim | 1 + src/app/profile/profileView.nim | 16 ++++++++++++++++ src/nim_status_client.nim | 2 +- ui/app/AppLayouts/Profile/LeftTab.qml | 2 +- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/app/profile/core.nim b/src/app/profile/core.nim index 64768a7953..88089f64d2 100644 --- a/src/app/profile/core.nim +++ b/src/app/profile/core.nim @@ -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 diff --git a/src/app/profile/profileView.nim b/src/app/profile/profileView.nim index ea9cdfb16a..a77ff420db 100644 --- a/src/app/profile/profileView.nim +++ b/src/app/profile/profileView.nim @@ -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 diff --git a/src/nim_status_client.nim b/src/nim_status_client.nim index dff03d5008..07bba86238 100644 --- a/src/nim_status_client.nim +++ b/src/nim_status_client.nim @@ -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() diff --git a/ui/app/AppLayouts/Profile/LeftTab.qml b/ui/app/AppLayouts/Profile/LeftTab.qml index be060996d0..32e1817745 100644 --- a/ui/app/AppLayouts/Profile/LeftTab.qml +++ b/ui/app/AppLayouts/Profile/LeftTab.qml @@ -41,7 +41,7 @@ ColumnLayout { Image { id: profileImg - source: "../../img/placeholder-profile-large.jpg" + source: profileModel.identicon width: 80 height: 80 fillMode: Image.PreserveAspectCrop