summaryrefslogtreecommitdiffabout
path: root/microkde/kdeui/kstdaction.h
Unidiff
Diffstat (limited to 'microkde/kdeui/kstdaction.h') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdeui/kstdaction.h568
1 files changed, 568 insertions, 0 deletions
diff --git a/microkde/kdeui/kstdaction.h b/microkde/kdeui/kstdaction.h
new file mode 100644
index 0000000..bc712b3
--- a/dev/null
+++ b/microkde/kdeui/kstdaction.h
@@ -0,0 +1,568 @@
1/* This file is part of the KDE libraries
2 Copyright (C) 1999,2000 Kurt Granroth <granroth@kde.org>
3 Copyright (C) 2001,2002 Ellis Whitehead <ellis@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA.
18*/
19#ifndef KSTDACTION_H
20#define KSTDACTION_H
21
22class QObject;
23class KAction;
24class KActionCollection;
25class KRecentFilesAction;
26class KToggleAction;
27class KToggleToolBarAction;
28
29#include <qstringlist.h>
30
31/**
32 * Convenience methods to access all standard KDE actions.
33 *
34 * These actions should be used instead of hardcoding menubar and
35 * toolbar items. Using these actions helps your application easily
36 * conform to the KDE UI Style Guide
37 * @see http://developer.kde.org/documentation/standards/kde/style/basics/index.html .
38 *
39 * All of the documentation for @ref KAction holds for KStdAction
40 * also. When in doubt on how things work, check the @ref KAction
41 * documention first.
42 *
43 * @sect Simple Example:
44 *
45 * In general, using standard actions should be a drop in replacement
46 * for regular actions. For example, if you previously had:
47 *
48 * <PRE>
49 * KAction *newAct = new KAction(i18n("&New"), QIconSet(BarIcon("filenew")),
50 * KStdAccel::key(KStdAccel::New), this,
51 * SLOT(fileNew()), actionCollection());
52 * </PRE>
53 *
54 * You could drop that and replace it with:
55 *
56 * <PRE>
57 * KAction *newAct = KStdAction::openNew(this, SLOT(fileNew()),
58 * actionCollection());
59 * </PRE>
60 *
61 * @sect Non-standard Usages
62 *
63 * It is possible to use the standard actions in various
64 * non-recommended ways. Say, for instance, you wanted to have a
65 * standard action (with the associated correct text and icon and
66 * accelerator, etc) but you didn't want it to go in the standard
67 * place (this is not recommended, by the way). One way to do this is
68 * to simply not use the XML UI framework and plug it into wherever
69 * you want. If you do want to use the XML UI framework (good!), then
70 * it is still possible.
71 *
72 * Basically, the XML building code matches names in the XML code with
73 * the internal names of the actions. You can find out the internal
74 * names of each of the standard actions by using the @ref stdName
75 * action like so: @ref KStdAction::stdName(KStdAction::Cut) would return
76 * 'edit_cut'. The XML building code will match 'edit_cut' to the
77 * attribute in the global XML file and place your action there.
78 *
79 * However, you can change the internal name. In this example, just
80 * do something like:
81 *
82 * <PRE>
83 * (void)KStdAction::cut(this, SLOT(editCut()), actionCollection(), "my_cut");
84 * </PRE>
85 *
86 * Now, in your local XML resource file (e.g., yourappui.rc), simply
87 * put 'my_cut' where you want it to go.
88 *
89 * Another non-standard usage concerns getting a pointer to an
90 * existing action if, say, you want to enable or disable the action.
91 * You could do it the recommended way and just grab a pointer when
92 * you instantiate it as in the the 'openNew' example above... or you
93 * could do it the hard way:
94 *
95 * <pre>
96 * KAction *cut = actionCollection()->action(KStdAction::stdName(KStdAction::Cut));
97 * </pre>
98 *
99 * Another non-standard usage concerns instantiating the action in the
100 * first place. Usually, you would use the member functions as
101 * shown above (e.g., KStdAction::cut(this, SLOT, parent)). You
102 * may, however, do this using the enums provided. This author can't
103 * think of a reason why you would want to, but, hey, if you do,
104 * here's how:
105 *
106 * <pre>
107 * (void)KStdAction::action(KStdAction::New, this, SLOT(fileNew()), actionCollection());
108 * (void)KStdAction::action(KStdAction::Cut, this, SLOT(editCut()), actionCollection());
109 * </pre>
110 *
111 * @author Kurt Granroth <granroth@kde.org>
112 */
113namespace KStdAction
114{
115 /**
116 * The standard menubar and toolbar actions.
117 */
118 enum StdAction {
119 ActionNone,
120
121 // File Menu
122 New, Open, OpenRecent, Save, SaveAs, Revert, Close,
123 Print, PrintPreview, Mail, Quit,
124
125 // Edit Menu
126 Undo, Redo, Cut, Copy, Paste, SelectAll, Deselect, Find, FindNext, FindPrev,
127 Replace,
128
129 // View Menu
130 ActualSize, FitToPage, FitToWidth, FitToHeight, ZoomIn, ZoomOut,
131 Zoom, Redisplay,
132
133 // Go Menu
134 Up, Back, Forward, Home, Prior, Next, Goto, GotoPage, GotoLine,
135 FirstPage, LastPage,
136
137 // Bookmarks Menu
138 AddBookmark, EditBookmarks,
139
140 // Tools Menu
141 Spelling,
142
143 // Settings Menu
144 ShowMenubar, ShowToolbar, ShowStatusbar, SaveOptions, KeyBindings,
145 Preferences, ConfigureToolbars,
146
147 // Help Menu
148 Help, HelpContents, WhatsThis, ReportBug, AboutApp, AboutKDE,
149 TipofDay, ///< @since 3.1
150
151 // Another settings menu item
152 ConfigureNotifications
153 };
154
155 /**
156 * Creates an action corresponding to the
157 * @ref KStdAction::StdAction enum.
158 */
159 KAction* create( StdAction id, const char *name,
160 const QObject *recvr, const char *slot,
161 KActionCollection* parent );
162
163 inline KAction* create( StdAction id,
164 const QObject *recvr, const char *slot,
165 KActionCollection* parent )
166 { return KStdAction::create( id, 0, recvr, slot, parent ); }
167
168 /**
169 * @obsolete. Creates an action corresponding to the
170 * @ref KStdAction::StdAction enum.
171 */
172 inline KAction *action(StdAction act_enum,
173 const QObject *recvr, const char *slot,
174 KActionCollection *parent, const char *name = 0L )
175 { return KStdAction::create( act_enum, name, recvr, slot, parent ); }
176
177 /**
178 * This will return the internal name of a given standard action.
179 */
180 const char* name( StdAction id );
181
182 /// @obsolete. Use #name
183 inline const char* stdName(StdAction act_enum) { return name( act_enum ); }
184
185 /**
186 * Returns a list of all standard names. Used by @ref KAccelManager
187 * to give those heigher weight.
188 * @since 3.1
189 */
190 QStringList stdNames();
191
192 /**
193 * Create a new document or window.
194 */
195 KAction *openNew(const QObject *recvr, const char *slot, KActionCollection* parent, const char *name = 0 );
196
197 /**
198 * Open an existing file.
199 */
200 KAction *open(const QObject *recvr, const char *slot, KActionCollection* parent, const char *name = 0 );
201
202 /**
203 * Open a recently used document.
204 * @param slot The SLOT to invoke when a URL is selected.
205 * Its signature is of the form slotURLSelected( const KURL & ).
206 */
207 KRecentFilesAction *openRecent(const QObject *recvr, const char *slot, KActionCollection* parent, const char *name = 0 );
208
209 /**
210 * Save the current document.
211 */
212 KAction *save(const QObject *recvr, const char *slot,
213 KActionCollection* parent, const char *name = 0 );
214
215 /**
216 * Save the current document under a different name.
217 */
218 KAction *saveAs(const QObject *recvr, const char *slot,
219 KActionCollection* parent, const char *name = 0 );
220
221 /**
222 * Revert the current document to the last saved version
223 * (essentially will undo all changes).
224 */
225 KAction *revert(const QObject *recvr, const char *slot,
226 KActionCollection* parent, const char *name = 0 );
227
228 /**
229 * Close the current document.
230 */
231 KAction *close(const QObject *recvr, const char *slot,
232 KActionCollection* parent, const char *name = 0 );
233
234 /**
235 * Print the current document.
236 */
237 KAction *print(const QObject *recvr, const char *slot,
238 KActionCollection* parent, const char *name = 0 );
239
240 /**
241 * Show a print preview of the current document.
242 */
243 KAction *printPreview(const QObject *recvr, const char *slot,
244 KActionCollection* parent, const char *name = 0 );
245
246 /**
247 * Mail this document.
248 */
249 KAction *mail(const QObject *recvr, const char *slot,
250 KActionCollection* parent, const char *name = 0 );
251
252 /**
253 * Quit the program.
254 */
255 KAction *quit(const QObject *recvr, const char *slot,
256 KActionCollection* parent, const char *name = 0 );
257
258 /**
259 * Undo the last operation.
260 */
261 KAction *undo(const QObject *recvr, const char *slot,
262 KActionCollection* parent, const char *name = 0 );
263
264 /**
265 * Redo the last operation.
266 */
267 KAction *redo(const QObject *recvr, const char *slot,
268 KActionCollection* parent, const char *name = 0 );
269
270 /**
271 * Cut selected area and store it in the clipboard.
272 */
273 KAction *cut(const QObject *recvr, const char *slot,
274 KActionCollection* parent, const char *name = 0 );
275
276 /**
277 * Copy the selected area into the clipboard.
278 */
279 KAction *copy(const QObject *recvr, const char *slot,
280 KActionCollection* parent, const char *name = 0 );
281
282 /**
283 * Paste the contents of clipboard at the current mouse or cursor
284 * position.
285 */
286 KAction *paste(const QObject *recvr, const char *slot,
287 KActionCollection* parent, const char *name = 0 );
288
289 /**
290 * Select all elements in the current document.
291 */
292 KAction *selectAll(const QObject *recvr, const char *slot,
293 KActionCollection* parent, const char *name = 0 );
294
295 /**
296 * Deselect any selected elements in the current document.
297 */
298 KAction *deselect(const QObject *recvr, const char *slot,
299 KActionCollection* parent, const char *name = 0 );
300
301 /**
302 * Initiate a 'find' request in the current document.
303 */
304 KAction *find(const QObject *recvr, const char *slot,
305 KActionCollection* parent, const char *name = 0 );
306
307 /**
308 * Find the next instance of a stored 'find'.
309 */
310 KAction *findNext(const QObject *recvr, const char *slot,
311 KActionCollection* parent, const char *name = 0 );
312
313 /**
314 * Find a previous instance of a stored 'find'.
315 */
316 KAction *findPrev(const QObject *recvr, const char *slot,
317 KActionCollection* parent, const char *name = 0 );
318
319 /**
320 * Find and replace matches.
321 */
322 KAction *replace(const QObject *recvr, const char *slot,
323 KActionCollection* parent, const char *name = 0 );
324
325 /**
326 * View the document at its actual size.
327 */
328 KAction *actualSize(const QObject *recvr, const char *slot,
329 KActionCollection* parent, const char *name = 0 );
330
331 /**
332 * Fit the document view to the size of the current window.
333 */
334 KAction *fitToPage(const QObject *recvr, const char *slot,
335 KActionCollection* parent, const char *name = 0 );
336
337 /**
338 * Fit the document view to the width of the current window.
339 */
340 KAction *fitToWidth(const QObject *recvr, const char *slot,
341 KActionCollection* parent, const char *name = 0 );
342
343 /**
344 * Fit the document view to the height of the current window.
345 */
346 KAction *fitToHeight(const QObject *recvr, const char *slot,
347 KActionCollection* parent, const char *name = 0 );
348
349 /**
350 * Zoom in.
351 */
352 KAction *zoomIn(const QObject *recvr, const char *slot,
353 KActionCollection* parent, const char *name = 0 );
354
355 /**
356 * Zoom out.
357 */
358 KAction *zoomOut(const QObject *recvr, const char *slot,
359 KActionCollection* parent, const char *name = 0 );
360
361 /**
362 * Popup a zoom dialog.
363 */
364 KAction *zoom(const QObject *recvr, const char *slot,
365 KActionCollection* parent, const char *name = 0 );
366
367 /**
368 * Redisplay or redraw the document.
369 */
370 KAction *redisplay(const QObject *recvr, const char *slot,
371 KActionCollection* parent, const char *name = 0 );
372
373 /**
374 * Move up (web style menu).
375 */
376 KAction *up(const QObject *recvr, const char *slot,
377 KActionCollection* parent, const char *name = 0 );
378
379 /**
380 * Move back (web style menu).
381 */
382 KAction *back(const QObject *recvr, const char *slot,
383 KActionCollection* parent, const char *name = 0 );
384
385 /**
386 * Move forward (web style menu).
387 */
388 KAction *forward(const QObject *recvr, const char *slot,
389 KActionCollection* parent, const char *name = 0 );
390
391 /**
392 * Go to the "Home" position or document.
393 */
394 KAction *home(const QObject *recvr, const char *slot,
395 KActionCollection* parent, const char *name = 0 );
396
397 /**
398 * Scroll up one page.
399 */
400 KAction *prior(const QObject *recvr, const char *slot,
401 KActionCollection* parent, const char *name = 0 );
402
403 /**
404 * Scroll down one page.
405 */
406 KAction *next(const QObject *recvr, const char *slot,
407 KActionCollection* parent, const char *name = 0 );
408
409 /**
410 * Go to somewhere in general.
411 */
412 KAction *goTo(const QObject *recvr, const char *slot,
413 KActionCollection* parent, const char *name = 0 );
414
415
416 /**
417 * Go to a specific page (dialog).
418 */
419 KAction *gotoPage(const QObject *recvr, const char *slot,
420 KActionCollection* parent, const char *name = 0 );
421
422 /**
423 * Go to a specific line (dialog).
424 */
425 KAction *gotoLine(const QObject *recvr, const char *slot,
426 KActionCollection* parent, const char *name = 0 );
427
428 /**
429 * Jump to the first page.
430 */
431 KAction *firstPage(const QObject *recvr, const char *slot,
432 KActionCollection* parent, const char *name = 0 );
433
434 /**
435 * Jump to the last page.
436 */
437 KAction *lastPage(const QObject *recvr, const char *slot,
438 KActionCollection* parent, const char *name = 0 );
439
440 /**
441 * Add the current page to the bookmarks tree.
442 */
443 KAction *addBookmark(const QObject *recvr, const char *slot,
444 KActionCollection* parent, const char *name = 0 );
445
446 /**
447 * Edit the application bookmarks.
448 */
449 KAction *editBookmarks(const QObject *recvr, const char *slot,
450 KActionCollection* parent, const char *name = 0 );
451
452 /**
453 * Pop up the spell checker.
454 */
455 KAction *spelling(const QObject *recvr, const char *slot,
456 KActionCollection* parent, const char *name = 0 );
457
458
459 /**
460 * Show/Hide the menubar.
461 */
462 KToggleAction *showMenubar(const QObject *recvr, const char *slot,
463 KActionCollection* parent, const char *name = 0 );
464
465 /**
466 * @obsolete. toolbar actions are created automatically now in the
467 * Settings menu. Don't use this anymore.
468 * See: @ref KMainWindow::createStandardStatusBarAction()
469 * Show/Hide the primary toolbar.
470 * @since 3.1
471 */
472 KToggleAction *showToolbar(const QObject *recvr, const char *slot,
473 KActionCollection* parent, const char *name = 0 );
474 /**
475 * @obsolete. toolbar actions are created automatically now in the
476 * Settings menu. Don't use this anymore.
477 * See: @ref KMainWindow::setStandardToolBarMenuEnabled(bool);
478 * Show/Hide the primary toolbar.
479 */
480 KToggleToolBarAction *showToolbar(const char* toolBarName,
481 KActionCollection* parent, const char *name = 0 );
482
483 /**
484 * Show/Hide the statusbar.
485 */
486 KToggleAction *showStatusbar(const QObject *recvr, const char *slot,
487 KActionCollection* parent, const char *name = 0 );
488
489 /**
490 * Display the save options dialog.
491 */
492 KAction *saveOptions(const QObject *recvr, const char *slot,
493 KActionCollection* parent, const char *name = 0 );
494
495 /**
496 * Display the configure key bindings dialog.
497 */
498 KAction *keyBindings(const QObject *recvr, const char *slot,
499 KActionCollection* parent, const char *name = 0 );
500
501 /**
502 * Display the preferences/options dialog.
503 */
504 KAction *preferences(const QObject *recvr, const char *slot,
505 KActionCollection* parent, const char *name = 0 );
506
507 /**
508 * The Customize Toolbar dialog.
509 */
510 KAction *configureToolbars(const QObject *recvr,
511 const char *slot,
512 KActionCollection* parent,
513 const char *name = 0 );
514
515 /**
516 * The Configure Notifications dialo
517 * @since 3.1
518 */
519 KAction *configureNotifications(const QObject *recvr,
520 const char *slot,
521 KActionCollection *parent,
522 const char *name = 0);
523
524 /**
525 * Display the help.
526 */
527 KAction *help(const QObject *recvr, const char *slot,
528 KActionCollection* parent, const char *name = 0 );
529
530 /**
531 * Display the help contents.
532 */
533 KAction *helpContents(const QObject *recvr, const char *slot,
534 KActionCollection* parent, const char *name = 0 );
535
536 /**
537 * Trigger the What's This cursor.
538 */
539 KAction *whatsThis(const QObject *recvr, const char *slot,
540 KActionCollection* parent, const char *name = 0 );
541
542 /**
543 * Display "Tip of the Day"
544 * @since 3.1
545 */
546 KAction *tipOfDay(const QObject *recvr, const char *slot,
547 KActionCollection* parent, const char *name = 0 );
548
549 /**
550 * Open up the Report Bug dialog.
551 */
552 KAction *reportBug(const QObject *recvr, const char *slot,
553 KActionCollection* parent, const char *name = 0 );
554
555 /**
556 * Display the application's About box.
557 */
558 KAction *aboutApp(const QObject *recvr, const char *slot,
559 KActionCollection* parent, const char *name = 0 );
560
561 /**
562 * Display the About KDE dialog.
563 */
564 KAction *aboutKDE(const QObject *recvr, const char *slot,
565 KActionCollection* parent, const char *name = 0 );
566}
567
568#endif // KSTDACTION_H