|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
#include <QDialogButtonBox>
|
|
|
|
|
#include <QApplication>
|
|
|
|
|
#include <QPushButton>
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QLabel>
|
|
|
|
@ -17,33 +18,34 @@ TextInputDialog::TextInputDialog(const QString& title, const QString &text, QWid
|
|
|
|
|
mButtonBox->addButton(QDialogButtonBox::Ok);
|
|
|
|
|
mButtonBox->addButton(QDialogButtonBox::Cancel);
|
|
|
|
|
|
|
|
|
|
setMaximumHeight(height());
|
|
|
|
|
setOkButtonEnabled(false);
|
|
|
|
|
setModal(true);
|
|
|
|
|
|
|
|
|
|
// Messageboxes on mac have no title
|
|
|
|
|
#ifndef Q_OS_MAC
|
|
|
|
|
setWindowTitle(title);
|
|
|
|
|
#else
|
|
|
|
|
Q_UNUSED(title);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
QLabel *label = new QLabel(this);
|
|
|
|
|
label->setText(text);
|
|
|
|
|
|
|
|
|
|
// Line edit
|
|
|
|
|
QValidator *validator = new QRegExpValidator(QRegExp("^[a-zA-Z0-9_]*$"), this); // Alpha-numeric + underscore
|
|
|
|
|
mLineEdit = new LineEdit(this);
|
|
|
|
|
mLineEdit->setValidator(validator);
|
|
|
|
|
mLineEdit->setCompleter(0);
|
|
|
|
|
|
|
|
|
|
QLabel *label = new QLabel(this);
|
|
|
|
|
label->setText(text);
|
|
|
|
|
|
|
|
|
|
QVBoxLayout *dialogLayout = new QVBoxLayout(this);
|
|
|
|
|
dialogLayout->addWidget(label);
|
|
|
|
|
dialogLayout->addWidget(mLineEdit);
|
|
|
|
|
dialogLayout->addWidget(mButtonBox);
|
|
|
|
|
|
|
|
|
|
// Messageboxes on mac have no title
|
|
|
|
|
#ifndef Q_OS_MAC
|
|
|
|
|
setWindowTitle(title);
|
|
|
|
|
#else
|
|
|
|
|
Q_UNUSED(title);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
setMaximumHeight(height());
|
|
|
|
|
setOkButtonEnabled(false);
|
|
|
|
|
setModal(true);
|
|
|
|
|
|
|
|
|
|
connect(mButtonBox, SIGNAL(accepted()), this, SLOT(accept()));
|
|
|
|
|
connect(mButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int TextInputDialog::exec()
|
|
|
|
@ -55,7 +57,17 @@ int TextInputDialog::exec()
|
|
|
|
|
|
|
|
|
|
void TextInputDialog::setOkButtonEnabled(bool enabled)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
QPushButton *okButton = mButtonBox->button(QDialogButtonBox::Ok);
|
|
|
|
|
okButton->setEnabled(enabled);
|
|
|
|
|
|
|
|
|
|
QPalette *palette = new QPalette();
|
|
|
|
|
palette->setColor(QPalette::Text,Qt::red);
|
|
|
|
|
|
|
|
|
|
if (enabled) {
|
|
|
|
|
mLineEdit->setPalette(QApplication::palette());
|
|
|
|
|
} else {
|
|
|
|
|
// Existing profile name, make the text red
|
|
|
|
|
mLineEdit->setPalette(*palette);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|