mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-05 04:53:54 -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
|
|
@ -12,8 +12,6 @@
|
|||
#include <QDesktopServices>
|
||||
#include <QMouseEvent>
|
||||
#include <QScrollBar>
|
||||
#include <QTextDocumentFragment>
|
||||
#include <QTextEdit>
|
||||
|
||||
const QColor DEFAULT_MENTION_COLOR = QColor(194, 31, 47);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
#include "customlineedit.h"
|
||||
|
||||
#include "settingscache.h"
|
||||
|
|
@ -38,8 +37,8 @@ bool LineEditUnfocusable::isUnfocusShortcut(QKeyEvent *event)
|
|||
QKeySequence key(modifier + keyNoMod);
|
||||
QList<QKeySequence> unfocusShortcut = SettingsCache::instance().shortcuts().getShortcut("Textbox/unfocusTextBox");
|
||||
|
||||
for (QList<QKeySequence>::iterator i = unfocusShortcut.begin(); i != unfocusShortcut.end(); ++i) {
|
||||
if (key.matches(*i) == QKeySequence::ExactMatch)
|
||||
for (const auto &unfocusKey : unfocusShortcut) {
|
||||
if (key.matches(unfocusKey) == QKeySequence::ExactMatch)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -12,12 +12,13 @@ class QString;
|
|||
// shortcuts and other shortcuts
|
||||
class LineEditUnfocusable : public QLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
LineEditUnfocusable(QWidget *parent = nullptr);
|
||||
LineEditUnfocusable(const QString &contents, QWidget *parent = nullptr);
|
||||
explicit LineEditUnfocusable(QWidget *parent = nullptr);
|
||||
explicit LineEditUnfocusable(const QString &contents, QWidget *parent = nullptr);
|
||||
|
||||
private:
|
||||
bool isUnfocusShortcut(QKeyEvent *key);
|
||||
static bool isUnfocusShortcut(QKeyEvent *key);
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "dlg_connect.h"
|
||||
|
||||
#include "settingscache.h"
|
||||
#include "stringsizes.h"
|
||||
#include "userconnection_information.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
|
|
@ -39,22 +40,27 @@ DlgConnect::DlgConnect(QWidget *parent) : QDialog(parent)
|
|||
|
||||
saveLabel = new QLabel(tr("Name:"));
|
||||
saveEdit = new QLineEdit;
|
||||
saveEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
saveLabel->setBuddy(saveEdit);
|
||||
|
||||
hostLabel = new QLabel(tr("&Host:"));
|
||||
hostEdit = new QLineEdit;
|
||||
hostEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
hostLabel->setBuddy(hostEdit);
|
||||
|
||||
portLabel = new QLabel(tr("&Port:"));
|
||||
portEdit = new QLineEdit;
|
||||
portEdit->setValidator(new QIntValidator(0, 0xffff, portEdit));
|
||||
portLabel->setBuddy(portEdit);
|
||||
|
||||
playernameLabel = new QLabel(tr("Player &name:"));
|
||||
playernameEdit = new QLineEdit;
|
||||
playernameEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
playernameLabel->setBuddy(playernameEdit);
|
||||
|
||||
passwordLabel = new QLabel(tr("P&assword:"));
|
||||
passwordEdit = new QLineEdit;
|
||||
passwordEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
passwordLabel->setBuddy(passwordEdit);
|
||||
passwordEdit->setEchoMode(QLineEdit::Password);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include "decklist.h"
|
||||
#include "main.h"
|
||||
#include "settingscache.h"
|
||||
#include "stringsizes.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QCloseEvent>
|
||||
|
|
@ -28,6 +29,7 @@ DlgCreateToken::DlgCreateToken(const QStringList &_predefinedTokens, QWidget *pa
|
|||
|
||||
nameLabel = new QLabel(tr("&Name:"));
|
||||
nameEdit = new QLineEdit(tr("Token"));
|
||||
nameEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
nameEdit->selectAll();
|
||||
connect(nameEdit, SIGNAL(textChanged(const QString &)), this, SLOT(updateSearch(const QString &)));
|
||||
nameLabel->setBuddy(nameEdit);
|
||||
|
|
@ -45,10 +47,12 @@ DlgCreateToken::DlgCreateToken(const QStringList &_predefinedTokens, QWidget *pa
|
|||
|
||||
ptLabel = new QLabel(tr("&P/T:"));
|
||||
ptEdit = new QLineEdit;
|
||||
ptEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
ptLabel->setBuddy(ptEdit);
|
||||
|
||||
annotationLabel = new QLabel(tr("&Annotation:"));
|
||||
annotationEdit = new QLineEdit;
|
||||
annotationEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
annotationLabel->setBuddy(annotationEdit);
|
||||
|
||||
destroyCheckBox = new QCheckBox(tr("&Destroy token when it leaves the table"));
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include "pb/serverinfo_game.pb.h"
|
||||
#include "pending_command.h"
|
||||
#include "settingscache.h"
|
||||
#include "stringsizes.h"
|
||||
#include "tab_room.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
|
@ -24,8 +25,8 @@ void DlgCreateGame::sharedCtor()
|
|||
rememberGameSettings = new QCheckBox(tr("Re&member settings"));
|
||||
descriptionLabel = new QLabel(tr("&Description:"));
|
||||
descriptionEdit = new QLineEdit;
|
||||
descriptionEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
descriptionLabel->setBuddy(descriptionEdit);
|
||||
descriptionEdit->setMaxLength(60);
|
||||
|
||||
maxPlayersLabel = new QLabel(tr("P&layers:"));
|
||||
maxPlayersEdit = new QSpinBox();
|
||||
|
|
@ -57,6 +58,7 @@ void DlgCreateGame::sharedCtor()
|
|||
|
||||
passwordLabel = new QLabel(tr("&Password:"));
|
||||
passwordEdit = new QLineEdit;
|
||||
passwordEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
passwordLabel->setBuddy(passwordEdit);
|
||||
|
||||
onlyBuddiesCheckBox = new QCheckBox(tr("Only &buddies can join"));
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#include "dlg_edit_avatar.h"
|
||||
|
||||
#include "stringsizes.h"
|
||||
|
||||
#include <QBuffer>
|
||||
#include <QDebug>
|
||||
#include <QDialogButtonBox>
|
||||
|
|
@ -75,6 +77,13 @@ QByteArray DlgEditAvatar::getImage()
|
|||
QByteArray ba;
|
||||
QBuffer buffer(&ba);
|
||||
buffer.open(QIODevice::WriteOnly);
|
||||
image.save(&buffer, "JPG");
|
||||
return ba;
|
||||
for (;;) {
|
||||
image.save(&buffer, "JPG");
|
||||
if (ba.length() > MAX_FILE_LENGTH) {
|
||||
ba.clear();
|
||||
image = image.scaledToWidth(image.width() / 2); // divide the amount of pixels in four to get the size down
|
||||
} else {
|
||||
return ba;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "dlg_edit_password.h"
|
||||
|
||||
#include "settingscache.h"
|
||||
#include "stringsizes.h"
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QGridLayout>
|
||||
|
|
@ -12,6 +13,7 @@ DlgEditPassword::DlgEditPassword(QWidget *parent) : QDialog(parent)
|
|||
{
|
||||
oldPasswordLabel = new QLabel(tr("Old password:"));
|
||||
oldPasswordEdit = new QLineEdit();
|
||||
oldPasswordEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
|
||||
auto &servers = SettingsCache::instance().servers();
|
||||
if (servers.getSavePassword()) {
|
||||
|
|
@ -23,11 +25,13 @@ DlgEditPassword::DlgEditPassword(QWidget *parent) : QDialog(parent)
|
|||
|
||||
newPasswordLabel = new QLabel(tr("New password:"));
|
||||
newPasswordEdit = new QLineEdit();
|
||||
newPasswordEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
newPasswordLabel->setBuddy(newPasswordLabel);
|
||||
newPasswordEdit->setEchoMode(QLineEdit::Password);
|
||||
|
||||
newPasswordLabel2 = new QLabel(tr("Confirm new password:"));
|
||||
newPasswordEdit2 = new QLineEdit();
|
||||
newPasswordEdit2->setMaxLength(MAX_NAME_LENGTH);
|
||||
newPasswordLabel2->setBuddy(newPasswordLabel2);
|
||||
newPasswordEdit2->setEchoMode(QLineEdit::Password);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
#include "carddatabase.h"
|
||||
#include "carddatabasemodel.h"
|
||||
#include "gettextwithmax.h"
|
||||
#include "main.h"
|
||||
#include "stringsizes.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QComboBox>
|
||||
|
|
@ -23,6 +25,7 @@ DlgEditTokens::DlgEditTokens(QWidget *parent) : QDialog(parent), currentCard(nul
|
|||
{
|
||||
nameLabel = new QLabel(tr("&Name:"));
|
||||
nameEdit = new QLineEdit;
|
||||
nameEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
nameEdit->setEnabled(false);
|
||||
nameLabel->setBuddy(nameEdit);
|
||||
|
||||
|
|
@ -40,11 +43,13 @@ DlgEditTokens::DlgEditTokens(QWidget *parent) : QDialog(parent), currentCard(nul
|
|||
|
||||
ptLabel = new QLabel(tr("&P/T:"));
|
||||
ptEdit = new QLineEdit;
|
||||
ptEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
ptLabel->setBuddy(ptEdit);
|
||||
connect(ptEdit, SIGNAL(textChanged(QString)), this, SLOT(ptChanged(QString)));
|
||||
|
||||
annotationLabel = new QLabel(tr("&Annotation:"));
|
||||
annotationEdit = new QLineEdit;
|
||||
annotationEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
annotationLabel->setBuddy(annotationEdit);
|
||||
connect(annotationEdit, SIGNAL(textChanged(QString)), this, SLOT(annotationChanged(QString)));
|
||||
|
||||
|
|
@ -142,9 +147,8 @@ void DlgEditTokens::tokenSelectionChanged(const QModelIndex ¤t, const QMod
|
|||
void DlgEditTokens::actAddToken()
|
||||
{
|
||||
QString name;
|
||||
bool askAgain = true;
|
||||
do {
|
||||
name = QInputDialog::getText(this, tr("Add token"), tr("Please enter the name of the token:"));
|
||||
for (;;) {
|
||||
name = getTextWithMax(this, tr("Add token"), tr("Please enter the name of the token:"));
|
||||
if (name.isEmpty())
|
||||
return;
|
||||
if (databaseModel->getDatabase()->getCard(name)) {
|
||||
|
|
@ -152,9 +156,9 @@ void DlgEditTokens::actAddToken()
|
|||
tr("The chosen name conflicts with an existing card or token.\nMake sure to enable "
|
||||
"the 'Token' set in the \"Manage sets\" dialog to display them correctly."));
|
||||
} else {
|
||||
askAgain = false;
|
||||
break;
|
||||
}
|
||||
} while (askAgain);
|
||||
}
|
||||
|
||||
QString setName = CardDatabase::TOKENS_SETNAME;
|
||||
CardInfoPerSetMap sets;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "dlg_edit_user.h"
|
||||
|
||||
#include "settingscache.h"
|
||||
#include "stringsizes.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDialogButtonBox>
|
||||
|
|
@ -12,6 +13,7 @@ DlgEditUser::DlgEditUser(QWidget *parent, QString email, QString country, QStrin
|
|||
{
|
||||
emailLabel = new QLabel(tr("Email:"));
|
||||
emailEdit = new QLineEdit();
|
||||
emailEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
emailLabel->setBuddy(emailEdit);
|
||||
emailEdit->setText(email);
|
||||
|
||||
|
|
@ -33,6 +35,7 @@ DlgEditUser::DlgEditUser(QWidget *parent, QString email, QString country, QStrin
|
|||
|
||||
realnameLabel = new QLabel(tr("Real name:"));
|
||||
realnameEdit = new QLineEdit();
|
||||
realnameEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
realnameLabel->setBuddy(realnameEdit);
|
||||
realnameEdit->setText(realName);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "dlg_forgotpasswordchallenge.h"
|
||||
|
||||
#include "settingscache.h"
|
||||
#include "stringsizes.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QDebug>
|
||||
|
|
@ -38,18 +39,22 @@ DlgForgotPasswordChallenge::DlgForgotPasswordChallenge(QWidget *parent) : QDialo
|
|||
|
||||
hostLabel = new QLabel(tr("&Host:"));
|
||||
hostEdit = new QLineEdit(lastfphost);
|
||||
hostEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
hostLabel->setBuddy(hostEdit);
|
||||
|
||||
portLabel = new QLabel(tr("&Port:"));
|
||||
portEdit = new QLineEdit(lastfpport);
|
||||
portEdit->setValidator(new QIntValidator(0, 0xffff, portEdit));
|
||||
portLabel->setBuddy(portEdit);
|
||||
|
||||
playernameLabel = new QLabel(tr("Player &name:"));
|
||||
playernameEdit = new QLineEdit(lastfpplayername);
|
||||
playernameEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
playernameLabel->setBuddy(playernameEdit);
|
||||
|
||||
emailLabel = new QLabel(tr("Email:"));
|
||||
emailEdit = new QLineEdit();
|
||||
emailEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
emailLabel->setBuddy(emailLabel);
|
||||
|
||||
if (!servers.getFPHostname().isEmpty() && !servers.getFPPort().isEmpty() && !servers.getFPPlayerName().isEmpty()) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "dlg_forgotpasswordrequest.h"
|
||||
|
||||
#include "settingscache.h"
|
||||
#include "stringsizes.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QDebug>
|
||||
|
|
@ -31,14 +32,17 @@ DlgForgotPasswordRequest::DlgForgotPasswordRequest(QWidget *parent) : QDialog(pa
|
|||
|
||||
hostLabel = new QLabel(tr("&Host:"));
|
||||
hostEdit = new QLineEdit(lastfphost);
|
||||
hostEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
hostLabel->setBuddy(hostEdit);
|
||||
|
||||
portLabel = new QLabel(tr("&Port:"));
|
||||
portEdit = new QLineEdit(lastfpport);
|
||||
portEdit->setValidator(new QIntValidator(0, 0xffff, portEdit));
|
||||
portLabel->setBuddy(portEdit);
|
||||
|
||||
playernameLabel = new QLabel(tr("Player &name:"));
|
||||
playernameEdit = new QLineEdit(lastfpplayername);
|
||||
playernameEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
playernameLabel->setBuddy(playernameEdit);
|
||||
|
||||
QGridLayout *grid = new QGridLayout;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "dlg_forgotpasswordreset.h"
|
||||
|
||||
#include "settingscache.h"
|
||||
#include "stringsizes.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QDebug>
|
||||
|
|
@ -37,27 +38,33 @@ DlgForgotPasswordReset::DlgForgotPasswordReset(QWidget *parent) : QDialog(parent
|
|||
|
||||
hostLabel = new QLabel(tr("&Host:"));
|
||||
hostEdit = new QLineEdit(lastfphost);
|
||||
hostEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
hostLabel->setBuddy(hostEdit);
|
||||
|
||||
portLabel = new QLabel(tr("&Port:"));
|
||||
portEdit = new QLineEdit(lastfpport);
|
||||
portEdit->setValidator(new QIntValidator(0, 0xffff, portEdit));
|
||||
portLabel->setBuddy(portEdit);
|
||||
|
||||
playernameLabel = new QLabel(tr("Player &name:"));
|
||||
playernameEdit = new QLineEdit(lastfpplayername);
|
||||
playernameEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
playernameLabel->setBuddy(playernameEdit);
|
||||
|
||||
tokenLabel = new QLabel(tr("Token:"));
|
||||
tokenEdit = new QLineEdit();
|
||||
tokenEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
tokenLabel->setBuddy(tokenLabel);
|
||||
|
||||
newpasswordLabel = new QLabel(tr("New Password:"));
|
||||
newpasswordEdit = new QLineEdit();
|
||||
newpasswordEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
newpasswordLabel->setBuddy(newpasswordEdit);
|
||||
newpasswordEdit->setEchoMode(QLineEdit::Password);
|
||||
|
||||
newpasswordverifyLabel = new QLabel(tr("New Password:"));
|
||||
newpasswordverifyEdit = new QLineEdit();
|
||||
newpasswordverifyEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
newpasswordverifyLabel->setBuddy(newpasswordEdit);
|
||||
newpasswordverifyEdit->setEchoMode(QLineEdit::Password);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "pb/serverinfo_user.pb.h"
|
||||
#include "settingscache.h"
|
||||
#include "stringsizes.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QDebug>
|
||||
|
|
@ -20,32 +21,39 @@ DlgRegister::DlgRegister(QWidget *parent) : QDialog(parent)
|
|||
|
||||
hostLabel = new QLabel(tr("&Host:"));
|
||||
hostEdit = new QLineEdit(servers.getHostname());
|
||||
hostEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
hostLabel->setBuddy(hostEdit);
|
||||
|
||||
portLabel = new QLabel(tr("&Port:"));
|
||||
portEdit = new QLineEdit(servers.getPort());
|
||||
portEdit->setValidator(new QIntValidator(0, 0xffff, portEdit));
|
||||
portLabel->setBuddy(portEdit);
|
||||
|
||||
playernameLabel = new QLabel(tr("Player &name:"));
|
||||
playernameEdit = new QLineEdit(servers.getPlayerName());
|
||||
playernameEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
playernameLabel->setBuddy(playernameEdit);
|
||||
|
||||
passwordLabel = new QLabel(tr("P&assword:"));
|
||||
passwordEdit = new QLineEdit();
|
||||
passwordEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
passwordLabel->setBuddy(passwordEdit);
|
||||
passwordEdit->setEchoMode(QLineEdit::Password);
|
||||
|
||||
passwordConfirmationLabel = new QLabel(tr("Password (again):"));
|
||||
passwordConfirmationEdit = new QLineEdit();
|
||||
passwordConfirmationEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
passwordConfirmationLabel->setBuddy(passwordConfirmationEdit);
|
||||
passwordConfirmationEdit->setEchoMode(QLineEdit::Password);
|
||||
|
||||
emailLabel = new QLabel(tr("Email:"));
|
||||
emailEdit = new QLineEdit();
|
||||
emailEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
emailLabel->setBuddy(emailEdit);
|
||||
|
||||
emailConfirmationLabel = new QLabel(tr("Email (again):"));
|
||||
emailConfirmationEdit = new QLineEdit();
|
||||
emailConfirmationEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
emailConfirmationLabel->setBuddy(emailConfirmationEdit);
|
||||
|
||||
countryLabel = new QLabel(tr("Country:"));
|
||||
|
|
@ -308,6 +316,7 @@ DlgRegister::DlgRegister(QWidget *parent) : QDialog(parent)
|
|||
|
||||
realnameLabel = new QLabel(tr("Real name:"));
|
||||
realnameEdit = new QLineEdit();
|
||||
realnameEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
realnameLabel->setBuddy(realnameEdit);
|
||||
|
||||
QGridLayout *grid = new QGridLayout;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "dlg_settings.h"
|
||||
|
||||
#include "carddatabase.h"
|
||||
#include "gettextwithmax.h"
|
||||
#include "main.h"
|
||||
#include "releasechannel.h"
|
||||
#include "sequenceEdit/sequenceedit.h"
|
||||
|
|
@ -76,12 +77,9 @@ GeneralSettingsPage::GeneralSettingsPage()
|
|||
|
||||
connect(&languageBox, SIGNAL(currentIndexChanged(int)), this, SLOT(languageBoxChanged(int)));
|
||||
connect(&pixmapCacheEdit, SIGNAL(valueChanged(int)), &settings, SLOT(setPixmapCacheSize(int)));
|
||||
connect(&updateReleaseChannelBox, SIGNAL(currentIndexChanged(int)), &settings,
|
||||
SLOT(setUpdateReleaseChannel(int)));
|
||||
connect(&updateNotificationCheckBox, SIGNAL(stateChanged(int)), &settings,
|
||||
SLOT(setNotifyAboutUpdate(int)));
|
||||
connect(&newVersionOracleCheckBox, SIGNAL(stateChanged(int)), &settings,
|
||||
SLOT(setNotifyAboutNewVersion(int)));
|
||||
connect(&updateReleaseChannelBox, SIGNAL(currentIndexChanged(int)), &settings, SLOT(setUpdateReleaseChannel(int)));
|
||||
connect(&updateNotificationCheckBox, SIGNAL(stateChanged(int)), &settings, SLOT(setNotifyAboutUpdate(int)));
|
||||
connect(&newVersionOracleCheckBox, SIGNAL(stateChanged(int)), &settings, SLOT(setNotifyAboutNewVersion(int)));
|
||||
connect(&showTipsOnStartup, SIGNAL(clicked(bool)), &settings, SLOT(setShowTipsOnStartup(bool)));
|
||||
|
||||
auto *personalGrid = new QGridLayout;
|
||||
|
|
@ -949,7 +947,8 @@ void MessagesSettingsPage::storeSettings()
|
|||
void MessagesSettingsPage::actAdd()
|
||||
{
|
||||
bool ok;
|
||||
QString msg = QInputDialog::getText(this, tr("Add message"), tr("Message:"), QLineEdit::Normal, QString(), &ok);
|
||||
QString msg =
|
||||
getTextWithMax(this, tr("Add message"), tr("Message:"), QLineEdit::Normal, QString(), &ok, MAX_TEXT_LENGTH);
|
||||
if (ok) {
|
||||
messageList->addItem(msg);
|
||||
storeSettings();
|
||||
|
|
@ -961,7 +960,8 @@ void MessagesSettingsPage::actEdit()
|
|||
if (messageList->currentItem()) {
|
||||
QString oldText = messageList->currentItem()->text();
|
||||
bool ok;
|
||||
QString msg = QInputDialog::getText(this, tr("Edit message"), tr("Message:"), QLineEdit::Normal, oldText, &ok);
|
||||
QString msg =
|
||||
getTextWithMax(this, tr("Edit message"), tr("Message:"), QLineEdit::Normal, oldText, &ok, MAX_TEXT_LENGTH);
|
||||
if (ok) {
|
||||
messageList->currentItem()->setText(msg);
|
||||
storeSettings();
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "dlg_creategame.h"
|
||||
#include "dlg_filter_games.h"
|
||||
#include "gamesmodel.h"
|
||||
#include "gettextwithmax.h"
|
||||
#include "pb/response.pb.h"
|
||||
#include "pb/room_commands.pb.h"
|
||||
#include "pb/serverinfo_game.pb.h"
|
||||
|
|
@ -243,7 +244,7 @@ void GameSelector::actJoin()
|
|||
QString password;
|
||||
if (game.with_password() && !(spectator && !game.spectators_need_password()) && !overrideRestrictions) {
|
||||
bool ok;
|
||||
password = QInputDialog::getText(this, tr("Join game"), tr("Password:"), QLineEdit::Password, QString(), &ok);
|
||||
password = getTextWithMax(this, tr("Join game"), tr("Password:"), QLineEdit::Password, QString(), &ok);
|
||||
if (!ok)
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
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();
|
||||
}
|
||||
}
|
||||
23
cockatrice/src/gettextwithmax.h
Normal file
23
cockatrice/src/gettextwithmax.h
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// custom QInputDialog::getText implementation that allows configuration of the max length
|
||||
#ifndef GETTEXTWITHMAX_H
|
||||
#define GETTEXTWITHMAX_H
|
||||
|
||||
#include "stringsizes.h"
|
||||
|
||||
#include <QInputDialog>
|
||||
|
||||
QString getTextWithMax(QWidget *parent,
|
||||
const QString &title,
|
||||
const QString &label,
|
||||
QLineEdit::EchoMode echo = QLineEdit::Normal,
|
||||
const QString &text = QString(),
|
||||
bool *ok = nullptr,
|
||||
int max = MAX_NAME_LENGTH,
|
||||
Qt::WindowFlags flags = Qt::WindowFlags(),
|
||||
Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
|
||||
static inline QString getTextWithMax(QWidget *parent, const QString &title, const QString &label, int max)
|
||||
{
|
||||
return getTextWithMax(parent, title, label, QLineEdit::Normal, QString(), nullptr, max);
|
||||
}
|
||||
|
||||
#endif // GETTEXTWITHMAX_H
|
||||
|
|
@ -10,6 +10,7 @@
|
|||
#include "deck_loader.h"
|
||||
#include "dlg_create_token.h"
|
||||
#include "gamescene.h"
|
||||
#include "gettextwithmax.h"
|
||||
#include "handcounter.h"
|
||||
#include "handzone.h"
|
||||
#include "main.h"
|
||||
|
|
@ -56,6 +57,7 @@
|
|||
#include "playertarget.h"
|
||||
#include "settingscache.h"
|
||||
#include "stackzone.h"
|
||||
#include "stringsizes.h"
|
||||
#include "tab_game.h"
|
||||
#include "tablezone.h"
|
||||
#include "thememanager.h"
|
||||
|
|
@ -3034,8 +3036,8 @@ void Player::actSetPT()
|
|||
}
|
||||
bool ok;
|
||||
dialogSemaphore = true;
|
||||
QString pt = QInputDialog::getText(game, tr("Change power/toughness"), tr("Change stats to:"), QLineEdit::Normal,
|
||||
oldPT, &ok);
|
||||
QString pt =
|
||||
getTextWithMax(game, tr("Change power/toughness"), tr("Change stats to:"), QLineEdit::Normal, oldPT, &ok);
|
||||
dialogSemaphore = false;
|
||||
if (clearCardsToDelete() || !ok) {
|
||||
return;
|
||||
|
|
@ -3141,7 +3143,8 @@ void Player::actSetAnnotation()
|
|||
bool ok;
|
||||
dialogSemaphore = true;
|
||||
QString annotation = QInputDialog::getMultiLineText(game, tr("Set annotation"),
|
||||
tr("Please enter the new annotation:"), oldAnnotation, &ok);
|
||||
tr("Please enter the new annotation:"), oldAnnotation, &ok)
|
||||
.left(MAX_NAME_LENGTH);
|
||||
dialogSemaphore = false;
|
||||
if (clearCardsToDelete() || !ok) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#include "pb/session_commands.pb.h"
|
||||
#include "pending_command.h"
|
||||
#include "soundengine.h"
|
||||
#include "stringsizes.h"
|
||||
#include "userinfobox.h"
|
||||
#include "userlist.h"
|
||||
|
||||
|
|
@ -60,6 +61,7 @@ TabUserLists::TabUserLists(TabSupervisor *_tabSupervisor,
|
|||
|
||||
QHBoxLayout *addToBuddyList = new QHBoxLayout;
|
||||
addBuddyEdit = new LineEditUnfocusable;
|
||||
addBuddyEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
addBuddyEdit->setPlaceholderText(tr("Add to Buddy List"));
|
||||
connect(addBuddyEdit, SIGNAL(returnPressed()), this, SLOT(addToBuddyList()));
|
||||
QPushButton *addBuddyButton = new QPushButton("Add");
|
||||
|
|
@ -69,6 +71,7 @@ TabUserLists::TabUserLists(TabSupervisor *_tabSupervisor,
|
|||
|
||||
QHBoxLayout *addToIgnoreList = new QHBoxLayout;
|
||||
addIgnoreEdit = new LineEditUnfocusable;
|
||||
addIgnoreEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
addIgnoreEdit->setPlaceholderText(tr("Add to Ignore List"));
|
||||
connect(addIgnoreEdit, SIGNAL(returnPressed()), this, SLOT(addToIgnoreList()));
|
||||
QPushButton *addIgnoreButton = new QPushButton("Add");
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "abstractclient.h"
|
||||
#include "pb/admin_commands.pb.h"
|
||||
#include "stringsizes.h"
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QGridLayout>
|
||||
|
|
@ -18,6 +19,7 @@ ShutdownDialog::ShutdownDialog(QWidget *parent) : QDialog(parent)
|
|||
{
|
||||
QLabel *reasonLabel = new QLabel(tr("&Reason for shutdown:"));
|
||||
reasonEdit = new QLineEdit;
|
||||
reasonEdit->setMaxLength(MAX_TEXT_LENGTH);
|
||||
reasonLabel->setBuddy(reasonEdit);
|
||||
QLabel *minutesLabel = new QLabel(tr("&Time until shutdown (minutes):"));
|
||||
minutesEdit = new QSpinBox;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
#include "pictureloader.h"
|
||||
#include "pixmapgenerator.h"
|
||||
#include "settingscache.h"
|
||||
#include "stringsizes.h"
|
||||
#include "tab_supervisor.h"
|
||||
#include "tappedout_interface.h"
|
||||
|
||||
|
|
@ -81,6 +82,7 @@ void TabDeckEditor::createDeckDock()
|
|||
nameLabel = new QLabel();
|
||||
nameLabel->setObjectName("nameLabel");
|
||||
nameEdit = new LineEditUnfocusable;
|
||||
nameEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
nameEdit->setObjectName("nameEdit");
|
||||
nameLabel->setBuddy(nameEdit);
|
||||
connect(nameEdit, SIGNAL(textChanged(const QString &)), this, SLOT(updateName(const QString &)));
|
||||
|
|
@ -798,9 +800,15 @@ bool TabDeckEditor::actSaveDeck()
|
|||
{
|
||||
DeckLoader *const deck = deckModel->getDeckList();
|
||||
if (deck->getLastRemoteDeckId() != -1) {
|
||||
QString deckString = deck->writeToString_Native();
|
||||
if (deckString.length() > MAX_FILE_LENGTH) {
|
||||
QMessageBox::critical(this, tr("Error"), tr("Could not save remote deck"));
|
||||
return false;
|
||||
}
|
||||
|
||||
Command_DeckUpload cmd;
|
||||
cmd.set_deck_id(static_cast<google::protobuf::uint32>(deck->getLastRemoteDeckId()));
|
||||
cmd.set_deck_list(deck->writeToString_Native().toStdString());
|
||||
cmd.set_deck_list(deckString.toStdString());
|
||||
|
||||
PendingCommand *pend = AbstractClient::prepareSessionCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this,
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include "abstractclient.h"
|
||||
#include "deck_loader.h"
|
||||
#include "decklist.h"
|
||||
#include "gettextwithmax.h"
|
||||
#include "pb/command_deck_del.pb.h"
|
||||
#include "pb/command_deck_del_dir.pb.h"
|
||||
#include "pb/command_deck_download.pb.h"
|
||||
|
|
@ -17,6 +18,7 @@
|
|||
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QFileSystemModel>
|
||||
#include <QGroupBox>
|
||||
#include <QHBoxLayout>
|
||||
|
|
@ -127,6 +129,24 @@ void TabDeckStorage::retranslateUi()
|
|||
aDeleteRemoteDeck->setText(tr("Delete"));
|
||||
}
|
||||
|
||||
QString TabDeckStorage::getTargetPath() const
|
||||
{
|
||||
RemoteDeckList_TreeModel::Node *curRight = serverDirView->getCurrentItem();
|
||||
if (curRight == nullptr)
|
||||
return {};
|
||||
auto *dir = dynamic_cast<RemoteDeckList_TreeModel::DirectoryNode *>(curRight);
|
||||
if (dir == nullptr) {
|
||||
dir = dynamic_cast<RemoteDeckList_TreeModel::DirectoryNode *>(curRight->getParent());
|
||||
if (dir != nullptr) {
|
||||
return dir->getPath();
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
} else {
|
||||
return dir->getPath();
|
||||
}
|
||||
}
|
||||
|
||||
void TabDeckStorage::actOpenLocalDeck()
|
||||
{
|
||||
QModelIndex curLeft = localDirView->selectionModel()->currentIndex();
|
||||
|
|
@ -146,35 +166,45 @@ void TabDeckStorage::actUpload()
|
|||
QModelIndex curLeft = localDirView->selectionModel()->currentIndex();
|
||||
if (localDirModel->isDir(curLeft))
|
||||
return;
|
||||
QString targetPath = getTargetPath();
|
||||
if (targetPath.length() > MAX_NAME_LENGTH) {
|
||||
qCritical() << "target path to upload to is too long" << targetPath;
|
||||
return;
|
||||
}
|
||||
|
||||
QString filePath = localDirModel->filePath(curLeft);
|
||||
QFile deckFile(filePath);
|
||||
QFileInfo deckFileInfo(deckFile);
|
||||
|
||||
QString deckString;
|
||||
DeckLoader deck;
|
||||
if (!deck.loadFromFile(filePath, DeckLoader::CockatriceFormat))
|
||||
bool error = !deck.loadFromFile(filePath, DeckLoader::CockatriceFormat);
|
||||
if (!error) {
|
||||
deckString = deck.writeToString_Native();
|
||||
error = deckString.length() > MAX_FILE_LENGTH;
|
||||
}
|
||||
if (error) {
|
||||
QMessageBox::critical(this, tr("Error"), tr("Invalid deck file"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (deck.getName().isEmpty()) {
|
||||
bool ok;
|
||||
QString deckName = QInputDialog::getText(this, tr("Enter deck name"),
|
||||
tr("This decklist does not have a name.\nPlease enter a name:"),
|
||||
QLineEdit::Normal, deckFileInfo.completeBaseName(), &ok);
|
||||
QString deckName =
|
||||
getTextWithMax(this, tr("Enter deck name"), tr("This decklist does not have a name.\nPlease enter a name:"),
|
||||
QLineEdit::Normal, deckFileInfo.completeBaseName(), &ok);
|
||||
if (!ok)
|
||||
return;
|
||||
if (deckName.isEmpty())
|
||||
deckName = tr("Unnamed deck");
|
||||
deck.setName(deckName);
|
||||
} else {
|
||||
deck.setName(deck.getName().left(MAX_NAME_LENGTH));
|
||||
}
|
||||
|
||||
QString targetPath;
|
||||
RemoteDeckList_TreeModel::Node *curRight = serverDirView->getCurrentItem();
|
||||
if (!curRight)
|
||||
return;
|
||||
if (!dynamic_cast<RemoteDeckList_TreeModel::DirectoryNode *>(curRight))
|
||||
curRight = curRight->getParent();
|
||||
targetPath = dynamic_cast<RemoteDeckList_TreeModel::DirectoryNode *>(curRight)->getPath();
|
||||
|
||||
Command_DeckUpload cmd;
|
||||
cmd.set_path(targetPath.toStdString());
|
||||
cmd.set_deck_list(deck.writeToString_Native().toStdString());
|
||||
cmd.set_deck_list(deckString.toStdString());
|
||||
|
||||
PendingCommand *pend = client->prepareSessionCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this,
|
||||
|
|
@ -184,8 +214,11 @@ void TabDeckStorage::actUpload()
|
|||
|
||||
void TabDeckStorage::uploadFinished(const Response &r, const CommandContainer &commandContainer)
|
||||
{
|
||||
if (r.response_code() != Response::RespOk)
|
||||
if (r.response_code() != Response::RespOk) {
|
||||
qCritical() << "failed to upload deck:" << r.response_code();
|
||||
QMessageBox::critical(this, tr("Error"), tr("Failed to upload deck to server"));
|
||||
return;
|
||||
}
|
||||
|
||||
const Response_DeckUpload &resp = r.GetExtension(Response_DeckUpload::ext);
|
||||
const Command_DeckUpload &cmd = commandContainer.session_command(0).GetExtension(Command_DeckUpload::ext);
|
||||
|
|
@ -282,7 +315,13 @@ void TabDeckStorage::downloadFinished(const Response &r,
|
|||
|
||||
void TabDeckStorage::actNewFolder()
|
||||
{
|
||||
QString folderName = QInputDialog::getText(this, tr("New folder"), tr("Name of new folder:"));
|
||||
QString targetPath = getTargetPath();
|
||||
int max_length = MAX_NAME_LENGTH - targetPath.length() - 1; // generated length would be path + / + name
|
||||
|
||||
if (max_length < 1) // can't create path that's short enough
|
||||
return;
|
||||
|
||||
QString folderName = getTextWithMax(this, tr("New folder"), tr("Name of new folder:"), max_length);
|
||||
if (folderName.isEmpty())
|
||||
return;
|
||||
|
||||
|
|
@ -291,15 +330,6 @@ void TabDeckStorage::actNewFolder()
|
|||
std::string folder = folderName.toStdString();
|
||||
std::replace(folder.begin(), folder.end(), '/', '-');
|
||||
|
||||
QString targetPath;
|
||||
RemoteDeckList_TreeModel::Node *curRight = serverDirView->getCurrentItem();
|
||||
if (!curRight)
|
||||
return;
|
||||
if (!dynamic_cast<RemoteDeckList_TreeModel::DirectoryNode *>(curRight))
|
||||
curRight = curRight->getParent();
|
||||
RemoteDeckList_TreeModel::DirectoryNode *dir = dynamic_cast<RemoteDeckList_TreeModel::DirectoryNode *>(curRight);
|
||||
targetPath = dir->getPath();
|
||||
|
||||
Command_DeckNewDir cmd;
|
||||
cmd.set_path(targetPath.toStdString());
|
||||
cmd.set_dir_name(folder);
|
||||
|
|
@ -328,15 +358,19 @@ void TabDeckStorage::actDeleteRemoteDeck()
|
|||
return;
|
||||
RemoteDeckList_TreeModel::DirectoryNode *dir = dynamic_cast<RemoteDeckList_TreeModel::DirectoryNode *>(curRight);
|
||||
if (dir) {
|
||||
QString path = dir->getPath();
|
||||
if (path.isEmpty())
|
||||
QString targetPath = dir->getPath();
|
||||
if (targetPath.isEmpty())
|
||||
return;
|
||||
if (targetPath.length() > MAX_NAME_LENGTH) {
|
||||
qCritical() << "target path to delete is too long" << targetPath;
|
||||
return;
|
||||
}
|
||||
if (QMessageBox::warning(this, tr("Delete remote folder"),
|
||||
tr("Are you sure you want to delete \"%1\"?").arg(path),
|
||||
tr("Are you sure you want to delete \"%1\"?").arg(targetPath),
|
||||
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
|
||||
return;
|
||||
Command_DeckDelDir cmd;
|
||||
cmd.set_path(path.toStdString());
|
||||
cmd.set_path(targetPath.toStdString());
|
||||
pend = client->prepareSessionCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this,
|
||||
SLOT(deleteFolderFinished(Response, CommandContainer)));
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ private:
|
|||
QGroupBox *leftGroupBox, *rightGroupBox;
|
||||
|
||||
QAction *aOpenLocalDeck, *aUpload, *aDeleteLocalDeck, *aOpenRemoteDeck, *aDownload, *aNewFolder, *aDeleteRemoteDeck;
|
||||
QString getTargetPath() const;
|
||||
private slots:
|
||||
void actOpenLocalDeck();
|
||||
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@
|
|||
#include "playerlistwidget.h"
|
||||
#include "replay_timeline_widget.h"
|
||||
#include "settingscache.h"
|
||||
#include "stringsizes.h"
|
||||
#include "tab_supervisor.h"
|
||||
#include "window_main.h"
|
||||
#include "zoneviewwidget.h"
|
||||
|
|
@ -268,14 +269,21 @@ void DeckViewContainer::loadLocalDeck()
|
|||
|
||||
QString fileName = dialog.selectedFiles().at(0);
|
||||
DeckLoader::FileFormat fmt = DeckLoader::getFormatFromName(fileName);
|
||||
QString deckString;
|
||||
DeckLoader deck;
|
||||
if (!deck.loadFromFile(fileName, fmt)) {
|
||||
|
||||
bool error = !deck.loadFromFile(fileName, fmt);
|
||||
if (!error) {
|
||||
deckString = deck.writeToString_Native();
|
||||
error = deckString.length() > MAX_FILE_LENGTH;
|
||||
}
|
||||
if (error) {
|
||||
QMessageBox::critical(this, tr("Error"), tr("The selected file could not be loaded."));
|
||||
return;
|
||||
}
|
||||
|
||||
Command_DeckSelect cmd;
|
||||
cmd.set_deck(deck.writeToString_Native().toStdString());
|
||||
cmd.set_deck(deckString.toStdString());
|
||||
PendingCommand *pend = parentGame->prepareGameCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this,
|
||||
SLOT(deckSelectFinished(const Response &)));
|
||||
|
|
@ -1823,6 +1831,7 @@ void TabGame::createMessageDock(bool bReplay)
|
|||
|
||||
sayLabel = new QLabel;
|
||||
sayEdit = new LineEditCompleter;
|
||||
sayEdit->setMaxLength(MAX_TEXT_LENGTH);
|
||||
sayLabel->setBuddy(sayEdit);
|
||||
completer = new QCompleter(autocompleteUserList, sayEdit);
|
||||
completer->setCaseSensitivity(Qt::CaseInsensitive);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include "pb/moderator_commands.pb.h"
|
||||
#include "pb/response_viewlog_history.pb.h"
|
||||
#include "pending_command.h"
|
||||
#include "stringsizes.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QDialogButtonBox>
|
||||
|
|
@ -148,18 +149,23 @@ void TabLog::createDock()
|
|||
{
|
||||
labelFindUserName = new QLabel(tr("Username: "));
|
||||
findUsername = new LineEditUnfocusable("");
|
||||
findUsername->setMaxLength(MAX_NAME_LENGTH);
|
||||
findUsername->setAlignment(Qt::AlignCenter);
|
||||
labelFindIPAddress = new QLabel(tr("IP Address: "));
|
||||
findIPAddress = new LineEditUnfocusable("");
|
||||
findIPAddress->setMaxLength(MAX_NAME_LENGTH);
|
||||
findIPAddress->setAlignment(Qt::AlignCenter);
|
||||
labelFindGameName = new QLabel(tr("Game Name: "));
|
||||
findGameName = new LineEditUnfocusable("");
|
||||
findGameName->setMaxLength(MAX_NAME_LENGTH);
|
||||
findGameName->setAlignment(Qt::AlignCenter);
|
||||
labelFindGameID = new QLabel(tr("GameID: "));
|
||||
findGameID = new LineEditUnfocusable("");
|
||||
findGameID->setMaxLength(MAX_NAME_LENGTH);
|
||||
findGameID->setAlignment(Qt::AlignCenter);
|
||||
labelMessage = new QLabel(tr("Message: "));
|
||||
findMessage = new LineEditUnfocusable("");
|
||||
findMessage->setMaxLength(MAX_TEXT_LENGTH);
|
||||
findMessage->setAlignment(Qt::AlignCenter);
|
||||
|
||||
mainRoom = new QCheckBox(tr("Main Room"));
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#include "pending_command.h"
|
||||
#include "settingscache.h"
|
||||
#include "soundengine.h"
|
||||
#include "stringsizes.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
|
|
@ -29,6 +30,7 @@ TabMessage::TabMessage(TabSupervisor *_tabSupervisor,
|
|||
connect(chatView, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString)));
|
||||
connect(chatView, SIGNAL(addMentionTag(QString)), this, SLOT(addMentionTag(QString)));
|
||||
sayEdit = new LineEditUnfocusable;
|
||||
sayEdit->setMaxLength(MAX_TEXT_LENGTH);
|
||||
connect(sayEdit, SIGNAL(returnPressed()), this, SLOT(sendMessage()));
|
||||
|
||||
QVBoxLayout *vbox = new QVBoxLayout;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
#include "pb/serverinfo_room.pb.h"
|
||||
#include "pending_command.h"
|
||||
#include "settingscache.h"
|
||||
#include "stringsizes.h"
|
||||
#include "tab_account.h"
|
||||
#include "tab_supervisor.h"
|
||||
#include "userlist.h"
|
||||
|
|
@ -60,6 +61,7 @@ TabRoom::TabRoom(TabSupervisor *_tabSupervisor,
|
|||
connect(&SettingsCache::instance(), SIGNAL(chatMentionCompleterChanged()), this, SLOT(actCompleterChanged()));
|
||||
sayLabel = new QLabel;
|
||||
sayEdit = new LineEditCompleter;
|
||||
sayEdit->setMaxLength(MAX_TEXT_LENGTH);
|
||||
sayLabel->setBuddy(sayEdit);
|
||||
connect(sayEdit, SIGNAL(returnPressed()), this, SLOT(sendMessage()));
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include "pb/session_commands.pb.h"
|
||||
#include "pending_command.h"
|
||||
#include "pixmapgenerator.h"
|
||||
#include "stringsizes.h"
|
||||
#include "tab_account.h"
|
||||
#include "tab_supervisor.h"
|
||||
#include "user_context_menu.h"
|
||||
|
|
@ -36,12 +37,15 @@ BanDialog::BanDialog(const ServerInfo_User &info, QWidget *parent) : QDialog(par
|
|||
nameBanCheckBox = new QCheckBox(tr("ban &user name"));
|
||||
nameBanCheckBox->setChecked(true);
|
||||
nameBanEdit = new QLineEdit(QString::fromStdString(info.name()));
|
||||
nameBanEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
ipBanCheckBox = new QCheckBox(tr("ban &IP address"));
|
||||
ipBanCheckBox->setChecked(true);
|
||||
ipBanEdit = new QLineEdit(QString::fromStdString(info.address()));
|
||||
ipBanEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
idBanCheckBox = new QCheckBox(tr("ban client I&D"));
|
||||
idBanCheckBox->setChecked(true);
|
||||
idBanEdit = new QLineEdit(QString::fromStdString(info.clientid()));
|
||||
idBanEdit->setMaxLength(MAX_NAME_LENGTH);
|
||||
if (QString::fromStdString(info.clientid()).isEmpty())
|
||||
idBanCheckBox->setChecked(false);
|
||||
|
||||
|
|
@ -129,7 +133,9 @@ WarningDialog::WarningDialog(const QString userName, const QString clientID, QWi
|
|||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
descriptionLabel = new QLabel(tr("Which warning would you like to send?"));
|
||||
nameWarning = new QLineEdit(userName);
|
||||
nameWarning->setMaxLength(MAX_NAME_LENGTH);
|
||||
warnClientID = new QLineEdit(clientID);
|
||||
warnClientID->setMaxLength(MAX_NAME_LENGTH);
|
||||
warningOption = new QComboBox();
|
||||
warningOption->addItem("");
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
#include "dlg_tip_of_the_day.h"
|
||||
#include "dlg_update.h"
|
||||
#include "dlg_viewlog.h"
|
||||
#include "gettextwithmax.h"
|
||||
#include "localclient.h"
|
||||
#include "localserver.h"
|
||||
#include "localserverinterface.h"
|
||||
|
|
@ -426,10 +427,10 @@ void MainWindow::loginError(Response::ResponseCode r,
|
|||
break;
|
||||
case Response::RespAccountNotActivated: {
|
||||
bool ok = false;
|
||||
QString token = QInputDialog::getText(this, tr("Account activation"),
|
||||
tr("Your account has not been activated yet.\nYou need to provide "
|
||||
"the activation token received in the activation email."),
|
||||
QLineEdit::Normal, QString(), &ok);
|
||||
QString token = getTextWithMax(this, tr("Account activation"),
|
||||
tr("Your account has not been activated yet.\nYou need to provide "
|
||||
"the activation token received in the activation email."),
|
||||
QLineEdit::Normal, QString(), &ok);
|
||||
if (ok && !token.isEmpty()) {
|
||||
client->activateToServer(token);
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue