mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-21 02:58:55 +00:00
Local settings service moved to AppController.
Old ProfileController and related props moved to AppController in order to have an usable app during refactoring of onboarding/login modules.
This commit is contained in:
parent
7568880f26
commit
c3a374c36a
@ -1,5 +1,6 @@
|
||||
import NimQml
|
||||
import NimQml, os, strformat
|
||||
|
||||
import ../../app_service/service/local_settings/service as local_settings_service
|
||||
import ../../app_service/service/accounts/service as accounts_service
|
||||
import ../../app_service/service/contacts/service as contact_service
|
||||
import ../../app_service/service/chat/service as chat_service
|
||||
@ -14,15 +15,40 @@ import global_singleton
|
||||
# provider/subscriber principe:
|
||||
import ../../app_service/[main]
|
||||
|
||||
# This to will be adapted to appropriate modules later:
|
||||
#################################################
|
||||
# At the end of refactoring this will be moved to
|
||||
# appropriate place or removed:
|
||||
import ../profile/core as profile
|
||||
# import ../onboarding/core as onboarding
|
||||
# import ../login/core as login
|
||||
# import status/types/[account]
|
||||
import status/types/[account]
|
||||
#################################################
|
||||
|
||||
|
||||
var i18nPath = ""
|
||||
if defined(development):
|
||||
i18nPath = joinPath(getAppDir(), "../ui/i18n")
|
||||
elif (defined(windows)):
|
||||
i18nPath = joinPath(getAppDir(), "../resources/i18n")
|
||||
elif (defined(macosx)):
|
||||
i18nPath = joinPath(getAppDir(), "../i18n")
|
||||
elif (defined(linux)):
|
||||
i18nPath = joinPath(getAppDir(), "../i18n")
|
||||
|
||||
var currentLanguageCode: string
|
||||
proc changeLanguage(locale: string) =
|
||||
if (locale == currentLanguageCode):
|
||||
return
|
||||
currentLanguageCode = locale
|
||||
let shouldRetranslate = not defined(linux)
|
||||
singletonInstance.engine.setTranslationPackage(joinPath(i18nPath, fmt"qml_{locale}.qm"), shouldRetranslate)
|
||||
|
||||
|
||||
type
|
||||
AppController* = ref object of RootObj
|
||||
appService: AppService
|
||||
# Services
|
||||
localSettingsService: local_settings_service.Service
|
||||
accountsService: accounts_service.Service
|
||||
contactService: contact_service.Service
|
||||
chatService: chat_service.Service
|
||||
@ -31,10 +57,14 @@ type
|
||||
startupModule: startup_module.AccessInterface
|
||||
mainModule: main_module.AccessInterface
|
||||
|
||||
# This to will be adapted to appropriate modules later:
|
||||
#################################################
|
||||
# At the end of refactoring this will be moved to
|
||||
# appropriate place or removed:
|
||||
profile: ProfileController
|
||||
# login: LoginController
|
||||
# onboarding: OnboardingController
|
||||
# accountArgs: AccountArgs
|
||||
#################################################
|
||||
|
||||
#################################################
|
||||
# Forward declaration section
|
||||
@ -48,19 +78,28 @@ proc userLoggedIn*(self: AppController)
|
||||
proc mainDidLoad*(self: AppController)
|
||||
#################################################
|
||||
|
||||
# proc connect(self: AppController) =
|
||||
# self.appService.status.events.once("login") do(a: Args):
|
||||
# self.accountArgs = AccountArgs(a)
|
||||
# self.load()
|
||||
|
||||
# self.appService.status.events.once("nodeStopped") do(a: Args):
|
||||
# self.login.reset()
|
||||
# self.onboarding.reset()
|
||||
#################################################
|
||||
# At the end of refactoring this will be moved to
|
||||
# appropriate place or removed:
|
||||
proc connect(self: AppController) =
|
||||
self.appService.status.events.once("loginCompleted") do(a: Args):
|
||||
var args = AccountArgs(a)
|
||||
self.profile.init(args.account)
|
||||
|
||||
# self.appService.status.events.once("login") do(a: Args):
|
||||
# self.accountArgs = AccountArgs(a)
|
||||
# self.load()
|
||||
|
||||
# self.appService.status.events.once("nodeStopped") do(a: Args):
|
||||
# self.login.reset()
|
||||
# self.onboarding.reset()
|
||||
#################################################
|
||||
|
||||
proc newAppController*(appService: AppService): AppController =
|
||||
result = AppController()
|
||||
result.appService = appService
|
||||
# Services
|
||||
result.localSettingsService = local_settings_service.newService()
|
||||
result.accountsService = accounts_service.newService()
|
||||
result.contactService = contact_service.newService()
|
||||
result.chatService = chat_service.newService()
|
||||
@ -71,39 +110,58 @@ proc newAppController*(appService: AppService): AppController =
|
||||
result.mainModule = main_module.newModule[AppController](result, result.chatService,
|
||||
result.communityService)
|
||||
|
||||
# Adding status and appService here now is just because of having a controll
|
||||
# over order of execution while we integrating this refactoring architecture
|
||||
# into the current app state.
|
||||
# Once we complete refactoring process we will get rid of "status" part/lib.
|
||||
#
|
||||
# This to will be adapted to appropriate modules later:
|
||||
#################################################
|
||||
# At the end of refactoring this will be moved to
|
||||
# appropriate place or removed:
|
||||
result.profile = profile.newController(appService.status, appService, result.localSettingsService, changeLanguage)
|
||||
# result.login = login.newController(appService.status, appService)
|
||||
# result.onboarding = onboarding.newController(appService.status)
|
||||
# singletonInstance.engine.setRootContextProperty("loginModel", result.login.variant)
|
||||
# singletonInstance.engine.setRootContextProperty("onboardingModel", result.onboarding.variant)
|
||||
#result.connect()
|
||||
result.connect()
|
||||
#################################################
|
||||
|
||||
proc delete*(self: AppController) =
|
||||
self.startupModule.delete
|
||||
self.mainModule.delete
|
||||
|
||||
#################################################
|
||||
# At the end of refactoring this will be moved to
|
||||
# appropriate place or removed:
|
||||
# self.login.delete
|
||||
# self.onboarding.delete
|
||||
self.profile.delete
|
||||
#################################################
|
||||
|
||||
self.localSettingsService.delete
|
||||
self.accountsService.delete
|
||||
self.contactService.delete
|
||||
self.chatService.delete
|
||||
self.communityService.delete
|
||||
|
||||
proc startupDidLoad*(self: AppController) =
|
||||
singletonInstance.engine.load(newQUrl("qrc:///main.qml"))
|
||||
#################################################
|
||||
# At the end of refactoring this will be moved to
|
||||
# appropriate place or removed:
|
||||
singletonInstance.engine.setRootContextProperty("profileModel", self.profile.variant)
|
||||
# self.login.init()
|
||||
# self.onboarding.init()
|
||||
#################################################
|
||||
|
||||
# We're applying default language before we load qml. Also we're aware that
|
||||
# switch language at runtime will have some impact to cpu usage.
|
||||
# https://doc.qt.io/archives/qtjambi-4.5.2_01/com/trolltech/qt/qtjambi-linguist-programmers.html
|
||||
changeLanguage("en")
|
||||
|
||||
singletonInstance.engine.load(newQUrl("qrc:///main.qml"))
|
||||
|
||||
proc mainDidLoad*(self: AppController) =
|
||||
# This to will be adapted to appropriate modules later:
|
||||
self.appService.onLoggedIn()
|
||||
self.startupModule.moveToAppState()
|
||||
|
||||
#################################################
|
||||
# At the end of refactoring this will be moved to
|
||||
# appropriate place or removed:
|
||||
# Reset login and onboarding to remove any mnemonic that would have been saved in the accounts list
|
||||
# self.login.reset()
|
||||
# self.onboarding.reset()
|
||||
@ -111,6 +169,7 @@ proc mainDidLoad*(self: AppController) =
|
||||
# self.login.moveToAppState()
|
||||
# self.onboarding.moveToAppState()
|
||||
# self.appService.status.events.emit("loginCompleted", self.accountArgs)
|
||||
#################################################
|
||||
|
||||
proc start*(self: AppController) =
|
||||
self.accountsService.init()
|
||||
|
@ -63,7 +63,7 @@ QtObject:
|
||||
identityImage: currNodeAcct.identityImage
|
||||
))
|
||||
|
||||
self.status.events.emit("accountChanged", AccountArgs(account: currNodeAcct))
|
||||
# self.status.events.emit("accountChanged", AccountArgs(account: currNodeAcct))
|
||||
|
||||
QtProperty[QVariant] currentAccount:
|
||||
read = getCurrentAccount
|
||||
@ -174,10 +174,11 @@ QtObject:
|
||||
self.keychainManager.storeDataAsync(username, password)
|
||||
|
||||
proc tryToObtainPassword*(self: LoginView) {.slot.} =
|
||||
let value = self.appService.localSettingsService.getAccountValue(
|
||||
LS_KEY_STORE_TO_KEYCHAIN).stringVal
|
||||
if (value == LS_VALUE_STORE):
|
||||
self.keychainManager.readDataAsync(self.currentAccount.username)
|
||||
discard
|
||||
# let value = self.appService.localSettingsService.getAccountValue(
|
||||
# LS_KEY_STORE_TO_KEYCHAIN).stringVal
|
||||
# if (value == LS_VALUE_STORE):
|
||||
# self.keychainManager.readDataAsync(self.currentAccount.username)
|
||||
|
||||
proc obtainingPasswordError*(self:LoginView, errorDescription: string) {.signal.}
|
||||
proc obtainingPasswordSuccess*(self:LoginView, password: string) {.signal.}
|
||||
|
@ -103,8 +103,8 @@ QtObject:
|
||||
|
||||
proc storeDerivedAndLogin(self: OnboardingView, password: string): string {.slot.} =
|
||||
let genAcc = self.currentAccount.account
|
||||
let acc = Account(name: genAcc.name, keyUid: genAcc.keyUid, identicon: genAcc.identicon, identityImage: genAcc.identityImage)
|
||||
self.status.events.emit("accountChanged", status_account_type.AccountArgs(account: acc))
|
||||
# let acc = Account(name: genAcc.name, keyUid: genAcc.keyUid, identicon: genAcc.identicon, identityImage: genAcc.identityImage)
|
||||
# self.status.events.emit("accountChanged", status_account_type.AccountArgs(account: acc))
|
||||
|
||||
try:
|
||||
result = self.status.accounts.storeDerivedAndLogin(self.status.fleet.config, genAcc, password).toJson
|
||||
|
@ -9,6 +9,7 @@ import status/wallet
|
||||
import status/types/[account, transaction, setting, profile, mailserver]
|
||||
import ../../app_service/[main]
|
||||
import ../../app_service/tasks/marathon/mailserver/events
|
||||
import ../../app_service/service/local_settings/service as local_settings_service
|
||||
import eventemitter
|
||||
import view
|
||||
import views/[ens_manager, devices, network, mailservers, contacts, muted_chats]
|
||||
@ -22,12 +23,15 @@ type ProfileController* = ref object
|
||||
variant*: QVariant
|
||||
status: Status
|
||||
appService: AppService
|
||||
localSettingsService: local_settings_service.Service
|
||||
|
||||
proc newController*(status: Status, appService: AppService, changeLanguage: proc(locale: string)): ProfileController =
|
||||
proc newController*(status: Status, appService: AppService,
|
||||
localSettingsService: local_settings_service.Service,
|
||||
changeLanguage: proc(locale: string)): ProfileController =
|
||||
result = ProfileController()
|
||||
result.status = status
|
||||
result.appService = appService
|
||||
result.view = newProfileView(status, appService, changeLanguage)
|
||||
result.view = newProfileView(status, appService, localSettingsService, changeLanguage)
|
||||
result.variant = newQVariant(result.view)
|
||||
|
||||
proc delete*(self: ProfileController) =
|
||||
|
@ -17,6 +17,7 @@ import status/notifications/[os_notifications]
|
||||
import ../chat/views/channels_list
|
||||
import ../../constants
|
||||
import ../../app_service/[main]
|
||||
import ../../app_service/service/local_settings/service as local_settings_service
|
||||
import ../utils/image_utils
|
||||
import ../../constants
|
||||
|
||||
@ -37,6 +38,7 @@ QtObject:
|
||||
network*: NetworkView
|
||||
status*: Status
|
||||
appService: AppService
|
||||
localSettingsService: local_settings_service.Service
|
||||
changeLanguage*: proc(locale: string)
|
||||
ens*: EnsManager
|
||||
|
||||
@ -57,7 +59,9 @@ QtObject:
|
||||
if not self.mailservers.isNil: self.mailservers.delete
|
||||
self.QObject.delete
|
||||
|
||||
proc newProfileView*(status: Status, appService: AppService, changeLanguage: proc(locale: string)): ProfileView =
|
||||
proc newProfileView*(status: Status, appService: AppService,
|
||||
localSettingsService: local_settings_service.Service,
|
||||
changeLanguage: proc(locale: string)): ProfileView =
|
||||
new(result, delete)
|
||||
result = ProfileView()
|
||||
result.profile = newProfileInfoView()
|
||||
@ -74,6 +78,7 @@ QtObject:
|
||||
result.changeLanguage = changeLanguage
|
||||
result.status = status
|
||||
result.appService = appService
|
||||
result.localSettingsService = localSettingsService
|
||||
result.setup
|
||||
|
||||
proc initialized*(self: ProfileView) {.signal.}
|
||||
@ -188,7 +193,7 @@ QtObject:
|
||||
read = getProfilePicture
|
||||
|
||||
proc getGlobalSettingsFile*(self: ProfileView): string {.slot.} =
|
||||
self.appService.localSettingsService.getGlobalSettingsFilePath
|
||||
self.localSettingsService.getGlobalSettingsFilePath
|
||||
|
||||
QtProperty[string] globalSettingsFile:
|
||||
read = getGlobalSettingsFile
|
||||
@ -202,10 +207,10 @@ QtObject:
|
||||
proc settingsFileChanged*(self: ProfileView) {.signal.}
|
||||
|
||||
proc getSettingsFile*(self: ProfileView): string {.slot.} =
|
||||
self.appService.localSettingsService.getSettingsFilePath
|
||||
self.localSettingsService.getSettingsFilePath
|
||||
|
||||
proc setSettingsFile*(self: ProfileView, pubKey: string) =
|
||||
self.appService.localSettingsService.updateSettingsFilePath(pubKey)
|
||||
self.localSettingsService.updateSettingsFilePath(pubKey)
|
||||
self.settingsFileChanged()
|
||||
|
||||
QtProperty[string] settingsFile:
|
||||
@ -215,11 +220,11 @@ QtObject:
|
||||
proc accountSettingsFileChanged*(self: ProfileView) {.signal.}
|
||||
|
||||
proc setAccountSettingsFile*(self: ProfileView, alias: string) =
|
||||
self.appService.localSettingsService.updateAccountSettingsFilePath(alias)
|
||||
self.localSettingsService.updateAccountSettingsFilePath(alias)
|
||||
self.accountSettingsFileChanged()
|
||||
|
||||
proc getAccountSettingsFile*(self: ProfileView): string {.slot.} =
|
||||
self.appService.localSettingsService.getAccountSettingsFilePath
|
||||
self.localSettingsService.getAccountSettingsFilePath
|
||||
|
||||
QtProperty[string] accountSettingsFile:
|
||||
read = getAccountSettingsFile
|
||||
|
@ -6,14 +6,13 @@ import
|
||||
./tasks/threadpool,
|
||||
./signals/signal_controller
|
||||
|
||||
import service/local_settings/service as local_settings_service
|
||||
import service/os_notification/service as os_notification_service
|
||||
import async_service/chat/service as chat_async_service
|
||||
import async_service/wallet/service as wallet_async_service
|
||||
|
||||
export status_lib_status
|
||||
export marathon, task_runner, signal_controller
|
||||
export local_settings_service, os_notification_service
|
||||
export os_notification_service
|
||||
export chat_async_service, wallet_async_service
|
||||
|
||||
logScope:
|
||||
@ -26,7 +25,6 @@ type AppService* = ref object
|
||||
marathon*: Marathon
|
||||
signalController*: SignalsController
|
||||
# services
|
||||
localSettingsService*: LocalSettingsService
|
||||
osNotificationService*: OsNotificationService
|
||||
# async services
|
||||
chatService*: ChatService
|
||||
@ -38,7 +36,6 @@ proc newAppService*(status: Status, worker: MarathonWorker): AppService =
|
||||
result.threadpool = newThreadPool()
|
||||
result.marathon = newMarathon(worker)
|
||||
result.signalController = newSignalsController(status)
|
||||
result.localSettingsService = newLocalSettingsService()
|
||||
result.osNotificationService = newOsNotificationService(status)
|
||||
result.chatService = newChatService(status, result.threadpool)
|
||||
result.walletService = newWalletService(status, result.threadpool)
|
||||
@ -47,7 +44,6 @@ proc delete*(self: AppService) =
|
||||
self.threadpool.teardown()
|
||||
self.marathon.teardown()
|
||||
self.signalController.delete()
|
||||
self.localSettingsService.delete()
|
||||
self.osNotificationService.delete()
|
||||
self.chatService.delete()
|
||||
self.walletService.delete()
|
||||
|
@ -13,7 +13,7 @@ logScope:
|
||||
topics = "local-settings"
|
||||
|
||||
QtObject:
|
||||
type LocalSettingsService* = ref object of QObject
|
||||
type Service* = ref object of QObject
|
||||
settingsFilePath: string
|
||||
settings: QSettings
|
||||
accountSettingsFilePath: string
|
||||
@ -21,7 +21,7 @@ QtObject:
|
||||
globalSettingsFilePath: string
|
||||
globalSettings: QSettings
|
||||
|
||||
proc setup(self: LocalSettingsService) =
|
||||
proc setup(self: Service) =
|
||||
self.settingsFilePath = os.joinPath(DATADIR, "qt", UNKNOWN_PROFILE)
|
||||
self.settings = newQSettings(self.settingsFilePath, QSettingsFormat.IniFormat)
|
||||
self.accountSettingsFilePath = os.joinPath(DATADIR, "qt", UNKNOWN_ACCOUNT)
|
||||
@ -30,25 +30,25 @@ QtObject:
|
||||
self.globalSettings = newQSettings(self.globalSettingsFilePath, QSettingsFormat.IniFormat)
|
||||
self.QObject.setup
|
||||
|
||||
proc delete*(self: LocalSettingsService) =
|
||||
proc delete*(self: Service) =
|
||||
self.settings.delete
|
||||
self.globalSettings.delete
|
||||
self.QObject.delete
|
||||
|
||||
proc newLocalSettingsService*(): LocalSettingsService =
|
||||
proc newService*(): Service =
|
||||
new(result, delete)
|
||||
result.setup
|
||||
|
||||
proc getGlobalSettingsFilePath*(self: LocalSettingsService): string =
|
||||
proc getGlobalSettingsFilePath*(self: Service): string =
|
||||
return self.globalSettingsFilePath
|
||||
|
||||
proc getAccountSettingsFilePath*(self: LocalSettingsService): string =
|
||||
proc getAccountSettingsFilePath*(self: Service): string =
|
||||
return self.accountSettingsFilePath
|
||||
|
||||
proc getSettingsFilePath*(self: LocalSettingsService): string =
|
||||
proc getSettingsFilePath*(self: Service): string =
|
||||
return self.settingsFilePath
|
||||
|
||||
proc updateSettingsFilePath*(self: LocalSettingsService, pubKey: string) =
|
||||
proc updateSettingsFilePath*(self: Service, pubKey: string) =
|
||||
let unknownSettingsPath = os.joinPath(DATADIR, "qt", UNKNOWN_PROFILE)
|
||||
if (not unknownSettingsPath.tryRemoveFile):
|
||||
# Only fails if the file exists and an there was an error removing it
|
||||
@ -59,7 +59,7 @@ QtObject:
|
||||
self.settingsFilePath = os.joinPath(DATADIR, "qt", pubKey)
|
||||
self.settings = newQSettings(self.settingsFilePath, QSettingsFormat.IniFormat)
|
||||
|
||||
proc updateAccountSettingsFilePath*(self: LocalSettingsService, alias: string) =
|
||||
proc updateAccountSettingsFilePath*(self: Service, alias: string) =
|
||||
let unknownAccountSettingsPath = os.joinPath(DATADIR, "qt", UNKNOWN_ACCOUNT)
|
||||
if (not unknownAccountSettingsPath.tryRemoveFile):
|
||||
# Only fails if the file exists and an there was an error removing it
|
||||
@ -70,32 +70,32 @@ QtObject:
|
||||
self.accountSettingsFilePath = os.joinPath(DATADIR, "qt", alias)
|
||||
self.accountSettings = newQSettings(self.accountSettingsFilePath, QSettingsFormat.IniFormat)
|
||||
|
||||
proc setAccountValue*(self: LocalSettingsService, key: string, value: QVariant) =
|
||||
proc setAccountValue*(self: Service, key: string, value: QVariant) =
|
||||
self.accountSettings.setValue(key, value)
|
||||
|
||||
proc getAccountValue*(self: LocalSettingsService, key: string,
|
||||
proc getAccountValue*(self: Service, key: string,
|
||||
defaultValue: QVariant = newQVariant()): QVariant =
|
||||
self.accountSettings.value(key, defaultValue)
|
||||
|
||||
proc removeAccountValue*(self: LocalSettingsService, key: string) =
|
||||
proc removeAccountValue*(self: Service, key: string) =
|
||||
self.accountSettings.remove(key)
|
||||
|
||||
proc setValue*(self: LocalSettingsService, key: string, value: QVariant) =
|
||||
proc setValue*(self: Service, key: string, value: QVariant) =
|
||||
self.settings.setValue(key, value)
|
||||
|
||||
proc getValue*(self: LocalSettingsService, key: string,
|
||||
proc getValue*(self: Service, key: string,
|
||||
defaultValue: QVariant = newQVariant()): QVariant =
|
||||
self.settings.value(key, defaultValue)
|
||||
|
||||
proc removeValue*(self: LocalSettingsService, key: string) =
|
||||
proc removeValue*(self: Service, key: string) =
|
||||
self.settings.remove(key)
|
||||
|
||||
proc setGlobalValue*(self: LocalSettingsService, key: string, value: QVariant) =
|
||||
proc setGlobalValue*(self: Service, key: string, value: QVariant) =
|
||||
self.globalSettings.setValue(key, value)
|
||||
|
||||
proc getGlobalValue*(self: LocalSettingsService, key: string,
|
||||
proc getGlobalValue*(self: Service, key: string,
|
||||
defaultValue: QVariant = newQVariant()): QVariant =
|
||||
self.globalSettings.value(key, defaultValue)
|
||||
|
||||
proc removeGlobalValue*(self: LocalSettingsService, key: string) =
|
||||
proc removeGlobalValue*(self: Service, key: string) =
|
||||
self.globalSettings.remove(key)
|
@ -6,8 +6,6 @@ import app/wallet/v2/core as walletV2
|
||||
import app/node/core as node
|
||||
import app/utilsView/core as utilsView
|
||||
import app/browser/core as browserView
|
||||
import app/profile/core as profile
|
||||
import app/profile/view
|
||||
import app/provider/core as provider
|
||||
import app/keycard/core as keycard
|
||||
import status/types/[account]
|
||||
@ -34,7 +32,7 @@ proc mainProc() =
|
||||
|
||||
ensureDirectories(DATADIR, TMPDIR, LOGDIR)
|
||||
|
||||
var currentLanguageCode: string
|
||||
# var currentLanguageCode: string
|
||||
|
||||
let fleets =
|
||||
if defined(windows) and defined(production):
|
||||
@ -96,15 +94,15 @@ proc mainProc() =
|
||||
if not defined(macosx):
|
||||
app.icon(app.applicationDirPath & statusAppIcon)
|
||||
|
||||
var i18nPath = ""
|
||||
if defined(development):
|
||||
i18nPath = joinPath(getAppDir(), "../ui/i18n")
|
||||
elif (defined(windows)):
|
||||
i18nPath = joinPath(getAppDir(), "../resources/i18n")
|
||||
elif (defined(macosx)):
|
||||
i18nPath = joinPath(getAppDir(), "../i18n")
|
||||
elif (defined(linux)):
|
||||
i18nPath = joinPath(getAppDir(), "../i18n")
|
||||
# var i18nPath = ""
|
||||
# if defined(development):
|
||||
# i18nPath = joinPath(getAppDir(), "../ui/i18n")
|
||||
# elif (defined(windows)):
|
||||
# i18nPath = joinPath(getAppDir(), "../resources/i18n")
|
||||
# elif (defined(macosx)):
|
||||
# i18nPath = joinPath(getAppDir(), "../i18n")
|
||||
# elif (defined(linux)):
|
||||
# i18nPath = joinPath(getAppDir(), "../i18n")
|
||||
|
||||
let networkAccessFactory = newQNetworkAccessManagerFactory(TMPDIR & "netcache")
|
||||
|
||||
@ -180,16 +178,12 @@ proc mainProc() =
|
||||
defer: browserController.delete()
|
||||
singletonInstance.engine.setRootContextProperty("browserModel", browserController.variant)
|
||||
|
||||
proc changeLanguage(locale: string) =
|
||||
if (locale == currentLanguageCode):
|
||||
return
|
||||
currentLanguageCode = locale
|
||||
let shouldRetranslate = not defined(linux)
|
||||
singletonInstance.engine.setTranslationPackage(joinPath(i18nPath, fmt"qml_{locale}.qm"), shouldRetranslate)
|
||||
|
||||
var profile = profile.newController(status, appService, changeLanguage)
|
||||
defer: profile.delete()
|
||||
singletonInstance.engine.setRootContextProperty("profileModel", profile.variant)
|
||||
# proc changeLanguage(locale: string) =
|
||||
# if (locale == currentLanguageCode):
|
||||
# return
|
||||
# currentLanguageCode = locale
|
||||
# let shouldRetranslate = not defined(linux)
|
||||
# singletonInstance.engine.setTranslationPackage(joinPath(i18nPath, fmt"qml_{locale}.qm"), shouldRetranslate)
|
||||
|
||||
var provider = provider.newController(status)
|
||||
defer: provider.delete()
|
||||
@ -198,19 +192,19 @@ proc mainProc() =
|
||||
var keycard = keycard.newController(status)
|
||||
defer: keycard.delete()
|
||||
|
||||
proc onAccountChanged(account: Account) =
|
||||
profile.view.setAccountSettingsFile(account.name)
|
||||
# proc onAccountChanged(account: Account) =
|
||||
# profile.view.setAccountSettingsFile(account.name)
|
||||
|
||||
status.events.on("accountChanged") do(a: Args):
|
||||
var args = AccountArgs(a)
|
||||
onAccountChanged(args.account)
|
||||
# status.events.on("accountChanged") do(a: Args):
|
||||
# var args = AccountArgs(a)
|
||||
# onAccountChanged(args.account)
|
||||
|
||||
status.events.once("loginCompleted") do(a: Args):
|
||||
var args = AccountArgs(a)
|
||||
|
||||
onAccountChanged(args.account)
|
||||
# onAccountChanged(args.account)
|
||||
status.startMessenger()
|
||||
profile.init(args.account)
|
||||
# profile.init(args.account)
|
||||
wallet.init()
|
||||
wallet2.init()
|
||||
provider.init()
|
||||
@ -262,10 +256,10 @@ proc mainProc() =
|
||||
var prValue = newQVariant(if defined(production): true else: false)
|
||||
singletonInstance.engine.setRootContextProperty("production", prValue)
|
||||
|
||||
# We're applying default language before we load qml. Also we're aware that
|
||||
# switch language at runtime will have some impact to cpu usage.
|
||||
# https://doc.qt.io/archives/qtjambi-4.5.2_01/com/trolltech/qt/qtjambi-linguist-programmers.html
|
||||
changeLanguage("en")
|
||||
# # We're applying default language before we load qml. Also we're aware that
|
||||
# # switch language at runtime will have some impact to cpu usage.
|
||||
# # https://doc.qt.io/archives/qtjambi-4.5.2_01/com/trolltech/qt/qtjambi-linguist-programmers.html
|
||||
# changeLanguage("en")
|
||||
|
||||
appController.start()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user