Files
pokerth/src/gui/qt/createnetworkgamedialog/createnetworkgamedialogimpl.cpp
T

172 lines
7.2 KiB
C++
Raw Normal View History

/*****************************************************************************
* PokerTH - The open source texas holdem engine *
* Copyright (C) 2006-2012 Felix Hammer, Florian Thauer, Lothar May *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
* *
* Additional permission under GNU AGPL version 3 section 7 *
* *
* If you modify this program, or any covered work, by linking or *
* combining it with the OpenSSL project's OpenSSL library (or a *
* modified version of that library), containing parts covered by the *
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
* permission to convey the resulting work. *
* Corresponding Source for a non-source form of such a combination *
* shall include the source code for the parts of OpenSSL used as well *
* as that of the covered work. *
2011-07-03 19:45:08 +00:00
*****************************************************************************/
#include "createnetworkgamedialogimpl.h"
#include "session.h"
2007-02-25 23:14:48 +00:00
#include "configfile.h"
#include "changecompleteblindsdialogimpl.h"
2007-05-13 13:32:06 +00:00
createNetworkGameDialogImpl::createNetworkGameDialogImpl(QWidget *parent, ConfigFile *c)
: QDialog(parent), myConfig(c)
{
2007-12-04 01:37:43 +00:00
#ifdef __APPLE__
2007-11-28 22:00:42 +00:00
setWindowModality(Qt::ApplicationModal);
setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog);
#endif
setupUi(this);
2012-12-21 00:36:01 +01:00
this->installEventFilter(this);
myChangeCompleteBlindsDialog = new changeCompleteBlindsDialogImpl;
2007-02-26 00:44:09 +00:00
fillFormular();
2007-02-25 23:14:48 +00:00
connect( radioButton_changeBlindsSettings, SIGNAL( clicked(bool) ), this, SLOT( callChangeBlindsDialog(bool) ) );
2012-01-30 20:54:05 +00:00
#ifndef GUI_800x480
connect( pushButton_cancel, SIGNAL( clicked() ), this, SLOT( cancel() ) );
2012-01-30 20:54:05 +00:00
#endif
connect( pushButton_createGame, SIGNAL( clicked() ), this, SLOT( createGame() ) );
}
2007-05-13 15:08:10 +00:00
void createNetworkGameDialogImpl::exec()
{
2007-05-13 15:08:10 +00:00
fillFormular();
QDialog::exec();
}
void createNetworkGameDialogImpl::createGame()
{
}
void createNetworkGameDialogImpl::cancel()
{
}
void createNetworkGameDialogImpl::fillFormular()
{
2007-02-26 00:44:09 +00:00
//Network Game Settings
2007-05-13 13:32:06 +00:00
spinBox_quantityPlayers->setValue(myConfig->readConfigInt("NetNumberOfPlayers"));
spinBox_startCash->setValue(myConfig->readConfigInt("NetStartCash"));
spinBox_netDelayBetweenHands->setValue(myConfig->readConfigInt("NetDelayBetweenHands"));
2007-05-30 08:05:53 +00:00
spinBox_netTimeOutPlayerAction->setValue(myConfig->readConfigInt("NetTimeOutPlayerAction"));
//fill changeCompleteBlindsDialog
myChangeCompleteBlindsDialog->spinBox_firstSmallBlind->setValue(myConfig->readConfigInt("NetFirstSmallBlind"));
myChangeCompleteBlindsDialog->radioButton_raiseBlindsAtHands->setChecked(myConfig->readConfigInt("NetRaiseBlindsAtHands"));
myChangeCompleteBlindsDialog->radioButton_raiseBlindsAtMinutes->setChecked(myConfig->readConfigInt("NetRaiseBlindsAtMinutes"));
myChangeCompleteBlindsDialog->spinBox_raiseSmallBlindEveryHands->setValue(myConfig->readConfigInt("NetRaiseSmallBlindEveryHands"));
myChangeCompleteBlindsDialog->spinBox_raiseSmallBlindEveryMinutes->setValue(myConfig->readConfigInt("NetRaiseSmallBlindEveryMinutes"));
myChangeCompleteBlindsDialog->radioButton_alwaysDoubleBlinds->setChecked(myConfig->readConfigInt("NetAlwaysDoubleBlinds"));
myChangeCompleteBlindsDialog->radioButton_manualBlindsOrder->setChecked(myConfig->readConfigInt("NetManualBlindsOrder"));
myChangeCompleteBlindsDialog->listWidget_blinds->clear();
myChangeCompleteBlindsDialog->spinBox_input->setMinimum(myChangeCompleteBlindsDialog->spinBox_firstSmallBlind->value()+1);
std::list<int> myBlindsList = myConfig->readConfigIntList("NetManualBlindsList");
std::list<int>::iterator it1;
for(it1= myBlindsList.begin(); it1 != myBlindsList.end(); ++it1) {
myChangeCompleteBlindsDialog->listWidget_blinds->addItem(QString::number(*it1,10));
}
myChangeCompleteBlindsDialog->sortBlindsList();
myChangeCompleteBlindsDialog->radioButton_afterThisAlwaysDoubleBlinds->setChecked(myConfig->readConfigInt("NetAfterMBAlwaysDoubleBlinds"));
myChangeCompleteBlindsDialog->radioButton_afterThisAlwaysRaiseAbout->setChecked(myConfig->readConfigInt("NetAfterMBAlwaysRaiseAbout"));
myChangeCompleteBlindsDialog->spinBox_afterThisAlwaysRaiseValue->setValue(myConfig->readConfigInt("NetAfterMBAlwaysRaiseValue"));
myChangeCompleteBlindsDialog->radioButton_afterThisStayAtLastBlind->setChecked(myConfig->readConfigInt("NetAfterMBStayAtLastBlind"));
2007-02-26 00:44:09 +00:00
}
void createNetworkGameDialogImpl::showDialog()
{
2007-02-26 00:44:09 +00:00
fillFormular();
exec();
}
void createNetworkGameDialogImpl::keyPressEvent ( QKeyEvent * event )
{
2012-12-31 00:20:05 +01:00
#ifndef ANDROID
if (event->key() == 16777220) {
pushButton_createGame->click(); //ENTER
}
2012-12-31 00:20:05 +01:00
#endif
}
void createNetworkGameDialogImpl::callChangeBlindsDialog(bool show)
{
if(show) {
myChangeCompleteBlindsDialog->exec();
if(myChangeCompleteBlindsDialog->result() == QDialog::Accepted ) {}
else {
radioButton_useSavedBlindsSettings->setChecked(TRUE);
}
}
}
2012-12-21 00:36:01 +01:00
bool createNetworkGameDialogImpl::eventFilter(QObject *obj, QEvent *event)
{
#ifdef ANDROID
2012-12-21 00:36:01 +01:00
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
//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;
2012-12-21 01:01:01 +01:00
} else if (event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_Back) {
event->ignore();
2012-12-21 00:36:01 +01:00
this->reject();
return false;
2012-12-21 01:01:01 +01:00
} else {
2012-12-21 00:36:01 +01:00
// pass the event on to the parent class
return QDialog::eventFilter(obj, event);
}
#else
return QDialog::eventFilter(obj, event);
#endif
}