refactor: ProfileView
This commit is contained in:
parent
426fe504b4
commit
ae30d04010
|
@ -6,14 +6,15 @@ import ../../status/libstatus/accounts/constants
|
|||
import ../../status/libstatus/types as status_types
|
||||
import ../../status/libstatus/settings as status_settings
|
||||
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/devices
|
||||
import ../../status/devices as status_devices
|
||||
import ../../status/chat/chat
|
||||
import ../../status/wallet
|
||||
import ../../eventemitter
|
||||
import view
|
||||
import views/ens_manager
|
||||
import views/[ens_manager, devices, network, mailservers, contacts]
|
||||
import ../chat/views/channels_list
|
||||
import chronicles
|
||||
|
||||
|
@ -42,19 +43,19 @@ proc init*(self: ProfileController, account: Account) =
|
|||
profile.id = pubKey
|
||||
profile.address = account.keyUid
|
||||
|
||||
self.view.addDevices(devices.getAllDevices())
|
||||
self.view.setDeviceSetup(devices.isDeviceSetup())
|
||||
self.view.devices.addDevices(status_devices.getAllDevices())
|
||||
self.view.devices.setDeviceSetup(status_devices.isDeviceSetup())
|
||||
self.view.setNewProfile(profile)
|
||||
self.view.setNetwork(network)
|
||||
self.view.network.setNetwork(network)
|
||||
self.view.ens.init()
|
||||
|
||||
for name, endpoint in self.status.fleet.config.getMailservers(status_settings.getFleet()).pairs():
|
||||
let mailserver = MailServer(name: name, endpoint: endpoint)
|
||||
self.view.addMailServerToList(mailserver)
|
||||
self.view.mailservers.add(mailserver)
|
||||
|
||||
let contacts = self.status.contacts.getContacts()
|
||||
self.status.chat.updateContacts(contacts)
|
||||
self.view.setContactList(contacts)
|
||||
self.view.contacts.setContactList(contacts)
|
||||
|
||||
self.status.events.on("channelLoaded") do(e: Args):
|
||||
var channel = ChannelArgs(e)
|
||||
|
@ -82,28 +83,28 @@ proc init*(self: ProfileController, account: Account) =
|
|||
|
||||
self.status.events.on("contactAdded") do(e: Args):
|
||||
let contacts = self.status.contacts.getContacts()
|
||||
self.view.setContactList(contacts)
|
||||
self.view.contacts.setContactList(contacts)
|
||||
|
||||
self.status.events.on("contactBlocked") do(e: Args):
|
||||
let contacts = self.status.contacts.getContacts()
|
||||
self.view.setContactList(contacts)
|
||||
self.view.contacts.setContactList(contacts)
|
||||
|
||||
self.status.events.on("contactUnblocked") do(e: Args):
|
||||
let contacts = self.status.contacts.getContacts()
|
||||
self.view.setContactList(contacts)
|
||||
self.view.contacts.setContactList(contacts)
|
||||
|
||||
self.status.events.on("contactRemoved") do(e: Args):
|
||||
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):
|
||||
let msgData = MessageSignal(e);
|
||||
if msgData.contacts.len > 0:
|
||||
# TODO: view should react to model changes
|
||||
self.status.chat.updateContacts(msgData.contacts)
|
||||
self.view.updateContactList(msgData.contacts)
|
||||
self.view.contacts.updateContactList(msgData.contacts)
|
||||
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):
|
||||
let tx = TransactionMinedArgs(e)
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
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 ../../status/profile/[mailserver, profile, devices]
|
||||
import ../../status/profile/profile
|
||||
import ../../status/profile as status_profile
|
||||
import ../../status/contacts as status_contacts
|
||||
import ../../status/accounts as status_accounts
|
||||
import ../../status/libstatus/settings as status_settings
|
||||
import ../../status/status
|
||||
import ../../status/devices as status_devices
|
||||
import ../../status/ens as status_ens
|
||||
import ../../status/chat/chat
|
||||
import ../../status/threads
|
||||
|
@ -18,167 +17,54 @@ import qrcode/qrcode
|
|||
QtObject:
|
||||
type ProfileView* = ref object of QObject
|
||||
profile*: ProfileInfoView
|
||||
mailserversList*: MailServersList
|
||||
contactList*: ContactList
|
||||
addedContacts*: ContactList
|
||||
blockedContacts*: ContactList
|
||||
contacts*: ContactsView
|
||||
devices*: DevicesView
|
||||
mailservers*: MailserversView
|
||||
mnemonic*: MnemonicView
|
||||
mutedChats*: ChannelsList
|
||||
mutedContacts*: ChannelsList
|
||||
deviceList*: DeviceList
|
||||
dappList*: DappList
|
||||
fleets*: Fleets
|
||||
network: string
|
||||
network*: NetworkView
|
||||
status*: Status
|
||||
isDeviceSetup: bool
|
||||
changeLanguage*: proc(locale: string)
|
||||
contactToAdd*: Profile
|
||||
ens*: EnsManager
|
||||
|
||||
proc setup(self: ProfileView) =
|
||||
self.QObject.setup
|
||||
|
||||
proc delete*(self: ProfileView) =
|
||||
if not self.mailserversList.isNil: self.mailserversList.delete
|
||||
if not self.contactList.isNil: self.contactList.delete
|
||||
if not self.addedContacts.isNil: self.addedContacts.delete
|
||||
if not self.blockedContacts.isNil: self.blockedContacts.delete
|
||||
if not self.contacts.isNil: self.contacts.delete
|
||||
if not self.devices.isNil: self.devices.delete
|
||||
if not self.mutedChats.isNil: self.mutedChats.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.profile.isNil: self.profile.delete
|
||||
if not self.dappList.isNil: self.dappList.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
|
||||
|
||||
proc newProfileView*(status: Status, changeLanguage: proc(locale: string)): ProfileView =
|
||||
new(result, delete)
|
||||
result = ProfileView()
|
||||
result.profile = newProfileInfoView()
|
||||
result.mailserversList = newMailServersList()
|
||||
result.contactList = newContactList()
|
||||
result.addedContacts = newContactList()
|
||||
result.blockedContacts = newContactList()
|
||||
result.contacts = newContactsView(status)
|
||||
result.devices = newDevicesView(status)
|
||||
result.network = newNetworkView(status)
|
||||
result.mnemonic = newMnemonicView(status)
|
||||
result.mailservers = newMailserversView(status)
|
||||
result.mutedChats = newChannelsList(status)
|
||||
result.mutedContacts = newChannelsList(status)
|
||||
result.deviceList = newDeviceList()
|
||||
result.dappList = newDappList(status)
|
||||
result.ens = newEnsManager(status)
|
||||
result.fleets = newFleets(status)
|
||||
result.network = ""
|
||||
result.status = status
|
||||
result.isDeviceSetup = false
|
||||
result.changeLanguage = changeLanguage
|
||||
result.contactToAdd = Profile(
|
||||
username: "",
|
||||
alias: "",
|
||||
ensName: ""
|
||||
)
|
||||
result.status = status
|
||||
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 getProfileSettingsFile(self: ProfileView): string {.slot.} =
|
||||
|
@ -208,27 +94,6 @@ QtObject:
|
|||
read = getProfile
|
||||
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.} =
|
||||
self.status.profile.logout()
|
||||
|
||||
|
@ -238,10 +103,6 @@ QtObject:
|
|||
proc nodeVersion*(self: ProfileView): string {.slot.} =
|
||||
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.} =
|
||||
result = "data:image/svg+xml;utf8," & generateQRCodeSVG(text, 2)
|
||||
|
||||
|
@ -249,39 +110,6 @@ QtObject:
|
|||
self.profile.setAppearance(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.} =
|
||||
return newQVariant(self.dappList)
|
||||
|
||||
|
@ -300,60 +128,6 @@ QtObject:
|
|||
QtProperty[QVariant] ens:
|
||||
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.} =
|
||||
result = $(self.status.profile.getLinkPreviewWhitelist())
|
||||
|
||||
|
@ -406,3 +180,32 @@ QtObject:
|
|||
self.mutedChatsListChanged()
|
||||
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
|
||||
|
|
|
@ -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)
|
|
@ -1,6 +1,7 @@
|
|||
import NimQml
|
||||
import Tables
|
||||
import ../../../status/profile/devices
|
||||
import ../../../status/devices as status_devices
|
||||
|
||||
type
|
||||
DeviceRoles {.pure.} = enum
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
@ -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
|
|
@ -41,7 +41,7 @@ QtObject:
|
|||
MailServerRoles.Endpoint.int:"endpoint",
|
||||
}.toTable
|
||||
|
||||
proc addMailServerToList*(self: MailServersList, mailserver: MailServer) =
|
||||
proc add*(self: MailServersList, mailserver: MailServer) =
|
||||
self.beginInsertRows(newQModelIndex(), self.mailservers.len, self.mailservers.len)
|
||||
self.mailservers.add(mailserver)
|
||||
self.endInsertRows()
|
||||
|
|
|
@ -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]
|
||||
|
||||
|
|
@ -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
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ Popup {
|
|||
height: 8
|
||||
radius: width / 2
|
||||
color: {
|
||||
switch (profileModel.network) {
|
||||
switch (profileModel.network.current) {
|
||||
case Constants.networkMainnet: return Style.current.green;
|
||||
case Constants.networkRopsten: return Style.current.turquoise;
|
||||
default: return Style.current.red
|
||||
|
@ -59,7 +59,7 @@ Popup {
|
|||
StyledText {
|
||||
id: networkText
|
||||
text: {
|
||||
switch (profileModel.network) {
|
||||
switch (profileModel.network.current) {
|
||||
case Constants.networkMainnet: return qsTr("Mainnet");
|
||||
case Constants.networkRopsten: return qsTr("Ropsten");
|
||||
default: return qsTr("Unknown")
|
||||
|
|
|
@ -28,7 +28,7 @@ StackLayout {
|
|||
chatInput.textInput.forceActiveFocus(Qt.MouseFocusReason)
|
||||
}
|
||||
|
||||
property bool isBlocked: profileModel.isContactBlocked(chatsModel.activeChannel.id)
|
||||
property bool isBlocked: profileModel.contacts.isContactBlocked(chatsModel.activeChannel.id)
|
||||
|
||||
|
||||
Component.onCompleted: {
|
||||
|
@ -72,9 +72,9 @@ StackLayout {
|
|||
}
|
||||
|
||||
Connections {
|
||||
target: profileModel
|
||||
target: profileModel.contacts
|
||||
onContactListChanged: {
|
||||
isBlocked = profileModel.isContactBlocked(chatsModel.activeChannel.id);
|
||||
isBlocked = profileModel.contacts.isContactBlocked(chatsModel.activeChannel.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ ModalPopup {
|
|||
RecipientSelector {
|
||||
id: selectRecipient
|
||||
accounts: walletModel.accounts
|
||||
contacts: profileModel.addedContacts
|
||||
contacts: profileModel.contacts.addedContacts
|
||||
label: root.isRequested ?
|
||||
qsTr("From") :
|
||||
qsTr("To")
|
||||
|
|
|
@ -96,7 +96,7 @@ ModalPopup {
|
|||
id: selectRecipient
|
||||
visible: false
|
||||
accounts: walletModel.accounts
|
||||
contacts: profileModel.addedContacts
|
||||
contacts: profileModel.contacts.addedContacts
|
||||
selectedRecipient: root.selectedRecipient
|
||||
readOnly: true
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ Item {
|
|||
SelectedMessage.set(messageId, fromAuthor);
|
||||
}
|
||||
// Get contact nickname
|
||||
const contactList = profileModel.contactList
|
||||
const contactList = profileModel.contacts.list
|
||||
const contactCount = contactList.rowCount()
|
||||
let nickname = ""
|
||||
for (let i = 0; i < contactCount; i++) {
|
||||
|
|
|
@ -64,8 +64,8 @@ SplitView {
|
|||
//% "Are you sure you want to remove this contact?"
|
||||
confirmationText: qsTrId("are-you-sure-you-want-to-remove-this-contact-")
|
||||
onConfirmButtonClicked: {
|
||||
if (profileModel.isAdded(chatColumn.contactToRemove)) {
|
||||
profileModel.removeContact(chatColumn.contactToRemove)
|
||||
if (profileModel.contacts.isAdded(chatColumn.contactToRemove)) {
|
||||
profileModel.contacts.removeContact(chatColumn.contactToRemove)
|
||||
}
|
||||
removeContactConfirmationDialog.parentPopup.close();
|
||||
removeContactConfirmationDialog.close();
|
||||
|
|
|
@ -29,16 +29,16 @@ ModalPopup {
|
|||
}
|
||||
|
||||
data.clear();
|
||||
const nbContacts = profileModel.contactList.rowCount()
|
||||
const nbContacts = profileModel.contacts.list.rowCount()
|
||||
for(let i = 0; i < nbContacts; i++){
|
||||
data.append({
|
||||
name: profileModel.contactList.rowData(i, "name"),
|
||||
localNickname: profileModel.contactList.rowData(i, "localNickname"),
|
||||
pubKey: profileModel.contactList.rowData(i, "pubKey"),
|
||||
address: profileModel.contactList.rowData(i, "address"),
|
||||
identicon: profileModel.contactList.rowData(i, "identicon"),
|
||||
name: profileModel.contacts.list.rowData(i, "name"),
|
||||
localNickname: profileModel.contacts.list.rowData(i, "localNickname"),
|
||||
pubKey: profileModel.contacts.list.rowData(i, "pubKey"),
|
||||
address: profileModel.contacts.list.rowData(i, "address"),
|
||||
identicon: profileModel.contacts.list.rowData(i, "identicon"),
|
||||
isUser: false,
|
||||
isContact: profileModel.contactList.rowData(i, "isContact") !== "false"
|
||||
isContact: profileModel.contacts.list.rowData(i, "isContact") !== "false"
|
||||
});
|
||||
}
|
||||
data.append({
|
||||
|
@ -49,7 +49,7 @@ ModalPopup {
|
|||
identicon: profileModel.profile.identicon,
|
||||
isUser: true
|
||||
});
|
||||
noContactsRect.visible = !profileModel.contactList.hasAddedContacts();
|
||||
noContactsRect.visible = !profileModel.contacts.list.hasAddedContacts();
|
||||
svMembers.visible = !noContactsRect.visible;
|
||||
if(!svMembers.visible){
|
||||
memberCount = 0;
|
||||
|
|
|
@ -20,16 +20,16 @@ ModalPopup {
|
|||
memberCount = chatsModel.activeChannel.members.rowCount();
|
||||
currMemberCount = memberCount;
|
||||
data.clear();
|
||||
const nbContacts = profileModel.contactList.rowCount()
|
||||
const nbContacts = profileModel.contacts.list.rowCount()
|
||||
for(let i = 0; i < nbContacts; i++){
|
||||
if(chatsModel.activeChannel.contains(profileModel.contactList.rowData(i, "pubKey"))) continue;
|
||||
if(profileModel.contactList.rowData(i, "isContact") === "false") continue;
|
||||
if(chatsModel.activeChannel.contains(profileModel.contacts.list.rowData(i, "pubKey"))) continue;
|
||||
if(profileModel.contacts.list.rowData(i, "isContact") === "false") continue;
|
||||
data.append({
|
||||
name: profileModel.contactList.rowData(i, "name"),
|
||||
localNickname: profileModel.contactList.rowData(i, "localNickname"),
|
||||
pubKey: profileModel.contactList.rowData(i, "pubKey"),
|
||||
address: profileModel.contactList.rowData(i, "address"),
|
||||
identicon: profileModel.contactList.rowData(i, "identicon"),
|
||||
name: profileModel.contacts.list.rowData(i, "name"),
|
||||
localNickname: profileModel.contacts.list.rowData(i, "localNickname"),
|
||||
pubKey: profileModel.contacts.list.rowData(i, "pubKey"),
|
||||
address: profileModel.contacts.list.rowData(i, "address"),
|
||||
identicon: profileModel.contacts.list.rowData(i, "identicon"),
|
||||
isUser: false
|
||||
});
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ ModalPopup {
|
|||
|
||||
property string nickname: {
|
||||
// Get contact nickname
|
||||
const contactList = profileModel.contactList
|
||||
const contactList = profileModel.contacts.list
|
||||
const contactCount = contactList.rowCount()
|
||||
let nickname = ""
|
||||
for (let i = 0; i < contactCount; i++) {
|
||||
|
|
|
@ -99,7 +99,7 @@ ModalPopup {
|
|||
}
|
||||
}
|
||||
popup.changeNickname(nicknameInput.textField.text)
|
||||
profileModel.changeContactNickname(fromAuthor, nicknameInput.textField.text)
|
||||
profileModel.contacts.changeContactNickname(fromAuthor, nicknameInput.textField.text)
|
||||
popup.close()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ ModalPopup {
|
|||
pubKey = "";
|
||||
ensUsername.text = "";
|
||||
chatKey.forceActiveFocus(Qt.MouseFocusReason)
|
||||
noContactsRect.visible = !profileModel.contactList.hasAddedContacts()
|
||||
noContactsRect.visible = !profileModel.contacts.list.hasAddedContacts()
|
||||
}
|
||||
|
||||
Input {
|
||||
|
@ -130,7 +130,7 @@ ModalPopup {
|
|||
spacing: 0
|
||||
clip: true
|
||||
id: contactListView
|
||||
model: profileModel.contactList
|
||||
model: profileModel.contacts.list
|
||||
delegate: Contact {
|
||||
showCheckbox: false
|
||||
pubKey: model.pubKey
|
||||
|
|
|
@ -39,7 +39,7 @@ ModalPopup {
|
|||
identicon = identiconParam || ""
|
||||
text = textParam || ""
|
||||
isEnsVerified = chatsModel.isEnsVerified(this.fromAuthor)
|
||||
isBlocked = profileModel.isContactBlocked(this.fromAuthor);
|
||||
isBlocked = profileModel.contacts.isContactBlocked(this.fromAuthor);
|
||||
alias = chatsModel.alias(this.fromAuthor) || ""
|
||||
|
||||
noFooter = !showFooter;
|
||||
|
@ -146,7 +146,7 @@ ModalPopup {
|
|||
BlockContactConfirmationDialog {
|
||||
id: blockContactConfirmationDialog
|
||||
onBlockButtonClicked: {
|
||||
profileModel.blockContact(fromAuthor)
|
||||
profileModel.contacts.blockContact(fromAuthor)
|
||||
blockContactConfirmationDialog.close();
|
||||
popup.close()
|
||||
|
||||
|
@ -160,7 +160,6 @@ ModalPopup {
|
|||
profileModel.unblockContact(fromAuthor)
|
||||
unblockContactConfirmationDialog.close();
|
||||
popup.close()
|
||||
|
||||
contactUnblocked(fromAuthor)
|
||||
}
|
||||
}
|
||||
|
@ -172,8 +171,8 @@ ModalPopup {
|
|||
//% "Are you sure you want to remove this contact?"
|
||||
confirmationText: qsTrId("are-you-sure-you-want-to-remove-this-contact-")
|
||||
onConfirmButtonClicked: {
|
||||
if (profileModel.isAdded(fromAuthor)) {
|
||||
profileModel.removeContact(fromAuthor);
|
||||
if (profileModel.contacts.isAdded(fromAuthor)) {
|
||||
profileModel.contacts.removeContact(fromAuthor);
|
||||
}
|
||||
removeContactConfirmationDialog.close();
|
||||
popup.close();
|
||||
|
@ -411,7 +410,7 @@ ModalPopup {
|
|||
id: addToContactsButton
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: Style.current.smallPadding
|
||||
label: profileModel.isAdded(fromAuthor) ?
|
||||
label: profileModel.contacts.isAdded(fromAuthor) ?
|
||||
//% "Remove Contact"
|
||||
qsTrId("remove-contact") :
|
||||
//% "Add to contacts"
|
||||
|
@ -419,11 +418,11 @@ ModalPopup {
|
|||
anchors.bottom: parent.bottom
|
||||
visible: !isBlocked
|
||||
onClicked: {
|
||||
if (profileModel.isAdded(fromAuthor)) {
|
||||
if (profileModel.contacts.isAdded(fromAuthor)) {
|
||||
removeContactConfirmationDialog.parentPopup = profilePopup;
|
||||
removeContactConfirmationDialog.open();
|
||||
} else {
|
||||
profileModel.addContact(fromAuthor);
|
||||
profileModel.contacts.addContact(fromAuthor);
|
||||
contactAdded(fromAuthor);
|
||||
profilePopup.close();
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ 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.right: menuButton.right
|
||||
anchors.rightMargin: 10
|
||||
|
|
|
@ -106,7 +106,7 @@ Item {
|
|||
}
|
||||
|
||||
StyledText {
|
||||
text: Utils.getNetworkName(profileModel.network)
|
||||
text: Utils.getNetworkName(profileModel.network.current)
|
||||
font.pixelSize: 15
|
||||
anchors.right: caret3.left
|
||||
anchors.rightMargin: Style.current.padding
|
||||
|
|
|
@ -64,7 +64,7 @@ ModalPopup {
|
|||
|
||||
Repeater {
|
||||
id: mnemonicRepeater
|
||||
model: profileModel.mnemonic.split(" ")
|
||||
model: profileModel.mnemonic.get.split(" ")
|
||||
Rectangle {
|
||||
id: word
|
||||
height: 40
|
||||
|
@ -178,7 +178,7 @@ ModalPopup {
|
|||
title: qsTr("Are you sure?")
|
||||
confirmationText: qsTr("You will not be able to see the whole seed phrase again")
|
||||
onConfirmButtonClicked: {
|
||||
profileModel.removeSeedPhrase()
|
||||
profileModel.mnemonic.remove()
|
||||
popup.close();
|
||||
removeSeedPhraseConfirm.close();
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ ModalPopup {
|
|||
seedWord1Idx = Math.floor(Math.random() * 12);
|
||||
} else {
|
||||
if(seedWord2Idx == -1){
|
||||
if(profileModel.getMnemonicWord(seedWord1Idx) !== txtFieldWord.text){
|
||||
if(profileModel.mnemonic.getWord(seedWord1Idx) !== txtFieldWord.text){
|
||||
validationError = qsTr("Wrong word");
|
||||
return;
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ ModalPopup {
|
|||
seedWord2Idx = Math.floor(Math.random() * 12);
|
||||
} while(seedWord2Idx == seedWord1Idx);
|
||||
} else {
|
||||
if(profileModel.getMnemonicWord(seedWord2Idx) !== txtFieldWord.text){
|
||||
if(profileModel.mnemonic.getWord(seedWord2Idx) !== txtFieldWord.text){
|
||||
validationError = qsTr("Wrong word");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -137,7 +137,7 @@ Rectangle {
|
|||
text: qsTrId("unblock-user")
|
||||
enabled: container.isBlocked
|
||||
onTriggered: {
|
||||
profileModel.unblockContact(address)
|
||||
profileModel.contacts.unblockContact(address)
|
||||
contactContextMenu.close()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ ListView {
|
|||
BlockContactConfirmationDialog {
|
||||
id: blockContactConfirmationDialog
|
||||
onBlockButtonClicked: {
|
||||
profileModel.blockContact(blockContactConfirmationDialog.contactAddress)
|
||||
profileModel.contacts.blockContact(blockContactConfirmationDialog.contactAddress)
|
||||
blockContactConfirmationDialog.close()
|
||||
}
|
||||
}
|
||||
|
@ -64,8 +64,8 @@ ListView {
|
|||
//% "Are you sure you want to remove this contact?"
|
||||
confirmationText: qsTrId("are-you-sure-you-want-to-remove-this-contact-")
|
||||
onConfirmButtonClicked: {
|
||||
if (profileModel.isAdded(removeContactConfirmationDialog.value)) {
|
||||
profileModel.removeContact(removeContactConfirmationDialog.value);
|
||||
if (profileModel.contacts.isAdded(removeContactConfirmationDialog.value)) {
|
||||
profileModel.contacts.removeContact(removeContactConfirmationDialog.value);
|
||||
}
|
||||
removeContactConfirmationDialog.close()
|
||||
}
|
||||
|
|
|
@ -99,13 +99,13 @@ Item {
|
|||
ContactList {
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
contacts: profileModel.blockedContacts
|
||||
contacts: profileModel.contacts.blockedContacts
|
||||
selectable: false
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: profileModel
|
||||
target: profileModel.contacts
|
||||
onContactToAddChanged: {
|
||||
contactsContainer.isPending = false
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ Item {
|
|||
title: qsTrId("add-contact")
|
||||
|
||||
property var lookupContact: Backpressure.debounce(addContactSearchInput, 400, function (value) {
|
||||
profileModel.lookupContact(value)
|
||||
profileModel.contacts.lookupContact(value)
|
||||
})
|
||||
|
||||
onOpened: {
|
||||
|
@ -140,7 +140,7 @@ Item {
|
|||
fontPixelSize: 15
|
||||
onEditingFinished: {
|
||||
contactsContainer.isPending = true
|
||||
profileModel.lookupContact(inputValue)
|
||||
profileModel.contacts.lookupContact(inputValue)
|
||||
contactsContainer.isPending = false
|
||||
}
|
||||
onTextChanged: {
|
||||
|
@ -177,26 +177,26 @@ Item {
|
|||
color: Style.current.darkGrey
|
||||
//% "User not found"
|
||||
text: qsTrId("user-not-found")
|
||||
visible: !contactsContainer.isPending && !!!profileModel.contactToAddUsername
|
||||
visible: !contactsContainer.isPending && !!!profileModel.contacts.contactToAddUsername
|
||||
}
|
||||
|
||||
StyledText {
|
||||
id: contactUsername
|
||||
text: profileModel.contactToAddUsername + " • "
|
||||
text: profileModel.contacts.contactToAddUsername + " • "
|
||||
font.pixelSize: 12
|
||||
color: Style.current.darkGrey
|
||||
visible: !!profileModel.contactToAddPubKey
|
||||
visible: !!profileModel.contacts.contactToAddPubKey
|
||||
}
|
||||
|
||||
StyledText {
|
||||
id: contactPubKey
|
||||
text: profileModel.contactToAddPubKey
|
||||
text: profileModel.contacts.contactToAddPubKey
|
||||
anchors.left: contactUsername.right
|
||||
width: 100
|
||||
font.pixelSize: 12
|
||||
elide: Text.ElideMiddle
|
||||
color: Style.current.darkGrey
|
||||
visible: !!profileModel.contactToAddPubKey
|
||||
visible: !!profileModel.contacts.contactToAddPubKey
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ Item {
|
|||
disabled: !contactToAddInfo.visible
|
||||
anchors.bottom: parent.bottom
|
||||
onClicked: {
|
||||
profileModel.addContact(profileModel.contactToAddPubKey);
|
||||
profileModel.addContact(profileModel.contacts.contactToAddPubKey);
|
||||
addContactModal.close()
|
||||
}
|
||||
}
|
||||
|
@ -219,14 +219,14 @@ Item {
|
|||
anchors.top: blockedContactsButton.bottom
|
||||
anchors.topMargin: Style.current.bigPadding
|
||||
anchors.bottom: parent.bottom
|
||||
contacts: profileModel.addedContacts
|
||||
contacts: profileModel.contacts.addedContacts
|
||||
selectable: false
|
||||
searchString: searchBox.text
|
||||
}
|
||||
|
||||
Item {
|
||||
id: element
|
||||
visible: profileModel.contactList.rowCount() === 0
|
||||
visible: profileModel.contacts.list.rowCount() === 0
|
||||
anchors.fill: parent
|
||||
|
||||
StyledText {
|
||||
|
|
|
@ -35,7 +35,7 @@ Item {
|
|||
anchors.topMargin: Style.current.padding
|
||||
anchors.right: syncContainer.right
|
||||
anchors.rightMargin: Style.current.padding
|
||||
visible: !profileModel.deviceSetup
|
||||
visible: !profileModel.devices.isSetup
|
||||
|
||||
StyledText {
|
||||
id: deviceNameLbl
|
||||
|
@ -59,7 +59,7 @@ Item {
|
|||
//% "Continue"
|
||||
label: qsTrId("continue")
|
||||
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.right: syncContainer.right
|
||||
anchors.rightMargin: Style.current.padding
|
||||
visible: profileModel.deviceSetup
|
||||
visible: profileModel.devices.isSetup
|
||||
height: childrenRect.height
|
||||
|
||||
Rectangle {
|
||||
|
@ -116,7 +116,7 @@ Item {
|
|||
MouseArea {
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
anchors.fill: parent
|
||||
onClicked: profileModel.advertiseDevice()
|
||||
onClicked: profileModel.devices.advertise()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ Item {
|
|||
anchors.bottomMargin: Style.current.padding
|
||||
anchors.right: syncContainer.right
|
||||
anchors.rightMargin: Style.current.padding
|
||||
visible: profileModel.deviceSetup
|
||||
visible: profileModel.devices.isSetup
|
||||
|
||||
|
||||
StyledText {
|
||||
|
@ -195,10 +195,10 @@ Item {
|
|||
anchors.left: deviceItemLbl.right
|
||||
anchors.leftMargin: Style.current.padding
|
||||
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
|
||||
onClicked : {
|
||||
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
|
||||
timer.setTimeout(function(){
|
||||
isSyncing = false
|
||||
|
|
|
@ -77,7 +77,7 @@ ModalPopup {
|
|||
id: selectRecipient
|
||||
visible: false
|
||||
accounts: walletModel.accounts
|
||||
contacts: profileModel.addedContacts
|
||||
contacts: profileModel.contacts.addedContacts
|
||||
selectedRecipient: { "address": utilsModel.ensRegisterAddress, "type": RecipientSelector.Type.Address }
|
||||
readOnly: true
|
||||
onSelectedRecipientChanged: if (isValid) { gasSelector.estimateGas() }
|
||||
|
|
|
@ -81,7 +81,7 @@ ModalPopup {
|
|||
id: selectRecipient
|
||||
visible: false
|
||||
accounts: walletModel.accounts
|
||||
contacts: profileModel.addedContacts
|
||||
contacts: profileModel.contacts.addedContacts
|
||||
selectedRecipient: { "address": utilsModel.ensRegisterAddress, "type": RecipientSelector.Type.Address }
|
||||
readOnly: true
|
||||
onSelectedRecipientChanged: if (isValid) { gasSelector.estimateGas() }
|
||||
|
|
|
@ -282,7 +282,7 @@ Item {
|
|||
anchors.bottom: parent.bottom
|
||||
anchors.bottomMargin: Style.current.padding
|
||||
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"
|
||||
label: !disabled ?
|
||||
qsTrId("start") :
|
||||
|
|
|
@ -26,7 +26,7 @@ Item {
|
|||
signal goToList();
|
||||
|
||||
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();
|
||||
} else {
|
||||
goToWelcome();
|
||||
|
|
|
@ -14,9 +14,9 @@ RowLayout {
|
|||
title: qsTr("Warning!")
|
||||
confirmationText: qsTr("The account will be logged out. When you unlock it again, the selected network will be used")
|
||||
onConfirmButtonClicked: {
|
||||
profileModel.network = newNetwork;
|
||||
profileModel.network.current = newNetwork;
|
||||
}
|
||||
onClosed: profileModel.triggerNetworkChange()
|
||||
onClosed: profileModel.network.triggerNetworkChange()
|
||||
}
|
||||
|
||||
width: parent.width
|
||||
|
@ -29,9 +29,9 @@ RowLayout {
|
|||
Layout.alignment: Qt.AlignRight
|
||||
ButtonGroup.group: networkSettings
|
||||
rightPadding: 0
|
||||
checked: profileModel.network === network
|
||||
checked: profileModel.network.current === network
|
||||
onClicked: {
|
||||
if (profileModel.network === network) return;
|
||||
if (profileModel.network.current === network) return;
|
||||
newNetwork = network;
|
||||
confirmDialog.open();
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ Item {
|
|||
|
||||
Rectangle {
|
||||
id: badge
|
||||
visible: !profileModel.isMnemonicBackedUp
|
||||
visible: !profileModel.mnemonic.isBackedUp
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 0
|
||||
|
@ -91,10 +91,10 @@ Item {
|
|||
}
|
||||
|
||||
MouseArea {
|
||||
enabled: !profileModel.isMnemonicBackedUp
|
||||
enabled: !profileModel.mnemonic.isBackedUp
|
||||
anchors.fill: parent
|
||||
onClicked: backupSeedModal.open()
|
||||
cursorShape: enabled && Qt.PointingHandCursor
|
||||
cursorShape: enabled ? Qt.PointingHandCursor : Qt.ArrowCursor
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ Item {
|
|||
anchors.topMargin: 48
|
||||
anchors.top: element4.bottom
|
||||
anchors.fill: parent
|
||||
model: profileModel.mailserversList
|
||||
model: profileModel.mailservers.list
|
||||
delegate: mailserversList
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import "../Profile/Sections"
|
|||
import "."
|
||||
|
||||
Rectangle {
|
||||
visible: !profileModel.isMnemonicBackedUp
|
||||
visible: !profileModel.mnemonic.isBackedUp
|
||||
height: visible ? 32 : 0
|
||||
Layout.fillWidth: true
|
||||
color: Style.current.red
|
||||
|
|
|
@ -71,7 +71,7 @@ ModalPopup {
|
|||
RecipientSelector {
|
||||
id: selectRecipient
|
||||
accounts: walletModel.accounts
|
||||
contacts: profileModel.addedContacts
|
||||
contacts: profileModel.contacts.addedContacts
|
||||
//% "Recipient"
|
||||
label: qsTrId("recipient")
|
||||
anchors.top: separator.bottom
|
||||
|
|
|
@ -138,7 +138,7 @@ RowLayout {
|
|||
|
||||
Rectangle {
|
||||
id: profileBadge
|
||||
visible: !profileModel.isMnemonicBackedUp && sLayout.children[sLayout.currentIndex] !== profileLayoutContainer
|
||||
visible: !profileModel.mnemonic.isBackedUp && sLayout.children[sLayout.currentIndex] !== profileLayoutContainer
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.right
|
||||
anchors.leftMargin: -10
|
||||
|
|
|
@ -51,7 +51,7 @@ Item {
|
|||
|
||||
|
||||
Connections {
|
||||
target: profileModel
|
||||
target: profileModel.contacts
|
||||
onContactChanged: {
|
||||
if(root.chatId === publicKey){
|
||||
// Hack warning: Triggering reload to avoid changing the current text binding
|
||||
|
@ -69,7 +69,7 @@ Item {
|
|||
switch(root.chatType){
|
||||
//% "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"
|
||||
qsTrId("chat-is-a-contact") :
|
||||
//% "Not a contact"
|
||||
|
|
|
@ -738,7 +738,7 @@ Rectangle {
|
|||
anchors.leftMargin: 2
|
||||
anchors.bottom: parent.bottom
|
||||
icon.name: "stickers_icon"
|
||||
visible: profileModel.network === Constants.networkMainnet
|
||||
visible: profileModel.network.current === Constants.networkMainnet
|
||||
width: visible ? 32 : 0
|
||||
type: "secondary"
|
||||
onClicked: {
|
||||
|
|
|
@ -81,7 +81,7 @@ ModalPopup {
|
|||
id: selectRecipient
|
||||
visible: false
|
||||
accounts: walletModel.accounts
|
||||
contacts: profileModel.addedContacts
|
||||
contacts: profileModel.contacts.addedContacts
|
||||
selectedRecipient: { "address": utilsModel.stickerMarketAddress, "type": RecipientSelector.Type.Address }
|
||||
readOnly: true
|
||||
onSelectedRecipientChanged: if (isValid) { gasSelector.estimateGas() }
|
||||
|
|
Loading…
Reference in New Issue