~ubuntu-branches/ubuntu/gutsy/kde4libs/gutsy

« back to all changes in this revision

Viewing changes to kdeui/actions/kstandardaction.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2007-02-21 11:00:12 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070221110012-6kw8khr9knv6lmg1
Tags: 3.80.3-0ubuntu1
New upstream unstable release

Show diffs side-by-side

added added

removed removed

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