mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-11 08:34:52 -07:00
implement max lengths for input dialogs that are sent to the server (#4522)
* implement max lengths for input dialogs that are sent to the server * missed a double setMaxLength * implement max string lengths server side * add custom getText dialog with max length * fix deck storage tab and miscellaneous server side * add max size for deck uploads * final pass on client side limits
This commit is contained in:
parent
d61c604bf4
commit
994704d353
37 changed files with 564 additions and 348 deletions
32
cockatrice/src/gettextwithmax.cpp
Normal file
32
cockatrice/src/gettextwithmax.cpp
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#include "gettextwithmax.h"
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue