2018-06-26 15:11:45 +02:00
|
|
|
#include "widgets/dialogs/TextInputDialog.hpp"
|
2017-01-17 00:15:44 +01:00
|
|
|
#include <QSizePolicy>
|
|
|
|
|
2017-04-14 17:52:22 +02:00
|
|
|
namespace chatterino {
|
2017-01-18 21:30:23 +01:00
|
|
|
|
2017-01-17 00:15:44 +01:00
|
|
|
TextInputDialog::TextInputDialog(QWidget *parent)
|
|
|
|
: QDialog(parent)
|
2018-07-06 19:23:47 +02:00
|
|
|
, vbox_(this)
|
|
|
|
, okButton_("OK")
|
|
|
|
, cancelButton_("Cancel")
|
2017-01-17 00:15:44 +01:00
|
|
|
{
|
2018-07-06 19:23:47 +02:00
|
|
|
this->vbox_.addWidget(&lineEdit_);
|
|
|
|
this->vbox_.addLayout(&buttonBox_);
|
|
|
|
this->buttonBox_.addStretch(1);
|
|
|
|
this->buttonBox_.addWidget(&okButton_);
|
|
|
|
this->buttonBox_.addWidget(&cancelButton_);
|
2017-01-17 00:15:44 +01:00
|
|
|
|
2018-07-06 19:23:47 +02:00
|
|
|
QObject::connect(&this->okButton_, SIGNAL(clicked()), this, SLOT(okButtonClicked()));
|
|
|
|
QObject::connect(&this->cancelButton_, SIGNAL(clicked()), this, SLOT(cancelButtonClicked()));
|
2017-01-17 00:15:44 +01:00
|
|
|
|
2018-07-06 19:23:47 +02:00
|
|
|
this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
2017-01-17 00:15:44 +01:00
|
|
|
|
2018-07-06 19:23:47 +02:00
|
|
|
this->setWindowFlags((this->windowFlags() & ~(Qt::WindowContextHelpButtonHint)) | Qt::Dialog |
|
|
|
|
Qt::MSWindowsFixedSizeDialogHint);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString TextInputDialog::getText() const
|
|
|
|
{
|
|
|
|
return this->lineEdit_.text();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TextInputDialog::setText(const QString &text)
|
|
|
|
{
|
|
|
|
this->lineEdit_.setText(text);
|
2017-01-17 00:15:44 +01:00
|
|
|
}
|
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
void TextInputDialog::okButtonClicked()
|
2017-01-17 00:15:44 +01:00
|
|
|
{
|
2018-07-06 19:23:47 +02:00
|
|
|
this->accept();
|
|
|
|
this->close();
|
2017-01-17 00:15:44 +01:00
|
|
|
}
|
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
void TextInputDialog::cancelButtonClicked()
|
2017-01-17 00:15:44 +01:00
|
|
|
{
|
2018-07-06 19:23:47 +02:00
|
|
|
this->reject();
|
|
|
|
this->close();
|
2017-01-17 00:15:44 +01:00
|
|
|
}
|
2017-06-07 10:09:24 +02:00
|
|
|
|
2018-04-07 21:21:56 +02:00
|
|
|
void TextInputDialog::highlightText()
|
|
|
|
{
|
2018-07-06 19:23:47 +02:00
|
|
|
this->lineEdit_.selectAll();
|
2018-04-07 21:21:56 +02:00
|
|
|
}
|
|
|
|
|
2017-06-07 10:09:24 +02:00
|
|
|
} // namespace chatterino
|