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

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