Skip to content

Commit

Permalink
Tab order implemented for templated (and auto-templated) fields
Browse files Browse the repository at this point in the history
  • Loading branch information
annejan committed Nov 17, 2015
1 parent 06c9e54 commit 2f9c6f7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions passworddialog.cpp
Expand Up @@ -41,6 +41,7 @@ void PasswordDialog::setPassword(QString password)
ui->lineEditPassword->setText(tokens[0]);
tokens.pop_front();
if (templating) {
QWidget *previous = ui->checkBoxShow;
for (int i = 0; i < ui->formLayout->rowCount(); i++) {
QLayoutItem *item = ui->formLayout->itemAt(i, QFormLayout::FieldRole);
if (item == NULL) {
Expand All @@ -55,6 +56,7 @@ void PasswordDialog::setPassword(QString password)
((QLineEdit*)widget)->setText(value);
}
}
previous = widget;
}
if (allFields) {
for (int j = 0; j < tokens.length(); j++) {
Expand All @@ -70,6 +72,8 @@ void PasswordDialog::setPassword(QString password)
line->setObjectName(field);
line->setText(value);
ui->formLayout->addRow(new QLabel(field), line);
setTabOrder(previous, line);
previous = line;
tokens.removeAt(j);
j--; // tokens.length() also got shortened by the remove..
}
Expand Down Expand Up @@ -100,13 +104,16 @@ QString PasswordDialog::getPassword()

void PasswordDialog::setTemplate(QString rawFields) {
fields = rawFields.split('\n');
QWidget *previous = ui->checkBoxShow;
foreach (QString field, fields) {
if (field.isEmpty()) {
continue;
}
QLineEdit *line = new QLineEdit();
line->setObjectName(field);
ui->formLayout->addRow(new QLabel(field), line);
setTabOrder(previous, line);
previous = line;
}
}

Expand Down

0 comments on commit 2f9c6f7

Please sign in to comment.