From c1d7266e50f16c91389248eb0b1f31c9ace8b3e0 Mon Sep 17 00:00:00 2001 From: doitux Date: Tue, 27 May 2014 08:04:47 +0200 Subject: [PATCH] multiple changes (like backbutton handling fixes) for android releases 1.1.1 --- src/gui/qt/aboutpokerth/aboutpokerthimpl.cpp | 2 +- .../changecompleteblindsdialogimpl.cpp | 2 +- .../changecontentdialogimpl.cpp | 2 +- .../createinternetgamedialogimpl.cpp | 3 +- .../createnetworkgamedialogimpl.cpp | 3 +- .../gamelobbydialog/gamelobbydialogimpl.cpp | 3 +- src/gui/qt/logfiledialog/logfiledialog.cpp | 51 ++++++++++++++----- .../startnetworkgamedialogimpl.cpp | 1 + src/gui/qt/styles/gametablestylereader.cpp | 2 +- src/pokerth.cpp | 30 +++++++++++ 10 files changed, 77 insertions(+), 22 deletions(-) diff --git a/src/gui/qt/aboutpokerth/aboutpokerthimpl.cpp b/src/gui/qt/aboutpokerth/aboutpokerthimpl.cpp index 6e49cfb8..5d0ff041 100755 --- a/src/gui/qt/aboutpokerth/aboutpokerthimpl.cpp +++ b/src/gui/qt/aboutpokerth/aboutpokerthimpl.cpp @@ -35,7 +35,7 @@ #ifdef ANDROID #ifndef ANDROID_TEST -#include "QtGui/5.2.0/QtGui/qpa/qplatformnativeinterface.h" +#include "QtGui/5.3.0/QtGui/qpa/qplatformnativeinterface.h" #include #endif #endif diff --git a/src/gui/qt/changecompleteblindsdialog/changecompleteblindsdialogimpl.cpp b/src/gui/qt/changecompleteblindsdialog/changecompleteblindsdialogimpl.cpp index c0c85304..1477cefa 100644 --- a/src/gui/qt/changecompleteblindsdialog/changecompleteblindsdialogimpl.cpp +++ b/src/gui/qt/changecompleteblindsdialog/changecompleteblindsdialogimpl.cpp @@ -133,7 +133,7 @@ bool changeCompleteBlindsDialogImpl::eventFilter(QObject *obj, QEvent *event) event->ignore(); return false; } else if (event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_Back) { - this->reject(); + event->ignore(); return true; } else { // pass the event on to the parent class diff --git a/src/gui/qt/changecontentdialog/changecontentdialogimpl.cpp b/src/gui/qt/changecontentdialog/changecontentdialogimpl.cpp index fd9075d5..1a81177d 100644 --- a/src/gui/qt/changecontentdialog/changecontentdialogimpl.cpp +++ b/src/gui/qt/changecontentdialog/changecontentdialogimpl.cpp @@ -139,7 +139,7 @@ bool changeContentDialogImpl::eventFilter(QObject *obj, QEvent *event) event->ignore(); return false; } else if (event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_Back) { - this->reject(); + event->ignore(); return true; } else { // pass the event on to the parent class diff --git a/src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.cpp b/src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.cpp index 43b090fb..b5728a13 100644 --- a/src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.cpp +++ b/src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.cpp @@ -284,8 +284,7 @@ bool createInternetGameDialogImpl::eventFilter(QObject *obj, QEvent *event) } else if (event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_Back) { event->ignore(); - this->reject(); - return false; + return true; } else { // pass the event on to the parent class return QDialog::eventFilter(obj, event); diff --git a/src/gui/qt/createnetworkgamedialog/createnetworkgamedialogimpl.cpp b/src/gui/qt/createnetworkgamedialog/createnetworkgamedialogimpl.cpp index 6857f10b..74c6663c 100644 --- a/src/gui/qt/createnetworkgamedialog/createnetworkgamedialogimpl.cpp +++ b/src/gui/qt/createnetworkgamedialog/createnetworkgamedialogimpl.cpp @@ -160,8 +160,7 @@ bool createNetworkGameDialogImpl::eventFilter(QObject *obj, QEvent *event) return false; } else if (event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_Back) { event->ignore(); - this->reject(); - return false; + return true; } else { // pass the event on to the parent class return QDialog::eventFilter(obj, event); diff --git a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp index 02dae737..4536d38e 100644 --- a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp +++ b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp @@ -1412,8 +1412,7 @@ bool gameLobbyDialogImpl::eventFilter(QObject *obj, QEvent *event) return QDialog::eventFilter(obj, event); } else if (event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_Back) { event->ignore(); - this->reject(); - return false; + return true; } else { // pass the event on to the parent class return QDialog::eventFilter(obj, event); diff --git a/src/gui/qt/logfiledialog/logfiledialog.cpp b/src/gui/qt/logfiledialog/logfiledialog.cpp index 1a749e57..e6380be7 100644 --- a/src/gui/qt/logfiledialog/logfiledialog.cpp +++ b/src/gui/qt/logfiledialog/logfiledialog.cpp @@ -155,10 +155,18 @@ void LogFileDialog::exportLogToHtml() if(selectedItem) { QFileInfo fi(selectedItem->data(0, Qt::UserRole).toString()); - QString fileName = QFileDialog::getSaveFileName(this, tr("Export PokerTH log file to HTML"), - QDir::homePath()+"/"+fi.baseName()+".html", - tr("PokerTH HTML log (*.html)")); - + QFileDialog dlg(this, tr("Export PokerTH log file to HTML"), + QDir::homePath()+"/"+fi.baseName()+".html", + tr("PokerTH HTML log (*.html)")); + dlg.setFileMode(QFileDialog::AnyFile); + dlg.setAcceptMode(QFileDialog::AcceptSave); +#ifdef ANDROID + dlg.setWindowState(Qt::WindowFullScreen); +#endif + QString fileName; + if(dlg.exec()) { + fileName = dlg.selectedFiles().first(); + } if(!fileName.isEmpty()) { myGuiLog->exportLogPdbToHtml(selectedItem->data(0, Qt::UserRole).toString(),fileName); } @@ -171,10 +179,18 @@ void LogFileDialog::exportLogToTxt() if(selectedItem) { QFileInfo fi(selectedItem->data(0, Qt::UserRole).toString()); - QString fileName = QFileDialog::getSaveFileName(this, tr("Export PokerTH log file to plain text"), - QDir::homePath()+"/"+fi.baseName()+".txt", - tr("PokerTH plain text log (*.txt)")); - + QFileDialog dlg(this, tr("Export PokerTH log file to plain text"), + QDir::homePath()+"/"+fi.baseName()+".txt", + tr("PokerTH plain text log (*.txt)")); + dlg.setFileMode(QFileDialog::AnyFile); + dlg.setAcceptMode(QFileDialog::AcceptSave); +#ifdef ANDROID + dlg.setWindowState(Qt::WindowFullScreen); +#endif + QString fileName; + if(dlg.exec()) { + fileName = dlg.selectedFiles().first(); + } if(!fileName.isEmpty()) { myGuiLog->exportLogPdbToTxt(selectedItem->data(0, Qt::UserRole).toString(),fileName); } @@ -187,10 +203,18 @@ void LogFileDialog::saveLogFileAs() if(selectedItem) { QFileInfo fi(selectedItem->data(0, Qt::UserRole).toString()); - QString fileName = QFileDialog::getSaveFileName(this, tr("Save PokerTH log file"), - QDir::homePath()+"/"+fi.baseName()+".pdb", - tr("PokerTH SQL log (*.pdb)")); - + QFileDialog dlg(this, tr("Save PokerTH log file"), + QDir::homePath()+"/"+fi.baseName()+".pdb", + tr("PokerTH SQL log (*.pdb)")); + dlg.setFileMode(QFileDialog::AnyFile); + dlg.setAcceptMode(QFileDialog::AcceptSave); +#ifdef ANDROID + dlg.setWindowState(Qt::WindowFullScreen); +#endif + QString fileName; + if(dlg.exec()) { + fileName = dlg.selectedFiles().first(); + } if(!fileName.isEmpty()) { QFile::copy(selectedItem->data(0, Qt::UserRole).toString(), fileName); } @@ -228,6 +252,9 @@ void LogFileDialog::keyPressEvent ( QKeyEvent * event ) ui->pushButton_deleteLog->click(); } } + else { + QDialog::keyPressEvent(event); + } } void LogFileDialog::uploadFile() diff --git a/src/gui/qt/startnetworkgamedialog/startnetworkgamedialogimpl.cpp b/src/gui/qt/startnetworkgamedialog/startnetworkgamedialogimpl.cpp index 6bc1d77d..8c4df872 100644 --- a/src/gui/qt/startnetworkgamedialog/startnetworkgamedialogimpl.cpp +++ b/src/gui/qt/startnetworkgamedialog/startnetworkgamedialogimpl.cpp @@ -240,6 +240,7 @@ void startNetworkGameDialogImpl::keyPressEvent ( QKeyEvent * event ) } else { keyUpDownChatCounter = 0; } + QDialog::keyPressEvent(event); } bool startNetworkGameDialogImpl::eventFilter(QObject *obj, QEvent *event) diff --git a/src/gui/qt/styles/gametablestylereader.cpp b/src/gui/qt/styles/gametablestylereader.cpp index 03097585..30ffb918 100644 --- a/src/gui/qt/styles/gametablestylereader.cpp +++ b/src/gui/qt/styles/gametablestylereader.cpp @@ -1332,7 +1332,7 @@ void GameTableStyleReader::showOutdatedErrorMessage() void GameTableStyleReader::setTableBackground(gameTableImpl *gt) { - gt->setStyleSheet("QMainWindow { background-image: url(\""+Table+"\"); background-position: bottom center; background-origin: content; background-repeat: no-repeat;}"); + gt->centralWidget()->setStyleSheet(".QWidget { background-image: url(\""+Table+"\"); background-position: bottom center; background-origin: content; background-repeat: no-repeat;}"); } void GameTableStyleReader::setChatLogStyle(QTextBrowser *tb) diff --git a/src/pokerth.cpp b/src/pokerth.cpp index 2f9981c1..19718e75 100755 --- a/src/pokerth.cpp +++ b/src/pokerth.cpp @@ -75,6 +75,13 @@ #define ENABLE_LEAK_CHECK() #endif +// #ifdef ANDROID +// #ifndef ANDROID_TEST +// // #include "QtGui/5.3.0/QtGui/qpa/qplatformnativeinterface.h" +// // #include +// #endif +// #endif + using namespace std; class startWindowImpl; @@ -246,6 +253,29 @@ int main( int argc, char **argv ) startWindowImpl mainWin(myConfig,myLog); #ifdef ANDROID +// //Do not start if API is smaller than x +// int api = -2; +// #ifndef ANDROID_TEST +// JavaVM *currVM = (JavaVM *)QApplication::platformNativeInterface()->nativeResourceForIntegration("JavaVM"); +// JNIEnv* env; +// if (currVM->AttachCurrentThread(&env, NULL)<0) { +// qCritical()<<"AttachCurrentThread failed"; +// } else { +// jclass jclassApplicationClass = env->FindClass("android/os/Build$VERSION"); +// if (jclassApplicationClass) { +// api = env->GetStaticIntField(jclassApplicationClass, env->GetStaticFieldID(jclassApplicationClass,"SDK_INT", "I")); +// } +// currVM->DetachCurrentThread(); +// } +// #endif +// Test api and maybe do not start for further android releases +// if(api < 14) { +// QMessageBox box(QMessageBox::Critical, "PokerTH Error", "Sorry, PokerTH needs Android version 4.0 or above to start", QMessageBox::Ok); +// box.show(); +// } +// else { +// mainWin.show(); +// } mainWin.show(); #else a.setActivationWindow(&mainWin, true);