1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 1997 Stefan Taferner <taferner@kde.org>
4 SPDX-FileCopyrightText: 2000 Nicolas Hadacek <hadacek@kde.org>
5 SPDX-FileCopyrightText: 2001, 2002 Ellis Whitehead <ellis@kde.org>
6
7 SPDX-License-Identifier: LGPL-2.0-or-later
8*/
9#ifndef KSTANDARDSHORTCUT_H
10#define KSTANDARDSHORTCUT_H
11
12#include <QKeySequence>
13#include <QString>
14
15#include <kconfiggui_export.h>
16
17/*!
18 * \namespace KStandardShortcut
19 * \inmodule KConfigGui
20 *
21 * \brief Convenient methods for access to the common accelerator keys in
22 * the key configuration.
23 *
24 * These are the standard keybindings that should
25 * be used in all KDE applications. They will be configurable,
26 * so do not hardcode the default behavior.
27 */
28namespace KStandardShortcut
29{
30// STUFF WILL BREAK IF YOU DON'T READ THIS!!!
31/*
32 *Always add new std-accels to the end of this enum, never in the middle!
33 *Don't forget to add the corresponding entries in g_infoStandardShortcut[] in kstandardshortcut.cpp, too.
34 *Values of elements here and positions of the corresponding entries in
35 *the big array g_infoStandardShortcut[] ABSOLUTELY MUST BE THE SAME.
36 * !!! !!!! !!!!! !!!!
37 * !!!! !!! !!!! !!!!
38 *
39 * Other Rules:
40 *
41 * - Never change the name of an existing shortcut
42 * - Never translate the name of a shortcut
43 */
44
45/*!
46 * Defines the identifier of all standard accelerators.
47 * \value AccelNone
48 * \value Open Open file.
49 * \value New Create a new document.
50 * \value Close Close current document.
51 * \value Save Save current document.
52 * \value Print Print current document.
53 * \value Quit Quit the program.
54 * \value Undo Undo last operation.
55 * \value Redo Redo last operation.
56 * \value Cut Cut selected area and store it in the clipboard.
57 * \value Copy Copy selected area into the clipboard.
58 * \value Paste Paste contents of clipboard at mouse/cursor position.
59 * \value PasteSelection Paste the selection at mouse/cursor position.
60 * \value SelectAll Select all.
61 * \value Deselect Deselect any selected elements.
62 * \value DeleteWordBack Delete a word back from mouse/cursor position.
63 * \value DeleteWordForward Delete a word forward from mouse/cursor position.
64 * \value Find Initiate a 'find' request in the current document.
65 * \value FindNext Find the next instance of a stored 'find'.
66 * \value FindPrev Find a previous instance of a stored 'find'.
67 * \value Replace Find and replace matches.
68 * \value Home Go to home page.
69 * \value Begin Go to beginning of the document.
70 * \value End Go to end of the document.
71 * \value Prior Scroll up one page.
72 * \value Next Scroll down one page.
73 * \value Up Up.
74 * \value Back Back.
75 * \value Forward Forward.
76 * \value Reload Reload.
77 * \value BeginningOfLine Go to beginning of current line.
78 * \value EndOfLine Go to end of current line.
79 * \value GotoLine Go to line.
80 * \value BackwardWord BackwardWord.
81 * \value ForwardWord ForwardWord.
82 * \value AddBookmark Add current page to bookmarks.
83 * \value ZoomIn Zoom in.
84 * \value ZoomOut Zoom out.
85 * \value FullScreen Full Screen mode.
86 * \value ShowMenubar Show Menu Bar.
87 * \value TabNext Next Tab.
88 * \value TabPrev Previous Tab.
89 * \value Help Help the user in the current situation.
90 * \value WhatsThis What's This button.
91 * \value TextCompletion Complete text in input widgets.
92 * \value PrevCompletion Iterate through a list when completion returns multiple items.
93 * \value NextCompletion Iterate through a list when completion returns multiple items.
94 * \value SubstringCompletion Find a string within another string or list of strings.
95 * \value RotateUp Help users iterate through a list of entries.
96 * \value RotateDown Help users iterate through a list of entries.
97 * \value OpenRecent Open a recently used document.
98 * \value SaveAs Save the current document under a different name.
99 * \value Revert Revert the current document to the last saved version.
100 * \value PrintPreview Show a print preview of the current document.
101 * \value Mail Send the current document by mail.
102 * \value Clear Clear the content of the focus widget.
103 * \value ActualSize View the document at its actual size.
104 * \value FitToPage Fit the document view to the size of the current window.
105 * \value FitToWidth Fit the document view to the width of the current window.
106 * \value FitToHeight Fit the document view to the height of the current window.
107 * \value Zoom Select the current zoom level.
108 * \value Goto Jump to some specific location in the document.
109 * \value GotoPage Go to a specific page.
110 * \value DocumentBack Move back (document style menu).
111 * \value DocumentForward Move forward (document style menu).
112 * \value EditBookmarks Edit the application bookmarks.
113 * \value Spelling Pop up the spell checker.
114 * \value ShowToolbar Show/Hide the toolbar.
115 * \value ShowStatusbar Show/Hide the statusbar.
116 * \value KeyBindings Display the configure key bindings dialog.
117 * \value Preferences Display the preferences/options dialog.
118 * \value ConfigureToolbars Display the toolbar configuration dialog.
119 * \value ConfigureNotifications Display the notifications configuration dialog.
120 * \value ReportBug Display the Report Bug dialog.
121 * \value SwitchApplicationLanguage Display the Switch Application Language dialog.
122 * \value AboutApp Display the application's About dialog.
123 * \value AboutKDE Display the About KDE dialog.
124 * \value [since 5.25] DeleteFile Permanently delete files or folders.
125 * \value [since 5.25] RenameFile Rename files or folders.
126 * \value [since 5.25] MoveToTrash Move files or folders to the trash.
127 * \value [since 5.26] Donate Open donation page on kde.org.
128 * \value [since 5.70] ShowHideHiddenFiles Toggle showing or hiding hidden files
129 * \value [since 5.74] CreateFolder Create a folder.
130 * \value [since 6.0] OpenMainMenu Open a main menu like the menu bar or a hamburger menu. Necessary for accessibility. * \value [since 6.0] OpenContextMenu
131 * Open a context menu for the object with keyboard focus. Necessary for accessibility. */
132enum StandardShortcut {
133 // C++ requires that the value of an enum symbol be one more than the previous one.
134 // This means that everything will be well-ordered from here on.
135 AccelNone = 0,
136 // File menu
137 Open,
138 New,
139 Close,
140 Save,
141 // The Print item
142 Print,
143 Quit,
144 // Edit menu
145 Undo,
146 Redo,
147 Cut,
148 Copy,
149 Paste,
150 PasteSelection,
151 SelectAll,
152 Deselect,
153 DeleteWordBack,
154 DeleteWordForward,
155 Find,
156 FindNext,
157 FindPrev,
158 Replace,
159 // Navigation
160 Home,
161 Begin,
162 End,
163 Prior,
164 Next,
165 Up,
166 Back,
167 Forward,
168 Reload,
169 // Text Navigation
170 BeginningOfLine,
171 EndOfLine,
172 GotoLine,
173 BackwardWord,
174 ForwardWord,
175 // View parameters
176 AddBookmark,
177 ZoomIn,
178 ZoomOut,
179 FullScreen,
180 ShowMenubar,
181 // Tabular navigation
182 TabNext,
183 TabPrev,
184 // Help menu
185 Help,
186 WhatsThis,
187 // Text completion
188 TextCompletion,
189 PrevCompletion,
190 NextCompletion,
191 SubstringCompletion,
192 RotateUp,
193 RotateDown,
194 OpenRecent,
195 SaveAs,
196 Revert,
197 PrintPreview,
198 Mail,
199 Clear,
200 ActualSize,
201 FitToPage,
202 FitToWidth,
203 FitToHeight,
204 Zoom,
205 Goto,
206 GotoPage,
207 DocumentBack,
208 DocumentForward,
209 EditBookmarks,
210 Spelling,
211 ShowToolbar,
212 ShowStatusbar,
213 KeyBindings,
214 Preferences,
215 ConfigureToolbars,
216 ConfigureNotifications,
217 ReportBug,
218 SwitchApplicationLanguage,
219 AboutApp,
220 AboutKDE,
221 DeleteFile,
222 RenameFile,
223 MoveToTrash,
224 Donate,
225 ShowHideHiddenFiles,
226 CreateFolder,
227 OpenMainMenu,
228 OpenContextMenu,
229 // Insert new items here!
230
231 StandardShortcutCount, // number of standard shortcuts
232};
233
234/*!
235 * Categories in which the standard shortcuts can be classified
236 * \since 5.74
237 * \value InvalidCategory
238 * \value File
239 * \value Edit
240 * \value Navigation
241 * \value View
242 * \value Settings
243 * \value Help
244 */
245enum class Category {
246 InvalidCategory = -1,
247 File,
248 Edit,
249 Navigation,
250 View,
251 Settings,
252 Help,
253};
254
255/*!
256 * Returns the keybinding for \a accel.
257 *
258 * On X11, if QApplication was initialized with GUI disabled, the
259 * default keybinding will always be returned.
260 *
261 * \a id the id of the accelerator
262 */
263KCONFIGGUI_EXPORT const QList<QKeySequence> &shortcut(StandardShortcut id);
264
265/*!
266 * Returns a unique name for the given accel.
267 *
268 * \a id the id of the accelerator
269 */
270KCONFIGGUI_EXPORT QString name(StandardShortcut id);
271
272/*!
273 * Returns a localized label for user-visible display.
274 *
275 * \a id the id of the accelerator
276 */
277KCONFIGGUI_EXPORT QString label(StandardShortcut id);
278
279/*!
280 * Returns an extended WhatsThis description for the given accelerator.
281 *
282 * \a id the id of the accelerator
283 */
284KCONFIGGUI_EXPORT QString whatsThis(StandardShortcut id);
285
286/*!
287 * Return the StandardShortcut id of the standard accel action which
288 * uses this key sequence, or AccelNone if none of them do.
289 *
290 * This is used by class KKeyChooser.
291 *
292 * \a keySeq the key sequence to search
293 */
294KCONFIGGUI_EXPORT StandardShortcut find(const QKeySequence &keySeq);
295
296/*!
297 * Return the StandardShortcut id of the standard accelerator action which
298 * has \a name as its name, or AccelNone if none of them do.
299 *
300 * \a name the name as returned by name(StandardShortcut id)
301 *
302 * \since 5.71
303 */
304KCONFIGGUI_EXPORT StandardShortcut findByName(const QString &name);
305
306/*!
307 * Returns the hardcoded default shortcut for \a id.
308 *
309 * This does not take into account the user's configuration.
310 *
311 * \a id the id of the accelerator
312 */
313KCONFIGGUI_EXPORT QList<QKeySequence> hardcodedDefaultShortcut(StandardShortcut id);
314
315/*!
316 * Saves the new shortcut \a cut for standard accel \a id.
317 */
318KCONFIGGUI_EXPORT void saveShortcut(StandardShortcut id, const QList<QKeySequence> &newShortcut);
319
320/*!
321 * Returns the appropriate category for the given StandardShortcut \a id.
322 * \since 5.73
323 */
324KCONFIGGUI_EXPORT Category category(StandardShortcut id);
325
326/*!
327 * Open file. Default: Ctrl-o
328 *
329 * Returns the shortcut of the standard accelerator
330 */
331KCONFIGGUI_EXPORT const QList<QKeySequence> &open();
332
333/*!
334 * Create a new document (or whatever). Default: Ctrl-n
335 *
336 * Returns the shortcut of the standard accelerator
337 */
338KCONFIGGUI_EXPORT const QList<QKeySequence> &openNew();
339
340/*!
341 * Close current document. Default: Ctrl-w
342 *
343 * Returns the shortcut of the standard accelerator
344 */
345KCONFIGGUI_EXPORT const QList<QKeySequence> &close();
346
347/*!
348 * Save current document. Default: Ctrl-s
349 *
350 * Returns the shortcut of the standard accelerator
351 */
352KCONFIGGUI_EXPORT const QList<QKeySequence> &save();
353
354/*!
355 * Print current document. Default: Ctrl-p
356 *
357 * Returns the shortcut of the standard accelerator
358 */
359KCONFIGGUI_EXPORT const QList<QKeySequence> &print();
360
361/*!
362 * Quit the program. Default: Ctrl-q
363 *
364 * Returns the shortcut of the standard accelerator
365 */
366KCONFIGGUI_EXPORT const QList<QKeySequence> &quit();
367
368/*!
369 * Undo last operation. Default: Ctrl-z
370 *
371 * Returns the shortcut of the standard accelerator
372 */
373KCONFIGGUI_EXPORT const QList<QKeySequence> &undo();
374
375/*!
376 * Redo last operation. Default: Shift-Ctrl-z
377 *
378 * Returns the shortcut of the standard accelerator
379 */
380KCONFIGGUI_EXPORT const QList<QKeySequence> &redo();
381
382/*!
383 * Cut selected area and store it in the clipboard. Default: Ctrl-x
384 *
385 * Returns the shortcut of the standard accelerator
386 */
387KCONFIGGUI_EXPORT const QList<QKeySequence> &cut();
388
389/*!
390 * Copy selected area into the clipboard. Default: Ctrl-c
391 *
392 * Returns the shortcut of the standard accelerator
393 */
394KCONFIGGUI_EXPORT const QList<QKeySequence> &copy();
395
396/*!
397 * Paste contents of clipboard at mouse/cursor position. Default: Ctrl-v
398 *
399 * Returns the shortcut of the standard accelerator
400 */
401KCONFIGGUI_EXPORT const QList<QKeySequence> &paste();
402
403/*!
404 * Paste the selection at mouse/cursor position. Default: Ctrl-Shift-Insert
405 *
406 * Returns the shortcut of the standard accelerator
407 */
408KCONFIGGUI_EXPORT const QList<QKeySequence> &pasteSelection();
409
410/*!
411 * Select all. Default: Ctrl-A
412 *
413 * Returns the shortcut of the standard accelerator
414 **/
415KCONFIGGUI_EXPORT const QList<QKeySequence> &selectAll();
416
417/*!
418 * Delete a word back from mouse/cursor position. Default: Ctrl-Backspace
419 *
420 * Returns the shortcut of the standard accelerator
421 */
422KCONFIGGUI_EXPORT const QList<QKeySequence> &deleteWordBack();
423
424/*!
425 * Delete a word forward from mouse/cursor position. Default: Ctrl-Delete
426 *
427 * Returns the shortcut of the standard accelerator
428 */
429KCONFIGGUI_EXPORT const QList<QKeySequence> &deleteWordForward();
430
431/*!
432 * Initiate a 'find' request in the current document. Default: Ctrl-f
433 *
434 * Returns the shortcut of the standard accelerator
435 */
436KCONFIGGUI_EXPORT const QList<QKeySequence> &find();
437
438/*!
439 * Find the next instance of a stored 'find' Default: F3
440 *
441 * Returns the shortcut of the standard accelerator
442 */
443KCONFIGGUI_EXPORT const QList<QKeySequence> &findNext();
444
445/*!
446 * Find a previous instance of a stored 'find'. Default: Shift-F3
447 *
448 * Returns the shortcut of the standard accelerator
449 */
450KCONFIGGUI_EXPORT const QList<QKeySequence> &findPrev();
451
452/*!
453 * Find and replace matches. Default: Ctrl-r
454 *
455 * Returns the shortcut of the standard accelerator
456 */
457KCONFIGGUI_EXPORT const QList<QKeySequence> &replace();
458
459/*!
460 * Zoom in. Default: Ctrl-Plus
461 *
462 * Returns the shortcut of the standard accelerator
463 */
464KCONFIGGUI_EXPORT const QList<QKeySequence> &zoomIn();
465
466/*!
467 * Zoom out. Default: Ctrl-Minus
468 *
469 * Returns the shortcut of the standard accelerator
470 */
471KCONFIGGUI_EXPORT const QList<QKeySequence> &zoomOut();
472
473/*!
474 * Go to home page. Default: Alt-Home
475 *
476 * Returns the shortcut of the standard accelerator
477 */
478KCONFIGGUI_EXPORT const QList<QKeySequence> &home();
479
480/*!
481 * Go to beginning of the document. Default: Ctrl-Home
482 *
483 * Returns the shortcut of the standard accelerator
484 */
485KCONFIGGUI_EXPORT const QList<QKeySequence> &begin();
486
487/*!
488 * Go to end of the document. Default: Ctrl-End
489 *
490 * Returns the shortcut of the standard accelerator
491 */
492KCONFIGGUI_EXPORT const QList<QKeySequence> &end();
493
494/*!
495 * Go to beginning of current line. Default: Home
496 *
497 * Returns the shortcut of the standard accelerator
498 */
499KCONFIGGUI_EXPORT const QList<QKeySequence> &beginningOfLine();
500
501/*!
502 * Go to end of current line. Default: End
503 *
504 * Returns the shortcut of the standard accelerator
505 */
506KCONFIGGUI_EXPORT const QList<QKeySequence> &endOfLine();
507
508/*!
509 * Scroll up one page. Default: Prior
510 *
511 * Returns the shortcut of the standard accelerator
512 */
513KCONFIGGUI_EXPORT const QList<QKeySequence> &prior();
514
515/*!
516 * Scroll down one page. Default: Next
517 *
518 * Returns the shortcut of the standard accelerator
519 */
520KCONFIGGUI_EXPORT const QList<QKeySequence> &next();
521
522/*!
523 * Go to line. Default: Ctrl+G
524 *
525 * Returns the shortcut of the standard accelerator
526 */
527KCONFIGGUI_EXPORT const QList<QKeySequence> &gotoLine();
528
529/*!
530 * Add current page to bookmarks. Default: Ctrl+B
531 *
532 * Returns the shortcut of the standard accelerator
533 */
534KCONFIGGUI_EXPORT const QList<QKeySequence> &addBookmark();
535
536/*!
537 * Next Tab. Default: Ctrl-<
538 *
539 * Returns the shortcut of the standard accelerator
540 */
541KCONFIGGUI_EXPORT const QList<QKeySequence> &tabNext();
542
543/*!
544 * Previous Tab. Default: Ctrl->
545 *
546 * Returns the shortcut of the standard accelerator
547 */
548KCONFIGGUI_EXPORT const QList<QKeySequence> &tabPrev();
549
550/*!
551 * Full Screen Mode. Default: Ctrl+Shift+F
552 *
553 * Returns the shortcut of the standard accelerator
554 */
555KCONFIGGUI_EXPORT const QList<QKeySequence> &fullScreen();
556
557/*!
558 * Help the user in the current situation. Default: F1
559 *
560 * Returns the shortcut of the standard accelerator
561 */
562KCONFIGGUI_EXPORT const QList<QKeySequence> &help();
563
564/*!
565 * Complete text in input widgets. Default Ctrl+E
566 *
567 * Returns the shortcut of the standard accelerator
568 **/
569KCONFIGGUI_EXPORT const QList<QKeySequence> &completion();
570
571/*!
572 * Iterate through a list when completion returns
573 * multiple items. Default: Ctrl+Up
574 *
575 * Returns the shortcut of the standard accelerator
576 */
577KCONFIGGUI_EXPORT const QList<QKeySequence> &prevCompletion();
578
579/*!
580 * Iterate through a list when completion returns
581 * multiple items. Default: Ctrl+Down
582 *
583 * Returns the shortcut of the standard accelerator
584 */
585KCONFIGGUI_EXPORT const QList<QKeySequence> &nextCompletion();
586
587/*!
588 * Find a string within another string or list of strings.
589 * Default: Ctrl-T
590 *
591 * Returns the shortcut of the standard accelerator
592 */
593KCONFIGGUI_EXPORT const QList<QKeySequence> &substringCompletion();
594
595/*!
596 * Help users iterate through a list of entries. Default: Up
597 *
598 * Returns the shortcut of the standard accelerator
599 */
600KCONFIGGUI_EXPORT const QList<QKeySequence> &rotateUp();
601
602/*!
603 * Help users iterate through a list of entries. Default: Down
604 *
605 * Returns the shortcut of the standard accelerator
606 */
607KCONFIGGUI_EXPORT const QList<QKeySequence> &rotateDown();
608
609/*!
610 * What's This button. Default: Shift+F1
611 *
612 * Returns the shortcut of the standard accelerator
613 */
614KCONFIGGUI_EXPORT const QList<QKeySequence> &whatsThis();
615
616/*!
617 * Reload. Default: F5
618 *
619 * Returns the shortcut of the standard accelerator
620 */
621KCONFIGGUI_EXPORT const QList<QKeySequence> &reload();
622
623/*!
624 * Up. Default: Alt+Up
625 *
626 * Returns the shortcut of the standard accelerator
627 */
628KCONFIGGUI_EXPORT const QList<QKeySequence> &up();
629
630/*!
631 * Back. Default: Alt+Left
632 *
633 * Returns the shortcut of the standard accelerator
634 */
635KCONFIGGUI_EXPORT const QList<QKeySequence> &back();
636
637/*!
638 * Forward. Default: ALT+Right
639 *
640 * Returns the shortcut of the standard accelerator
641 */
642KCONFIGGUI_EXPORT const QList<QKeySequence> &forward();
643
644/*!
645 * BackwardWord. Default: Ctrl+Left
646 *
647 * Returns the shortcut of the standard accelerator
648 */
649KCONFIGGUI_EXPORT const QList<QKeySequence> &backwardWord();
650
651/*!
652 * ForwardWord. Default: Ctrl+Right
653 *
654 * Returns the shortcut of the standard accelerator
655 */
656KCONFIGGUI_EXPORT const QList<QKeySequence> &forwardWord();
657
658/*!
659 * Show Menu Bar. Default: Ctrl-M
660 *
661 * Returns the shortcut of the standard accelerator
662 */
663KCONFIGGUI_EXPORT const QList<QKeySequence> &showMenubar();
664
665/*!
666 * Permanently delete files or folders. Default: Shift+Delete
667 *
668 * Returns the shortcut of the standard accelerator
669 * \since 5.25
670 */
671KCONFIGGUI_EXPORT const QList<QKeySequence> &deleteFile();
672
673/*!
674 * Rename files or folders. Default: F2
675 *
676 * Returns the shortcut of the standard accelerator
677 * \since 5.25
678 */
679KCONFIGGUI_EXPORT const QList<QKeySequence> &renameFile();
680
681/*!
682 * Create a folder. Default: Ctrl+Shift+N
683 *
684 * Returns the shortcut of the standard accelerator
685 * \since 5.74
686 */
687KCONFIGGUI_EXPORT const QList<QKeySequence> &createFolder();
688
689/*!
690 * Moves files or folders to the trash. Default: Delete
691 *
692 * Returns the shortcut of the standard accelerator
693 * \since 5.25
694 */
695KCONFIGGUI_EXPORT const QList<QKeySequence> &moveToTrash();
696
697/*!
698 * Opens the app's settings window. Default: Ctrl+Shift+Comma
699 *
700 * Returns the shortcut of the standard accelerator
701 * \since 5.64
702 */
703KCONFIGGUI_EXPORT const QList<QKeySequence> &preferences();
704
705/*!
706 * Shows or hides hidden files. Defaults: Ctrl+H, Alt+.
707 *
708 * Returns the shortcut of the standard accelerator
709 * \since 5.70
710 */
711KCONFIGGUI_EXPORT const QList<QKeySequence> &showHideHiddenFiles();
712
713/*!
714 * Open a main menu like the menu bar or a hamburger menu.
715 * Necessary for accessibility. Default: F10
716 *
717 * Returns the shortcut of the standard accelerator
718 * \since 6.0
719 */
720KCONFIGGUI_EXPORT const QList<QKeySequence> &openMainMenu();
721
722/*!
723 * Open a context menu for the object with keyboard focus.
724 * Necessary for accessibility. Default: Menu, Shift+F10
725 *
726 * Returns the shortcut of the standard accelerator
727 * \since 6.0
728 */
729KCONFIGGUI_EXPORT const QList<QKeySequence> &openContextMenu();
730}
731
732#endif // KSTANDARDSHORTCUT_H
733

source code of kconfig/src/gui/kstandardshortcut.h