20 #include "kstdgameaction.h"
24 #include <kstdaccel.h>
29 KStdGameAction::KStdGameAction()
32 KStdGameAction::~KStdGameAction()
36 const char *slot, KActionCollection *parent,
39 return create( act_enum, name, recvr, slot, parent );
44 return name(act_enum);
47 struct KStdGameActionInfo
50 KStdAccel::StdAccel globalAccel;
54 const char* psWhatsThis;
55 const char* psIconName;
58 const KStdGameActionInfo g_rgActionInfo[] = {
60 { KStdGameAction::New, KStdAccel::New, 0,
"game_new", I18N_NOOP2(
"new game",
"&New"), 0,
"filenew" },
61 { KStdGameAction::Load, KStdAccel::Open, 0,
"game_load", I18N_NOOP(
"&Load..."), 0,
"fileopen" },
62 { KStdGameAction::LoadRecent, KStdAccel::AccelNone, 0,
"game_load_recent", I18N_NOOP(
"Load &Recent"), 0, 0 },
63 { KStdGameAction::Restart, KStdAccel::Reload, 0,
"game_restart", I18N_NOOP(
"Restart &Game"), 0,
"reload" },
64 { KStdGameAction::Save, KStdAccel::Save, 0,
"game_save", I18N_NOOP(
"&Save"), 0,
"filesave" },
65 { KStdGameAction::SaveAs, KStdAccel::AccelNone, 0,
"game_save_as", I18N_NOOP(
"Save &As..."), 0,
"filesaveas" },
66 { KStdGameAction::End, KStdAccel::End, 0,
"game_end", I18N_NOOP(
"&End Game"), 0,
"fileclose" },
67 { KStdGameAction::Pause, KStdAccel::AccelNone, TQt::Key_P,
"game_pause", I18N_NOOP(
"Pa&use"), 0,
"player_pause" },
68 { KStdGameAction::Highscores, KStdAccel::AccelNone, TQt::CTRL+TQt::Key_H,
"game_highscores", I18N_NOOP(
"Show &Highscores"), 0,
"highscore" },
69 { KStdGameAction::Print, KStdAccel::Print, 0,
"game_print", I18N_NOOP(
"&Print..."), 0,
"fileprint" },
70 { KStdGameAction::Quit, KStdAccel::Quit, 0,
"game_quit", I18N_NOOP(
"&Quit"), 0,
"exit" },
72 { KStdGameAction::Repeat, KStdAccel::AccelNone, 0,
"move_repeat", I18N_NOOP(
"Repeat"), 0, 0 },
73 { KStdGameAction::Undo, KStdAccel::Undo, 0,
"move_undo", I18N_NOOP(
"Und&o"), 0,
"undo" },
74 { KStdGameAction::Redo, KStdAccel::Redo, 0,
"move_redo", I18N_NOOP(
"Re&do"), 0,
"redo" },
75 { KStdGameAction::Roll, KStdAccel::AccelNone, TQt::CTRL+TQt::Key_R,
"move_roll", I18N_NOOP(
"&Roll Dice"), 0,
"roll" },
76 { KStdGameAction::EndTurn, KStdAccel::AccelNone, 0,
"move_end_turn", I18N_NOOP(
"End Turn"), 0,
"endturn" },
77 { KStdGameAction::Hint, KStdAccel::AccelNone, TQt::Key_H,
"move_hint", I18N_NOOP(
"&Hint"), 0,
"idea" },
78 { KStdGameAction::Demo, KStdAccel::AccelNone, TQt::Key_D,
"move_demo", I18N_NOOP(
"&Demo"), 0,
"1rightarrow" },
79 { KStdGameAction::Solve, KStdAccel::AccelNone, 0,
"move_solve", I18N_NOOP(
"&Solve"), 0,
"wizard" },
81 { KStdGameAction::ChooseGameType, KStdAccel::AccelNone, 0,
"options_choose_game_type", I18N_NOOP(
"Choose Game &Type"), 0, 0 },
82 { KStdGameAction::Carddecks, KStdAccel::AccelNone, 0,
"options_configure_carddecks", I18N_NOOP(
"Configure &Carddecks..."), 0, 0 },
83 { KStdGameAction::ConfigureHighscores, KStdAccel::AccelNone, 0,
"options_configure_highscores", I18N_NOOP(
"Configure &Highscores..."), 0, 0 },
85 { KStdGameAction::ActionNone, KStdAccel::AccelNone, 0, 0, 0, 0, 0 }
90 for (uint i = 0; g_rgActionInfo[i].id!=KStdGameAction::ActionNone; i++) {
91 if( g_rgActionInfo[i].
id ==
id )
92 return &g_rgActionInfo[i];
99 const TQObject *recvr,
const char *slot,
100 KActionCollection* parent )
102 KAction* pAction = 0;
103 const KStdGameActionInfo* pInfo = infoPtr(
id );
104 kdDebug(125) <<
"KStdGameAction::create( " <<
id <<
"=" << (pInfo ? pInfo->psName : (
const char*)0) <<
", " << parent <<
", " << name <<
" )" << endl;
106 TQString sLabel = i18n(pInfo->psLabel);
107 KShortcut cut = (pInfo->globalAccel==KStdAccel::AccelNone
108 ? KShortcut(pInfo->shortcut)
109 : KStdAccel::shortcut(pInfo->globalAccel));
110 const char *n = name ? name : pInfo->psName;
114 new KRecentFilesAction(sLabel, cut, recvr, slot, parent, n);
118 pAction =
new KToggleAction( sLabel, pInfo->psIconName, cut,
119 recvr, slot, parent, n);
122 pAction =
new KSelectAction( sLabel, pInfo->psIconName, cut,
123 recvr, slot, parent, n);
126 pAction =
new KAction( sLabel, pInfo->psIconName, cut,
127 recvr, slot, parent, n);
136 const KStdGameActionInfo* pInfo = infoPtr(
id );
137 return (pInfo) ? pInfo->psName : 0;
141 KActionCollection *parent,
const char *name )
144 KActionCollection *parent,
const char *name )
147 KActionCollection *parent,
const char *name )
148 {
return static_cast<KRecentFilesAction *
>(
KStdGameAction::create(LoadRecent, name, recvr, slot, parent)); }
150 KActionCollection *parent,
const char *name )
153 KActionCollection *parent,
const char *name )
156 KActionCollection *parent,
const char *name )
159 KActionCollection *parent,
const char *name )
162 KActionCollection *parent,
const char *name )
165 KActionCollection *parent,
const char *name )
168 KActionCollection *parent,
const char *name )
172 KActionCollection *parent,
const char *name )
175 KActionCollection *parent,
const char *name )
179 KActionCollection *parent,
const char *name )
183 KActionCollection *parent,
const char *name )
186 KActionCollection *parent,
const char *name )
190 KActionCollection *parent,
const char *name )
193 KActionCollection *parent,
const char *name)
196 KActionCollection *parent,
const char *name)
199 KActionCollection *parent,
const char *name)
202 KActionCollection *parent,
const char *name)
205 KActionCollection *parent,
const char *name)
206 {
return static_cast<KSelectAction *
>(
KStdGameAction::create(ChooseGameType, name, recvr, slot, parent)); }
208 KActionCollection *parent,
const char *name)