MainWindow::MainWindow() { setCaption(tr("GA Bots " VERSION)); initActions(); initMenuBar(); initToolBar(); initStatusBar(); initGABotDoc(); initView(); ViewToolBar->setOn(true); ViewStatusBar->setOn(true); //ViewGame->setOn(true); connect(GABotDoc, SIGNAL(gameReady(bool)), this, SLOT(slotGameReady(bool))); connect(GABotDoc, SIGNAL(teamAScores()), View, SLOT(slotScoreA())); connect(GABotDoc, SIGNAL(teamBScores()), View, SLOT(slotScoreB())); connect(GABotDoc, SIGNAL(clearScores()), View, SLOT(slotClearScores())); connect(GABotDoc, SIGNAL(moveTeamA(Coordinate, Coordinate)), View, SLOT(slotMoveTeamA(Coordinate, Coordinate))); connect(GABotDoc, SIGNAL(moveTeamB(Coordinate, Coordinate)), View, SLOT(slotMoveTeamB(Coordinate, Coordinate))); connect(GABotDoc, SIGNAL(turnTeamA(Coordinate, Direction)), View, SLOT(slotTurnTeamA(Coordinate, Direction))); connect(GABotDoc, SIGNAL(turnTeamB(Coordinate, Direction)), View, SLOT(slotTurnTeamB(Coordinate, Direction))); connect(GABotDoc, SIGNAL(moveBall(Coordinate,Coordinate)), View, SLOT(slotMoveBall(Coordinate,Coordinate))); connect(GoGame, SIGNAL(activated()), this, SLOT(slotGoGame())); connect(GoGame, SIGNAL(activated()), GABotDoc, SLOT(slotStartTimer())); connect(StopGame, SIGNAL(activated()), GABotDoc, SLOT(slotStopTimer())); connect(StopGame, SIGNAL(activated()), this, SLOT(slotStopGame())); connect(View, SIGNAL(valueChanged(int)), this, SLOT(slotTickInterval(int))); connect(GABotDoc, SIGNAL(clearField()), View, SLOT(slotClearField())); connect(ResetScreen, SIGNAL(activated()), View, SLOT(slotClearField())); //not sure if we should clear the field whenever regenerating the team // connect(TeamAGenerate,SIGNAL(activated()), View, SLOT(slotClearField())); // connect(TeamBGenerate,SIGNAL(activated()), View, SLOT(slotClearField())); connect(GABotDoc, SIGNAL(gameOver()), View, SLOT(slotClearField())); connect(GABotDoc, SIGNAL(gameOver()), View, SLOT(slotClearScores())); connect(GABotDoc, SIGNAL(gameOver()), this, SLOT(slotGameOver())); }
/* ******************************************************************************** * * * Class ExLineEdit * * * ******************************************************************************** */ ExLineEdit::ExLineEdit(QWidget *parent) : QWidget(parent) { m_lineEdit = new QLineEdit(this); m_lineEdit->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Minimum ); // widget settings this->setFocusPolicy(m_lineEdit->focusPolicy()); this->setAttribute(Qt::WA_InputMethodEnabled); this->setSizePolicy(m_lineEdit->sizePolicy()); this->setBackgroundRole(m_lineEdit->backgroundRole()); this->setMouseTracking(true); setPalette(m_lineEdit->palette()); // line edit m_lineEdit->setFrame(false); m_lineEdit->setContextMenuPolicy(Qt::NoContextMenu); m_lineEdit->setFocusProxy(this); m_lineEdit->setStyleSheet("background:transparent"); // clearButton m_clearButton = new ClearButton(this); //! connection QObject::connect(m_clearButton, SIGNAL(clicked()), this, SLOT(slotClearField())); QObject::connect(m_lineEdit, SIGNAL(textChanged(const QString&)), this, SLOT(slotOnTextChanged(const QString&))); QObject::connect(m_lineEdit, SIGNAL(returnPressed()), this, SIGNAL(textfield_entered())); }
//----------------------------------------------------------------- void GABot::prepareGame(void) { GAGame = new Game(this, TeamA, TeamB, 1000, 80, 40); TeamA->goals(0); TeamB->goals(0); GAGame->reset(); connect(GAGame, SIGNAL(ballMoved(Coordinate,Coordinate)), this, SLOT(slotBallMoved(Coordinate,Coordinate))); connect(GAGame, SIGNAL(teamAScores()), this,SLOT(slotTeamAScores()) ); connect(GAGame, SIGNAL(teamBScores()), this,SLOT(slotTeamBScores()) ); connect(GAGame, SIGNAL(clearField()), this, SLOT(slotClearField()) ); connect(GAGame, SIGNAL(gameOver()), this, SLOT(slotGameOver()) ); }