mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-09 01:23:57 -07:00
* [Cleanup] Unused #includes Took 44 minutes * [Cleanup] More unused #includes Took 55 minutes * [Cleanup] Include QSet Took 4 minutes * [Cleanup] Include QDebug in deck_list.cpp Took 3 minutes * [Cleanup] Include protocol stuff in servatrice_database_interface.h Took 3 minutes * [Cleanup] Include QDialogButtonBox Took 8 minutes * [Cleanup] Include QUrl Took 8 minutes * [Cleanup] Include QTextOption in header. Took 3 minutes * [Cleanup] Include QMap in user_list_manager.h Took 8 minutes * [Cleanup] Adjust qjson Took 8 minutes * [Cleanup] include button box. Took 3 minutes * [Cleanup] Redo fwd declarations. * [Cleanup] Redo last removed fwd declarations. --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
34 lines
1,013 B
C++
34 lines
1,013 B
C++
#include "get_text_with_max.h"
|
|
|
|
#include <QInputDialog>
|
|
|
|
QString getTextWithMax(QWidget *parent,
|
|
const QString &title,
|
|
const QString &label,
|
|
QLineEdit::EchoMode mode,
|
|
const QString &text,
|
|
bool *ok,
|
|
int max,
|
|
Qt::WindowFlags flags,
|
|
Qt::InputMethodHints inputMethodHints)
|
|
{
|
|
auto *dialog = new QInputDialog(parent, flags);
|
|
dialog->setWindowTitle(title);
|
|
dialog->setLabelText(label);
|
|
dialog->setTextValue(text);
|
|
dialog->setTextEchoMode(mode);
|
|
dialog->setInputMethodHints(inputMethodHints);
|
|
|
|
// find the qlineedit that this dialog holds, there should be only one
|
|
dialog->findChild<QLineEdit *>()->setMaxLength(max);
|
|
|
|
const int ret = dialog->exec();
|
|
if (ok != nullptr) {
|
|
*ok = !!ret;
|
|
}
|
|
if (ret) {
|
|
return dialog->textValue();
|
|
} else {
|
|
return QString();
|
|
}
|
|
}
|