void KMahjongg::setupKAction() { KStandardGameAction::gameNew(this, SLOT(startNewGame()), actionCollection()); KStandardGameAction::load(this, SLOT(loadGame()), actionCollection()); KStandardGameAction::save(this, SLOT(saveGame()), actionCollection()); KStandardGameAction::quit(this, SLOT(close()), actionCollection()); KStandardGameAction::restart(this, SLOT(restartGame()), actionCollection()); QAction * newNumGame = actionCollection()->addAction(QStringLiteral("game_new_numeric")); newNumGame->setText(i18n("New Numbered Game...")); connect(newNumGame, &QAction::triggered, this, &KMahjongg::startNewNumeric); QAction * action = KStandardGameAction::hint(m_gameView, SLOT(helpMove()), this); actionCollection()->addAction(action->objectName(), action); QAction * shuffle = actionCollection()->addAction(QStringLiteral("move_shuffle")); shuffle->setText(i18n("Shu&ffle")); shuffle->setIcon(QIcon::fromTheme(QStringLiteral("view-refresh"))); connect(shuffle, &QAction::triggered, m_gameView, &GameView::shuffle); QAction * angleccw = actionCollection()->addAction(QStringLiteral("view_angleccw")); angleccw->setText(i18n("Rotate View Counterclockwise")); angleccw->setIcon(QIcon::fromTheme(QStringLiteral("object-rotate-left"))); actionCollection()->setDefaultShortcut(angleccw, Qt::Key_F); connect(angleccw, &QAction::triggered, m_gameView, &GameView::angleSwitchCCW); QAction * anglecw = actionCollection()->addAction(QStringLiteral("view_anglecw")); anglecw->setText(i18n("Rotate View Clockwise")); anglecw->setIcon(QIcon::fromTheme(QStringLiteral("object-rotate-right"))); actionCollection()->setDefaultShortcut(anglecw, Qt::Key_G); connect(anglecw, &QAction::triggered, m_gameView, &GameView::angleSwitchCW); m_demoAction = KStandardGameAction::demo(this, SLOT(demoMode()), actionCollection()); KStandardGameAction::highscores(this, SLOT(showHighscores()), actionCollection()); m_pauseAction = KStandardGameAction::pause(this, SLOT(pause()), actionCollection()); // move m_undoAction = KStandardGameAction::undo(this, SLOT(undo()), actionCollection()); m_redoAction = KStandardGameAction::redo(this, SLOT(redo()), actionCollection()); // edit QAction * boardEdit = actionCollection()->addAction(QStringLiteral("game_board_editor")); boardEdit->setText(i18n("&Board Editor")); connect(boardEdit, &QAction::triggered, this, &KMahjongg::slotBoardEditor); // settings KStandardAction::preferences(this, SLOT(showSettings()), actionCollection()); setupGUI(qApp->desktop()->availableGeometry().size() * 0.7); }
// --------------------------------------------------------- void KMahjongg::setupKAction() { // game KStdGameAction::gameNew(this, SLOT(newGame()), actionCollection()); KStdGameAction::load(this, SLOT(loadGame()), actionCollection()); KStdGameAction::save(this, SLOT(saveGame()), actionCollection()); KStdGameAction::quit(this, SLOT(close()), actionCollection()); KStdGameAction::restart(this, SLOT(restartGame()), actionCollection()); new KAction(i18n("New Numbered Game..."), "newnum", 0, this, SLOT(startNewNumeric()), actionCollection(), "game_new_numeric"); new KAction(i18n("Open Th&eme..."), 0, this, SLOT(openTheme()), actionCollection(), "game_open_theme"); new KAction(i18n("Open &Tileset..."), 0, this, SLOT(openTileset()), actionCollection(), "game_open_tileset"); new KAction(i18n("Open &Background..."), 0, this, SLOT(openBackground()), actionCollection(), "game_open_background"); new KAction(i18n("Open La&yout..."), 0, this, SLOT(openLayout()), actionCollection(), "game_open_layout"); new KAction(i18n("Sa&ve Theme..."), 0, this, SLOT(saveTheme()), actionCollection(), "game_save_theme"); // originally "file" ends here KStdGameAction::hint(bw, SLOT(helpMove()), actionCollection()); new KAction(i18n("Shu&ffle"), "reload", 0, bw, SLOT(shuffle()), actionCollection(), "move_shuffle"); demoAction = KStdGameAction::demo(this, SLOT(demoMode()), actionCollection()); showMatchingTilesAction = new KToggleAction(i18n("Show &Matching Tiles"), 0, this, SLOT(showMatchingTiles()), actionCollection(), "options_show_matching_tiles"); showMatchingTilesAction->setCheckedState(i18n("Hide &Matching Tiles")); showMatchingTilesAction->setChecked(Prefs::showMatchingTiles()); bw->setShowMatch( Prefs::showMatchingTiles() ); KStdGameAction::highscores(this, SLOT(showHighscores()), actionCollection()); pauseAction = KStdGameAction::pause(this, SLOT(pause()), actionCollection()); // TODO: store the background ; open on startup // TODO: same about layout // TODO: same about theme // move undoAction = KStdGameAction::undo(this, SLOT(undo()), actionCollection()); redoAction = KStdGameAction::redo(this, SLOT(redo()), actionCollection()); // edit new KAction(i18n("&Board Editor"), 0, this, SLOT(slotBoardEditor()), actionCollection(), "edit_board_editor"); // settings KStdAction::preferences(this, SLOT(showSettings()), actionCollection()); setupGUI(); }