diff --git a/ui/app/AppLayouts/Onboarding/OnboardingLayout.qml b/ui/app/AppLayouts/Onboarding/OnboardingLayout.qml index 525b00cbb0..7efea804fb 100644 --- a/ui/app/AppLayouts/Onboarding/OnboardingLayout.qml +++ b/ui/app/AppLayouts/Onboarding/OnboardingLayout.qml @@ -8,7 +8,6 @@ import StatusQ.Core.Theme 0.1 import utils 1.0 import shared.popups.keycard 1.0 -import shared.panels 1.0 import "controls" import "views" @@ -31,16 +30,6 @@ OnboardingBasePage { loader.sourceComponent = undefined } - MockedKeycardLibFlowController { - anchors.top: parent.top - anchors.left: parent.left - anchors.topMargin: Style.current.bigPadding - anchors.leftMargin: 4 * Style.current.bigPadding - visible: localAppSettings.testEnvironment - - relatedModule: root.startupStore.startupModuleInst - } - Loader { id: loader anchors.fill: parent diff --git a/ui/app/mainui/AppMain.qml b/ui/app/mainui/AppMain.qml index 2133bb503d..98f4fa769c 100644 --- a/ui/app/mainui/AppMain.qml +++ b/ui/app/mainui/AppMain.qml @@ -1622,20 +1622,4 @@ Item { onClosed: userAgreementLoader.active = false } } - - Loader { - id: mockedKeycardLibInitialController - anchors.right: parent.right - anchors.bottom: parent.bottom - active: localAppSettings.testEnvironment - - sourceComponent: MockedKeycardLibInitialController { - width: 450 - height: 500 - - onClose: { - mockedKeycardLibInitialController.active = false - } - } - } } diff --git a/ui/imports/shared/panels/MockedKeycardLibInitialController.qml b/ui/imports/shared/panels/MockedKeycardLibControllerWindow.qml similarity index 62% rename from ui/imports/shared/panels/MockedKeycardLibInitialController.qml rename to ui/imports/shared/panels/MockedKeycardLibControllerWindow.qml index e3dc8a38b7..474fcd1c11 100644 --- a/ui/imports/shared/panels/MockedKeycardLibInitialController.qml +++ b/ui/imports/shared/panels/MockedKeycardLibControllerWindow.qml @@ -1,4 +1,5 @@ import QtQuick 2.14 +import QtQuick.Controls 2.14 import QtQuick.Layouts 1.14 import StatusQ.Core 0.1 @@ -9,78 +10,104 @@ import shared.controls 1.0 import utils 1.0 -Rectangle { +ApplicationWindow { id: root - color: Style.current.modalBackground - radius: Style.current.radius - border.color: Style.current.grey3 - border.width: 2 + property var relatedModule - signal close() + title: qsTr("Mocked Keycard Lib Controller") + minimumHeight: 600 + minimumWidth: 450 QtObject { id: d property int btnWidth: 30 property int btnHeight: 30 - property int margin: 8 - - property bool minimized: false - property int maxWidth - property int maxHeight - onMinimizedChanged: { - if (minimized) { - d.maxWidth = root.width - d.maxHeight = root.height - root.width = header.implicitWidth + 2 * d.margin - root.height = header.implicitHeight + 2 * d.margin - return - } - root.width = d.maxWidth - root.height = d.maxHeight - } + property int margin: 16 + property int spacing: 16 } - Row { - id: header - anchors.right: parent.right - anchors.rightMargin: d.margin + ColumnLayout { + id: commands anchors.top: parent.top - anchors.topMargin: d.margin - spacing: d.margin + anchors.left: parent.left + anchors.right: parent.right + anchors.margins: d.margin + spacing: d.spacing - StatusFlatRoundButton { - type: StatusFlatRoundButton.Type.Secondary - icon.name: d.minimized? "chevron-up" : "chevron-down" - icon.color: Theme.palette.directColor1 - implicitWidth: d.btnWidth - implicitHeight: d.btnHeight - onClicked: { - d.minimized = !d.minimized - } + StatusBaseText { + text: qsTr("Use this buttons to control the flow") } - StatusFlatRoundButton { - type: StatusFlatRoundButton.Type.Secondary - icon.name: "close" - icon.color: Theme.palette.directColor1 - implicitWidth: d.btnWidth - implicitHeight: d.btnHeight - onClicked: { - root.close() + Flow { + Layout.fillWidth: true + spacing: d.spacing + + StatusButton { + text: qsTr("Plugin Reader") + + onClicked: { + if (!!root.relatedModule) { + root.relatedModule.pluginMockedReaderAction() + } + } + } + + StatusButton { + text: qsTr("Unplug Reader") + + onClicked: { + if (!!root.relatedModule) { + root.relatedModule.unplugMockedReaderAction() + } + } + } + + StatusButton { + text: qsTr("Insert Keycard 1") + + onClicked: { + if (!!root.relatedModule) { + root.relatedModule.insertMockedKeycardAction(1) + } + } + } + + StatusButton { + text: qsTr("Insert Keycard 2") + + onClicked: { + if (!!root.relatedModule) { + root.relatedModule.insertMockedKeycardAction(2) + } + } + } + + StatusButton { + text: qsTr("Remove Keycard") + + onClicked: { + if (!!root.relatedModule) { + root.relatedModule.removeMockedKeycardAction() + } + } + } + + Item { + Layout.fillWidth: true + Layout.preferredHeight: 1 } } } MockedKeycardReaderStateSelector { id: readerState - anchors.top: parent.top + anchors.top: commands.bottom anchors.left: parent.left - anchors.topMargin: Style.current.bigPadding - anchors.leftMargin: Style.current.bigPadding - visible: !d.minimized - title: qsTr("Initial reader state") + anchors.margins: d.margin + anchors.topMargin: 3 * d.margin + title: qsTr("Set initial reader state (refers to keycard 1 only)") } StatusTabBar { @@ -88,8 +115,8 @@ Rectangle { anchors.top: readerState.bottom anchors.left: parent.left anchors.right: parent.right - anchors.margins: Style.current.bigPadding - visible: !d.minimized + anchors.margins: d.margin + anchors.topMargin: 3 * d.margin StatusTabButton { width: implicitWidth @@ -109,14 +136,15 @@ Rectangle { anchors.left: parent.left anchors.right: parent.right anchors.margins: Style.current.halfPadding - visible: !d.minimized currentIndex: tabBar.currentIndex KeycardSettingsTab { cardIndex: 1 onRegisterKeycard: { - mainModule.registerMockedKeycard(cardIndex, readerState.selectedState, kcState, kc, kcHelper) + if (!!root.relatedModule) { + relatedModule.registerMockedKeycard(cardIndex, readerState.selectedState, kcState, kc, kcHelper) + } } } @@ -124,7 +152,9 @@ Rectangle { cardIndex: 2 onRegisterKeycard: { - mainModule.registerMockedKeycard(cardIndex, MockedKeycardReaderStateSelector.NoKeycard, kcState, kc, kcHelper) + if (!!root.relatedModule) { + relatedModule.registerMockedKeycard(cardIndex, MockedKeycardReaderStateSelector.NoKeycard, kcState, kc, kcHelper) + } } } } @@ -137,7 +167,7 @@ Rectangle { signal registerKeycard(int kcState, string kc, string kcHelper) ColumnLayout { - spacing: 16 + spacing: d.spacing MockedKeycardStateSelector { id: keycardState @@ -147,7 +177,7 @@ Rectangle { Column { id: customSection visible: keycardState.selectedState === MockedKeycardStateSelector.CustomKeycard - spacing: 16 + spacing: d.spacing StatusInput { id: mockedKeycard diff --git a/ui/imports/shared/panels/MockedKeycardLibFlowController.qml b/ui/imports/shared/panels/MockedKeycardLibFlowController.qml deleted file mode 100644 index cf53e46495..0000000000 --- a/ui/imports/shared/panels/MockedKeycardLibFlowController.qml +++ /dev/null @@ -1,65 +0,0 @@ -import QtQuick 2.14 -import QtQuick.Layouts 1.14 - -import StatusQ.Controls 0.1 - -RowLayout { - id: root - - property var relatedModule - - StatusButton { - text: qsTr("Plugin R") - - onClicked: { - if (!!root.relatedModule) { - root.relatedModule.pluginMockedReaderAction() - } - } - } - - StatusButton { - text: qsTr("Unplug R") - - onClicked: { - if (!!root.relatedModule) { - root.relatedModule.unplugMockedReaderAction() - } - } - } - - StatusButton { - text: qsTr("Ins Kc 1") - - onClicked: { - if (!!root.relatedModule) { - root.relatedModule.insertMockedKeycardAction(1) - } - } - } - - StatusButton { - text: qsTr("Ins Kc 2") - - onClicked: { - if (!!root.relatedModule) { - root.relatedModule.insertMockedKeycardAction(2) - } - } - } - - StatusButton { - text: qsTr("Remove Kc") - - onClicked: { - if (!!root.relatedModule) { - root.relatedModule.removeMockedKeycardAction() - } - } - } - - Item { - Layout.fillWidth: true - Layout.preferredHeight: 1 - } -} diff --git a/ui/imports/shared/panels/qmldir b/ui/imports/shared/panels/qmldir index 5d14fd9b18..26c4a8434e 100644 --- a/ui/imports/shared/panels/qmldir +++ b/ui/imports/shared/panels/qmldir @@ -25,5 +25,4 @@ StatusAssetSelector 1.0 StatusAssetSelector.qml StyledText 1.0 StyledText.qml TextWithLabel 1.0 TextWithLabel.qml DropAndEditImagePanel 1.0 DropAndEditImagePanel.qml -MockedKeycardLibFlowController 1.0 MockedKeycardLibFlowController.qml -MockedKeycardLibInitialController 1.0 MockedKeycardLibInitialController.qml +MockedKeycardLibControllerWindow 1.0 MockedKeycardLibControllerWindow.qml diff --git a/ui/imports/shared/popups/keycard/KeycardPopup.qml b/ui/imports/shared/popups/keycard/KeycardPopup.qml index cfc784239e..a84987763c 100644 --- a/ui/imports/shared/popups/keycard/KeycardPopup.qml +++ b/ui/imports/shared/popups/keycard/KeycardPopup.qml @@ -83,23 +83,21 @@ StatusModal { id: content width: scrollView.availableWidth implicitHeight: { - let additionalHeight = localAppSettings.testEnvironment? 60 : 0 - // for all flows if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.factoryResetConfirmationDisplayMetadata) { if (!root.sharedKeycardModule.keyPairStoredOnKeycardIsKnown) { - return Constants.keycard.general.popupBiggerHeight + additionalHeight + return Constants.keycard.general.popupBiggerHeight } } if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.importFromKeycard && root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.manageKeycardAccounts && root.sharedKeycardModule.keyPairHelper.accounts.count > 1) { - return Constants.keycard.general.popupBiggerHeight + additionalHeight + return Constants.keycard.general.popupBiggerHeight } - return Constants.keycard.general.popupHeight + additionalHeight + return Constants.keycard.general.popupHeight } sharedKeycardModule: root.sharedKeycardModule diff --git a/ui/imports/shared/popups/keycard/KeycardPopupContent.qml b/ui/imports/shared/popups/keycard/KeycardPopupContent.qml index 11bc902105..49aba7f028 100644 --- a/ui/imports/shared/popups/keycard/KeycardPopupContent.qml +++ b/ui/imports/shared/popups/keycard/KeycardPopupContent.qml @@ -1,7 +1,6 @@ import QtQuick 2.14 import utils 1.0 -import shared.panels 1.0 import "./states" @@ -19,26 +18,9 @@ Item { property bool primaryButtonEnabled: false } - MockedKeycardLibFlowController { - id: mockedLibFlowController - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - anchors.leftMargin: Style.current.padding - anchors.rightMargin: Style.current.padding - visible: localAppSettings.testEnvironment - - relatedModule: mainModule - } - Loader { id: loader - - anchors.top: mockedLibFlowController.visible? mockedLibFlowController.bottom : parent.top - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.right: parent.right - + anchors.fill: parent sourceComponent: { switch (root.sharedKeycardModule.currentState.stateType) { case Constants.keycardSharedState.biometrics: diff --git a/ui/main.qml b/ui/main.qml index 5044476e6f..62bc28000e 100644 --- a/ui/main.qml +++ b/ui/main.qml @@ -95,6 +95,29 @@ StatusWindow { QtObject { id: d property int previousApplicationState: -1 + + property var mockedKeycardControllerWindow + function runMockedKeycardControllerWindow() { + if (localAppSettings.testEnvironment) { + if (!!d.mockedKeycardControllerWindow) { + d.mockedKeycardControllerWindow.close() + } + + console.info("running mocked keycard lib controller window") + var c = Qt.createComponent("qrc:/imports/shared/panels/MockedKeycardLibControllerWindow.qml"); + if (c.status === Component.Ready) { + d.mockedKeycardControllerWindow = c.createObject(applicationWindow, { + "relatedModule": startupOnboarding.visible? + startupModule : + mainModule + }) + if (d.mockedKeycardControllerWindow) { + d.mockedKeycardControllerWindow.show() + d.mockedKeycardControllerWindow.requestActivate() + } + } + } + } } Action { @@ -152,6 +175,8 @@ StatusWindow { function onStartUpUIRaised() { applicationWindow.appIsReady = true; applicationWindow.storeAppState(); + + d.runMockedKeycardControllerWindow() } function onAppStateChanged(state) { @@ -194,6 +219,8 @@ StatusWindow { Style.changeTheme(localAppSettings.theme, systemPalette.isCurrentSystemThemeDark()) Style.changeFontSize(localAccountSensitiveSettings.fontSize) Theme.updateFontSize(localAccountSensitiveSettings.fontSize) + + d.runMockedKeycardControllerWindow() } else if(state === Constants.appState.appEncryptionProcess) { loader.sourceComponent = undefined appLoadingAnimation.active = true @@ -380,11 +407,11 @@ StatusWindow { Qt.quit() return } - + if (localAccountSensitiveSettings.quitOnClose) { Qt.quit(); return - } + } applicationWindow.visible = false; }