50 lines
1.6 KiB
C++
50 lines
1.6 KiB
C++
#pragma once
|
|
#include <QDialog>
|
|
#include <QFormLayout>
|
|
#include <QLineEdit>
|
|
#include <QCheckBox>
|
|
#include <QDialogButtonBox>
|
|
#include <qtextedit.h>
|
|
#include "db/BankProfileInfo.h"
|
|
|
|
class BankEditDialog final : public QDialog {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit BankEditDialog(const BankProfileInfo &app, QWidget *parent = nullptr) : QDialog(parent) {
|
|
setWindowTitle("Настройка " + app.name);
|
|
setModal(true);
|
|
|
|
auto *form = new QFormLayout(this);
|
|
firstEdit = new QLineEdit(this);
|
|
firstEdit->setText(app.pinCode);
|
|
secondEdit = new QTextEdit(this);
|
|
secondEdit->setMaximumHeight(100);
|
|
secondEdit->setPlainText(app.comment);
|
|
toggle = new QCheckBox(tr("Включен"), this);
|
|
toggle->setChecked(app.status == "active");
|
|
|
|
form->addRow(tr("Пин-код:"), firstEdit);
|
|
form->addRow(tr("Комментарий:"), secondEdit);
|
|
form->addRow(QString(), toggle);
|
|
|
|
auto *buttons = new QDialogButtonBox(Qt::Horizontal, this);
|
|
buttons->addButton(tr("Сохранить"), QDialogButtonBox::AcceptRole);
|
|
buttons->addButton(tr("Отмена"), QDialogButtonBox::RejectRole);
|
|
form->addRow(buttons);
|
|
|
|
connect(buttons, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
|
connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
|
}
|
|
|
|
|
|
QString firstValue() const { return firstEdit->text(); }
|
|
QString secondValue() const { return secondEdit->toPlainText(); }
|
|
bool toggled() const { return toggle->isChecked(); }
|
|
|
|
private:
|
|
QLineEdit *firstEdit;
|
|
QTextEdit *secondEdit;
|
|
QCheckBox *toggle;
|
|
};
|