void MainWindow::createToolBars() { m_tabBar = new GameTabBar(); m_tabBar->setDocumentMode(true); m_tabBar->setTabsClosable(true); m_tabBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); connect(m_tabBar, SIGNAL(currentChanged(int)), this, SLOT(onTabChanged(int))); connect(m_tabBar, SIGNAL(tabCloseRequested(int)), this, SLOT(onTabCloseRequested(int))); connect(m_showPreviousTabAct, SIGNAL(triggered()), m_tabBar, SLOT(showPreviousTab())); connect(m_showNextTabAct, SIGNAL(triggered()), m_tabBar, SLOT(showNextTab())); QToolBar* toolBar = new QToolBar(tr("Game Tabs")); toolBar->setVisible(false); toolBar->setFloatable(false); toolBar->setMovable(false); toolBar->setAllowedAreas(Qt::TopToolBarArea); toolBar->addWidget(m_tabBar); addToolBar(toolBar); }
void MainWindow::createActions() { m_newGameAct = new QAction(tr("&New..."), this); m_newGameAct->setShortcut(QKeySequence::New); m_closeGameAct = new QAction(tr("&Close"), this); #ifdef Q_OS_WIN32 m_closeGameAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_W)); #else m_closeGameAct->setShortcut(QKeySequence::Close); #endif m_saveGameAct = new QAction(tr("&Save"), this); m_saveGameAct->setShortcut(QKeySequence::Save); m_saveGameAsAct = new QAction(tr("Save &As..."), this); m_saveGameAsAct->setShortcut(QKeySequence::SaveAs); m_copyFenAct = new QAction(tr("Copy FEN"), this); QAction* copyFenSequence = new QAction(m_gameViewer); copyFenSequence->setShortcut(QKeySequence::Copy); copyFenSequence->setShortcutContext(Qt::WidgetWithChildrenShortcut); m_gameViewer->addAction(copyFenSequence); m_quitGameAct = new QAction(tr("&Quit"), this); m_quitGameAct->setMenuRole(QAction::QuitRole); #ifdef Q_OS_WIN32 m_quitGameAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q)); #else m_quitGameAct->setShortcut(QKeySequence::Quit); #endif m_newTournamentAct = new QAction(tr("New..."), this); m_stopTournamentAct = new QAction(tr("Stop"), this); m_manageEnginesAct = new QAction(tr("Manage..."), this); m_showGameDatabaseWindowAct = new QAction(tr("&Game Database"), this); m_showGameWallAct = new QAction(tr("Game Wall"), this); m_showPreviousTabAct = new QAction(tr("Show Previous Tab"), this); #ifdef Q_OS_MAC m_showPreviousTabAct->setShortcut(QKeySequence(Qt::MetaModifier + Qt::ShiftModifier + Qt::Key_Tab)); #else m_showPreviousTabAct->setShortcut(QKeySequence(Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_Tab)); #endif m_showNextTabAct = new QAction(tr("Show Next Tab"), this); #ifdef Q_OS_MAC m_showNextTabAct->setShortcut(QKeySequence(Qt::MetaModifier + Qt::Key_Tab)); #else m_showNextTabAct->setShortcut(QKeySequence(Qt::ControlModifier + Qt::Key_Tab)); #endif m_aboutAct = new QAction(tr("About Cute Chess..."), this); m_aboutAct->setMenuRole(QAction::AboutRole); connect(m_newGameAct, SIGNAL(triggered()), this, SLOT(newGame())); connect(m_copyFenAct, SIGNAL(triggered()), this, SLOT(copyFen())); connect(copyFenSequence, SIGNAL(triggered()), this, SLOT(copyFen())); connect(m_closeGameAct, SIGNAL(triggered()), this, SLOT(closeCurrentGame())); connect(m_saveGameAct, SIGNAL(triggered()), this, SLOT(save())); connect(m_saveGameAsAct, SIGNAL(triggered()), this, SLOT(saveAs())); connect(m_quitGameAct, SIGNAL(triggered()), qApp, SLOT(closeAllWindows())); connect(m_newTournamentAct, SIGNAL(triggered()), this, SLOT(newTournament())); connect(m_manageEnginesAct, SIGNAL(triggered()), this, SLOT(manageEngines())); connect(m_showGameDatabaseWindowAct, SIGNAL(triggered()), CuteChessApplication::instance(), SLOT(showGameDatabaseDialog())); connect(m_showGameWallAct, SIGNAL(triggered()), CuteChessApplication::instance(), SLOT(showGameWall())); connect(m_showPreviousTabAct, SIGNAL(triggered()), this, SLOT(showPreviousTab())); connect(m_showNextTabAct, SIGNAL(triggered()), this, SLOT(showNextTab())); connect(m_aboutAct, SIGNAL(triggered()), this, SLOT(showAboutDialog())); }