android return key behaviour enhancements

This commit is contained in:
doitux
2012-12-21 00:36:01 +01:00
parent 5a869691e4
commit 5a87ce08b3
10 changed files with 152 additions and 2 deletions
@@ -29,6 +29,7 @@ changeCompleteBlindsDialogImpl::changeCompleteBlindsDialogImpl(QWidget *parent,
setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog);
#endif #endif
setupUi(this); setupUi(this);
this->installEventFilter(this);
connect( pushButton_add, SIGNAL( clicked() ), this, SLOT( addBlindValueToList() ) ); connect( pushButton_add, SIGNAL( clicked() ), this, SLOT( addBlindValueToList() ) );
connect( pushButton_delete, SIGNAL( clicked() ), this, SLOT( removeBlindFromList() ) ); connect( pushButton_delete, SIGNAL( clicked() ), this, SLOT( removeBlindFromList() ) );
@@ -92,3 +93,42 @@ void changeCompleteBlindsDialogImpl::sortBlindsList()
listWidget_blinds->clear(); listWidget_blinds->clear();
listWidget_blinds->addItems(tempStringList); listWidget_blinds->addItems(tempStringList);
} }
bool changeCompleteBlindsDialogImpl::eventFilter(QObject *obj, QEvent *event)
{
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(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
}
@@ -36,6 +36,7 @@ public:
changeCompleteBlindsDialogImpl(QWidget *parent = 0, ConfigFile *c = 0); changeCompleteBlindsDialogImpl(QWidget *parent = 0, ConfigFile *c = 0);
void exec(); void exec();
bool eventFilter(QObject *obj, QEvent *event);
public slots: public slots:
bool getSettingsCorrect() const { bool getSettingsCorrect() const {
@@ -27,6 +27,7 @@ changeContentDialogImpl::changeContentDialogImpl(QWidget *parent, ConfigFile *co
setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog);
#endif #endif
setupUi(this); setupUi(this);
this->installEventFilter(this);
switch (myType) { switch (myType) {
case CHANGE_HUMAN_PLAYER_NAME: { case CHANGE_HUMAN_PLAYER_NAME: {
@@ -106,3 +107,30 @@ void changeContentDialogImpl::saveContent()
myConfig->writeBuffer(); myConfig->writeBuffer();
} }
bool changeContentDialogImpl::eventFilter(QObject *obj, QEvent *event)
{
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(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
}
@@ -35,6 +35,7 @@ class changeContentDialogImpl: public QDialog, public Ui::changeContentDialog
Q_OBJECT Q_OBJECT
public: public:
changeContentDialogImpl(QWidget *parent, ConfigFile *config, DialogType t); changeContentDialogImpl(QWidget *parent, ConfigFile *config, DialogType t);
bool eventFilter(QObject *obj, QEvent *event);
public slots: public slots:
@@ -30,6 +30,7 @@ createInternetGameDialogImpl::createInternetGameDialogImpl(QWidget *parent, Conf
setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog);
#endif #endif
setupUi(this); setupUi(this);
this->installEventFilter(this);
comboBox_gameType->setItemData(0, GAME_TYPE_NORMAL, Qt::UserRole); comboBox_gameType->setItemData(0, GAME_TYPE_NORMAL, Qt::UserRole);
comboBox_gameType->setItemData(1, GAME_TYPE_REGISTERED_ONLY, 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")); myChangeCompleteBlindsDialog->radioButton_afterThisStayAtLastBlind->setChecked(myConfig->readConfigInt("NetAfterMBStayAtLastBlind"));
} }
} }
bool createInternetGameDialogImpl::eventFilter(QObject *obj, QEvent *event)
{
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(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
}
@@ -41,6 +41,7 @@ public:
changeCompleteBlindsDialogImpl* getChangeCompleteBlindsDialog() { changeCompleteBlindsDialogImpl* getChangeCompleteBlindsDialog() {
return myChangeCompleteBlindsDialog; return myChangeCompleteBlindsDialog;
} }
bool eventFilter(QObject *obj, QEvent *event);
public slots: public slots:
@@ -28,6 +28,7 @@ createNetworkGameDialogImpl::createNetworkGameDialogImpl(QWidget *parent, Config
setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog);
#endif #endif
setupUi(this); setupUi(this);
this->installEventFilter(this);
myChangeCompleteBlindsDialog = new changeCompleteBlindsDialogImpl; myChangeCompleteBlindsDialog = new changeCompleteBlindsDialogImpl;
@@ -128,3 +129,38 @@ void createNetworkGameDialogImpl::callChangeBlindsDialog(bool show)
} }
} }
bool createNetworkGameDialogImpl::eventFilter(QObject *obj, QEvent *event)
{
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(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
}
@@ -42,6 +42,7 @@ public:
changeCompleteBlindsDialogImpl* getChangeCompleteBlindsDialog() { changeCompleteBlindsDialogImpl* getChangeCompleteBlindsDialog() {
return myChangeCompleteBlindsDialog; return myChangeCompleteBlindsDialog;
} }
bool eventFilter(QObject *obj, QEvent *event);
public slots: public slots:
@@ -155,7 +155,7 @@ bool internetGameLoginDialogImpl::eventFilter(QObject *obj, QEvent *event)
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event); QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
#ifdef ANDROID #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 (event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_Return) {
if(lineEdit_username->hasFocus()) { if(lineEdit_username->hasFocus()) {
lineEdit_password->setFocus(); lineEdit_password->setFocus();
@@ -87,7 +87,7 @@ bool newGameDialogImpl::eventFilter(QObject *obj, QEvent *event)
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event); QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
#ifdef ANDROID #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 (event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_Return) {
if(spinBox_gameSpeed->hasFocus()) { if(spinBox_gameSpeed->hasFocus()) {
spinBox_gameSpeed->clearFocus(); spinBox_gameSpeed->clearFocus();