refactor: ProfileView

This commit is contained in:
Richard Ramos 2020-12-06 18:15:51 -04:00 committed by Iuri Matias
parent 426fe504b4
commit ae30d04010
40 changed files with 507 additions and 346 deletions

View File

@ -6,14 +6,15 @@ import ../../status/libstatus/accounts/constants
import ../../status/libstatus/types as status_types import ../../status/libstatus/types as status_types
import ../../status/libstatus/settings as status_settings import ../../status/libstatus/settings as status_settings
import ../../status/profile/[profile, mailserver] import ../../status/profile/[profile, mailserver]
import ../../status/[status, contacts] import ../../status/status
import ../../status/contacts as status_contacts
import ../../status/chat as status_chat import ../../status/chat as status_chat
import ../../status/devices import ../../status/devices as status_devices
import ../../status/chat/chat import ../../status/chat/chat
import ../../status/wallet import ../../status/wallet
import ../../eventemitter import ../../eventemitter
import view import view
import views/ens_manager import views/[ens_manager, devices, network, mailservers, contacts]
import ../chat/views/channels_list import ../chat/views/channels_list
import chronicles import chronicles
@ -42,19 +43,19 @@ proc init*(self: ProfileController, account: Account) =
profile.id = pubKey profile.id = pubKey
profile.address = account.keyUid profile.address = account.keyUid
self.view.addDevices(devices.getAllDevices()) self.view.devices.addDevices(status_devices.getAllDevices())
self.view.setDeviceSetup(devices.isDeviceSetup()) self.view.devices.setDeviceSetup(status_devices.isDeviceSetup())
self.view.setNewProfile(profile) self.view.setNewProfile(profile)
self.view.setNetwork(network) self.view.network.setNetwork(network)
self.view.ens.init() self.view.ens.init()
for name, endpoint in self.status.fleet.config.getMailservers(status_settings.getFleet()).pairs(): for name, endpoint in self.status.fleet.config.getMailservers(status_settings.getFleet()).pairs():
let mailserver = MailServer(name: name, endpoint: endpoint) let mailserver = MailServer(name: name, endpoint: endpoint)
self.view.addMailServerToList(mailserver) self.view.mailservers.add(mailserver)
let contacts = self.status.contacts.getContacts() let contacts = self.status.contacts.getContacts()
self.status.chat.updateContacts(contacts) self.status.chat.updateContacts(contacts)
self.view.setContactList(contacts) self.view.contacts.setContactList(contacts)
self.status.events.on("channelLoaded") do(e: Args): self.status.events.on("channelLoaded") do(e: Args):
var channel = ChannelArgs(e) var channel = ChannelArgs(e)
@ -82,28 +83,28 @@ proc init*(self: ProfileController, account: Account) =
self.status.events.on("contactAdded") do(e: Args): self.status.events.on("contactAdded") do(e: Args):
let contacts = self.status.contacts.getContacts() let contacts = self.status.contacts.getContacts()
self.view.setContactList(contacts) self.view.contacts.setContactList(contacts)
self.status.events.on("contactBlocked") do(e: Args): self.status.events.on("contactBlocked") do(e: Args):
let contacts = self.status.contacts.getContacts() let contacts = self.status.contacts.getContacts()
self.view.setContactList(contacts) self.view.contacts.setContactList(contacts)
self.status.events.on("contactUnblocked") do(e: Args): self.status.events.on("contactUnblocked") do(e: Args):
let contacts = self.status.contacts.getContacts() let contacts = self.status.contacts.getContacts()
self.view.setContactList(contacts) self.view.contacts.setContactList(contacts)
self.status.events.on("contactRemoved") do(e: Args): self.status.events.on("contactRemoved") do(e: Args):
let contacts = self.status.contacts.getContacts() let contacts = self.status.contacts.getContacts()
self.view.setContactList(contacts) self.view.contacts.setContactList(contacts)
self.status.events.on(SignalType.Message.event) do(e: Args): self.status.events.on(SignalType.Message.event) do(e: Args):
let msgData = MessageSignal(e); let msgData = MessageSignal(e);
if msgData.contacts.len > 0: if msgData.contacts.len > 0:
# TODO: view should react to model changes # TODO: view should react to model changes
self.status.chat.updateContacts(msgData.contacts) self.status.chat.updateContacts(msgData.contacts)
self.view.updateContactList(msgData.contacts) self.view.contacts.updateContactList(msgData.contacts)
if msgData.installations.len > 0: if msgData.installations.len > 0:
self.view.addDevices(msgData.installations) self.view.devices.addDevices(msgData.installations)
self.status.events.on(PendingTransactionType.RegisterENS.confirmed) do(e: Args): self.status.events.on(PendingTransactionType.RegisterENS.confirmed) do(e: Args):
let tx = TransactionMinedArgs(e) let tx = TransactionMinedArgs(e)

View File

