TicTacToe::TicTacToe( bool meFirst, int boardSize, QWidget *parent, const char *name ) : QWidget( parent, name ) { Q3VBoxLayout * l = new Q3VBoxLayout( this, 6 ); // Create a message label message = new QLabel( this ); message->setFrameStyle( Q3Frame::WinPanel | Q3Frame::Sunken ); message->setAlignment( Qt::AlignCenter ); l->addWidget( message ); // Create the game board and connect the signal finished() to this // gameOver() slot board = new TicTacGameBoard( meFirst, boardSize, this ); connect( board, SIGNAL(finished()), SLOT(gameOver()) ); l->addWidget( board ); // Create a horizontal frame line Q3Frame *line = new Q3Frame( this ); line->setFrameStyle( Q3Frame::HLine | Q3Frame::Sunken ); l->addWidget( line ); // Create the combo box for deciding who should start, and // connect its clicked() signals to the buttonClicked() slot whoStarts = new QComboBox( this ); whoStarts->insertItem( "Opponent starts" ); whoStarts->insertItem( "You start" ); l->addWidget( whoStarts ); whoStarts->setEnabled(false); whoStarts->setCurrentIndex(meFirst); // Create the push buttons and connect their clicked() signals // to this right slots. connect( board, SIGNAL(myMove(int)), this, SIGNAL(myMove(int))); connect( board, SIGNAL(stateChanged()), this, SLOT(newState())); newGame = new QPushButton( "Play!", this ); connect( newGame, SIGNAL(clicked()), SLOT(newGameClicked()) ); newGame->setEnabled(false); quit = new QPushButton( "Quit", this ); connect( quit, SIGNAL(clicked()), this, SIGNAL(closing()) ); Q3HBoxLayout * b = new Q3HBoxLayout; l->addLayout( b ); b->addWidget( newGame ); b->addWidget( quit ); newState(); //board->newGame(); newGameClicked(); }
TicTacToe::TicTacToe( int boardSize, QWidget *parent, const char *name ) : QWidget( parent, name ) { QVBoxLayout * l = new QVBoxLayout( this, 6 ); // Create a message label message = new QLabel( this ); message->setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); message->setAlignment( AlignCenter ); l->addWidget( message ); // Create the game board and connect the signal finished() to this // gameOver() slot board = new TicTacGameBoard( boardSize, this ); connect( board, SIGNAL(finished()), SLOT(gameOver()) ); l->addWidget( board ); // Create a horizontal frame line QFrame *line = new QFrame( this ); line->setFrameStyle( QFrame::HLine | QFrame::Sunken ); l->addWidget( line ); // Create the combo box for deciding who should start, and // connect its clicked() signals to the buttonClicked() slot whoStarts = new QComboBox( this ); whoStarts->insertItem( "Computer starts" ); whoStarts->insertItem( "Human starts" ); l->addWidget( whoStarts ); // Create the push buttons and connect their clicked() signals // to this right slots. newGame = new QPushButton( "Play!", this ); connect( newGame, SIGNAL(clicked()), SLOT(newGameClicked()) ); quit = new QPushButton( "Quit", this ); connect( quit, SIGNAL(clicked()), qApp, SLOT(quit()) ); QHBoxLayout * b = new QHBoxLayout; l->addLayout( b ); b->addWidget( newGame ); b->addWidget( quit ); newState(); }
RTMainWindow::RTMainWindow(GameConfiguration& config, QWidget* parent) : QMainWindow(parent), popupTimer(NULL), popupNeedsRebuilding(true) { setupButtons(); setupToolbar(); setupLayout(config); setWindowIcon(QIcon(QCoreApplication::applicationDirPath() +"/../img/logo.png")); setWindowTitle(QString("RoboTower GUI")); QObject::connect(startBtn, SIGNAL(clicked()), this, SLOT(startOnClick())); QObject::connect(stopBtn, SIGNAL(clicked()), this, SLOT(stopOnClick())); QObject::connect(newGameAction, SIGNAL(triggered()), this, SLOT(newGameClicked())); QObject::connect(currentGame, SIGNAL(togglePause()), this, SIGNAL(togglePause())); QFont font(this->font()); font.setBold(true); font.setPointSize(font.pointSize() + 2); this->setFont(font); }