2022-03-03 22:50:53 +00:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQml.StateMachine 1.14 as DSM
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
import "views"
|
|
|
|
import "stores"
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: root
|
|
|
|
property bool hasAccounts
|
2022-03-07 22:59:38 +00:00
|
|
|
property string keysMainSetState: ""
|
2022-05-11 14:45:15 +00:00
|
|
|
property string prevState: ""
|
2022-03-07 22:59:38 +00:00
|
|
|
|
2022-03-03 22:50:53 +00:00
|
|
|
signal loadApp()
|
2022-03-04 23:31:31 +00:00
|
|
|
signal onBoardingStepChanged(var view, string state)
|
2022-03-03 22:50:53 +00:00
|
|
|
|
|
|
|
property var stateMachine: DSM.StateMachine {
|
|
|
|
id: stateMachine
|
|
|
|
initialState: onboardingState
|
|
|
|
running: true
|
|
|
|
|
|
|
|
DSM.State {
|
|
|
|
id: onboardingState
|
2022-03-07 22:59:38 +00:00
|
|
|
initialState: root.hasAccounts ? stateLogin : welcomeMainState
|
2022-03-03 22:50:53 +00:00
|
|
|
|
|
|
|
DSM.State {
|
2022-03-07 22:59:38 +00:00
|
|
|
id: welcomeMainState
|
2022-03-04 23:31:31 +00:00
|
|
|
onEntered: { onBoardingStepChanged(welcomeMain, ""); }
|
2022-03-03 22:50:53 +00:00
|
|
|
|
2022-03-07 22:59:38 +00:00
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: keysMainState
|
|
|
|
signal: Global.applicationWindow.navigateTo
|
|
|
|
guard: path === "KeyMain"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DSM.State {
|
|
|
|
id: keysMainState
|
|
|
|
onEntered: { onBoardingStepChanged(keysMain, root.keysMainSetState); }
|
|
|
|
|
2022-03-03 22:50:53 +00:00
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: genKeyState
|
|
|
|
signal: Global.applicationWindow.navigateTo
|
|
|
|
guard: path === "GenKey"
|
|
|
|
}
|
2022-03-07 22:59:38 +00:00
|
|
|
|
|
|
|
DSM.SignalTransition {
|
2022-03-15 22:27:36 +00:00
|
|
|
targetState: importSeedState
|
2022-03-07 22:59:38 +00:00
|
|
|
signal: Global.applicationWindow.navigateTo
|
2022-03-15 22:27:36 +00:00
|
|
|
guard: path === "ImportSeed"
|
2022-03-07 22:59:38 +00:00
|
|
|
}
|
2022-03-03 22:50:53 +00:00
|
|
|
|
2022-03-07 22:59:38 +00:00
|
|
|
DSM.SignalTransition {
|
2022-03-15 22:27:36 +00:00
|
|
|
targetState: welcomeMainState
|
2022-03-07 22:59:38 +00:00
|
|
|
signal: Global.applicationWindow.navigateTo
|
2022-03-15 22:27:36 +00:00
|
|
|
guard: path === "Welcome"
|
2022-03-03 22:50:53 +00:00
|
|
|
}
|
2022-03-07 22:59:38 +00:00
|
|
|
|
|
|
|
DSM.SignalTransition {
|
2022-03-15 22:27:36 +00:00
|
|
|
targetState: stateLogin
|
2022-03-07 22:59:38 +00:00
|
|
|
signal: Global.applicationWindow.navigateTo
|
2022-03-15 22:27:36 +00:00
|
|
|
guard: path === "LogIn"
|
2022-03-07 22:59:38 +00:00
|
|
|
}
|
2022-03-03 22:50:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DSM.State {
|
|
|
|
id: genKeyState
|
2022-03-04 23:31:31 +00:00
|
|
|
onEntered: { onBoardingStepChanged(genKey, ""); }
|
2022-03-07 22:59:38 +00:00
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: welcomeMainState
|
|
|
|
signal: Global.applicationWindow.navigateTo
|
|
|
|
guard: path === "Welcome"
|
|
|
|
}
|
2022-03-03 22:50:53 +00:00
|
|
|
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: appState
|
2022-03-07 22:59:38 +00:00
|
|
|
signal: Global.applicationWindow.navigateTo
|
|
|
|
guard: path === "LoggedIn"
|
|
|
|
}
|
|
|
|
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: stateLogin
|
|
|
|
signal: Global.applicationWindow.navigateTo
|
|
|
|
guard: path === "LogIn"
|
2022-03-03 22:50:53 +00:00
|
|
|
}
|
2022-05-05 10:49:19 +00:00
|
|
|
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: importSeedState
|
|
|
|
signal: Global.applicationWindow.navigateTo
|
|
|
|
guard: path === "ImportSeed"
|
|
|
|
}
|
2022-03-03 22:50:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DSM.State {
|
2022-03-15 22:27:36 +00:00
|
|
|
id: importSeedState
|
|
|
|
property string seedInputState: "existingUser"
|
|
|
|
onEntered: { onBoardingStepChanged(seedPhrase, seedInputState); }
|
2022-03-03 22:50:53 +00:00
|
|
|
|
|
|
|
DSM.SignalTransition {
|
2022-03-15 22:27:36 +00:00
|
|
|
targetState: keysMainState
|
|
|
|
signal: Global.applicationWindow.navigateTo
|
|
|
|
guard: path === "KeyMain"
|
2022-03-03 22:50:53 +00:00
|
|
|
}
|
2022-03-01 15:59:38 +00:00
|
|
|
|
|
|
|
DSM.SignalTransition {
|
2022-03-15 22:27:36 +00:00
|
|
|
targetState: genKeyState
|
|
|
|
signal: Global.applicationWindow.navigateTo
|
|
|
|
guard: path === "GenKey"
|
2022-03-01 15:59:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DSM.State {
|
2022-03-15 22:27:36 +00:00
|
|
|
id: keycardState
|
|
|
|
onEntered: { onBoardingStepChanged(keycardFlowSelection, ""); }
|
2022-03-01 15:59:38 +00:00
|
|
|
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: appState
|
|
|
|
signal: startupModule.appStateChanged
|
|
|
|
guard: state === Constants.appState.main
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-03 22:50:53 +00:00
|
|
|
DSM.State {
|
|
|
|
id: stateLogin
|
2022-03-04 23:31:31 +00:00
|
|
|
onEntered: { onBoardingStepChanged(login, ""); }
|
2022-03-03 22:50:53 +00:00
|
|
|
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: appState
|
|
|
|
signal: startupModule.appStateChanged
|
|
|
|
guard: state === Constants.appState.main
|
|
|
|
}
|
|
|
|
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: genKeyState
|
|
|
|
signal: Global.applicationWindow.navigateTo
|
|
|
|
guard: path === "GenKey"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: root.hasAccounts ? stateLogin : keysMainState
|
|
|
|
signal: Global.applicationWindow.navigateTo
|
|
|
|
guard: path === "InitialState"
|
|
|
|
}
|
|
|
|
|
|
|
|
DSM.SignalTransition {
|
2022-03-07 22:59:38 +00:00
|
|
|
targetState: keysMainState
|
2022-03-03 22:50:53 +00:00
|
|
|
signal: Global.applicationWindow.navigateTo
|
2022-03-07 22:59:38 +00:00
|
|
|
guard: path === "KeysMain"
|
2022-03-03 22:50:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: keycardState
|
|
|
|
signal: Global.applicationWindow.navigateTo
|
|
|
|
guard: path === "KeycardFlowSelection"
|
|
|
|
}
|
|
|
|
|
|
|
|
DSM.FinalState {
|
|
|
|
id: onboardingDoneState
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DSM.State {
|
|
|
|
id: appState
|
|
|
|
onEntered: loadApp();
|
|
|
|
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: stateLogin
|
|
|
|
signal: startupModule.logOut
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-04 23:31:31 +00:00
|
|
|
property var welcomeComponent: Component {
|
|
|
|
id: welcomeMain
|
|
|
|
WelcomeView {
|
|
|
|
onBtnNewUserClicked: {
|
2022-03-07 22:59:38 +00:00
|
|
|
root.keysMainSetState = "getkeys";
|
|
|
|
Global.applicationWindow.navigateTo("KeyMain");
|
2022-03-04 23:31:31 +00:00
|
|
|
}
|
|
|
|
onBtnExistingUserClicked: {
|
2022-03-07 22:59:38 +00:00
|
|
|
root.keysMainSetState = "connectkeys";
|
|
|
|
Global.applicationWindow.navigateTo("KeyMain");
|
2022-03-04 23:31:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-03 22:50:53 +00:00
|
|
|
property var keysMainComponent: Component {
|
|
|
|
id: keysMain
|
|
|
|
KeysMainView {
|
2022-03-04 23:31:31 +00:00
|
|
|
onButtonClicked: {
|
2022-03-15 22:27:36 +00:00
|
|
|
if (state === "importseed") {
|
2022-05-24 13:50:19 +00:00
|
|
|
importSeedState.seedInputState = "existingUser";
|
2022-03-15 22:27:36 +00:00
|
|
|
Global.applicationWindow.navigateTo("ImportSeed");
|
|
|
|
} else {
|
2022-05-24 13:50:19 +00:00
|
|
|
importSeedState.seedInputState = "newUser";
|
2022-03-15 22:27:36 +00:00
|
|
|
Global.applicationWindow.navigateTo("GenKey");
|
|
|
|
}
|
2022-03-04 23:31:31 +00:00
|
|
|
}
|
|
|
|
onKeycardLinkClicked: {
|
|
|
|
Global.applicationWindow.navigateTo("KeycardFlowSelection");
|
|
|
|
}
|
|
|
|
onSeedLinkClicked: {
|
2022-05-24 13:50:19 +00:00
|
|
|
if (state === "getkeys") {
|
|
|
|
importSeedState.seedInputState = "newUser";
|
|
|
|
state = "importseed";
|
|
|
|
} else {
|
|
|
|
importSeedState.seedInputState = "existingUser";
|
|
|
|
Global.applicationWindow.navigateTo("ImportSeed");
|
|
|
|
}
|
2022-03-04 23:31:31 +00:00
|
|
|
}
|
|
|
|
onBackClicked: {
|
2022-05-24 13:50:19 +00:00
|
|
|
if (state === "importseed") {
|
|
|
|
state = "getkeys";
|
2022-05-26 09:53:53 +00:00
|
|
|
} else if ((root.keysMainSetState === "connectkeys" && LoginStore.currentAccount.username !== "") || root.prevState === "LogIn") {
|
2022-03-15 22:27:36 +00:00
|
|
|
Global.applicationWindow.navigateTo("LogIn");
|
|
|
|
} else {
|
|
|
|
Global.applicationWindow.navigateTo("Welcome");
|
|
|
|
}
|
2022-03-04 23:31:31 +00:00
|
|
|
}
|
2022-03-03 22:50:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-15 22:27:36 +00:00
|
|
|
property var seedPhraseInputComponent: Component {
|
|
|
|
id: seedPhrase
|
|
|
|
SeedPhraseInputView {
|
|
|
|
onExit: {
|
2022-05-24 13:50:19 +00:00
|
|
|
if (root.keysMainSetState !== "connectkeys") {
|
2022-03-15 22:27:36 +00:00
|
|
|
root.keysMainSetState = "importseed";
|
2022-03-03 22:50:53 +00:00
|
|
|
}
|
2022-05-24 13:50:19 +00:00
|
|
|
Global.applicationWindow.navigateTo("KeyMain");
|
2022-03-03 22:50:53 +00:00
|
|
|
}
|
2022-03-15 22:27:36 +00:00
|
|
|
onSeedValidated: {
|
2022-05-05 10:49:19 +00:00
|
|
|
root.keysMainSetState = "importseed";
|
2022-03-15 22:27:36 +00:00
|
|
|
Global.applicationWindow.navigateTo("GenKey");
|
|
|
|
}
|
2022-03-03 22:50:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
property var genKeyComponent: Component {
|
|
|
|
id: genKey
|
|
|
|
GenKeyView {
|
2022-03-15 22:27:36 +00:00
|
|
|
onExit: {
|
2022-05-05 10:49:19 +00:00
|
|
|
if (root.keysMainSetState === "importseed") {
|
|
|
|
root.keysMainSetState = "connectkeys"
|
|
|
|
Global.applicationWindow.navigateTo("ImportSeed");
|
2022-05-24 13:50:19 +00:00
|
|
|
} else if (LoginStore.currentAccount.username !== "" && importSeedState.seedInputState === "existingUser") {
|
2022-03-07 22:59:38 +00:00
|
|
|
Global.applicationWindow.navigateTo("LogIn");
|
2022-03-03 22:50:53 +00:00
|
|
|
} else {
|
2022-03-07 22:59:38 +00:00
|
|
|
Global.applicationWindow.navigateTo("KeysMain");
|
2022-03-03 22:50:53 +00:00
|
|
|
}
|
|
|
|
}
|
2022-03-07 22:59:38 +00:00
|
|
|
onKeysGenerated: {
|
|
|
|
Global.applicationWindow.navigateTo("LoggedIn")
|
|
|
|
}
|
2022-03-03 22:50:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
property var keycardFlowSelectionComponent: Component {
|
|
|
|
id: keycardFlowSelection
|
|
|
|
KeycardFlowSelectionView {
|
2022-05-24 13:50:19 +00:00
|
|
|
onClosed: {
|
2022-03-03 22:50:53 +00:00
|
|
|
if (root.hasAccounts) {
|
|
|
|
Global.applicationWindow.navigateTo("InitialState")
|
|
|
|
} else {
|
|
|
|
Global.applicationWindow.navigateTo("KeysMain")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
property var loginComponent: Component {
|
|
|
|
id: login
|
|
|
|
LoginView {
|
2022-05-11 14:45:15 +00:00
|
|
|
onAddNewUserClicked: {
|
|
|
|
root.keysMainSetState = "getkeys";
|
|
|
|
root.prevState = "LogIn"
|
|
|
|
Global.applicationWindow.navigateTo("KeysMain");
|
2022-03-03 22:50:53 +00:00
|
|
|
}
|
2022-03-15 22:27:36 +00:00
|
|
|
onAddExistingKeyClicked: {
|
|
|
|
root.keysMainSetState = "connectkeys";
|
2022-05-11 14:45:15 +00:00
|
|
|
root.prevState = "LogIn"
|
2022-03-15 22:27:36 +00:00
|
|
|
Global.applicationWindow.navigateTo("KeysMain");
|
2022-03-03 22:50:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|