@ -1,13 +1,12 @@
import NimQml, sequtils, strutils, sugar, os, json import NimQml, sequtils, strutils, sugar, os, json
import views/[mailservers_list, ens_manager, contact_list, fleets, profile_info, device_list, dapp_list] import views/[mailservers_list, ens_manager, contacts, devices, mailservers, mnemonic, network, fleets, profile_info, device_list, dapp_list]
import ../chat/views/channels_list import ../chat/views/channels_list
import ../../status/profile/[mailserver, profile, devices] import ../../status/profile/profile
import ../../status/profile as status_profile import ../../status/profile as status_profile
import ../../status/contacts as status_contacts import ../../status/contacts as status_contacts
import ../../status/accounts as status_accounts import ../../status/accounts as status_accounts
import ../../status/libstatus/settings as status_settings import ../../status/libstatus/settings as status_settings
import ../../status/status import ../../status/status
import ../../status/devices as status_devices
import ../../status/ens as status_ens import ../../status/ens as status_ens
import ../../status/chat/chat import ../../status/chat/chat
import ../../status/threads import ../../status/threads
@ -18,167 +17,54 @@ import qrcode/qrcode
QtObject: QtObject:
type ProfileView* = ref object of QObject type ProfileView* = ref object of QObject
profile*: ProfileInfoView profile*: ProfileInfoView
mailserversList*: MailServersList contacts*: ContactsView
contactList*: ContactList devices*: DevicesView
addedContacts*: ContactList mailservers*: MailserversView
blockedContacts*: ContactList mnemonic*: MnemonicView
mutedChats*: ChannelsList mutedChats*: ChannelsList
mutedContacts*: ChannelsList mutedContacts*: ChannelsList
deviceList*: DeviceList
dappList*: DappList dappList*: DappList
fleets*: Fleets fleets*: Fleets
network: string network*: NetworkView
status*: Status status*: Status
isDeviceSetup: bool
changeLanguage*: proc(locale: string) changeLanguage*: proc(locale: string)
contactToAdd*: Profile
ens*: EnsManager ens*: EnsManager
proc setup(self: ProfileView) = proc setup(self: ProfileView) =
self.QObject.setup self.QObject.setup
proc delete*(self: ProfileView) = proc delete*(self: ProfileView) =
if not self.mailserversList.isNil: self.mailserversList.delete if not self.contacts.isNil: self.contacts.delete
if not self.contactList.isNil: self.contactList.delete if not self.devices.isNil: self.devices.delete
if not self.addedContacts.isNil: self.addedContacts.delete
if not self.blockedContacts.isNil: self.blockedContacts.delete
if not self.mutedChats.isNil: self.mutedChats.delete if not self.mutedChats.isNil: self.mutedChats.delete
if not self.mutedContacts.isNil: self.mutedContacts.delete if not self.mutedContacts.isNil: self.mutedContacts.delete
if not self.deviceList.isNil: self.deviceList.delete
if not self.ens.isNil: self.ens.delete if not self.ens.isNil: self.ens.delete
if not self.profile.isNil: self.profile.delete if not self.profile.isNil: self.profile.delete
if not self.dappList.isNil: self.dappList.delete if not self.dappList.isNil: self.dappList.delete
if not self.fleets.isNil: self.fleets.delete if not self.fleets.isNil: self.fleets.delete
if not self.network.isNil: self.network.delete
if not self.mnemonic.isNil: self.mnemonic.delete
if not self.mailservers.isNil: self.mailservers.delete
self.QObject.delete self.QObject.delete
proc newProfileView*(status: Status, changeLanguage: proc(locale: string)): ProfileView = proc newProfileView*(status: Status, changeLanguage: proc(locale: string)): ProfileView =
new(result, delete) new(result, delete)
result = ProfileView() result = ProfileView()
result.profile = newProfileInfoView() result.profile = newProfileInfoView()
result.mailserversList = newMailServersList() result.contacts = newContactsView(status)
result.contactList = newContactList() result.devices = newDevicesView(status)
result.addedContacts = newContactList() result.network = newNetworkView(status)
result.blockedContacts = newContactList() result.mnemonic = newMnemonicView(status)
result.mailservers = newMailserversView(status)
result.mutedChats = newChannelsList(status) result.mutedChats = newChannelsList(status)
result.mutedContacts = newChannelsList(status) result.mutedContacts = newChannelsList(status)
result.deviceList = newDeviceList()
result.dappList = newDappList(status) result.dappList = newDappList(status)
result.ens = newEnsManager(status) result.ens = newEnsManager(status)
result.fleets = newFleets(status) result.fleets = newFleets(status)
result.network = ""
result.status = status
result.isDeviceSetup = false
result.changeLanguage = changeLanguage result.changeLanguage = changeLanguage
result.contactToAdd = Profile( result.status = status
username: "",
alias: "",
ensName: ""
)
result.setup result.setup
proc addMailServerToList*(self: ProfileView, mailserver: MailServer) =
self.mailserversList.addMailServerToList(mailserver)
proc getMailserversList(self: ProfileView): QVariant {.slot.} =
return newQVariant(self.mailserversList)
QtProperty[QVariant] mailserversList:
read = getMailserversList
proc updateContactList*(self: ProfileView, contacts: seq[Profile]) =
for contact in contacts:
self.contactList.updateContact(contact)
if contact.systemTags.contains(":contact/added"):
self.addedContacts.updateContact(contact)
if contact.systemTags.contains(":contact/blocked"):
self.blockedContacts.updateContact(contact)
proc contactListChanged*(self: ProfileView) {.signal.}
proc getContactList(self: ProfileView): QVariant {.slot.} =
return newQVariant(self.contactList)
proc setContactList*(self: ProfileView, contactList: seq[Profile]) =
self.contactList.setNewData(contactList)
self.addedContacts.setNewData(contactList.filter(c => c.systemTags.contains(":contact/added")))
self.blockedContacts.setNewData(contactList.filter(c => c.systemTags.contains(":contact/blocked")))
self.contactListChanged()
QtProperty[QVariant] contactList:
read = getContactList
write = setContactList
notify = contactListChanged
proc getAddedContacts(self: ProfileView): QVariant {.slot.} =
return newQVariant(self.addedContacts)
QtProperty[QVariant] addedContacts:
read = getAddedContacts
notify = contactListChanged
proc getBlockedContacts(self: ProfileView): QVariant {.slot.} =
return newQVariant(self.blockedContacts)
QtProperty[QVariant] blockedContacts:
read = getBlockedContacts
notify = contactListChanged
proc isContactBlocked*(self: ProfileView, pubkey: string): bool {.slot.} =
for contact in self.blockedContacts.contacts:
if contact.id == pubkey:
return true
return false
proc isMnemonicBackedUp*(self: ProfileView): bool {.slot.} =
let mnemonic = status_settings.getSetting[string](Setting.Mnemonic, "")
return mnemonic == ""
proc seedPhraseRemoved*(self: ProfileView) {.signal.}
QtProperty[bool] isMnemonicBackedUp:
read = isMnemonicBackedUp
notify = seedPhraseRemoved
proc getMnemonic*(self: ProfileView): QVariant {.slot.} =
# Do not keep the mnemonic in memory, so fetch it when necessary
let mnemonic = status_settings.getSetting[string](Setting.Mnemonic, "")
return newQVariant(mnemonic)
QtProperty[QVariant] mnemonic:
read = getMnemonic
notify = seedPhraseRemoved
proc removeSeedPhrase*(self: ProfileView) {.slot.} =
discard status_settings.saveSetting(Setting.Mnemonic, "")
self.seedPhraseRemoved()
proc getMnemonicWord*(self: ProfileView, idx: int): string {.slot.} =
let mnemonics = status_settings.getSetting[string](Setting.Mnemonic, "").split(" ")
return mnemonics[idx]
proc networkChanged*(self: ProfileView) {.signal.}
proc triggerNetworkChange*(self: ProfileView) {.slot.} =
self.networkChanged()
proc getNetwork*(self: ProfileView): QVariant {.slot.} =
return newQVariant(self.network)
proc setNetwork*(self: ProfileView, network: string) =
self.network = network
self.networkChanged()
proc setNetworkAndPersist*(self: ProfileView, network: string) {.slot.} =
self.network = network
self.networkChanged()
self.status.accounts.changeNetwork(self.status.fleet.config, network)
quit(QuitSuccess) # quits the app TODO: change this to logout instead when supported
QtProperty[QVariant] network:
read = getNetwork
write = setNetworkAndPersist
notify = networkChanged
proc profileSettingsFileChanged*(self: ProfileView) {.signal.} proc profileSettingsFileChanged*(self: ProfileView) {.signal.}
proc getProfileSettingsFile(self: ProfileView): string {.slot.} = proc getProfileSettingsFile(self: ProfileView): string {.slot.} =
@ -208,27 +94,6 @@ QtObject:
read = getProfile read = getProfile
notify = profileChanged notify = profileChanged
proc contactToAddChanged*(self: ProfileView) {.signal.}
proc getContactToAddUsername(self: ProfileView): QVariant {.slot.} =
var username = self.contactToAdd.alias;
if self.contactToAdd.ensVerified and self.contactToAdd.ensName != "":
username = self.contactToAdd.ensName
return newQVariant(username)
QtProperty[QVariant] contactToAddUsername:
read = getContactToAddUsername
notify = contactToAddChanged
proc getContactToAddPubKey(self: ProfileView): QVariant {.slot.} =
return newQVariant(self.contactToAdd.address)
QtProperty[QVariant] contactToAddPubKey:
read = getContactToAddPubKey
notify = contactToAddChanged
proc logout*(self: ProfileView) {.slot.} = proc logout*(self: ProfileView) {.slot.} =
self.status.profile.logout() self.status.profile.logout()
@ -238,49 +103,12 @@ QtObject:
proc nodeVersion*(self: ProfileView): string {.slot.} = proc nodeVersion*(self: ProfileView): string {.slot.} =
self.status.getNodeVersion() self.status.getNodeVersion()
proc isAdded*(self: ProfileView, id: string): bool {.slot.} =
if id == "": return false
self.status.contacts.isAdded(id)
proc qrCode*(self: ProfileView, text:string): string {.slot.} = proc qrCode*(self: ProfileView, text:string): string {.slot.} =
result = "data:image/svg+xml;utf8," & generateQRCodeSVG(text, 2) result = "data:image/svg+xml;utf8," & generateQRCodeSVG(text, 2)
proc changeTheme*(self: ProfileView, theme: int) {.slot.} = proc changeTheme*(self: ProfileView, theme: int) {.slot.} =
self.profile.setAppearance(theme) self.profile.setAppearance(theme)
self.status.saveSetting(Setting.Appearance, $theme) self.status.saveSetting(Setting.Appearance, $theme)
proc isDeviceSetup*(self: ProfileView): bool {.slot} =
result = self.isDeviceSetup
proc deviceSetupChanged*(self: ProfileView) {.signal.}
proc setDeviceSetup*(self: ProfileView, isSetup: bool) {.slot} =
self.isDeviceSetup = isSetup
self.deviceSetupChanged()
QtProperty[bool] deviceSetup:
read = isDeviceSetup
notify = deviceSetupChanged
proc setDeviceName*(self: ProfileView, deviceName: string) {.slot.} =
status_devices.setDeviceName(deviceName)
self.setDeviceSetup(true)
proc syncAllDevices*(self: ProfileView) {.slot.} =
status_devices.syncAllDevices()
proc advertiseDevice*(self: ProfileView) {.slot.} =
status_devices.advertise()
proc addDevices*(self: ProfileView, devices: seq[Installation]) =
for dev in devices:
self.deviceList.addDeviceToList(dev)
proc getDeviceList(self: ProfileView): QVariant {.slot.} =
return newQVariant(self.deviceList)
QtProperty[QVariant] deviceList:
read = getDeviceList
proc getDappList(self: ProfileView): QVariant {.slot.} = proc getDappList(self: ProfileView): QVariant {.slot.} =
return newQVariant(self.dappList) return newQVariant(self.dappList)
@ -300,60 +128,6 @@ QtObject:
QtProperty[QVariant] ens: QtProperty[QVariant] ens:
read = getEnsManager read = getEnsManager
proc enableInstallation*(self: ProfileView, installationId: string, enable: bool) {.slot.} =
if enable:
status_devices.enable(installationId)
else:
status_devices.disable(installationId)
proc lookupContact*(self: ProfileView, value: string) {.slot.} =
if value == "":
return
spawnAndSend(self, "ensResolved") do: # Call self.ensResolved(string) when ens is resolved
var id = value
if not id.startsWith("0x"):
id = status_ens.pubkey(id)
id
proc ensResolved(self: ProfileView, id: string) {.slot.} =
let contact = self.status.contacts.getContactByID(id)
if contact != nil:
self.contactToAdd = contact
else:
self.contactToAdd = Profile(
username: "",
alias: "",
ensName: "",
ensVerified: false
)
self.contactToAddChanged()
proc contactChanged(self: ProfileView, publicKey: string, isAdded: bool) {.signal.}
proc addContact*(self: ProfileView, publicKey: string): string {.slot.} =
result = self.status.contacts.addContact(publicKey)
self.contactChanged(publicKey, true)
proc changeContactNickname*(self: ProfileView, publicKey: string, nickname: string) {.slot.} =
var nicknameToSet = nickname
if (nicknameToSet == ""):
nicknameToSet = DELETE_CONTACT
discard self.status.contacts.addContact(publicKey, nicknameToSet)
proc unblockContact*(self: ProfileView, publicKey: string) {.slot.} =
self.contactListChanged()
discard self.status.contacts.unblockContact(publicKey)
proc blockContact*(self: ProfileView, publicKey: string): string {.slot.} =
self.contactListChanged()
return self.status.contacts.blockContact(publicKey)
proc removeContact*(self: ProfileView, publicKey: string) {.slot.} =
self.status.contacts.removeContact(publicKey)
self.contactChanged(publicKey, false)
proc getLinkPreviewWhitelist*(self: ProfileView): string {.slot.} = proc getLinkPreviewWhitelist*(self: ProfileView): string {.slot.} =
result = $(self.status.profile.getLinkPreviewWhitelist()) result = $(self.status.profile.getLinkPreviewWhitelist())
@ -406,3 +180,32 @@ QtObject:
self.mutedChatsListChanged() self.mutedChatsListChanged()
self.mutedContactsListChanged() self.mutedContactsListChanged()
proc getContacts*(self: ProfileView): QVariant {.slot.} =
newQVariant(self.contacts)
QtProperty[QVariant] contacts:
read = getContacts
proc getDevices*(self: ProfileView): QVariant {.slot.} =
newQVariant(self.devices)
QtProperty[QVariant] devices:
read = getDevices
proc getMailservers*(self: ProfileView): QVariant {.slot.} =
newQVariant(self.mailservers)
QtProperty[QVariant] mailservers:
read = getMailservers
proc getMnemonic*(self: ProfileView): QVariant {.slot.} =
newQVariant(self.mnemonic)
QtProperty[QVariant] mnemonic:
read = getMnemonic
proc getNetwork*(self: ProfileView): QVariant {.slot.} =
newQVariant(self.network)
QtProperty[QVariant] network:
read = getNetwork

View File

@ -0,0 +1,156 @@
import NimQml, chronicles, sequtils, sugar, strutils
import ../../../status/status
import ../../../status/threads
import contact_list
import ../../../status/profile/profile
import ../../../status/ens as status_ens
logScope:
topics = "contacts-view"
QtObject:
type ContactsView* = ref object of QObject
status: Status
contactList*: ContactList
addedContacts*: ContactList
blockedContacts*: ContactList
contactToAdd*: Profile
proc setup(self: ContactsView) =
self.QObject.setup
proc delete*(self: ContactsView) =
self.contactList.delete
self.addedContacts.delete
self.blockedContacts.delete
self.QObject.delete
proc newContactsView*(status: Status): ContactsView =
new(result, delete)
result.status = status
result.contactList = newContactList()
result.addedContacts = newContactList()
result.blockedContacts = newContactList()
result.contactToAdd = Profile(
username: "",
alias: "",
ensName: ""
)
result.setup
proc updateContactList*(self: ContactsView, contacts: seq[Profile]) =
for contact in contacts:
self.contactList.updateContact(contact)
if contact.systemTags.contains(":contact/added"):
self.addedContacts.updateContact(contact)
if contact.systemTags.contains(":contact/blocked"):
self.blockedContacts.updateContact(contact)
proc contactListChanged*(self: ContactsView) {.signal.}
proc getContactList(self: ContactsView): QVariant {.slot.} =
return newQVariant(self.contactList)
proc setContactList*(self: ContactsView, contactList: seq[Profile]) =
self.contactList.setNewData(contactList)
self.addedContacts.setNewData(contactList.filter(c => c.systemTags.contains(":contact/added")))
self.blockedContacts.setNewData(contactList.filter(c => c.systemTags.contains(":contact/blocked")))
self.contactListChanged()
QtProperty[QVariant] list:
read = getContactList
write = setContactList
notify = contactListChanged
proc getAddedContacts(self: ContactsView): QVariant {.slot.} =
return newQVariant(self.addedContacts)
QtProperty[QVariant] addedContacts:
read = getAddedContacts
notify = contactListChanged
proc getBlockedContacts(self: ContactsView): QVariant {.slot.} =
return newQVariant(self.blockedContacts)
QtProperty[QVariant] blockedContacts:
read = getBlockedContacts
notify = contactListChanged
proc isContactBlocked*(self: ContactsView, pubkey: string): bool {.slot.} =
for contact in self.blockedContacts.contacts:
if contact.id == pubkey:
return true
return false
proc contactToAddChanged*(self: ContactsView) {.signal.}
proc getContactToAddUsername(self: ContactsView): QVariant {.slot.} =
var username = self.contactToAdd.alias;
if self.contactToAdd.ensVerified and self.contactToAdd.ensName != "":
username = self.contactToAdd.ensName
return newQVariant(username)
QtProperty[QVariant] contactToAddUsername:
read = getContactToAddUsername
notify = contactToAddChanged
proc getContactToAddPubKey(self: ContactsView): QVariant {.slot.} =
return newQVariant(self.contactToAdd.address)
QtProperty[QVariant] contactToAddPubKey:
read = getContactToAddPubKey
notify = contactToAddChanged
proc isAdded*(self: ContactsView, id: string): bool {.slot.} =
if id == "": return false
self.status.contacts.isAdded(id)
proc lookupContact*(self: ContactsView, value: string) {.slot.} =
if value == "":
return
spawnAndSend(self, "ensResolved") do: # Call self.ensResolved(string) when ens is resolved
var id = value
if not id.startsWith("0x"):
id = status_ens.pubkey(id)
id
proc ensResolved(self: ContactsView, id: string) {.slot.} =
let contact = self.status.contacts.getContactByID(id)
if contact != nil:
self.contactToAdd = contact
else:
self.contactToAdd = Profile(
username: "",
alias: "",
ensName: "",
ensVerified: false
)
self.contactToAddChanged()
proc contactChanged(self: ContactsView, publicKey: string, isAdded: bool) {.signal.}
proc addContact*(self: ContactsView, publicKey: string): string {.slot.} =
result = self.status.contacts.addContact(publicKey)
self.contactChanged(publicKey, true)
proc changeContactNickname*(self: ContactsView, publicKey: string, nickname: string) {.slot.} =
var nicknameToSet = nickname
if (nicknameToSet == ""):
nicknameToSet = DELETE_CONTACT
discard self.status.contacts.addContact(publicKey, nicknameToSet)
proc unblockContact*(self: ContactsView, publicKey: string) {.slot.} =
self.contactListChanged()
discard self.status.contacts.unblockContact(publicKey)
proc blockContact*(self: ContactsView, publicKey: string): string {.slot.} =
self.contactListChanged()
return self.status.contacts.blockContact(publicKey)
proc removeContact*(self: ContactsView, publicKey: string) {.slot.} =
self.status.contacts.removeContact(publicKey)
self.contactChanged(publicKey, false)

