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
@@ -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<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
public:
changeContentDialogImpl(QWidget *parent, ConfigFile *config, DialogType t);
bool eventFilter(QObject *obj, QEvent *event);
public slots: