m (No longer encessary. FindLibKDEGames.cmake is fixed) |
|||
| Line 28: | Line 28: | ||
Add some code like this to your action setup code. | Add some code like this to your action setup code. | ||
<code cppqt n> | <code cppqt n> | ||
| − | #include < | + | #include <KStandardGameAction> |
void setupActions() | void setupActions() | ||
| Tutorial Series | KDE Games |
| Previous | Introduction to KDE4 programming |
| What's Next | High Scores Tutorial |
| Further Reading | KStandardGameAction, KStandardAction |
This tutorial will explain the usage of KStandardGameActions in libkdegames.
This class is an extension to the usual KStandardAction class which provides easy access to often used KDE actions.
Using these actions helps maintaining consistency among the games.
Games often use different menu entries than other programs, e.g. games use the menu "game" instead of "file". This class provides the entries which differ from the usual KStandardAction entries.
Add some code like this to your action setup code.
void setupActions() {
// Game
KStandardGameAction::gameNew(this,
SLOT(newGame()),
actionCollection());
KStandardGameAction::highscores(this,
SLOT(showHighscores()),
actionCollection());
KStandardGameAction::quit(this,
SLOT(close()),
actionCollection());
// Move
KStandardGameAction::undo(this,
SLOT(undoMove()),
actionCollection());
KStandardGameAction::redo(this,
SLOT(redoMove()),
actionCollection());
// Settings
KStandardGameAction::configureHighscores(this,
SLOT(configureHighscores()),
actionCollection());
setupGUI();
}