#pragma once
#include <QDialog>
#include <QFormLayout>
#include <QLineEdit>
#include <QCheckBox>
#include <QDialogButtonBox>

// 1) Определяем диалог
class BankEditDialog : public QDialog {
    Q_OBJECT

public:
    explicit BankEditDialog(QWidget *parent = nullptr) : QDialog(parent) {

        setWindowTitle(tr("Введите данные"));
        setModal(true); // делаем его модальным

        // 2) Форма с полями
        auto *form = new QFormLayout(this);
        firstEdit = new QLineEdit(this);
        secondEdit = new QLineEdit(this);
        toggle = new QCheckBox(tr("Включено"), this);

        form->addRow(tr("Первое поле:"), firstEdit);
        form->addRow(tr("Второе поле:"), secondEdit);
        form->addRow(QString(), toggle);

        // 3) Кнопки OK / Cancel
        auto *buttons = new QDialogButtonBox(
            QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
            Qt::Horizontal,
            this
        );
        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->text(); }
    bool toggled() const { return toggle->isChecked(); }

private:
    QLineEdit *firstEdit;
    QLineEdit *secondEdit;
    QCheckBox *toggle;
};