View File

@ -1,6 +1,7 @@
import NimQml import NimQml
import Tables import Tables
import ../../../status/profile/devices import ../../../status/profile/devices
import ../../../status/devices as status_devices
type type
DeviceRoles {.pure.} = enum DeviceRoles {.pure.} = enum

View File

@ -0,0 +1,69 @@
import NimQml, chronicles
import ../../../status/status
import ../../../status/devices as status_devices
import ../../../status/profile/devices
import device_list
logScope:
topics = "devices-view"
QtObject:
type DevicesView* = ref object of QObject
status: Status
deviceList*: DeviceList
isDeviceSetup: bool
proc setup(self: DevicesView) =
self.QObject.setup
proc delete*(self: DevicesView) =
if not self.deviceList.isNil: self.deviceList.delete
self.QObject.delete
proc newDevicesView*(status: Status): DevicesView =
new(result, delete)
result.status = status
result.deviceList = newDeviceList()
result.isDeviceSetup = false
result.setup
proc isDeviceSetup*(self: DevicesView): bool {.slot} =
result = self.isDeviceSetup
proc deviceSetupChanged*(self: DevicesView) {.signal.}
proc setDeviceSetup*(self: DevicesView, isSetup: bool) {.slot} =
self.isDeviceSetup = isSetup
self.deviceSetupChanged()
QtProperty[bool] isSetup:
read = isDeviceSetup
notify = deviceSetupChanged
proc setName*(self: DevicesView, deviceName: string) {.slot.} =
status_devices.setDeviceName(deviceName)
self.setDeviceSetup(true)
proc syncAll*(self: DevicesView) {.slot.} =
status_devices.syncAllDevices()
proc advertise*(self: DevicesView) {.slot.} =
status_devices.advertise()
proc addDevices*(self: DevicesView, devices: seq[Installation]) =
for dev in devices:
self.deviceList.addDeviceToList(dev)
proc getDeviceList(self: DevicesView): QVariant {.slot.} =
return newQVariant(self.deviceList)
QtProperty[QVariant] list:
read = getDeviceList
proc enableInstallation*(self: DevicesView, installationId: string, enable: bool) {.slot.} =
if enable:
status_devices.enable(installationId)
else:
status_devices.disable(installationId)

View File

@ -0,0 +1,35 @@
import NimQml, chronicles
import ../../../status/status
import ../../../status/profile/mailserver
import mailservers_list
import ../../../status/libstatus/settings as status_settings
logScope:
topics = "mailservers-view"
QtObject:
type MailserversView* = ref object of QObject
status: Status
mailserversList*: MailServersList
proc setup(self: MailserversView) =
self.QObject.setup
proc delete*(self: MailserversView) =
self.mailserversList.delete
self.QObject.delete
proc newMailserversView*(status: Status): MailserversView =
new(result, delete)
result.status = status
result.mailserversList = newMailServersList()
result.setup
proc add*(self: MailserversView, mailserver: MailServer) =
self.mailserversList.add(mailserver)
proc getMailserversList(self: MailserversView): QVariant {.slot.} =
return newQVariant(self.mailserversList)
QtProperty[QVariant] list:
read = getMailserversList

View File

@ -41,7 +41,7 @@ QtObject:
MailServerRoles.Endpoint.int:"endpoint", MailServerRoles.Endpoint.int:"endpoint",
}.toTable }.toTable
proc addMailServerToList*(self: MailServersList, mailserver: MailServer) = proc add*(self: MailServersList, mailserver: MailServer) =
self.beginInsertRows(newQModelIndex(), self.mailservers.len, self.mailservers.len) self.beginInsertRows(newQModelIndex(), self.mailservers.len, self.mailservers.len)
self.mailservers.add(mailserver) self.mailservers.add(mailserver)
self.endInsertRows() self.endInsertRows()

View File

@ -0,0 +1,51 @@
import NimQml, chronicles, strutils
import ../../../status/status
import ../../../status/libstatus/settings as status_settings
import ../../../status/libstatus/types
logScope:
topics = "mnemonic-view"
QtObject:
type MnemonicView* = ref object of QObject
status: Status
proc setup(self: MnemonicView) =
self.QObject.setup
proc delete*(self: MnemonicView) =
self.QObject.delete
proc newMnemonicView*(status: Status): MnemonicView =
new(result, delete)
result.status = status
result.setup
proc isBackedUp*(self: MnemonicView): bool {.slot.} =
let mnemonic = status_settings.getSetting[string](Setting.Mnemonic, "")
return mnemonic == ""
proc seedPhraseRemoved*(self: MnemonicView) {.signal.}
QtProperty[bool] isBackedUp:
read = isBackedUp
notify = seedPhraseRemoved
proc getMnemonic*(self: MnemonicView): QVariant {.slot.} =
# Do not keep the mnemonic in memory, so fetch it when necessary
let mnemonic = status_settings.getSetting[string](Setting.Mnemonic, "")
return newQVariant(mnemonic)
QtProperty[QVariant] get:
read = getMnemonic
notify = seedPhraseRemoved
proc remove*(self: MnemonicView) {.slot.} =
discard status_settings.saveSetting(Setting.Mnemonic, "")
self.seedPhraseRemoved()
proc getWord*(self: MnemonicView, idx: int): string {.slot.} =
let mnemonics = status_settings.getSetting[string](Setting.Mnemonic, "").split(" ")
return mnemonics[idx]

View File

@ -0,0 +1,46 @@
import NimQml, chronicles
import ../../../status/status
logScope:
topics = "network-view"
QtObject:
type NetworkView* = ref object of QObject
status: Status
network: string
proc setup(self: NetworkView) =
self.QObject.setup
proc delete*(self: NetworkView) =
self.QObject.delete
proc newNetworkView*(status: Status): NetworkView =
new(result, delete)
result.status = status
result.setup
proc networkChanged*(self: NetworkView) {.signal.}
proc triggerNetworkChange*(self: NetworkView) {.slot.} =
self.networkChanged()
proc getNetwork*(self: NetworkView): QVariant {.slot.} =
return newQVariant(self.network)
proc setNetwork*(self: NetworkView, network: string) =
self.network = network
self.networkChanged()
proc setNetworkAndPersist*(self: NetworkView, network: string) {.slot.} =
self.network = network
self.networkChanged()
self.status.accounts.changeNetwork(self.status.fleet.config, network)
quit(QuitSuccess) # quits the app TODO: change this to logout instead when supported
QtProperty[QVariant] current:
read = getNetwork
write = setNetworkAndPersist
notify = networkChanged

