1
0
forked from BRT/arc
arc/views/device/EditBankAccountDialog.h
2025-07-27 14:28:35 +05:00

64 lines
2.1 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
#include <QDialog>
#include <QFormLayout>
#include <QLineEdit>
#include <QCheckBox>
#include <QDialogButtonBox>
#include <QComboBox>
#include <QSettings>
#include "db/AccountInfo.h"
class EditBankAccountDialog final : public QDialog {
Q_OBJECT
public:
explicit EditBankAccountDialog(const AccountInfo &account, QWidget *parent = nullptr) : QDialog(parent) {
if (account.id > 0) {
setWindowTitle("Настройка аккаунта *" + account.lastNumbers);
} else {
setWindowTitle("Настройка нового аккаунта");
}
setModal(true);
resize(300, 160);
const QSettings settings("config.ini", QSettings::IniFormat);
QStringList currencies = settings.value("common/currencies", QStringList()).toStringList();
auto *form = new QFormLayout(this);
cardNumber = new QLineEdit(this);
cardNumber->setText(account.description);
currency = new QComboBox(this);
for (QString c: currencies) {
currency->addItem(c);
}
currency->setCurrentText(account.currency);
toggle = new QCheckBox(tr("В работе"), this);
toggle->setChecked(account.status == AccountStatus::Active);
form->addRow(tr("Номер карты:"), cardNumber);
form->addRow(tr("Валюта:"), currency);
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 cardNumberValue() const { return cardNumber->text(); }
QString currencyValue() const { return currency->currentText(); }
bool toggled() const { return toggle->isChecked(); }
private:
QLineEdit *cardNumber;
QComboBox *currency;
QCheckBox *toggle;
};