Skip to content

Commit 7bb93a6

Browse files
committed
bug fix for enter key
1 parent 17a2bf1 commit 7bb93a6

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/loginform.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,14 @@ void LoginForm::keyPressEvent(QKeyEvent *event)
10271027

10281028
if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) {
10291029

1030+
1031+
10301032
winClicked = false;
1033+
1034+
if(justshowed){
1035+
justshowed = false;
1036+
return;
1037+
}
10311038
if(ui->stackedWidget->currentIndex() == ui->stackedWidget->indexOf(ui->resetpage))
10321039
on_resetpasswordButton_clicked();
10331040
else if(ui->stackedWidget->currentIndex() == ui->stackedWidget->indexOf(ui->warningpage)){
@@ -1043,10 +1050,9 @@ void LoginForm::keyPressEvent(QKeyEvent *event)
10431050
ui->passwordInput->setFocus();
10441051
} else if(ui->userInput->hasFocus() && !ui->userInput->isHidden() && ui->passwordInput->text().isEmpty()){
10451052
ui->passwordInput->setFocus();
1046-
}else{
1053+
}else {
10471054
startLogin();
10481055
}
1049-
10501056
}
10511057
}
10521058
else if (event->key() == Qt::Key_Escape) {
@@ -1092,7 +1098,7 @@ void LoginForm::keyPressEvent(QKeyEvent *event)
10921098
QWidget::keyPressEvent(event);
10931099
}
10941100

1095-
1101+
justshowed = false;
10961102
}
10971103

10981104
void LoginForm::keyReleaseEvent(QKeyEvent *event){
@@ -2491,6 +2497,7 @@ void LoginForm::hideAll(void){
24912497
//ui->usersframe->hide();
24922498
// ui->userspage->hide();
24932499
ui->passwordInput->hide();
2500+
ui->passwordInput->clearFocus();
24942501
//ui->userInput->hide();
24952502

24962503
hide();
@@ -2518,9 +2525,14 @@ void LoginForm::showAll(void){
25182525
ui->passwordInput->setFocus();
25192526
else
25202527
ui->userInput->setFocus();
2521-
2528+
justshowed = true;
25222529
}
25232530

25242531
ishidden = false;
25252532
}
25262533

2534+
2535+
void LoginForm::on_passwordInput_textEdited(const QString &arg1)
2536+
{
2537+
justshowed = false;
2538+
}

src/loginform.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ private slots:
144144

145145
void on_pushButton_left_clicked();
146146

147+
void on_passwordInput_textEdited(const QString &arg1);
148+
147149
private:
148150
void initialize();
149151

@@ -228,6 +230,7 @@ private slots:
228230
bool winClicked;
229231
QString currentSessionStr;
230232
bool ishidden = false;
233+
bool justshowed = false;
231234

232235

233236

0 commit comments

Comments
 (0)