View File

@ -47,7 +47,7 @@ Popup {
height: 8 height: 8
radius: width / 2 radius: width / 2
color: { color: {
switch (profileModel.network) { switch (profileModel.network.current) {
case Constants.networkMainnet: return Style.current.green; case Constants.networkMainnet: return Style.current.green;
case Constants.networkRopsten: return Style.current.turquoise; case Constants.networkRopsten: return Style.current.turquoise;
default: return Style.current.red default: return Style.current.red
@ -59,7 +59,7 @@ Popup {
StyledText { StyledText {
id: networkText id: networkText
text: { text: {
switch (profileModel.network) { switch (profileModel.network.current) {
case Constants.networkMainnet: return qsTr("Mainnet"); case Constants.networkMainnet: return qsTr("Mainnet");
case Constants.networkRopsten: return qsTr("Ropsten"); case Constants.networkRopsten: return qsTr("Ropsten");
default: return qsTr("Unknown") default: return qsTr("Unknown")

View File

@ -28,7 +28,7 @@ StackLayout {
chatInput.textInput.forceActiveFocus(Qt.MouseFocusReason) chatInput.textInput.forceActiveFocus(Qt.MouseFocusReason)
} }
property bool isBlocked: profileModel.isContactBlocked(chatsModel.activeChannel.id) property bool isBlocked: profileModel.contacts.isContactBlocked(chatsModel.activeChannel.id)
Component.onCompleted: { Component.onCompleted: {
@ -72,9 +72,9 @@ StackLayout {
} }
Connections { Connections {
target: profileModel target: profileModel.contacts
onContactListChanged: { onContactListChanged: {
isBlocked = profileModel.isContactBlocked(chatsModel.activeChannel.id); isBlocked = profileModel.contacts.isContactBlocked(chatsModel.activeChannel.id);
} }
} }

View File

@ -66,7 +66,7 @@ ModalPopup {
RecipientSelector { RecipientSelector {
id: selectRecipient id: selectRecipient
accounts: walletModel.accounts accounts: walletModel.accounts
contacts: profileModel.addedContacts contacts: profileModel.contacts.addedContacts
label: root.isRequested ? label: root.isRequested ?
qsTr("From") : qsTr("From") :
qsTr("To") qsTr("To")

View File

@ -96,7 +96,7 @@ ModalPopup {
id: selectRecipient id: selectRecipient
visible: false visible: false
accounts: walletModel.accounts accounts: walletModel.accounts
contacts: profileModel.addedContacts contacts: profileModel.contacts.addedContacts
selectedRecipient: root.selectedRecipient selectedRecipient: root.selectedRecipient
readOnly: true readOnly: true
} }

View File

@ -66,7 +66,7 @@ Item {
SelectedMessage.set(messageId, fromAuthor); SelectedMessage.set(messageId, fromAuthor);
} }
// Get contact nickname // Get contact nickname
const contactList = profileModel.contactList const contactList = profileModel.contacts.list
const contactCount = contactList.rowCount() const contactCount = contactList.rowCount()
let nickname = "" let nickname = ""
for (let i = 0; i < contactCount; i++) { for (let i = 0; i < contactCount; i++) {

View File

@ -64,8 +64,8 @@ SplitView {
//% "Are you sure you want to remove this contact?" //% "Are you sure you want to remove this contact?"
confirmationText: qsTrId("are-you-sure-you-want-to-remove-this-contact-") confirmationText: qsTrId("are-you-sure-you-want-to-remove-this-contact-")
onConfirmButtonClicked: { onConfirmButtonClicked: {
if (profileModel.isAdded(chatColumn.contactToRemove)) { if (profileModel.contacts.isAdded(chatColumn.contactToRemove)) {
profileModel.removeContact(chatColumn.contactToRemove) profileModel.contacts.removeContact(chatColumn.contactToRemove)
} }
removeContactConfirmationDialog.parentPopup.close(); removeContactConfirmationDialog.parentPopup.close();
removeContactConfirmationDialog.close(); removeContactConfirmationDialog.close();

View File

@ -29,16 +29,16 @@ ModalPopup {
} }
data.clear(); data.clear();
const nbContacts = profileModel.contactList.rowCount() const nbContacts = profileModel.contacts.list.rowCount()
for(let i = 0; i < nbContacts; i++){ for(let i = 0; i < nbContacts; i++){
data.append({ data.append({
name: profileModel.contactList.rowData(i, "name"), name: profileModel.contacts.list.rowData(i, "name"),
localNickname: profileModel.contactList.rowData(i, "localNickname"), localNickname: profileModel.contacts.list.rowData(i, "localNickname"),
pubKey: profileModel.contactList.rowData(i, "pubKey"), pubKey: profileModel.contacts.list.rowData(i, "pubKey"),
address: profileModel.contactList.rowData(i, "address"), address: profileModel.contacts.list.rowData(i, "address"),
identicon: profileModel.contactList.rowData(i, "identicon"), identicon: profileModel.contacts.list.rowData(i, "identicon"),
isUser: false, isUser: false,
isContact: profileModel.contactList.rowData(i, "isContact") !== "false" isContact: profileModel.contacts.list.rowData(i, "isContact") !== "false"
}); });
} }
data.append({ data.append({
@ -49,7 +49,7 @@ ModalPopup {
identicon: profileModel.profile.identicon, identicon: profileModel.profile.identicon,
isUser: true isUser: true
}); });
noContactsRect.visible = !profileModel.contactList.hasAddedContacts(); noContactsRect.visible = !profileModel.contacts.list.hasAddedContacts();
svMembers.visible = !noContactsRect.visible; svMembers.visible = !noContactsRect.visible;
if(!svMembers.visible){ if(!svMembers.visible){
memberCount = 0; memberCount = 0;

View File

@ -20,16 +20,16 @@ ModalPopup {
memberCount = chatsModel.activeChannel.members.rowCount(); memberCount = chatsModel.activeChannel.members.rowCount();
currMemberCount = memberCount; currMemberCount = memberCount;
data.clear(); data.clear();
const nbContacts = profileModel.contactList.rowCount() const nbContacts = profileModel.contacts.list.rowCount()
for(let i = 0; i < nbContacts; i++){ for(let i = 0; i < nbContacts; i++){
if(chatsModel.activeChannel.contains(profileModel.contactList.rowData(i, "pubKey"))) continue; if(chatsModel.activeChannel.contains(profileModel.contacts.list.rowData(i, "pubKey"))) continue;
if(profileModel.contactList.rowData(i, "isContact") === "false") continue; if(profileModel.contacts.list.rowData(i, "isContact") === "false") continue;
data.append({ data.append({
name: profileModel.contactList.rowData(i, "name"), name: profileModel.contacts.list.rowData(i, "name"),
localNickname: profileModel.contactList.rowData(i, "localNickname"), localNickname: profileModel.contacts.list.rowData(i, "localNickname"),
pubKey: profileModel.contactList.rowData(i, "pubKey"), pubKey: profileModel.contacts.list.rowData(i, "pubKey"),
address: profileModel.contactList.rowData(i, "address"), address: profileModel.contacts.list.rowData(i, "address"),
identicon: profileModel.contactList.rowData(i, "identicon"), identicon: profileModel.contacts.list.rowData(i, "identicon"),
isUser: false isUser: false
}); });
} }
@ -264,7 +264,7 @@ ModalPopup {
property string nickname: { property string nickname: {
// Get contact nickname // Get contact nickname
const contactList = profileModel.contactList const contactList = profileModel.contacts.list
const contactCount = contactList.rowCount() const contactCount = contactList.rowCount()
let nickname = "" let nickname = ""
for (let i = 0; i < contactCount; i++) { for (let i = 0; i < contactCount; i++) {

View File

@ -99,7 +99,7 @@ ModalPopup {
} }
} }
popup.changeNickname(nicknameInput.textField.text) popup.changeNickname(nicknameInput.textField.text)
profileModel.changeContactNickname(fromAuthor, nicknameInput.textField.text) profileModel.contacts.changeContactNickname(fromAuthor, nicknameInput.textField.text)
popup.close() popup.close()
} }
} }

View File

@ -67,7 +67,7 @@ ModalPopup {
pubKey = ""; pubKey = "";
ensUsername.text = ""; ensUsername.text = "";
chatKey.forceActiveFocus(Qt.MouseFocusReason) chatKey.forceActiveFocus(Qt.MouseFocusReason)
noContactsRect.visible = !profileModel.contactList.hasAddedContacts() noContactsRect.visible = !profileModel.contacts.list.hasAddedContacts()
} }
Input { Input {
@ -130,7 +130,7 @@ ModalPopup {
spacing: 0 spacing: 0
clip: true clip: true
id: contactListView id: contactListView
model: profileModel.contactList model: profileModel.contacts.list
delegate: Contact { delegate: Contact {
showCheckbox: false showCheckbox: false
pubKey: model.pubKey pubKey: model.pubKey

View File

@ -39,7 +39,7 @@ ModalPopup {
identicon = identiconParam || "" identicon = identiconParam || ""
text = textParam || "" text = textParam || ""
isEnsVerified = chatsModel.isEnsVerified(this.fromAuthor) isEnsVerified = chatsModel.isEnsVerified(this.fromAuthor)
isBlocked = profileModel.isContactBlocked(this.fromAuthor); isBlocked = profileModel.contacts.isContactBlocked(this.fromAuthor);
alias = chatsModel.alias(this.fromAuthor) || "" alias = chatsModel.alias(this.fromAuthor) || ""
noFooter = !showFooter; noFooter = !showFooter;
@ -146,7 +146,7 @@ ModalPopup {
BlockContactConfirmationDialog { BlockContactConfirmationDialog {
id: blockContactConfirmationDialog id: blockContactConfirmationDialog
onBlockButtonClicked: { onBlockButtonClicked: {
profileModel.blockContact(fromAuthor) profileModel.contacts.blockContact(fromAuthor)
blockContactConfirmationDialog.close(); blockContactConfirmationDialog.close();
popup.close() popup.close()
@ -160,7 +160,6 @@ ModalPopup {
profileModel.unblockContact(fromAuthor) profileModel.unblockContact(fromAuthor)
unblockContactConfirmationDialog.close(); unblockContactConfirmationDialog.close();
popup.close() popup.close()
contactUnblocked(fromAuthor) contactUnblocked(fromAuthor)
} }
} }
@ -172,8 +171,8 @@ ModalPopup {
//% "Are you sure you want to remove this contact?" //% "Are you sure you want to remove this contact?"
confirmationText: qsTrId("are-you-sure-you-want-to-remove-this-contact-") confirmationText: qsTrId("are-you-sure-you-want-to-remove-this-contact-")
onConfirmButtonClicked: { onConfirmButtonClicked: {
if (profileModel.isAdded(fromAuthor)) { if (profileModel.contacts.isAdded(fromAuthor)) {
profileModel.removeContact(fromAuthor); profileModel.contacts.removeContact(fromAuthor);
} }
removeContactConfirmationDialog.close(); removeContactConfirmationDialog.close();
popup.close(); popup.close();
@ -411,7 +410,7 @@ ModalPopup {
id: addToContactsButton id: addToContactsButton
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: Style.current.smallPadding anchors.rightMargin: Style.current.smallPadding
label: profileModel.isAdded(fromAuthor) ? label: profileModel.contacts.isAdded(fromAuthor) ?
//% "Remove Contact" //% "Remove Contact"
qsTrId("remove-contact") : qsTrId("remove-contact") :
//% "Add to contacts" //% "Add to contacts"
@ -419,11 +418,11 @@ ModalPopup {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
visible: !isBlocked visible: !isBlocked
onClicked: { onClicked: {
if (profileModel.isAdded(fromAuthor)) { if (profileModel.contacts.isAdded(fromAuthor)) {
removeContactConfirmationDialog.parentPopup = profilePopup; removeContactConfirmationDialog.parentPopup = profilePopup;
removeContactConfirmationDialog.open(); removeContactConfirmationDialog.open();
} else { } else {
profileModel.addContact(fromAuthor); profileModel.contacts.addContact(fromAuthor);
contactAdded(fromAuthor); contactAdded(fromAuthor);
profilePopup.close(); profilePopup.close();
} }

View File

@ -40,7 +40,7 @@ Rectangle {
} }
Rectangle { Rectangle {
visible: !profileModel.isMnemonicBackedUp && !active && ProfileConstants.PRIVACY_AND_SECURITY === menuItemId visible: !profileModel.mnemonic.isBackedUp && !active && ProfileConstants.PRIVACY_AND_SECURITY === menuItemId
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.right: menuButton.right anchors.right: menuButton.right
anchors.rightMargin: 10 anchors.rightMargin: 10

View File

@ -106,7 +106,7 @@ Item {
} }
StyledText { StyledText {
text: Utils.getNetworkName(profileModel.network) text: Utils.getNetworkName(profileModel.network.current)
font.pixelSize: 15 font.pixelSize: 15
anchors.right: caret3.left anchors.right: caret3.left
anchors.rightMargin: Style.current.padding anchors.rightMargin: Style.current.padding

View File

@ -64,7 +64,7 @@ ModalPopup {
Repeater { Repeater {
id: mnemonicRepeater id: mnemonicRepeater
model: profileModel.mnemonic.split(" ") model: profileModel.mnemonic.get.split(" ")
Rectangle { Rectangle {
id: word id: word
height: 40 height: 40
@ -178,7 +178,7 @@ ModalPopup {
title: qsTr("Are you sure?") title: qsTr("Are you sure?")
confirmationText: qsTr("You will not be able to see the whole seed phrase again") confirmationText: qsTr("You will not be able to see the whole seed phrase again")
onConfirmButtonClicked: { onConfirmButtonClicked: {
profileModel.removeSeedPhrase() profileModel.mnemonic.remove()
popup.close(); popup.close();
removeSeedPhraseConfirm.close(); removeSeedPhraseConfirm.close();
} }
@ -226,7 +226,7 @@ ModalPopup {
seedWord1Idx = Math.floor(Math.random() * 12); seedWord1Idx = Math.floor(Math.random() * 12);
} else { } else {
if(seedWord2Idx == -1){ if(seedWord2Idx == -1){
if(profileModel.getMnemonicWord(seedWord1Idx) !== txtFieldWord.text){ if(profileModel.mnemonic.getWord(seedWord1Idx) !== txtFieldWord.text){
validationError = qsTr("Wrong word"); validationError = qsTr("Wrong word");
return; return;
} }
@ -238,7 +238,7 @@ ModalPopup {
seedWord2Idx = Math.floor(Math.random() * 12); seedWord2Idx = Math.floor(Math.random() * 12);
} while(seedWord2Idx == seedWord1Idx); } while(seedWord2Idx == seedWord1Idx);
} else { } else {
if(profileModel.getMnemonicWord(seedWord2Idx) !== txtFieldWord.text){ if(profileModel.mnemonic.getWord(seedWord2Idx) !== txtFieldWord.text){
validationError = qsTr("Wrong word"); validationError = qsTr("Wrong word");
return; return;
} }

View File

@ -137,7 +137,7 @@ Rectangle {
text: qsTrId("unblock-user") text: qsTrId("unblock-user")
enabled: container.isBlocked enabled: container.isBlocked
onTriggered: { onTriggered: {
profileModel.unblockContact(address) profileModel.contacts.unblockContact(address)
contactContextMenu.close() contactContextMenu.close()
} }
} }

View File

@ -52,7 +52,7 @@ ListView {
BlockContactConfirmationDialog { BlockContactConfirmationDialog {
id: blockContactConfirmationDialog id: blockContactConfirmationDialog
onBlockButtonClicked: { onBlockButtonClicked: {
profileModel.blockContact(blockContactConfirmationDialog.contactAddress) profileModel.contacts.blockContact(blockContactConfirmationDialog.contactAddress)
blockContactConfirmationDialog.close() blockContactConfirmationDialog.close()
} }
} }
@ -64,8 +64,8 @@ ListView {
//% "Are you sure you want to remove this contact?" //% "Are you sure you want to remove this contact?"
confirmationText: qsTrId("are-you-sure-you-want-to-remove-this-contact-") confirmationText: qsTrId("are-you-sure-you-want-to-remove-this-contact-")
onConfirmButtonClicked: { onConfirmButtonClicked: {
if (profileModel.isAdded(removeContactConfirmationDialog.value)) { if (profileModel.contacts.isAdded(removeContactConfirmationDialog.value)) {
profileModel.removeContact(removeContactConfirmationDialog.value); profileModel.contacts.removeContact(removeContactConfirmationDialog.value);
} }
removeContactConfirmationDialog.close() removeContactConfirmationDialog.close()
} }

View File

@ -99,13 +99,13 @@ Item {
ContactList { ContactList {
anchors.top: parent.top anchors.top: parent.top
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
contacts: profileModel.blockedContacts contacts: profileModel.contacts.blockedContacts
selectable: false selectable: false
} }
} }
Connections { Connections {
target: profileModel target: profileModel.contacts
onContactToAddChanged: { onContactToAddChanged: {
contactsContainer.isPending = false contactsContainer.isPending = false
} }
@ -125,7 +125,7 @@ Item {
title: qsTrId("add-contact") title: qsTrId("add-contact")
property var lookupContact: Backpressure.debounce(addContactSearchInput, 400, function (value) { property var lookupContact: Backpressure.debounce(addContactSearchInput, 400, function (value) {
profileModel.lookupContact(value) profileModel.contacts.lookupContact(value)
}) })
onOpened: { onOpened: {
@ -140,7 +140,7 @@ Item {
fontPixelSize: 15 fontPixelSize: 15
onEditingFinished: { onEditingFinished: {
contactsContainer.isPending = true contactsContainer.isPending = true
profileModel.lookupContact(inputValue) profileModel.contacts.lookupContact(inputValue)
contactsContainer.isPending = false contactsContainer.isPending = false
} }
onTextChanged: { onTextChanged: {
@ -177,26 +177,26 @@ Item {
color: Style.current.darkGrey color: Style.current.darkGrey
//% "User not found" //% "User not found"
text: qsTrId("user-not-found") text: qsTrId("user-not-found")
visible: !contactsContainer.isPending && !!!profileModel.contactToAddUsername visible: !contactsContainer.isPending && !!!profileModel.contacts.contactToAddUsername
} }
StyledText { StyledText {
id: contactUsername id: contactUsername
text: profileModel.contactToAddUsername + " • " text: profileModel.contacts.contactToAddUsername + " • "
font.pixelSize: 12 font.pixelSize: 12
color: Style.current.darkGrey color: Style.current.darkGrey
visible: !!profileModel.contactToAddPubKey visible: !!profileModel.contacts.contactToAddPubKey
} }
StyledText { StyledText {
id: contactPubKey id: contactPubKey
text: profileModel.contactToAddPubKey text: profileModel.contacts.contactToAddPubKey
anchors.left: contactUsername.right anchors.left: contactUsername.right
width: 100 width: 100
font.pixelSize: 12 font.pixelSize: 12
elide: Text.ElideMiddle elide: Text.ElideMiddle
color: Style.current.darkGrey color: Style.current.darkGrey
visible: !!profileModel.contactToAddPubKey visible: !!profileModel.contacts.contactToAddPubKey
} }
} }
@ -208,7 +208,7 @@ Item {
disabled: !contactToAddInfo.visible disabled: !contactToAddInfo.visible
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
onClicked: { onClicked: {
profileModel.addContact(profileModel.contactToAddPubKey); profileModel.addContact(profileModel.contacts.contactToAddPubKey);
addContactModal.close() addContactModal.close()
} }
} }
@ -219,14 +219,14 @@ Item {
anchors.top: blockedContactsButton.bottom anchors.top: blockedContactsButton.bottom
anchors.topMargin: Style.current.bigPadding anchors.topMargin: Style.current.bigPadding
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
contacts: profileModel.addedContacts contacts: profileModel.contacts.addedContacts
selectable: false selectable: false
searchString: searchBox.text searchString: searchBox.text
} }
Item { Item {
id: element id: element
visible: profileModel.contactList.rowCount() === 0 visible: profileModel.contacts.list.rowCount() === 0
anchors.fill: parent anchors.fill: parent
StyledText { StyledText {

View File

@ -35,7 +35,7 @@ Item {
anchors.topMargin: Style.current.padding anchors.topMargin: Style.current.padding
anchors.right: syncContainer.right anchors.right: syncContainer.right
anchors.rightMargin: Style.current.padding anchors.rightMargin: Style.current.padding
visible: !profileModel.deviceSetup visible: !profileModel.devices.isSetup
StyledText { StyledText {
id: deviceNameLbl id: deviceNameLbl
@ -59,7 +59,7 @@ Item {
//% "Continue" //% "Continue"
label: qsTrId("continue") label: qsTrId("continue")
disabled: deviceNameTxt.text === "" disabled: deviceNameTxt.text === ""
onClicked : profileModel.setDeviceName(deviceNameTxt.text.trim()) onClicked : profileModel.devices.setName(deviceNameTxt.text.trim())
} }
} }
@ -71,7 +71,7 @@ Item {
anchors.topMargin: Style.current.padding anchors.topMargin: Style.current.padding
anchors.right: syncContainer.right anchors.right: syncContainer.right
anchors.rightMargin: Style.current.padding anchors.rightMargin: Style.current.padding
visible: profileModel.deviceSetup visible: profileModel.devices.isSetup
height: childrenRect.height height: childrenRect.height
Rectangle { Rectangle {
@ -116,7 +116,7 @@ Item {
MouseArea { MouseArea {
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
anchors.fill: parent anchors.fill: parent
onClicked: profileModel.advertiseDevice() onClicked: profileModel.devices.advertise()
} }
} }
@ -147,7 +147,7 @@ Item {
anchors.bottomMargin: Style.current.padding anchors.bottomMargin: Style.current.padding
anchors.right: syncContainer.right anchors.right: syncContainer.right
anchors.rightMargin: Style.current.padding anchors.rightMargin: Style.current.padding
visible: profileModel.deviceSetup visible: profileModel.devices.isSetup
StyledText { StyledText {
@ -195,10 +195,10 @@ Item {
anchors.left: deviceItemLbl.right anchors.left: deviceItemLbl.right
anchors.leftMargin: Style.current.padding anchors.leftMargin: Style.current.padding
anchors.top: deviceItemLbl.top anchors.top: deviceItemLbl.top
onClicked: profileModel.enableInstallation(model.installationId, devicePairedSwitch) onClicked: profileModel.devices.enableInstallation(model.installationId, devicePairedSwitch)
} }
} }
model: profileModel.deviceList model: profileModel.devices.list
} }
} }
@ -215,7 +215,7 @@ Item {
disabled: isSyncing disabled: isSyncing
onClicked : { onClicked : {
isSyncing = true; isSyncing = true;
profileModel.syncAllDevices() profileModel.devices.syncAll()
// Currently we don't know how long it takes, so we just disable for 10s, to avoid spamming // Currently we don't know how long it takes, so we just disable for 10s, to avoid spamming
timer.setTimeout(function(){ timer.setTimeout(function(){
isSyncing = false isSyncing = false

View File

@ -77,7 +77,7 @@ ModalPopup {
id: selectRecipient id: selectRecipient
visible: false visible: false
accounts: walletModel.accounts accounts: walletModel.accounts
contacts: profileModel.addedContacts contacts: profileModel.contacts.addedContacts
selectedRecipient: { "address": utilsModel.ensRegisterAddress, "type": RecipientSelector.Type.Address } selectedRecipient: { "address": utilsModel.ensRegisterAddress, "type": RecipientSelector.Type.Address }
readOnly: true readOnly: true
onSelectedRecipientChanged: if (isValid) { gasSelector.estimateGas() } onSelectedRecipientChanged: if (isValid) { gasSelector.estimateGas() }

View File

@ -81,7 +81,7 @@ ModalPopup {
id: selectRecipient id: selectRecipient
visible: false visible: false
accounts: walletModel.accounts accounts: walletModel.accounts
contacts: profileModel.addedContacts contacts: profileModel.contacts.addedContacts
selectedRecipient: { "address": utilsModel.ensRegisterAddress, "type": RecipientSelector.Type.Address } selectedRecipient: { "address": utilsModel.ensRegisterAddress, "type": RecipientSelector.Type.Address }
readOnly: true readOnly: true
onSelectedRecipientChanged: if (isValid) { gasSelector.estimateGas() } onSelectedRecipientChanged: if (isValid) { gasSelector.estimateGas() }

View File

@ -282,7 +282,7 @@ Item {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.bottomMargin: Style.current.padding anchors.bottomMargin: Style.current.padding
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
disabled: profileModel.network !== Constants.networkMainnet // Comment this to use on testnet disabled: profileModel.network.current !== Constants.networkMainnet // Comment this to use on testnet
//% "Start" //% "Start"
label: !disabled ? label: !disabled ?
qsTrId("start") : qsTrId("start") :

View File

@ -26,7 +26,7 @@ Item {
signal goToList(); signal goToList();
function goToStart(){ /* Comment this to use on testnet */ function goToStart(){ /* Comment this to use on testnet */
if(profileModel.ens.rowCount() > 0 && profileModel.network === "mainnet_rpc"){ if(profileModel.ens.rowCount() > 0 && profileModel.network.current === "mainnet_rpc"){
goToList(); goToList();
} else { } else {
goToWelcome(); goToWelcome();

View File

@ -14,9 +14,9 @@ RowLayout {
title: qsTr("Warning!") title: qsTr("Warning!")
confirmationText: qsTr("The account will be logged out. When you unlock it again, the selected network will be used") confirmationText: qsTr("The account will be logged out. When you unlock it again, the selected network will be used")
onConfirmButtonClicked: { onConfirmButtonClicked: {
profileModel.network = newNetwork; profileModel.network.current = newNetwork;
} }
onClosed: profileModel.triggerNetworkChange() onClosed: profileModel.network.triggerNetworkChange()
} }
width: parent.width width: parent.width
@ -29,9 +29,9 @@ RowLayout {
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
ButtonGroup.group: networkSettings ButtonGroup.group: networkSettings
rightPadding: 0 rightPadding: 0
checked: profileModel.network === network checked: profileModel.network.current === network
onClicked: { onClicked: {
if (profileModel.network === network) return; if (profileModel.network.current === network) return;
newNetwork = network; newNetwork = network;
confirmDialog.open(); confirmDialog.open();
} }

View File

@ -74,7 +74,7 @@ Item {
Rectangle { Rectangle {
id: badge id: badge
visible: !profileModel.isMnemonicBackedUp visible: !profileModel.mnemonic.isBackedUp
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: 0 anchors.rightMargin: 0
@ -91,10 +91,10 @@ Item {
} }
MouseArea { MouseArea {
enabled: !profileModel.isMnemonicBackedUp enabled: !profileModel.mnemonic.isBackedUp
anchors.fill: parent anchors.fill: parent
onClicked: backupSeedModal.open() onClicked: backupSeedModal.open()
cursorShape: enabled && Qt.PointingHandCursor cursorShape: enabled ? Qt.PointingHandCursor : Qt.ArrowCursor
} }
} }

View File

@ -36,7 +36,7 @@ Item {
anchors.topMargin: 48 anchors.topMargin: 48
anchors.top: element4.bottom anchors.top: element4.bottom
anchors.fill: parent anchors.fill: parent
model: profileModel.mailserversList model: profileModel.mailservers.list
delegate: mailserversList delegate: mailserversList
} }
} }

View File

@ -7,7 +7,7 @@ import "../Profile/Sections"
import "." import "."
Rectangle { Rectangle {
visible: !profileModel.isMnemonicBackedUp visible: !profileModel.mnemonic.isBackedUp
height: visible ? 32 : 0 height: visible ? 32 : 0
Layout.fillWidth: true Layout.fillWidth: true
color: Style.current.red color: Style.current.red

View File

@ -71,7 +71,7 @@ ModalPopup {
RecipientSelector { RecipientSelector {
id: selectRecipient id: selectRecipient
accounts: walletModel.accounts accounts: walletModel.accounts
contacts: profileModel.addedContacts contacts: profileModel.contacts.addedContacts
//% "Recipient" //% "Recipient"
label: qsTrId("recipient") label: qsTrId("recipient")
anchors.top: separator.bottom anchors.top: separator.bottom

View File

@ -138,7 +138,7 @@ RowLayout {
Rectangle { Rectangle {
id: profileBadge id: profileBadge
visible: !profileModel.isMnemonicBackedUp && sLayout.children[sLayout.currentIndex] !== profileLayoutContainer visible: !profileModel.mnemonic.isBackedUp && sLayout.children[sLayout.currentIndex] !== profileLayoutContainer
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.right anchors.left: parent.right
anchors.leftMargin: -10 anchors.leftMargin: -10

View File

@ -51,7 +51,7 @@ Item {
Connections { Connections {
target: profileModel target: profileModel.contacts
onContactChanged: { onContactChanged: {
if(root.chatId === publicKey){ if(root.chatId === publicKey){
// Hack warning: Triggering reload to avoid changing the current text binding // Hack warning: Triggering reload to avoid changing the current text binding
@ -69,7 +69,7 @@ Item {
switch(root.chatType){ switch(root.chatType){
//% "Public chat" //% "Public chat"
case Constants.chatTypePublic: return qsTrId("public-chat") case Constants.chatTypePublic: return qsTrId("public-chat")
case Constants.chatTypeOneToOne: return (profileModel.isAdded(root.chatId) ? case Constants.chatTypeOneToOne: return (profileModel.contacts.isAdded(root.chatId) ?
//% "Contact" //% "Contact"
qsTrId("chat-is-a-contact") : qsTrId("chat-is-a-contact") :
//% "Not a contact" //% "Not a contact"

View File

@ -738,7 +738,7 @@ Rectangle {
anchors.leftMargin: 2 anchors.leftMargin: 2
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
icon.name: "stickers_icon" icon.name: "stickers_icon"
visible: profileModel.network === Constants.networkMainnet visible: profileModel.network.current === Constants.networkMainnet
width: visible ? 32 : 0 width: visible ? 32 : 0
type: "secondary" type: "secondary"
onClicked: { onClicked: {

View File

@ -81,7 +81,7 @@ ModalPopup {
id: selectRecipient id: selectRecipient
visible: false visible: false
accounts: walletModel.accounts accounts: walletModel.accounts
contacts: profileModel.addedContacts contacts: profileModel.contacts.addedContacts
selectedRecipient: { "address": utilsModel.stickerMarketAddress, "type": RecipientSelector.Type.Address } selectedRecipient: { "address": utilsModel.stickerMarketAddress, "type": RecipientSelector.Type.Address }
readOnly: true readOnly: true
onSelectedRecipientChanged: if (isValid) { gasSelector.estimateGas() } onSelectedRecipientChanged: if (isValid) { gasSelector.estimateGas() }