Development/Tutorials/Games/KStandardGameAction: Difference between revisions
< Development | Tutorials
No edit summary |
(Mark for updating) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 11: | Line 11: | ||
reading={{class|KStandardGameAction}}, {{class|KStandardAction}} | reading={{class|KStandardGameAction}}, {{class|KStandardAction}} | ||
}} | |||
{{Review| | |||
* Port to KF5 | |||
* Add more content | |||
}} | }} | ||
Line 27: | Line 32: | ||
== Usage == | == Usage == | ||
Add some code like this to your action setup code. | Add some code like this to your action setup code. | ||
< | <syntaxhighlight lang="cpp-qt" line> | ||
#include < | #include <KStandardGameAction> | ||
void setupActions() | void setupActions() | ||
Line 58: | Line 63: | ||
setupGUI(); | setupGUI(); | ||
} | } | ||
</ | </syntaxhighlight> | ||
[[Category:C++]] | [[Category:C++]] | ||
[[Category:KDEGames]] | [[Category:KDEGames]] |
Latest revision as of 14:23, 31 May 2019
KStandardGameAction
Tutorial Series | KDE Games |
Previous | Introduction to KDE4 programming |
What's Next | High Scores Tutorial |
Further Reading | KStandardGameAction, KStandardAction |
Warning
This page needs a review and probably holds information that needs to be fixed.
Parts to be reviewed:
- Port to KF5
- Add more content
Abstract
This tutorial will explain the usage of KStandardGameActions in libkdegames.
KStandardGameAction
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.
Usage
Add some code like this to your action setup code.
#include <KStandardGameAction>
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();
}