void KBlocksWin::setupGUILayout() { QAction *action; action = KStandardGameAction::gameNew(this, SLOT(singleGame()), actionCollection()); action->setText(i18n("Single Game")); actionCollection()->addAction(QStringLiteral("newGame"), action); action = new QAction(this); action->setText(i18n("Human vs AI")); actionCollection()->addAction(QStringLiteral("pve_step"), action); connect(action, &QAction::triggered, this, &KBlocksWin::pveStepGame); m_pauseAction = KStandardGameAction::pause(this, SLOT(pauseGame()), actionCollection()); actionCollection()->addAction(QStringLiteral("pauseGame"), m_pauseAction); m_pauseAction->setEnabled(false); action = KStandardGameAction::highscores(this, SLOT(showHighscore()), actionCollection()); actionCollection()->addAction(QStringLiteral("showHighscores"), action); action = KStandardGameAction::quit(this, SLOT(close()), actionCollection()); actionCollection()->addAction(QStringLiteral("quit"), action); KStandardAction::preferences(this, SLOT(configureSettings()), actionCollection()); KToggleAction *soundAction = new KToggleAction(i18n("&Play sounds"), this); soundAction->setChecked(Settings::sounds()); actionCollection()->addAction(QStringLiteral("sounds"), soundAction); connect(soundAction, &KToggleAction::triggered, this, &KBlocksWin::setSoundsEnabled); // TODO mScore = new QLabel(i18n("Points: 0 - Lines: 0 - Level: 0")); statusBar()->addPermanentWidget(mScore); connect(mpGameScene, &KBlocksScene::scoreChanged, this, &KBlocksWin::onScoreChanged); connect(mpGameScene, &KBlocksScene::isHighscore, this, &KBlocksWin::onIsHighscore); Kg::difficulty()->addStandardLevelRange( KgDifficultyLevel::Easy, KgDifficultyLevel::Hard ); KgDifficultyGUI::init(this); connect(Kg::difficulty(), &KgDifficulty::currentLevelChanged, this, &KBlocksWin::levelChanged); setupGUI(); }
void KBlocksWin::setupGUILayout() { QAction *action; action = KStandardGameAction::gameNew(this, SLOT(singleGame()), actionCollection()); action->setText(i18n("Single Game")); actionCollection()->addAction( QLatin1String( "newGame" ), action); action = new KAction(this); action->setText(i18n("Human vs AI")); actionCollection()->addAction( QLatin1String( "pve_step" ), action); connect(action, SIGNAL(triggered(bool)), this, SLOT(pveStepGame())); m_pauseAction = KStandardGameAction::pause(this, SLOT(pauseGame()), actionCollection()); actionCollection()->addAction( QLatin1String( "pauseGame" ), m_pauseAction); action = KStandardGameAction::highscores(this, SLOT(showHighscore()), actionCollection()); actionCollection()->addAction( QLatin1String( "showHighscores" ), action); action = KStandardGameAction::quit(this, SLOT(close()), actionCollection()); actionCollection()->addAction( QLatin1String( "quit" ), action); KStandardAction::preferences(this, SLOT(configureSettings()), actionCollection()); KAction* soundAction = new KToggleAction(i18n("&Play sounds"), this); soundAction->setChecked(Settings::sounds()); actionCollection()->addAction( QLatin1String( "sounds" ), soundAction); connect(soundAction, SIGNAL(triggered(bool)), this, SLOT(setSoundsEnabled(bool))); // TODO statusBar()->insertItem( i18n("Points: 0 - Lines: 0 - Level: 0"), 0 ); connect(mpGameScene, SIGNAL(scoreChanged(int,int,int,int)), this, SLOT(onScoreChanged(int,int,int,int))); connect(mpGameScene, SIGNAL(isHighscore(int,int,int)), this, SLOT(onIsHighscore(int,int,int))); Kg::difficulty()->addStandardLevelRange( KgDifficultyLevel::Easy, KgDifficultyLevel::Hard ); KgDifficultyGUI::init(this); connect(Kg::difficulty(), SIGNAL(currentLevelChanged(const KgDifficultyLevel*)), SLOT(levelChanged())); setupGUI(); }
void SensorLogger::contextMenuRequest( const QModelIndex &index, const QPoint &point ) { LogSensor *sensor = mModel->sensor( index ); QMenu pm; QAction *action = 0; if (hasSettingsDialog()) { action = pm.addAction(i18n("&Properties")); action->setData( 1 ); } if(!mSharedSettings->locked) { action = pm.addAction(i18n("&Remove Display")); action->setData( 2 ); pm.addSeparator(); action = pm.addAction(i18n("&Remove Sensor")); action->setData( 3 ); if ( !sensor ) action->setEnabled( false ); action = pm.addAction(i18n("&Edit Sensor...")); action->setData( 4 ); if ( !sensor ) action->setEnabled( false ); } if ( sensor ) { if ( sensor->isLogging() ) { action = pm.addAction(i18n("St&op Logging")); action->setData( 6 ); } else { action = pm.addAction(i18n("S&tart Logging")); action->setData( 5 ); } } action = pm.exec( point ); if ( !action ) return; switch (action->data().toInt()) { case 1: configureSettings(); break; case 2: { KSGRD::SensorDisplay::DeleteEvent *ev = new KSGRD::SensorDisplay::DeleteEvent( this ); kapp->postEvent(parent(), ev); break; } case 3: if ( sensor ) mModel->removeSensor( sensor ); break; case 4: if ( sensor ) editSensor( sensor ); break; case 5: if ( sensor ) sensor->startLogging(); break; case 6: if ( sensor ) sensor->stopLogging(); break; } }
void MainWindow::setupActions() { // Game KStandardGameAction::gameNew(this, SLOT(startNewGame()), actionCollection()); m_pauseAction = KStandardGameAction::pause(this, SLOT(pauseGame(bool)), actionCollection()); connect(Kg::difficulty(), &KgDifficulty::gameRunningChanged, m_pauseAction, &QAction::setEnabled); QAction *action = KStandardGameAction::solve(m_view, SLOT(solve()), actionCollection()); connect(Kg::difficulty(), &KgDifficulty::gameRunningChanged, action, &QAction::setEnabled); KStandardGameAction::highscores(this, SLOT(showHighscores()), actionCollection()); KStandardGameAction::quit(this, SLOT(close()), actionCollection()); // Settings KStandardAction::preferences(this, SLOT(configureSettings()), actionCollection()); action = new QAction(i18n("&Unlock All"), this); connect(action, SIGNAL(triggered()), m_view->rootObject(), SLOT(unlockAll())); connect(Kg::difficulty(), &KgDifficulty::gameRunningChanged, action, &QAction::setEnabled); actionCollection()->addAction( QStringLiteral( "unlock_all" ), action); action = new QAction(i18n("Keyboard: Field right"), this); actionCollection()->setDefaultShortcut(action, Qt::Key_Right); connect(action, SIGNAL(triggered()), m_view->rootObject(), SLOT(kbGoRight())); actionCollection()->addAction( QStringLiteral( "kb_go_right" ), action); action = new QAction(i18n("Keyboard: Field left"),this); actionCollection()->setDefaultShortcut(action, Qt::Key_Left); connect(action, SIGNAL(triggered()), m_view->rootObject(), SLOT(kbGoLeft())); actionCollection()->addAction( QStringLiteral( "kb_go_left" ), action); action = new QAction(i18n("Keyboard: Field up"),this); actionCollection()->setDefaultShortcut(action, Qt::Key_Up); connect(action, SIGNAL(triggered()), m_view->rootObject(), SLOT(kbGoUp())); actionCollection()->addAction( QStringLiteral( "kb_go_up" ), action); action = new QAction(i18n("Keyboard: Field down"),this); actionCollection()->setDefaultShortcut(action, Qt::Key_Down); connect(action, SIGNAL(triggered()), m_view->rootObject(), SLOT(kbGoDown())); actionCollection()->addAction( QStringLiteral( "kb_go_down" ), action); action = new QAction(i18n("Keyboard: Turn clockwise"),this); actionCollection()->setDefaultShortcut(action, Qt::Key_Return); connect(action, SIGNAL(triggered()), m_view->rootObject(), SLOT(rotateClockwise())); actionCollection()->addAction( QStringLiteral( "kb_turn_clockwise" ), action); action = new QAction(i18n("Keyboard: Turn counterclockwise"),this); actionCollection()->setDefaultShortcut(action, Qt::CTRL + Qt::Key_Return); connect(action, SIGNAL(triggered()), m_view->rootObject(), SLOT(rotateCounterclockwise())); actionCollection()->addAction( QStringLiteral( "kb_turn_counterclockwise" ), action); action = new QAction(i18n("Keyboard: Toggle lock"),this); actionCollection()->setDefaultShortcut(action, Qt::Key_Space); connect(action, SIGNAL(triggered()), m_view->rootObject(), SLOT(toggleLock())); actionCollection()->addAction( QStringLiteral( "kb_lock" ), action); }