High cpu usage fix

This commit is contained in:
Sale Djenic 2021-07-28 13:57:55 +02:00 committed by Iuri Matias
parent 97f0a0435d
commit c1b47f1c9c
2 changed files with 59 additions and 56 deletions

View File

@ -80,6 +80,7 @@ QtObject:
proc setNewProfile*(self: ProfileView, profile: Profile) = proc setNewProfile*(self: ProfileView, profile: Profile) =
self.profile.setProfile(profile) self.profile.setProfile(profile)
self.profileSettings.removeUnknownAccountSettings() self.profileSettings.removeUnknownAccountSettings()
self.profileChanged()
QtProperty[QVariant] profile: QtProperty[QVariant] profile:
read = getProfile read = getProfile

View File

@ -35,9 +35,10 @@ QtObject:
result.sendUserStatus = false result.sendUserStatus = false
result.setup result.setup
proc profileChanged*(self: ProfileInfoView) {.signal.}
proc identityImageChanged*(self: ProfileInfoView) {.signal.} proc identityImageChanged*(self: ProfileInfoView) {.signal.}
proc sendUserStatusChanged*(self: ProfileInfoView) {.signal.}
proc appearanceChanged*(self: ProfileInfoView) {.signal.}
proc messagesFromContactsOnlyChanged*(self: ProfileInfoView) {.signal.}
proc setProfile*(self: ProfileInfoView, profile: Profile) = proc setProfile*(self: ProfileInfoView, profile: Profile) =
self.username = profile.username self.username = profile.username
@ -49,7 +50,55 @@ QtObject:
self.identityImage = profile.identityImage self.identityImage = profile.identityImage
self.messagesFromContactsOnly = profile.messagesFromContactsOnly self.messagesFromContactsOnly = profile.messagesFromContactsOnly
self.sendUserStatus = profile.sendUserStatus self.sendUserStatus = profile.sendUserStatus
self.profileChanged()
proc username*(self: ProfileInfoView): string {.slot.} = result = self.username
QtProperty[string] username:
read = username
proc identicon*(self: ProfileInfoView): string {.slot.} = result = self.identicon
QtProperty[string] identicon:
read = identicon
proc pubKey*(self: ProfileInfoView): string {.slot.} = self.pubKey
QtProperty[string] pubKey:
read = pubKey
proc address*(self: ProfileInfoView): string {.slot.} = self.address
QtProperty[string] address:
read = address
proc ensVerified*(self: ProfileInfoView): bool {.slot.} = self.ensVerified
QtProperty[bool] ensVerified:
read = ensVerified
proc appearance*(self: ProfileInfoView): int {.slot.} = result = self.appearance
proc setAppearance*(self: ProfileInfoView, appearance: int) {.slot.} =
if self.appearance == appearance:
return
self.appearance = appearance
self.appearanceChanged()
QtProperty[int] appearance:
read = appearance
write = setAppearance
notify = appearanceChanged
proc messagesFromContactsOnly*(self: ProfileInfoView): bool {.slot.} = result = self.messagesFromContactsOnly
proc setMessagesFromContactsOnly*(self: ProfileInfoView, messagesFromContactsOnly: bool) {.slot.} =
if self.messagesFromContactsOnly == messagesFromContactsOnly:
return
self.messagesFromContactsOnly = messagesFromContactsOnly
self.messagesFromContactsOnlyChanged()
QtProperty[bool] messagesFromContactsOnly:
read = messagesFromContactsOnly
write = setMessagesFromContactsOnly
notify = messagesFromContactsOnlyChanged
proc setIdentityImage*(self: ProfileInfoView, identityImage: IdentityImage) = proc setIdentityImage*(self: ProfileInfoView, identityImage: IdentityImage) =
self.identityImage = identityImage self.identityImage = identityImage
@ -59,44 +108,12 @@ QtObject:
self.identityImage = IdentityImage() self.identityImage = IdentityImage()
self.identityImageChanged() self.identityImageChanged()
proc username*(self: ProfileInfoView): string {.slot.} = result = self.username
QtProperty[string] username:
read = username
notify = profileChanged
proc appearance*(self: ProfileInfoView): int {.slot.} = result = self.appearance
proc setAppearance*(self: ProfileInfoView, appearance: int) {.slot.} =
if self.appearance == appearance:
return
self.appearance = appearance
self.profileChanged()
QtProperty[int] appearance:
read = appearance
write = setAppearance
notify = profileChanged
proc messagesFromContactsOnly*(self: ProfileInfoView): bool {.slot.} = result = self.messagesFromContactsOnly
proc setMessagesFromContactsOnly*(self: ProfileInfoView, messagesFromContactsOnly: bool) {.slot.} =
if self.messagesFromContactsOnly == messagesFromContactsOnly:
return
self.messagesFromContactsOnly = messagesFromContactsOnly
self.profileChanged()
QtProperty[bool] messagesFromContactsOnly:
read = messagesFromContactsOnly
write = setMessagesFromContactsOnly
notify = profileChanged
proc identicon*(self: ProfileInfoView): string {.slot.} = result = self.identicon
QtProperty[string] identicon:
read = identicon
notify = profileChanged
proc thumbnailImage*(self: ProfileInfoView): string {.slot.} = proc thumbnailImage*(self: ProfileInfoView): string {.slot.} =
if (?.self.identityImage.thumbnail != ""): if (?.self.identityImage.thumbnail != ""):
result = self.identityImage.thumbnail result = self.identityImage.thumbnail
else: else:
result = self.identicon result = self.identicon
QtProperty[string] thumbnailImage: QtProperty[string] thumbnailImage:
read = thumbnailImage read = thumbnailImage
notify = identityImageChanged notify = identityImageChanged
@ -106,41 +123,26 @@ QtObject:
result = self.identityImage.large result = self.identityImage.large
else: else:
result = self.identicon result = self.identicon
QtProperty[string] largeImage: QtProperty[string] largeImage:
read = largeImage read = largeImage
notify = identityImageChanged notify = identityImageChanged
proc hasIdentityImage*(self: ProfileInfoView): bool {.slot.} = proc hasIdentityImage*(self: ProfileInfoView): bool {.slot.} =
result = (?.self.identityImage.thumbnail != "") result = (?.self.identityImage.thumbnail != "")
QtProperty[bool] hasIdentityImage: QtProperty[bool] hasIdentityImage:
read = hasIdentityImage read = hasIdentityImage
notify = identityImageChanged notify = identityImageChanged
proc pubKey*(self: ProfileInfoView): string {.slot.} = self.pubKey
QtProperty[string] pubKey:
read = pubKey
notify = profileChanged
proc address*(self: ProfileInfoView): string {.slot.} = self.address
QtProperty[string] address:
read = address
notify = profileChanged
proc ensVerified*(self: ProfileInfoView): bool {.slot.} = self.ensVerified
QtProperty[bool] ensVerified:
read = ensVerified
notify = profileChanged
proc sendUserStatus*(self: ProfileInfoView): bool {.slot.} = result = self.sendUserStatus proc sendUserStatus*(self: ProfileInfoView): bool {.slot.} = result = self.sendUserStatus
proc setSendUserStatus*(self: ProfileInfoView, sendUserStatus: bool) {.slot.} = proc setSendUserStatus*(self: ProfileInfoView, sendUserStatus: bool) {.slot.} =
if self.sendUserStatus == sendUserStatus: if self.sendUserStatus == sendUserStatus:
return return
self.sendUserStatus = sendUserStatus self.sendUserStatus = sendUserStatus
self.profileChanged() self.sendUserStatusChanged()
QtProperty[bool] sendUserStatus: QtProperty[bool] sendUserStatus:
read = sendUserStatus read = sendUserStatus
write = setSendUserStatus write = setSendUserStatus
notify = profileChanged notify = sendUserStatusChanged