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
|
|
|
|
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
|
|
|
|
initialState: root.hasAccounts ? stateLogin : keysMainState
|
|
|
|
|
|
|
|
DSM.State {
|
|
|
|
id: keysMainState
|
2022-03-04 23:31:31 +00:00
|
|
|
onEntered: { onBoardingStepChanged(welcomeMain, ""); }
|
2022-03-03 22:50:53 +00:00
|
|
|
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: genKeyState
|
|
|
|
signal: Global.applicationWindow.navigateTo
|
|
|
|
guard: path === "GenKey"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DSM.State {
|
|
|
|
id: existingKeyState
|
2022-03-04 23:31:31 +00:00
|
|
|
onEntered: { onBoardingStepChanged(existingKey, ""); }
|
2022-03-03 22:50:53 +00:00
|
|
|
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: appState
|
|
|
|
signal: startupModule.appStateChanged
|
|
|
|
guard: state === Constants.appState.main
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DSM.State {
|
|
|
|
id: genKeyState
|
2022-03-04 23:31:31 +00:00
|
|
|
onEntered: { onBoardingStepChanged(genKey, ""); }
|
2022-03-03 22:50:53 +00:00
|
|
|
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: appState
|
|
|
|
signal: startupModule.appStateChanged
|
|
|
|
guard: state === Constants.appState.main
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DSM.State {
|
|
|
|
id: keycardState
|
2022-03-04 23:31:31 +00:00
|
|
|
onEntered: { onBoardingStepChanged(keycardFlowSelection, ""); }
|
2022-03-03 22:50:53 +00:00
|
|
|
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: appState
|
|
|
|
signal: startupModule.appStateChanged
|
|
|
|
guard: state === Constants.appState.main
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-01 15:59:38 +00:00
|
|
|
DSM.State {
|
|
|
|
id: createPasswordState
|
|
|
|
onEntered: loader.sourceComponent = createPassword
|
|
|
|
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: appState
|
|
|
|
signal: startupModule.appStateChanged
|
|
|
|
guard: state === Constants.appState.main
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DSM.State {
|
|
|
|
id: confirmPasswordState
|
|
|
|
onEntered: loader.sourceComponent = confirmPassword
|
|
|
|
|
|
|
|
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 {
|
|
|
|
targetState: existingKeyState
|
|
|
|
signal: Global.applicationWindow.navigateTo
|
|
|
|
guard: path === "ExistingKey"
|
|
|
|
}
|
|
|
|
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: keysMainState
|
|
|
|
signal: Global.applicationWindow.navigateTo
|
|
|
|
guard: path === "KeysMain"
|
|
|
|
}
|
|
|
|
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: keycardState
|
|
|
|
signal: Global.applicationWindow.navigateTo
|
|
|
|
guard: path === "KeycardFlowSelection"
|
|
|
|
}
|
|
|
|
|
2022-03-01 15:59:38 +00:00
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: createPasswordState
|
|
|
|
signal: applicationWindow.navigateTo
|
|
|
|
guard: path === "CreatePassword"
|
|
|
|
}
|
|
|
|
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: confirmPasswordState
|
|
|
|
signal: applicationWindow.navigateTo
|
|
|
|
guard: path === "ConfirmPassword"
|
|
|
|
}
|
|
|
|
|
2022-03-03 22:50:53 +00:00
|
|
|
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: {
|
|
|
|
onBoardingStepChanged(keysMain, "getkeys");
|
|
|
|
}
|
|
|
|
onBtnExistingUserClicked: {
|
|
|
|
onBoardingStepChanged(keysMain, "connectkeys");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-03 22:50:53 +00:00
|
|
|
property var keysMainComponent: Component {
|
|
|
|
id: keysMain
|
|
|
|
KeysMainView {
|
2022-03-04 23:31:31 +00:00
|
|
|
onButtonClicked: {
|
|
|
|
Global.applicationWindow.navigateTo("GenKey");
|
|
|
|
}
|
|
|
|
onKeycardLinkClicked: {
|
|
|
|
Global.applicationWindow.navigateTo("KeycardFlowSelection");
|
|
|
|
}
|
|
|
|
onSeedLinkClicked: {
|
|
|
|
Global.applicationWindow.navigateTo("ExistingKey");
|
|
|
|
}
|
|
|
|
onBackClicked: {
|
|
|
|
onBoardingStepChanged(welcomeMain, "");
|
|
|
|
}
|
2022-03-03 22:50:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
property var existingKeyComponent: Component {
|
|
|
|
id: existingKey
|
|
|
|
ExistingKeyView {
|
2022-03-01 15:59:38 +00:00
|
|
|
onShowCreatePasswordView: { Global.applicationWindow.navigateTo("CreatePassword") }
|
2022-03-03 22:50:53 +00:00
|
|
|
onClosed: function () {
|
|
|
|
if (root.hasAccounts) {
|
|
|
|
Global.applicationWindow.navigateTo("InitialState")
|
|
|
|
} else {
|
|
|
|
Global.applicationWindow.navigateTo("KeysMain")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
property var genKeyComponent: Component {
|
|
|
|
id: genKey
|
|
|
|
GenKeyView {
|
2022-03-01 15:59:38 +00:00
|
|
|
onShowCreatePasswordView: { Global.applicationWindow.navigateTo("CreatePassword") }
|
2022-03-03 22:50:53 +00:00
|
|
|
onClosed: function () {
|
|
|
|
if (root.hasAccounts) {
|
|
|
|
Global.applicationWindow.navigateTo("InitialState")
|
|
|
|
} else {
|
|
|
|
Global.applicationWindow.navigateTo("KeysMain")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
property var keycardFlowSelectionComponent: Component {
|
|
|
|
id: keycardFlowSelection
|
|
|
|
KeycardFlowSelectionView {
|
|
|
|
onClosed: function () {
|
|
|
|
if (root.hasAccounts) {
|
|
|
|
Global.applicationWindow.navigateTo("InitialState")
|
|
|
|
} else {
|
|
|
|
Global.applicationWindow.navigateTo("KeysMain")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
property var loginComponent: Component {
|
|
|
|
id: login
|
|
|
|
LoginView {
|
|
|
|
onGenKeyClicked: function () {
|
|
|
|
Global.applicationWindow.navigateTo("GenKey")
|
|
|
|
}
|
|
|
|
onExistingKeyClicked: function () {
|
|
|
|
Global.applicationWindow.navigateTo("ExistingKey")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-03-01 15:59:38 +00:00
|
|
|
|
|
|
|
property var d: QtObject {
|
|
|
|
property string newPassword
|
|
|
|
property string confirmationPassword
|
|
|
|
}
|
|
|
|
|
|
|
|
property var createPasswordComponent: Component {
|
|
|
|
id: createPassword
|
|
|
|
CreatePasswordView {
|
2022-03-22 09:29:59 +00:00
|
|
|
store: OnboardingStore
|
2022-03-01 15:59:38 +00:00
|
|
|
newPassword: d.newPassword
|
|
|
|
confirmationPassword: d.confirmationPassword
|
|
|
|
|
|
|
|
onPasswordCreated: {
|
|
|
|
d.newPassword = newPassword
|
|
|
|
d.confirmationPassword = confirmationPassword
|
|
|
|
applicationWindow.navigateTo("ConfirmPassword")
|
|
|
|
}
|
|
|
|
onBackClicked: {
|
|
|
|
d.newPassword = ""
|
|
|
|
d.confirmationPassword = ""
|
|
|
|
applicationWindow.navigateTo("InitialState");
|
|
|
|
console.warn("TODO: Integration with onboarding flow!")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
property var confirmPasswordComponent: Component {
|
|
|
|
id: confirmPassword
|
|
|
|
ConfirmPasswordView {
|
|
|
|
password: d.newPassword
|
|
|
|
|
|
|
|
onBackClicked: { applicationWindow.navigateTo("CreatePassword") }
|
|
|
|
}
|
|
|
|
}
|
2022-03-03 22:50:53 +00:00
|
|
|
}
|