Skip to content

Commit

Permalink
Fix dialogs having focus on the wrong element
Browse files Browse the repository at this point in the history
  • Loading branch information
pgallo725 committed Nov 30, 2019
1 parent 9b5afb1 commit bd08d7e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 4 additions & 2 deletions textedit/NewDocumentWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ void NewDocumentWindow::resetFields()
//Reset all fields
ui->lineEdit_fileName->setText("");
ui->label_incorrectFilename->setText("");

//Reset the focus
ui->lineEdit_fileName->setFocus();
}

void NewDocumentWindow::acceptClicked()
Expand All @@ -64,7 +67,6 @@ void NewDocumentWindow::acceptClicked()

void NewDocumentWindow::rejectClicked()
{
//Reset fields and closes
resetFields();
//Close the window
this->close();
}
10 changes: 6 additions & 4 deletions textedit/OpenUriWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,17 @@ void OpenUriWindow::resetFields()
//Reset fields
ui->label_incorrectUri->setText("");
ui->lineEdit_uri->setText("");

//Reset focus
ui->lineEdit_uri->setFocus();
}

void OpenUriWindow::acceptClicked()
{
//Gets uri
//Gets URI inserted by user
_uri = ui->lineEdit_uri->text();

//If filename is valid it closes and confirm operation else print an error
//If filename is valid it closes and confirms operation else print an error
if (!_uri.isEmpty())
this->done(QDialog::Accepted);
else
Expand All @@ -57,7 +60,6 @@ void OpenUriWindow::acceptClicked()

void OpenUriWindow::rejectClicked()
{
//Reset fields and closes
resetFields();
//Close the window
this->close();
}

0 comments on commit bd08d7e

Please sign in to comment.