1 | /* |
2 | This file is part of the KDE libraries |
3 | SPDX-FileCopyrightText: 1999, 2000 Kurt Granroth <granroth@kde.org> |
4 | SPDX-FileCopyrightText: 2001, 2002 Ellis Whitehead <ellis@kde.org> |
5 | |
6 | SPDX-License-Identifier: LGPL-2.0-only |
7 | */ |
8 | #ifndef KGUISTANDARDACTION_H |
9 | #define KGUISTANDARDACTION_H |
10 | |
11 | #include <QAction> |
12 | #include <QList> |
13 | #include <QStringList> |
14 | |
15 | #include <KStandardShortcut> |
16 | #include <kconfiggui_export.h> |
17 | |
18 | #include <optional> |
19 | #include <type_traits> |
20 | |
21 | class QObject; |
22 | class QAction; |
23 | |
24 | /*! |
25 | * \namespace KStandardActions |
26 | * \inmodule KConfigGui |
27 | * |
28 | * \brief Convenience methods to access all standard KDE actions. |
29 | * |
30 | * These actions should be used instead of hardcoding menubar and |
31 | * toolbar items. Using these actions helps your application easily |
32 | * conform to the \l {https://develop.kde.org/hig/} {KDE Human Interface Guidelines}. |
33 | * |
34 | * All of the documentation for QAction holds for KStandardActions |
35 | * also. When in doubt on how things work, check the QAction |
36 | * documentation first. |
37 | * Please note that calling any of these methods automatically adds the action |
38 | * to the actionCollection() of the QObject given by the 'parent' parameter. |
39 | * |
40 | * Simple Example: |
41 | * |
42 | * In general, using standard actions should be a drop in replacement |
43 | * for regular actions. For example, if you previously had: |
44 | * \code |
45 | * QAction *newAct = new QAction(QIcon::fromTheme("document-new"), |
46 | * i18n("&New"), |
47 | * this); |
48 | * newAct->setShortcut(KStandardShortcut::shortcut(KStandardShortcut::New).constFirst()); |
49 | * connect(newAct, &QAction::triggered, this, &ClassFoo::fileNew); |
50 | * \endcode |
51 | * |
52 | * You can replace it with: |
53 | * \code |
54 | * QAction *newAct = KStandardActions::openNew(this, &ClassFoo::fileNew, this); |
55 | * \endcode |
56 | * |
57 | * Alternatively you can instantiate the action using the StandardAction enums |
58 | * provided. This author can't think of a reason why you would want to, but, hey, |
59 | * if you do, here's how: |
60 | * |
61 | * \code |
62 | * QAction *newAct = KStandardActions::create(KStandardActions::New, this, &ClassFoo::fileNew, this); |
63 | * \endcode |
64 | * |
65 | * Relationship with KActionCollection from KXMLGui |
66 | * |
67 | * If a KActionCollection is passed as the parent then the action will be |
68 | * automatically added to that collection: |
69 | * \code |
70 | * QAction *cut = KStandardActions::cut(this, &ClassFoo::editCut, actionCollection()); |
71 | * \endcode |
72 | * |
73 | * Each action has a unique internal name which can be queried using the |
74 | * name method. For example KStandardActions::name(KStandardActions::Cut) |
75 | * would return 'edit_cut'. This name can be used as a unique identifier |
76 | * for the actions. So if you wanted to add an existing standard action |
77 | * to an action collection you can do so like this: |
78 | * \code |
79 | * QAction *cut = KStandardActions::cut(this, &ClassFoo::editCut, this); |
80 | * actionCollection()->addAction(KStandardActions::name(KStandardActions::Cut), cut); |
81 | * \endcode |
82 | * |
83 | * You can then get a pointer to the action using |
84 | * \code |
85 | * QAction *cutPtr = actionCollection()->action(KStandardActions::name(KStandardActions::Cut)); |
86 | * \endcode |
87 | * |
88 | * \since 6.3 |
89 | */ |
90 | namespace KStandardActions |
91 | { |
92 | /*! |
93 | * The standard menubar and toolbar actions. |
94 | * \omitvalue ActionNone, |
95 | * \value New Create a new document or window. |
96 | * \value Open Open an existing file. |
97 | * \value OpenRecent Open a recently used document. |
98 | * \value Save Save the current document. |
99 | * \value SaveAs Save the current document under a different name. |
100 | * \value Revert Revert the current document to the last saved version. |
101 | * \value Close Close the current document. |
102 | * \value Print Print the current document. |
103 | * \value PrintPreview Show a print preview of the current document. |
104 | * \value Mail Send the current document by mail. |
105 | * \value Quit Quit the program. |
106 | * \value Undo Undo the last operation. |
107 | * \value Redo Redo the last operation. |
108 | * \value Cut Cut selected area and store it in the clipboard. |
109 | * \value Copy Copy selected area and store it in the clipboard. |
110 | * \value Paste Paste the contents of clipboard at the current mouse or cursor. |
111 | * \value SelectAll Select all elements in the current document. |
112 | * \value Deselect Deselect any selected elements in the current document. |
113 | * \value Find Initiate a 'find' request in the current document. |
114 | * \value FindNext Find the next instance of a stored 'find' |
115 | * \value FindPrev Find a previous instance of a stored 'find'. |
116 | * \value Replace Find and replace matches. |
117 | * \value ActualSize View the document at its actual size. |
118 | * \value FitToPage Fit the document view to the size of the current window. |
119 | * \value FitToWidth Fit the document view to the width of the current window. |
120 | * \value FitToHeight Fit the document view to the height of the current window. |
121 | * \value ZoomIn Zoom in the current document. |
122 | * \value ZoomOut Zoom out the current document. |
123 | * \value Zoom Select the current zoom level. |
124 | * \value Redisplay Redisplay or redraw the document. |
125 | * \value Up Move up (web style menu). |
126 | * \value Back Move back (web style menu). |
127 | * \value Forward Move forward (web style menu). |
128 | * \value Home Go to the "Home" position or document. |
129 | * \value Prior Scroll up one page. |
130 | * \value Next Scroll down one page. |
131 | * \value Goto Jump to some specific location in the document. |
132 | * \value GotoPage Go to a specific page. |
133 | * \value GotoLine Go to a specific line. |
134 | * \value FirstPage Jump to the first page. |
135 | * \value LastPage Jump to the last page. |
136 | * \value DocumentBack Move back (document style menu). |
137 | * \value DocumentForward Move forward (document style menu). |
138 | * \value AddBookmark Add the current page to the bookmarks tree. |
139 | * \value EditBookmarks Edit the application bookmarks. |
140 | * \value Spelling Pop up the spell checker. |
141 | * \value ShowMenubar Show/Hide the menubar. |
142 | * \value ShowToolbar Show/Hide the toolbar. |
143 | * \value ShowStatusbar Show/Hide the statusbar. |
144 | * \value KeyBindings Display the configure key bindings dialog. |
145 | * \value Preferences Display the preferences/options dialog. |
146 | * \value ConfigureToolbars Display the toolbar configuration dialog. |
147 | * \value HelpContents Display the handbook of the application. |
148 | * \value WhatsThis Trigger the What's This cursor. |
149 | * \value ReportBug Open up the Report Bug dialog. |
150 | * \value AboutApp Display the application's About box. |
151 | * \value AboutKDE Display the About KDE dialog. |
152 | * \value ConfigureNotifications Display the notifications configuration dialog. |
153 | * \value FullScreen Switch to/from full screen mode. |
154 | * \value Clear Clear the content of the focus widget. |
155 | * \value SwitchApplicationLanguage Display the Switch Application Language dialog. |
156 | * \value DeleteFile Permanently deletes files or folders. |
157 | * \value RenameFile Renames files or folders. |
158 | * \value MoveToTrash Moves files or folders to the trash. |
159 | * \value Donate Open donation page on kde.org. |
160 | * \value HamburgerMenu Opens a menu that substitutes the menubar. |
161 | */ |
162 | enum StandardAction { |
163 | ActionNone, |
164 | // File Menu |
165 | New, |
166 | Open, |
167 | OpenRecent, |
168 | Save, |
169 | SaveAs, |
170 | Revert, |
171 | Close, |
172 | Print, |
173 | PrintPreview, |
174 | Mail, |
175 | Quit, |
176 | // Edit Menu |
177 | Undo, |
178 | Redo, |
179 | Cut, |
180 | Copy, |
181 | Paste, |
182 | SelectAll, |
183 | Deselect, |
184 | Find, |
185 | FindNext, |
186 | FindPrev, |
187 | Replace, |
188 | // View Menu |
189 | ActualSize, |
190 | FitToPage, |
191 | FitToWidth, |
192 | FitToHeight, |
193 | ZoomIn, |
194 | ZoomOut, |
195 | Zoom, |
196 | Redisplay, |
197 | // Go Menu |
198 | Up, |
199 | Back, |
200 | Forward, |
201 | Home, |
202 | Prior, |
203 | Next, |
204 | Goto, |
205 | GotoPage, |
206 | GotoLine, |
207 | FirstPage, |
208 | LastPage, |
209 | DocumentBack, |
210 | DocumentForward, |
211 | // Bookmarks Menu |
212 | AddBookmark, |
213 | EditBookmarks, |
214 | // Tools Menu |
215 | Spelling, |
216 | // Settings Menu |
217 | ShowMenubar, |
218 | ShowToolbar, |
219 | ShowStatusbar, |
220 | KeyBindings, |
221 | Preferences, |
222 | ConfigureToolbars, |
223 | // Help Menu |
224 | HelpContents, |
225 | WhatsThis, |
226 | ReportBug, |
227 | AboutApp, |
228 | AboutKDE, |
229 | // Other standard actions |
230 | ConfigureNotifications, |
231 | FullScreen, |
232 | Clear, |
233 | SwitchApplicationLanguage, |
234 | DeleteFile, |
235 | RenameFile, |
236 | MoveToTrash, |
237 | Donate, |
238 | HamburgerMenu |
239 | // To keep in sync with KConfigWidgets::KStandardAction |
240 | }; |
241 | |
242 | KCONFIGGUI_EXPORT QAction *_kgui_createInternal(StandardAction id, QObject *parent); |
243 | |
244 | /*! |
245 | * Creates an action corresponding to one of the |
246 | * KStandardActions::StandardAction actions, which is connected to the given |
247 | * object and \a slot, and is owned by \a parent. |
248 | * |
249 | * If not explicitly specified, \a connectionType will be AutoConnection for all actions |
250 | * except for ConfigureToolbars it will be QueuedConnection. |
251 | * |
252 | * \sa create(StandardAction, const QObject *, const char *, QObject *) |
253 | */ |
254 | template<class Receiver, class Func> |
255 | inline QAction *create(StandardAction id, const Receiver *recvr, Func slot, QObject *parent, std::optional<Qt::ConnectionType> connectionType = std::nullopt) |
256 | { |
257 | QAction *action = _kgui_createInternal(id, parent); |
258 | // ConfigureToolbars is special because of bug #200815 |
259 | const Qt::ConnectionType defaultConnectionType = (id == ConfigureToolbars) ? Qt::QueuedConnection : Qt::AutoConnection; |
260 | QObject::connect(action, &QAction::triggered, recvr, slot, connectionType.value_or(u: defaultConnectionType)); |
261 | return action; |
262 | } |
263 | |
264 | /*! |
265 | * This will return the internal name of a given standard action. |
266 | */ |
267 | KCONFIGGUI_EXPORT QString name(StandardAction id); |
268 | |
269 | /*! |
270 | * Returns a list of all actionIds. |
271 | */ |
272 | KCONFIGGUI_EXPORT QList<StandardAction> actionIds(); |
273 | |
274 | /*! |
275 | * Returns the standardshortcut associated with \a actionId. |
276 | * |
277 | * \a id The identifier whose associated shortcut is wanted. |
278 | */ |
279 | KCONFIGGUI_EXPORT KStandardShortcut::StandardShortcut shortcutForActionId(StandardAction id); |
280 | |
281 | /*! |
282 | * Create a new document or window. |
283 | */ |
284 | template<class Receiver, class Func> |
285 | inline QAction *openNew(const Receiver *recvr, Func slot, QObject *parent) |
286 | { |
287 | return create(New, recvr, slot, parent); |
288 | } |
289 | |
290 | /*! |
291 | * Open an existing file. |
292 | */ |
293 | template<class Receiver, class Func> |
294 | inline QAction *open(const Receiver *recvr, Func slot, QObject *parent) |
295 | { |
296 | return create(Open, recvr, slot, parent); |
297 | } |
298 | |
299 | /*! |
300 | * Save the current document. |
301 | */ |
302 | template<class Receiver, class Func> |
303 | inline QAction *save(const Receiver *recvr, Func slot, QObject *parent) |
304 | { |
305 | return create(Save, recvr, slot, parent); |
306 | } |
307 | |
308 | /*! |
309 | * Save the current document under a different name. |
310 | */ |
311 | template<class Receiver, class Func> |
312 | inline QAction *saveAs(const Receiver *recvr, Func slot, QObject *parent) |
313 | { |
314 | return create(SaveAs, recvr, slot, parent); |
315 | } |
316 | |
317 | /*! |
318 | * Revert the current document to the last saved version |
319 | * (essentially will undo all changes). |
320 | */ |
321 | template<class Receiver, class Func> |
322 | inline QAction *revert(const Receiver *recvr, Func slot, QObject *parent) |
323 | { |
324 | return create(Revert, recvr, slot, parent); |
325 | } |
326 | |
327 | /*! |
328 | * Close the current document. |
329 | */ |
330 | template<class Receiver, class Func> |
331 | inline QAction *close(const Receiver *recvr, Func slot, QObject *parent) |
332 | { |
333 | return create(Close, recvr, slot, parent); |
334 | } |
335 | |
336 | /*! |
337 | * Print the current document. |
338 | */ |
339 | template<class Receiver, class Func> |
340 | inline QAction *print(const Receiver *recvr, Func slot, QObject *parent) |
341 | { |
342 | return create(Print, recvr, slot, parent); |
343 | } |
344 | |
345 | /*! |
346 | * Show a print preview of the current document. |
347 | */ |
348 | template<class Receiver, class Func> |
349 | inline QAction *printPreview(const Receiver *recvr, Func slot, QObject *parent) |
350 | { |
351 | return create(PrintPreview, recvr, slot, parent); |
352 | } |
353 | |
354 | /*! |
355 | * Mail this document. |
356 | */ |
357 | template<class Receiver, class Func> |
358 | inline QAction *mail(const Receiver *recvr, Func slot, QObject *parent) |
359 | { |
360 | return create(Mail, recvr, slot, parent); |
361 | } |
362 | |
363 | /*! |
364 | * Quit the program. |
365 | * |
366 | * Note that you probably want to connect this action to either QWidget::close() |
367 | * or QApplication::closeAllWindows(), but not QApplication::quit(), so that |
368 | * KMainWindow::queryClose() is called on any open window (to warn the user |
369 | * about unsaved changes for example). |
370 | */ |
371 | template<class Receiver, class Func> |
372 | inline QAction *quit(const Receiver *recvr, Func slot, QObject *parent) |
373 | { |
374 | return create(Quit, recvr, slot, parent); |
375 | } |
376 | |
377 | /*! |
378 | * Undo the last operation. |
379 | */ |
380 | template<class Receiver, class Func> |
381 | inline QAction *undo(const Receiver *recvr, Func slot, QObject *parent) |
382 | { |
383 | return create(Undo, recvr, slot, parent); |
384 | } |
385 | |
386 | /*! |
387 | * Redo the last operation. |
388 | */ |
389 | template<class Receiver, class Func> |
390 | inline QAction *redo(const Receiver *recvr, Func slot, QObject *parent) |
391 | { |
392 | return create(Redo, recvr, slot, parent); |
393 | } |
394 | |
395 | /*! |
396 | * Cut selected area and store it in the clipboard. |
397 | */ |
398 | template<class Receiver, class Func> |
399 | inline QAction *cut(const Receiver *recvr, Func slot, QObject *parent) |
400 | { |
401 | return create(Cut, recvr, slot, parent); |
402 | } |
403 | |
404 | /*! |
405 | * Copy the selected area into the clipboard. |
406 | */ |
407 | template<class Receiver, class Func> |
408 | inline QAction *copy(const Receiver *recvr, Func slot, QObject *parent) |
409 | { |
410 | return create(Copy, recvr, slot, parent); |
411 | } |
412 | |
413 | /*! |
414 | * Paste the contents of clipboard at the current mouse or cursor |
415 | * position. |
416 | */ |
417 | template<class Receiver, class Func> |
418 | inline QAction *paste(const Receiver *recvr, Func slot, QObject *parent) |
419 | { |
420 | return create(Paste, recvr, slot, parent); |
421 | } |
422 | |
423 | /*! |
424 | * Clear the content of the focus widget |
425 | */ |
426 | template<class Receiver, class Func> |
427 | inline QAction *clear(const Receiver *recvr, Func slot, QObject *parent) |
428 | { |
429 | return create(Clear, recvr, slot, parent); |
430 | } |
431 | |
432 | /*! |
433 | * Select all elements in the current document. |
434 | */ |
435 | template<class Receiver, class Func> |
436 | inline QAction *selectAll(const Receiver *recvr, Func slot, QObject *parent) |
437 | { |
438 | return create(SelectAll, recvr, slot, parent); |
439 | } |
440 | |
441 | /*! |
442 | * Deselect any selected elements in the current document. |
443 | */ |
444 | template<class Receiver, class Func> |
445 | inline QAction *deselect(const Receiver *recvr, Func slot, QObject *parent) |
446 | { |
447 | return create(Deselect, recvr, slot, parent); |
448 | } |
449 | |
450 | /*! |
451 | * Initiate a 'find' request in the current document. |
452 | */ |
453 | template<class Receiver, class Func> |
454 | inline QAction *find(const Receiver *recvr, Func slot, QObject *parent) |
455 | { |
456 | return create(Find, recvr, slot, parent); |
457 | } |
458 | |
459 | /*! |
460 | * Find the next instance of a stored 'find'. |
461 | */ |
462 | template<class Receiver, class Func> |
463 | inline QAction *findNext(const Receiver *recvr, Func slot, QObject *parent) |
464 | { |
465 | return create(FindNext, recvr, slot, parent); |
466 | } |
467 | |
468 | /*! |
469 | * Find a previous instance of a stored 'find'. |
470 | */ |
471 | template<class Receiver, class Func> |
472 | inline QAction *findPrev(const Receiver *recvr, Func slot, QObject *parent) |
473 | { |
474 | return create(FindPrev, recvr, slot, parent); |
475 | } |
476 | |
477 | /*! |
478 | * Find and replace matches. |
479 | */ |
480 | template<class Receiver, class Func> |
481 | inline QAction *replace(const Receiver *recvr, Func slot, QObject *parent) |
482 | { |
483 | return create(Replace, recvr, slot, parent); |
484 | } |
485 | |
486 | /*! |
487 | * View the document at its actual size. |
488 | */ |
489 | template<class Receiver, class Func> |
490 | inline QAction *actualSize(const Receiver *recvr, Func slot, QObject *parent) |
491 | { |
492 | return create(ActualSize, recvr, slot, parent); |
493 | } |
494 | |
495 | /*! |
496 | * Fit the document view to the size of the current window. |
497 | */ |
498 | template<class Receiver, class Func> |
499 | inline QAction *fitToPage(const Receiver *recvr, Func slot, QObject *parent) |
500 | { |
501 | return create(FitToPage, recvr, slot, parent); |
502 | } |
503 | |
504 | /*! |
505 | * Fit the document view to the width of the current window. |
506 | */ |
507 | template<class Receiver, class Func> |
508 | inline QAction *fitToWidth(const Receiver *recvr, Func slot, QObject *parent) |
509 | { |
510 | return create(FitToWidth, recvr, slot, parent); |
511 | } |
512 | |
513 | /*! |
514 | * Fit the document view to the height of the current window. |
515 | */ |
516 | template<class Receiver, class Func> |
517 | inline QAction *fitToHeight(const Receiver *recvr, Func slot, QObject *parent) |
518 | { |
519 | return create(FitToHeight, recvr, slot, parent); |
520 | } |
521 | |
522 | /*! |
523 | * Zoom in the current document view. |
524 | */ |
525 | template<class Receiver, class Func> |
526 | inline QAction *zoomIn(const Receiver *recvr, Func slot, QObject *parent) |
527 | { |
528 | return create(ZoomIn, recvr, slot, parent); |
529 | } |
530 | |
531 | /*! |
532 | * Zoom out the current document view. |
533 | */ |
534 | template<class Receiver, class Func> |
535 | inline QAction *zoomOut(const Receiver *recvr, Func slot, QObject *parent) |
536 | { |
537 | return create(ZoomOut, recvr, slot, parent); |
538 | } |
539 | |
540 | /*! |
541 | * Select the current zoom level. |
542 | */ |
543 | template<class Receiver, class Func> |
544 | inline QAction *zoom(const Receiver *recvr, Func slot, QObject *parent) |
545 | { |
546 | return create(Zoom, recvr, slot, parent); |
547 | } |
548 | |
549 | /*! |
550 | * Redisplay or redraw the document. |
551 | */ |
552 | template<class Receiver, class Func> |
553 | inline QAction *redisplay(const Receiver *recvr, Func slot, QObject *parent) |
554 | { |
555 | return create(Redisplay, recvr, slot, parent); |
556 | } |
557 | |
558 | /*! |
559 | * Move up (web style menu). |
560 | */ |
561 | template<class Receiver, class Func> |
562 | inline QAction *up(const Receiver *recvr, Func slot, QObject *parent) |
563 | { |
564 | return create(Up, recvr, slot, parent); |
565 | } |
566 | |
567 | /*! |
568 | * Move back (web style menu). |
569 | */ |
570 | template<class Receiver, class Func> |
571 | inline QAction *back(const Receiver *recvr, Func slot, QObject *parent) |
572 | { |
573 | return create(Back, recvr, slot, parent); |
574 | } |
575 | |
576 | /*! |
577 | * Move forward (web style menu). |
578 | */ |
579 | template<class Receiver, class Func> |
580 | inline QAction *forward(const Receiver *recvr, Func slot, QObject *parent) |
581 | { |
582 | return create(Forward, recvr, slot, parent); |
583 | } |
584 | |
585 | /*! |
586 | * Go to the "Home" position or document. |
587 | */ |
588 | template<class Receiver, class Func> |
589 | inline QAction *home(const Receiver *recvr, Func slot, QObject *parent) |
590 | { |
591 | return create(Home, recvr, slot, parent); |
592 | } |
593 | |
594 | /*! |
595 | * Scroll up one page. |
596 | */ |
597 | template<class Receiver, class Func> |
598 | inline QAction *prior(const Receiver *recvr, Func slot, QObject *parent) |
599 | { |
600 | return create(Prior, recvr, slot, parent); |
601 | } |
602 | |
603 | /*! |
604 | * Scroll down one page. |
605 | */ |
606 | template<class Receiver, class Func> |
607 | inline QAction *next(const Receiver *recvr, Func slot, QObject *parent) |
608 | { |
609 | return create(Next, recvr, slot, parent); |
610 | } |
611 | |
612 | /*! |
613 | * Jump to some specific location in the document. |
614 | */ |
615 | template<class Receiver, class Func> |
616 | inline QAction *goTo(const Receiver *recvr, Func slot, QObject *parent) |
617 | { |
618 | return create(Goto, recvr, slot, parent); |
619 | } |
620 | |
621 | /*! |
622 | * Go to a specific page. |
623 | */ |
624 | template<class Receiver, class Func> |
625 | inline QAction *gotoPage(const Receiver *recvr, Func slot, QObject *parent) |
626 | { |
627 | return create(GotoPage, recvr, slot, parent); |
628 | } |
629 | |
630 | /*! |
631 | * Go to a specific line. |
632 | */ |
633 | template<class Receiver, class Func> |
634 | inline QAction *gotoLine(const Receiver *recvr, Func slot, QObject *parent) |
635 | { |
636 | return create(GotoLine, recvr, slot, parent); |
637 | } |
638 | |
639 | /*! |
640 | * Jump to the first page. |
641 | */ |
642 | template<class Receiver, class Func> |
643 | inline QAction *firstPage(const Receiver *recvr, Func slot, QObject *parent) |
644 | { |
645 | return create(FirstPage, recvr, slot, parent); |
646 | } |
647 | |
648 | /*! |
649 | * Jump to the last page. |
650 | */ |
651 | template<class Receiver, class Func> |
652 | inline QAction *lastPage(const Receiver *recvr, Func slot, QObject *parent) |
653 | { |
654 | return create(LastPage, recvr, slot, parent); |
655 | } |
656 | |
657 | /*! |
658 | * Move back (document style menu). |
659 | */ |
660 | template<class Receiver, class Func> |
661 | inline QAction *documentBack(const Receiver *recvr, Func slot, QObject *parent) |
662 | { |
663 | return create(DocumentBack, recvr, slot, parent); |
664 | } |
665 | |
666 | /*! |
667 | * Move forward (document style menu). |
668 | */ |
669 | template<class Receiver, class Func> |
670 | inline QAction *documentForward(const Receiver *recvr, Func slot, QObject *parent) |
671 | { |
672 | return create(DocumentForward, recvr, slot, parent); |
673 | } |
674 | |
675 | /*! |
676 | * Add the current page to the bookmarks tree. |
677 | */ |
678 | template<class Receiver, class Func> |
679 | inline QAction *addBookmark(const Receiver *recvr, Func slot, QObject *parent) |
680 | { |
681 | return create(AddBookmark, recvr, slot, parent); |
682 | } |
683 | |
684 | /*! |
685 | * Edit the application bookmarks. |
686 | */ |
687 | template<class Receiver, class Func> |
688 | inline QAction *editBookmarks(const Receiver *recvr, Func slot, QObject *parent) |
689 | { |
690 | return create(EditBookmarks, recvr, slot, parent); |
691 | } |
692 | |
693 | /*! |
694 | * Pop up the spell checker. |
695 | */ |
696 | template<class Receiver, class Func> |
697 | inline QAction *spelling(const Receiver *recvr, Func slot, QObject *parent) |
698 | { |
699 | return create(Spelling, recvr, slot, parent); |
700 | } |
701 | |
702 | /*! |
703 | * Display the configure key bindings dialog. |
704 | * |
705 | * Note that you might be able to use the pre-built KXMLGUIFactory's function: |
706 | * \code |
707 | * KStandardActions::keyBindings(guiFactory(), &KXMLGUIFactory::showConfigureShortcutsDialog, actionCollection()); |
708 | * \endcode |
709 | */ |
710 | template<class Receiver, class Func> |
711 | inline QAction *keyBindings(const Receiver *recvr, Func slot, QObject *parent) |
712 | { |
713 | return create(KeyBindings, recvr, slot, parent); |
714 | } |
715 | |
716 | /*! |
717 | * Display the preferences/options dialog. |
718 | */ |
719 | template<class Receiver, class Func> |
720 | inline QAction *preferences(const Receiver *recvr, Func slot, QObject *parent) |
721 | { |
722 | return create(Preferences, recvr, slot, parent); |
723 | } |
724 | |
725 | /*! |
726 | * Display the toolbar configuration dialog. |
727 | */ |
728 | template<class Receiver, class Func> |
729 | inline QAction *configureToolbars(const Receiver *recvr, Func slot, QObject *parent) |
730 | { |
731 | return create(ConfigureToolbars, recvr, slot, parent); |
732 | } |
733 | |
734 | /*! |
735 | * Display the notifications configuration dialog. |
736 | */ |
737 | template<class Receiver, class Func> |
738 | inline QAction *configureNotifications(const Receiver *recvr, Func slot, QObject *parent) |
739 | { |
740 | return create(ConfigureNotifications, recvr, slot, parent); |
741 | } |
742 | |
743 | /*! |
744 | * Display the Switch Application Language dialog. |
745 | */ |
746 | template<class Receiver, class Func> |
747 | inline QAction *switchApplicationLanguage(const Receiver *recvr, Func slot, QObject *parent) |
748 | { |
749 | return create(SwitchApplicationLanguage, recvr, slot, parent); |
750 | } |
751 | |
752 | /*! |
753 | * Display the handbook of the application. |
754 | */ |
755 | template<class Receiver, class Func> |
756 | inline QAction *helpContents(const Receiver *recvr, Func slot, QObject *parent) |
757 | { |
758 | return create(HelpContents, recvr, slot, parent); |
759 | } |
760 | |
761 | /*! |
762 | * Trigger the What's This cursor. |
763 | */ |
764 | template<class Receiver, class Func> |
765 | inline QAction *whatsThis(const Receiver *recvr, Func slot, QObject *parent) |
766 | { |
767 | return create(WhatsThis, recvr, slot, parent); |
768 | } |
769 | |
770 | /*! |
771 | * Open up the Report Bug dialog. |
772 | */ |
773 | template<class Receiver, class Func> |
774 | inline QAction *reportBug(const Receiver *recvr, Func slot, QObject *parent) |
775 | { |
776 | return create(ReportBug, recvr, slot, parent); |
777 | } |
778 | |
779 | /*! |
780 | * Display the application's About box. |
781 | */ |
782 | template<class Receiver, class Func> |
783 | inline QAction *aboutApp(const Receiver *recvr, Func slot, QObject *parent) |
784 | { |
785 | return create(AboutApp, recvr, slot, parent); |
786 | } |
787 | |
788 | /*! |
789 | * Display the About KDE dialog. |
790 | */ |
791 | template<class Receiver, class Func> |
792 | inline QAction *aboutKDE(const Receiver *recvr, Func slot, QObject *parent) |
793 | { |
794 | return create(AboutKDE, recvr, slot, parent); |
795 | } |
796 | |
797 | /*! |
798 | * Permanently deletes files or folders. |
799 | */ |
800 | template<class Receiver, class Func> |
801 | inline QAction *deleteFile(const Receiver *recvr, Func slot, QObject *parent) |
802 | { |
803 | return create(DeleteFile, recvr, slot, parent); |
804 | } |
805 | |
806 | /*! |
807 | * Renames files or folders. |
808 | */ |
809 | template<class Receiver, class Func> |
810 | inline QAction *renameFile(const Receiver *recvr, Func slot, QObject *parent) |
811 | { |
812 | return create(RenameFile, recvr, slot, parent); |
813 | } |
814 | |
815 | /*! |
816 | * Moves files or folders to the trash. |
817 | */ |
818 | template<class Receiver, class Func> |
819 | inline QAction *moveToTrash(const Receiver *recvr, Func slot, QObject *parent) |
820 | { |
821 | return create(MoveToTrash, recvr, slot, parent); |
822 | } |
823 | |
824 | /*! |
825 | * Open donation page on kde.org. |
826 | */ |
827 | template<class Receiver, class Func> |
828 | inline QAction *donate(const Receiver *recvr, Func slot, QObject *parent) |
829 | { |
830 | return create(Donate, recvr, slot, parent); |
831 | } |
832 | } |
833 | |
834 | #endif // KSTDACTION_H |
835 | |