Skip to content
Snippets Groups Projects
Commit 37fd2514 authored by Ming Rui Zhang's avatar Ming Rui Zhang
Browse files

wizardview: line edit enter key submits

Add enter key event handle for lineEdits in wizardview

Gitlab: #470

Change-Id: I41948196742068cd0a03ff37efe93982410e91ce
parent 77b8f285
No related branches found
No related tags found
No related merge requests found
......@@ -42,6 +42,8 @@ TextField {
property var backgroundColor: JamiTheme.editBackgroundColor
property var borderColor: JamiTheme.greyBorderColor
property bool loseFocusWhenEnterPressed: false
signal imageClicked
onBorderColorModeChanged: {
......@@ -147,4 +149,20 @@ TextField {
if (event.button == Qt.RightButton)
lineEditContextMenu.openMenuAt(event)
}
// Enter/Return keys intervention
// Now, both editingFinished and accepted
// signals will be emitted with focus set to false
// Use editingFinished when the info is saved by focus lost
// (since losing focus will also emit editingFinished)
// Use accepted when the info is not saved by focus lost
Keys.onPressed: {
if (event.key === Qt.Key_Enter ||
event.key === Qt.Key_Return) {
if (loseFocusWhenEnterPressed)
root.focus = false
root.accepted()
event.accepted = true;
}
}
}
......@@ -121,6 +121,7 @@ Rectangle {
KeyNavigation.down: KeyNavigation.tab
onTextChanged: errorText = ""
onAccepted: usernameManagerEdit.forceActiveFocus()
}
Label {
......@@ -156,6 +157,7 @@ Rectangle {
KeyNavigation.down: KeyNavigation.tab
onTextChanged: errorText = ""
onAccepted: passwordManagerEdit.forceActiveFocus()
}
MaterialLineEdit {
......@@ -186,6 +188,10 @@ Rectangle {
KeyNavigation.down: KeyNavigation.tab
onTextChanged: errorText = ""
onAccepted: {
if (connectBtn.enabled)
connectBtn.clicked()
}
}
SpinnerButton {
......
......@@ -138,6 +138,13 @@ Rectangle {
placeholderText: isRendezVous ? JamiStrings.chooseAName :
JamiStrings.chooseYourUserName
onAccepted: {
if (chooseUsernameButton.enabled)
chooseUsernameButton.clicked()
else
skipButton.clicked()
}
}
Label {
......@@ -306,6 +313,8 @@ Rectangle {
KeyNavigation.tab: passwordConfirmEdit
KeyNavigation.up: passwordSwitch
KeyNavigation.down: KeyNavigation.tab
onAccepted: passwordConfirmEdit.forceActiveFocus()
}
MaterialLineEdit {
......@@ -329,6 +338,11 @@ Rectangle {
backButton
KeyNavigation.up: passwordEdit
KeyNavigation.down: KeyNavigation.tab
onAccepted: {
if (createAccountButton.enabled)
createAccountButton.clicked()
}
}
Label {
......
......@@ -102,6 +102,8 @@ Rectangle {
KeyNavigation.tab: sipProxyEdit
KeyNavigation.up: backButton
KeyNavigation.down: KeyNavigation.tab
onAccepted: sipProxyEdit.forceActiveFocus()
}
MaterialLineEdit {
......@@ -121,6 +123,8 @@ Rectangle {
KeyNavigation.tab: sipUsernameEdit
KeyNavigation.up: sipServernameEdit
KeyNavigation.down: KeyNavigation.tab
onAccepted: sipUsernameEdit.forceActiveFocus()
}
MaterialLineEdit {
......@@ -140,6 +144,8 @@ Rectangle {
KeyNavigation.tab: sipPasswordEdit
KeyNavigation.up: sipProxyEdit
KeyNavigation.down: KeyNavigation.tab
onAccepted: sipPasswordEdit.forceActiveFocus()
}
MaterialLineEdit {
......@@ -160,6 +166,8 @@ Rectangle {
KeyNavigation.tab: createAccountButton
KeyNavigation.up: sipUsernameEdit
KeyNavigation.down: KeyNavigation.tab
onAccepted: createAccountButton.clicked()
}
MaterialButton {
......
......@@ -195,6 +195,10 @@ Rectangle {
KeyNavigation.down: KeyNavigation.tab
onTextChanged: errorText = ""
onAccepted: {
if (connectBtn.enabled)
connectBtn.clicked()
}
}
SpinnerButton {
......
......@@ -108,6 +108,7 @@ Rectangle {
KeyNavigation.down: KeyNavigation.tab
onTextChanged: errorText = ""
onAccepted: pinFromDevice.forceActiveFocus()
}
Text {
......@@ -158,6 +159,10 @@ Rectangle {
KeyNavigation.down: KeyNavigation.tab
onTextChanged: errorText = ""
onAccepted: {
if (connectBtn.enabled)
connectBtn.clicked()
}
}
SpinnerButton {
......
......@@ -171,6 +171,11 @@ Rectangle {
AccountAdapter.setCurrAccDisplayName(lastFirstChar)
}
}
onAccepted: {
if (saveProfileBtn.enabled)
saveProfileBtn.clicked()
}
}
SpinnerButton {
......
......@@ -647,6 +647,8 @@ WizardView {
}
function test_createAccountPageKeyNavigation() {
uut.clearSignalSpy()
var welcomePage = findChild(uut, "welcomePage")
var createAccountPage = findChild(uut, "createAccountPage")
......@@ -741,8 +743,6 @@ WizardView {
compare(usernameEdit.focus, true)
// To createAccountPage - passwordSetupPage
keyClick(Qt.Key_Down)
keyClick(Qt.Key_Down)
keyClick(Qt.Key_Enter)
keyClick(Qt.Key_Tab)
compare(passwordSwitch.focus, true)
......@@ -861,14 +861,52 @@ WizardView {
keyClick(Qt.Key_Up)
compare(passwordSwitch.focus, true)
// Go back to welcomePage
keyClick(Qt.Key_Up)
passwordEdit.text = ""
passwordConfirmEdit.text = ""
// Check lineEdit enter key press corrspond correctly
keyClick(Qt.Key_Tab)
keyClick(Qt.Key_Enter)
keyClick(Qt.Key_Up)
keyClick(Qt.Key_Enter)
compare(passwordConfirmEdit.focus, true)
passwordEdit.text = "test"
passwordConfirmEdit.text = "test"
keyClick(Qt.Key_Enter)
// Wait until the account creation is finished
spyAccountIsReady.wait()
compare(spyAccountIsReady.count, 1)
// Go back to welcomePage
WizardViewStepModel.nextStep()
var showBackup = (WizardViewStepModel.accountCreationOption ===
WizardViewStepModel.AccountCreationOption.CreateJamiAccount
|| WizardViewStepModel.accountCreationOption ===
WizardViewStepModel.AccountCreationOption.CreateRendezVous)
&& !AppSettingsManager.getValue(Settings.NeverShowMeAgain)
if (showBackup) {
WizardViewStepModel.nextStep()
}
spyAccountConfigFinalized.wait()
compare(spyAccountConfigFinalized.count, 1)
spyCloseWizardView.wait()
compare(spyCloseWizardView.count, 1)
AccountAdapter.deleteCurrentAccount()
// Wait until the account removal is finished
spyAccountIsRemoved.wait()
compare(spyAccountIsRemoved.count, 1)
}
function test_importFromDevicePageKeyNavigation() {
uut.clearSignalSpy()
var welcomePage = findChild(uut, "welcomePage")
var importFromDevicePage = findChild(uut, "importFromDevicePage")
......@@ -980,6 +1018,20 @@ WizardView {
importFromDevicePageConnectBtn.spinnerTriggered = false
// Check lineEdit enter key press corrspond correctly
keyClick(Qt.Key_Enter)
compare(pinFromDevice.focus, true)
keyClick(Qt.Key_Up)
keyClick(Qt.Key_Enter)
compare(pinFromDevice.focus, true)
pinFromDevice.text = "test"
keyClick(Qt.Key_Enter)
spyReportFailure.wait(15000)
verify(spyReportFailure.count >= 1)
// Go back to welcomePage
keyClick(Qt.Key_Up)
keyClick(Qt.Key_Up)
......@@ -987,6 +1039,8 @@ WizardView {
}
function test_importFromBackupPageKeyNavigation() {
uut.clearSignalSpy()
var welcomePage = findChild(uut, "welcomePage")
var importFromBackupPage = findChild(uut, "importFromBackupPage")
......@@ -1099,6 +1153,18 @@ WizardView {
importFromBackupPageConnectBtn.spinnerTriggered = false
// Check lineEdit enter key press corrspond correctly
var fileName = "gz_test.gz"
var wrongPassword = "ccc"
importFromBackupPage.filePath = UtilsAdapter.toFileAbsolutepath(
"tests/qml/src/resources/gz_test.gz") + "/" + fileName
passwordFromBackupEdit.text = wrongPassword
keyClick(Qt.Key_Enter)
spyReportFailure.wait(15000)
verify(spyReportFailure.count >= 1)
// Go back to welcomePage
keyClick(Qt.Key_Up)
keyClick(Qt.Key_Up)
......@@ -1106,6 +1172,8 @@ WizardView {
}
function test_connectToAccountManagerPageKeyNavigation() {
uut.clearSignalSpy()
var welcomePage = findChild(uut, "welcomePage")
var connectToAccountManagerPage = findChild(uut, "connectToAccountManagerPage")
......@@ -1250,8 +1318,21 @@ WizardView {
connectToAccountManagerPageConnectBtn.spinnerTriggered = false
// Check lineEdit enter key press corrspond correctly
accountManagerEdit.text = "test"
usernameManagerEdit.text = "test"
passwordManagerEdit.text = "test"
keyClick(Qt.Key_Enter)
keyClick(Qt.Key_Enter)
keyClick(Qt.Key_Enter)
spyReportFailure.wait(15000)
verify(spyReportFailure.count >= 1)
// Go back to welcomePage
keyClick(Qt.Key_Up)
keyClick(Qt.Key_Tab)
keyClick(Qt.Key_Tab)
keyClick(Qt.Key_Enter)
// Hide advanced options
......@@ -1259,6 +1340,8 @@ WizardView {
}
function test_createSIPAccountPageKeyNavigation() {
uut.clearSignalSpy()
var welcomePage = findChild(uut, "welcomePage")
var createSIPAccountPage = findChild(uut, "createSIPAccountPage")
......@@ -1339,10 +1422,33 @@ WizardView {
keyClick(Qt.Key_Up)
compare(sipServernameEdit.focus, true)
// Go back to welcomePage
keyClick(Qt.Key_Up)
// Check lineEdit enter key press corrspond correctly
keyClick(Qt.Key_Enter)
keyClick(Qt.Key_Enter)
keyClick(Qt.Key_Enter)
keyClick(Qt.Key_Enter)
// Wait until the account creation is finished
spyAccountIsReady.wait()
compare(spyAccountIsReady.count, 1)
spyAccountStatusChanged.wait()
verify(spyAccountStatusChanged.count >= 1)
WizardViewStepModel.nextStep()
spyAccountConfigFinalized.wait()
compare(spyAccountConfigFinalized.count, 1)
spyCloseWizardView.wait()
compare(spyCloseWizardView.count, 1)
AccountAdapter.deleteCurrentAccount()
// Wait until the account removal is finished
spyAccountIsRemoved.wait()
compare(spyAccountIsRemoved.count, 1)
// Hide advanced options
showAdvancedButton.clicked()
}
......@@ -1564,7 +1670,15 @@ WizardView {
setAvatarWidget.isPreviewing = false
WizardViewStepModel.nextStep()
// Check lineEdit enter key press corrspond correctly
var aliasName = "test"
aliasEdit.text = aliasName
spyAccountStatusChanged.clear()
keyClick(Qt.Key_Tab)
keyClick(Qt.Key_Tab)
keyClick(Qt.Key_Tab)
keyClick(Qt.Key_Enter)
var showBackup = (WizardViewStepModel.accountCreationOption ===
WizardViewStepModel.AccountCreationOption.CreateJamiAccount
......@@ -1577,9 +1691,15 @@ WizardView {
WizardViewStepModel.nextStep()
}
spyAccountStatusChanged.wait()
verify(spyAccountStatusChanged.count >= 1)
spyCloseWizardView.wait()
compare(spyCloseWizardView.count, 1)
// Check alias text
compare(SettingsAdapter.getCurrentAccount_Profile_Info_Alias(), aliasName)
AccountAdapter.deleteCurrentAccount()
// Wait until the account removal is finished
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment