From 5a87ce08b33c796a83811d17e331a6bb85491423 Mon Sep 17 00:00:00 2001 From: doitux Date: Fri, 21 Dec 2012 00:36:01 +0100 Subject: [PATCH] android return key behaviour enhancements --- .../changecompleteblindsdialogimpl.cpp | 40 ++++++++++++++++++ .../changecompleteblindsdialogimpl.h | 1 + .../changecontentdialogimpl.cpp | 28 +++++++++++++ .../changecontentdialogimpl.h | 1 + .../createinternetgamedialogimpl.cpp | 42 +++++++++++++++++++ .../createinternetgamedialogimpl.h | 1 + .../createnetworkgamedialogimpl.cpp | 36 ++++++++++++++++ .../createnetworkgamedialogimpl.h | 1 + .../internetgamelogindialogimpl.cpp | 2 +- .../newlocalgamedialog/newgamedialogimpl.cpp | 2 +- 10 files changed, 152 insertions(+), 2 deletions(-) diff --git a/src/gui/qt/changecompleteblindsdialog/changecompleteblindsdialogimpl.cpp b/src/gui/qt/changecompleteblindsdialog/changecompleteblindsdialogimpl.cpp index 081cbce3..4d8619e3 100644 --- a/src/gui/qt/changecompleteblindsdialog/changecompleteblindsdialogimpl.cpp +++ b/src/gui/qt/changecompleteblindsdialog/changecompleteblindsdialogimpl.cpp @@ -29,6 +29,7 @@ changeCompleteBlindsDialogImpl::changeCompleteBlindsDialogImpl(QWidget *parent, setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); #endif setupUi(this); + this->installEventFilter(this); connect( pushButton_add, SIGNAL( clicked() ), this, SLOT( addBlindValueToList() ) ); connect( pushButton_delete, SIGNAL( clicked() ), this, SLOT( removeBlindFromList() ) ); @@ -92,3 +93,42 @@ void changeCompleteBlindsDialogImpl::sortBlindsList() listWidget_blinds->clear(); listWidget_blinds->addItems(tempStringList); } + + +bool changeCompleteBlindsDialogImpl::eventFilter(QObject *obj, QEvent *event) +{ + QKeyEvent *keyEvent = static_cast(event); + +#ifdef ANDROID + //androi changes for return key behavior (hopefully useless from necessitas beta2) + if (event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_Return) { + if(spinBox_afterThisAlwaysRaiseValue->hasFocus()) { + spinBox_afterThisAlwaysRaiseValue->clearFocus(); + } + if(spinBox_firstSmallBlind->hasFocus()) { + spinBox_firstSmallBlind->clearFocus(); + } + if(spinBox_input->hasFocus()) { + spinBox_input->clearFocus(); + } + if(spinBox_raiseSmallBlindEveryHands->hasFocus()) { + spinBox_raiseSmallBlindEveryHands->clearFocus(); + } + if(spinBox_raiseSmallBlindEveryMinutes->hasFocus()) { + spinBox_raiseSmallBlindEveryMinutes->clearFocus(); + } + event->ignore(); + return false; + } + else if (event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_Back) { + this->reject(); + return true; + } + else { + // pass the event on to the parent class + return QDialog::eventFilter(obj, event); + } +#else + return QDialog::eventFilter(obj, event); +#endif +} diff --git a/src/gui/qt/changecompleteblindsdialog/changecompleteblindsdialogimpl.h b/src/gui/qt/changecompleteblindsdialog/changecompleteblindsdialogimpl.h index 4dc784a4..7ceb1105 100644 --- a/src/gui/qt/changecompleteblindsdialog/changecompleteblindsdialogimpl.h +++ b/src/gui/qt/changecompleteblindsdialog/changecompleteblindsdialogimpl.h @@ -36,6 +36,7 @@ public: changeCompleteBlindsDialogImpl(QWidget *parent = 0, ConfigFile *c = 0); void exec(); + bool eventFilter(QObject *obj, QEvent *event); public slots: bool getSettingsCorrect() const { diff --git a/src/gui/qt/changecontentdialog/changecontentdialogimpl.cpp b/src/gui/qt/changecontentdialog/changecontentdialogimpl.cpp index 4654dc30..1d6b6e3f 100644 --- a/src/gui/qt/changecontentdialog/changecontentdialogimpl.cpp +++ b/src/gui/qt/changecontentdialog/changecontentdialogimpl.cpp @@ -27,6 +27,7 @@ changeContentDialogImpl::changeContentDialogImpl(QWidget *parent, ConfigFile *co setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); #endif setupUi(this); + this->installEventFilter(this); switch (myType) { case CHANGE_HUMAN_PLAYER_NAME: { @@ -106,3 +107,30 @@ void changeContentDialogImpl::saveContent() myConfig->writeBuffer(); } + + +bool changeContentDialogImpl::eventFilter(QObject *obj, QEvent *event) +{ + QKeyEvent *keyEvent = static_cast(event); + +#ifdef ANDROID + //androi changes for return key behavior (hopefully useless from necessitas beta2) + if (event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_Return) { + if(lineEdit->hasFocus()) { + lineEdit->clearFocus(); + } + event->ignore(); + return false; + } + else if (event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_Back) { + this->reject(); + return true; + } + else { + // pass the event on to the parent class + return QDialog::eventFilter(obj, event); + } +#else + return QDialog::eventFilter(obj, event); +#endif +} diff --git a/src/gui/qt/changecontentdialog/changecontentdialogimpl.h b/src/gui/qt/changecontentdialog/changecontentdialogimpl.h index a755b63c..f36a789b 100644 --- a/src/gui/qt/changecontentdialog/changecontentdialogimpl.h +++ b/src/gui/qt/changecontentdialog/changecontentdialogimpl.h @@ -35,6 +35,7 @@ class changeContentDialogImpl: public QDialog, public Ui::changeContentDialog Q_OBJECT public: changeContentDialogImpl(QWidget *parent, ConfigFile *config, DialogType t); + bool eventFilter(QObject *obj, QEvent *event); public slots: diff --git a/src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.cpp b/src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.cpp index 7e17a43b..5edbfaea 100644 --- a/src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.cpp +++ b/src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.cpp @@ -30,6 +30,7 @@ createInternetGameDialogImpl::createInternetGameDialogImpl(QWidget *parent, Conf setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); #endif setupUi(this); + this->installEventFilter(this); comboBox_gameType->setItemData(0, GAME_TYPE_NORMAL, Qt::UserRole); comboBox_gameType->setItemData(1, GAME_TYPE_REGISTERED_ONLY, Qt::UserRole); @@ -231,3 +232,44 @@ void createInternetGameDialogImpl::gameTypeChanged() myChangeCompleteBlindsDialog->radioButton_afterThisStayAtLastBlind->setChecked(myConfig->readConfigInt("NetAfterMBStayAtLastBlind")); } } + +bool createInternetGameDialogImpl::eventFilter(QObject *obj, QEvent *event) +{ + QKeyEvent *keyEvent = static_cast(event); + +#ifdef ANDROID + //androi changes for return key behavior (hopefully useless from necessitas beta2) + if (event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_Return) { + if(spinBox_startCash->hasFocus()) { + spinBox_startCash->clearFocus(); + } + if(spinBox_quantityPlayers->hasFocus()) { + spinBox_quantityPlayers->clearFocus(); + } + if(spinBox_netTimeOutPlayerAction->hasFocus()) { + spinBox_netTimeOutPlayerAction->clearFocus(); + } + if(spinBox_netDelayBetweenHands->hasFocus()) { + spinBox_netDelayBetweenHands->clearFocus(); + } + if(lineEdit_gameName->hasFocus()) { + lineEdit_gameName->clearFocus(); + } + if(lineEdit_Password->hasFocus()) { + lineEdit_Password->clearFocus(); + } + event->ignore(); + return false; + } + else if (event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_Back) { + this->reject(); + return true; + } + else { + // pass the event on to the parent class + return QDialog::eventFilter(obj, event); + } +#else + return QDialog::eventFilter(obj, event); +#endif +} diff --git a/src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.h b/src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.h index 6c2589b0..7eed0c91 100644 --- a/src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.h +++ b/src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.h @@ -41,6 +41,7 @@ public: changeCompleteBlindsDialogImpl* getChangeCompleteBlindsDialog() { return myChangeCompleteBlindsDialog; } + bool eventFilter(QObject *obj, QEvent *event); public slots: diff --git a/src/gui/qt/createnetworkgamedialog/createnetworkgamedialogimpl.cpp b/src/gui/qt/createnetworkgamedialog/createnetworkgamedialogimpl.cpp index a507638b..19e9aae8 100644 --- a/src/gui/qt/createnetworkgamedialog/createnetworkgamedialogimpl.cpp +++ b/src/gui/qt/createnetworkgamedialog/createnetworkgamedialogimpl.cpp @@ -28,6 +28,7 @@ createNetworkGameDialogImpl::createNetworkGameDialogImpl(QWidget *parent, Config setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); #endif setupUi(this); + this->installEventFilter(this); myChangeCompleteBlindsDialog = new changeCompleteBlindsDialogImpl; @@ -128,3 +129,38 @@ void createNetworkGameDialogImpl::callChangeBlindsDialog(bool show) } } + +bool createNetworkGameDialogImpl::eventFilter(QObject *obj, QEvent *event) +{ + QKeyEvent *keyEvent = static_cast(event); + +#ifdef ANDROID + //androi changes for return key behavior (hopefully useless from necessitas beta2) + if (event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_Return) { + if(spinBox_startCash ->hasFocus()) { + spinBox_startCash->clearFocus(); + } + if(spinBox_quantityPlayers->hasFocus()) { + spinBox_quantityPlayers->clearFocus(); + } + if(spinBox_netTimeOutPlayerAction->hasFocus()) { + spinBox_netTimeOutPlayerAction->clearFocus(); + } + if(spinBox_netDelayBetweenHands->hasFocus()) { + spinBox_netDelayBetweenHands->clearFocus(); + } + event->ignore(); + return false; + } + else if (event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_Back) { + this->reject(); + return true; + } + else { + // pass the event on to the parent class + return QDialog::eventFilter(obj, event); + } +#else + return QDialog::eventFilter(obj, event); +#endif +} diff --git a/src/gui/qt/createnetworkgamedialog/createnetworkgamedialogimpl.h b/src/gui/qt/createnetworkgamedialog/createnetworkgamedialogimpl.h index 35700c70..65b94992 100644 --- a/src/gui/qt/createnetworkgamedialog/createnetworkgamedialogimpl.h +++ b/src/gui/qt/createnetworkgamedialog/createnetworkgamedialogimpl.h @@ -42,6 +42,7 @@ public: changeCompleteBlindsDialogImpl* getChangeCompleteBlindsDialog() { return myChangeCompleteBlindsDialog; } + bool eventFilter(QObject *obj, QEvent *event); public slots: diff --git a/src/gui/qt/internetgamelogindialog/internetgamelogindialogimpl.cpp b/src/gui/qt/internetgamelogindialog/internetgamelogindialogimpl.cpp index c17d6a9d..b2cc88fa 100644 --- a/src/gui/qt/internetgamelogindialog/internetgamelogindialogimpl.cpp +++ b/src/gui/qt/internetgamelogindialog/internetgamelogindialogimpl.cpp @@ -155,7 +155,7 @@ bool internetGameLoginDialogImpl::eventFilter(QObject *obj, QEvent *event) QKeyEvent *keyEvent = static_cast(event); #ifdef ANDROID - //androi hack for crash bug (hopefully useless from necessitas beta2) + //androi changes for return key behavior (hopefully useless from necessitas beta2) if (event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_Return) { if(lineEdit_username->hasFocus()) { lineEdit_password->setFocus(); diff --git a/src/gui/qt/newlocalgamedialog/newgamedialogimpl.cpp b/src/gui/qt/newlocalgamedialog/newgamedialogimpl.cpp index af8f30aa..0c5354f7 100755 --- a/src/gui/qt/newlocalgamedialog/newgamedialogimpl.cpp +++ b/src/gui/qt/newlocalgamedialog/newgamedialogimpl.cpp @@ -87,7 +87,7 @@ bool newGameDialogImpl::eventFilter(QObject *obj, QEvent *event) QKeyEvent *keyEvent = static_cast(event); #ifdef ANDROID - //androi hack for crash bug (hopefully useless from necessitas beta2) + //androi changes for return key behavior (hopefully useless from necessitas beta2) if (event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_Return) { if(spinBox_gameSpeed->hasFocus()) { spinBox_gameSpeed->clearFocus();