| 1 | #include "dialog.h" |
|---|---|
| 2 | #include "ui_dialog.h" |
| 3 | |
| 4 | Dialog::Dialog(QWidget *parent) |
| 5 | : QDialog(parent) |
| 6 | , ui(new Ui::Dialog) |
| 7 | { |
| 8 | ui->setupUi(this); |
| 9 | } |
| 10 | |
| 11 | Dialog::~Dialog() |
| 12 | { |
| 13 | delete ui; |
| 14 | } |
| 15 | |
| 16 | int Dialog::showPrompt(const QString &prompt) |
| 17 | { |
| 18 | ui->txtPrompt->setText(prompt); |
| 19 | return exec(); |
| 20 | } |
| 21 | |
| 22 | QString Dialog::getInput() |
| 23 | { |
| 24 | return ui->txtInput->text(); |
| 25 | } |
| 26 | |
| 27 | |
| 28 | void Dialog::on_txtInput_returnPressed() |
| 29 | { |
| 30 | if (!ui->txtInput->text().isEmpty()) |
| 31 | accept(); |
| 32 | } |
| 33 | |
| 34 | void Dialog::closeEvent(QCloseEvent *event) |
| 35 | { |
| 36 | reject(); |
| 37 | } |
| 38 |