# HG changeset patch # User koda # Date 1308558980 -7200 # Node ID e6b1a11c15e82f5562b75b151014621876991b0a # Parent 5e6f5373f6860ba2b0d3e2c4f26cb0c90c803392# Parent 2db030882bc90144f546f800fc702ee8211f0a0e merge Zorg's changes diff -r 2db030882bc9 -r e6b1a11c15e8 QTfrontend/gameuiconfig.cpp --- a/QTfrontend/gameuiconfig.cpp Mon Jun 20 02:03:15 2011 -0400 +++ b/QTfrontend/gameuiconfig.cpp Mon Jun 20 10:36:20 2011 +0200 @@ -75,6 +75,8 @@ Form->ui.pageOptions->editNetNick->setText(netNick); + Form->ui.pageOptions->editNetPassword->installEventFilter(this); + int passLength = value("net/passwordlength", 0).toInt(); setNetPasswordLength(passLength); @@ -327,6 +329,24 @@ return (netPasswordLength() == 0 || Form->ui.pageOptions->editNetPassword->text() != QString(netPasswordLength(), '\0')); } +// When hedgewars launches, the password field is set with null characters. If the user tries to edit the field and there are such characters, then clear the field +bool GameUIConfig::eventFilter(QObject *object, QEvent *event) +{ + if (event->type() == QEvent::FocusIn) + { + if ((QLineEdit *)object == Form->ui.pageOptions->editNetPassword) + { + if (!netPasswordIsValid()) + { + Form->ui.pageOptions->editNetPassword->clear(); + } + } + } + + // Don't filter anything + return false; +} + void GameUIConfig::setNetPasswordLength(int passwordLength) { if (passwordLength > 0) diff -r 2db030882bc9 -r e6b1a11c15e8 QTfrontend/gameuiconfig.h --- a/QTfrontend/gameuiconfig.h Mon Jun 20 02:03:15 2011 -0400 +++ b/QTfrontend/gameuiconfig.h Mon Jun 20 10:36:20 2011 +0200 @@ -22,6 +22,7 @@ #include #include #include +#include class HWForm; class QSettings; @@ -69,9 +70,9 @@ public slots: void SaveOptions(); - private: bool netPasswordIsValid(); + bool eventFilter(QObject *object, QEvent *event); quint8 depth; };