2020-02-14 01:08:02 +01:00
|
|
|
|
#include "input_dialog.h"
|
2018-12-09 18:36:30 +01:00
|
|
|
|
|
2020-02-22 20:42:49 +01:00
|
|
|
|
#include <QVBoxLayout>
|
2018-12-09 18:36:30 +01:00
|
|
|
|
#include <QDialogButtonBox>
|
2020-02-22 20:42:49 +01:00
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
|
#include <QPushButton>
|
2018-12-09 18:36:30 +01:00
|
|
|
|
|
|
|
|
|
|
input_dialog::input_dialog(int max_length, const QString& text, const QString& title, const QString& label, const QString& placeholder, QWidget *parent, Qt::WindowFlags f)
|
|
|
|
|
|
: QDialog(parent, f)
|
|
|
|
|
|
{
|
|
|
|
|
|
setWindowTitle(title);
|
|
|
|
|
|
|
2020-02-14 01:08:02 +01:00
|
|
|
|
m_label = new QLabel(label);
|
2018-12-09 18:36:30 +01:00
|
|
|
|
|
2020-02-14 01:08:02 +01:00
|
|
|
|
QLineEdit* input = new QLineEdit();
|
|
|
|
|
|
input->setPlaceholderText(placeholder);
|
|
|
|
|
|
input->setText(text);
|
|
|
|
|
|
input->setMaxLength(max_length);
|
|
|
|
|
|
input->setClearButtonEnabled(true);
|
|
|
|
|
|
connect(input, &QLineEdit::textChanged, this, &input_dialog::text_changed);
|
2018-12-09 18:36:30 +01:00
|
|
|
|
|
|
|
|
|
|
QDialogButtonBox* button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
|
|
|
|
|
connect(button_box, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
|
|
|
|
|
connect(button_box, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
|
|
|
|
|
|
|
|
|
|
|
QVBoxLayout* layout = new QVBoxLayout();
|
|
|
|
|
|
layout->addWidget(m_label);
|
2020-02-14 01:08:02 +01:00
|
|
|
|
layout->addWidget(input);
|
2018-12-09 18:36:30 +01:00
|
|
|
|
layout->addWidget(button_box);
|
|
|
|
|
|
setLayout(layout);
|
|
|
|
|
|
|
|
|
|
|
|
setFixedHeight(sizeHint().height());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-02-14 01:08:02 +01:00
|
|
|
|
input_dialog::~input_dialog()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void input_dialog::set_label_text(const QString& text)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_label->setText(text);
|
|
|
|
|
|
}
|