File indexing completed on 2024-05-12 03:54:28
0001 /* 0002 This file is part of the KDE libraries 0003 SPDX-FileCopyrightText: 1997 Stefan Taferner <taferner@kde.org> 0004 SPDX-FileCopyrightText: 2000 Nicolas Hadacek <hadacek@kde.org> 0005 SPDX-FileCopyrightText: 2001, 2002 Ellis Whitehead <ellis@kde.org> 0006 0007 SPDX-License-Identifier: LGPL-2.0-or-later 0008 */ 0009 #ifndef KSTANDARDSHORTCUT_H 0010 #define KSTANDARDSHORTCUT_H 0011 0012 #include <QKeySequence> 0013 #include <QString> 0014 0015 #include <kconfiggui_export.h> 0016 0017 /** 0018 * \namespace KStandardShortcut 0019 * Convenient methods for access to the common accelerator keys in 0020 * the key configuration. These are the standard keybindings that should 0021 * be used in all KDE applications. They will be configurable, 0022 * so do not hardcode the default behavior. 0023 */ 0024 namespace KStandardShortcut 0025 { 0026 // STUFF WILL BREAK IF YOU DON'T READ THIS!!! 0027 /* 0028 *Always add new std-accels to the end of this enum, never in the middle! 0029 *Don't forget to add the corresponding entries in g_infoStandardShortcut[] in kstandardshortcut.cpp, too. 0030 *Values of elements here and positions of the corresponding entries in 0031 *the big array g_infoStandardShortcut[] ABSOLUTELY MUST BE THE SAME. 0032 * !!! !!!! !!!!! !!!! 0033 * !!!! !!! !!!! !!!! 0034 * 0035 * Other Rules: 0036 * 0037 * - Never change the name of an existing shortcut 0038 * - Never translate the name of a shortcut 0039 */ 0040 0041 /** 0042 * Defines the identifier of all standard accelerators. 0043 */ 0044 enum StandardShortcut { 0045 // C++ requires that the value of an enum symbol be one more than the previous one. 0046 // This means that everything will be well-ordered from here on. 0047 AccelNone = 0, 0048 // File menu 0049 Open, ///< Open file. 0050 New, ///< Create a new document. 0051 Close, ///< Close current document. 0052 Save, ///< Save current document. 0053 // The Print item 0054 Print, ///< Print current document. 0055 Quit, ///< Quit the program. 0056 // Edit menu 0057 Undo, ///< Undo last operation. 0058 Redo, ///< Redo last operation. 0059 Cut, ///< Cut selected area and store it in the clipboard. 0060 Copy, ///< Copy selected area into the clipboard. 0061 Paste, ///< Paste contents of clipboard at mouse/cursor position. 0062 PasteSelection, ///< Paste the selection at mouse/cursor position. 0063 SelectAll, ///< Select all. 0064 Deselect, ///< Deselect any selected elements. 0065 DeleteWordBack, ///< Delete a word back from mouse/cursor position. 0066 DeleteWordForward, ///< Delete a word forward from mouse/cursor position. 0067 Find, ///< Initiate a 'find' request in the current document. 0068 FindNext, ///< Find the next instance of a stored 'find'. 0069 FindPrev, ///< Find a previous instance of a stored 'find'. 0070 Replace, ///< Find and replace matches. 0071 // Navigation 0072 Home, ///< Go to home page. 0073 Begin, ///< Go to beginning of the document. 0074 End, ///< Go to end of the document. 0075 Prior, ///< Scroll up one page. 0076 Next, ///< Scroll down one page. 0077 Up, ///< Up. 0078 Back, ///< Back. 0079 Forward, ///< Forward. 0080 Reload, ///< Reload. 0081 // Text Navigation 0082 BeginningOfLine, ///< Go to beginning of current line. 0083 EndOfLine, ///< Go to end of current line. 0084 GotoLine, ///< Go to line. 0085 BackwardWord, ///< BackwardWord. 0086 ForwardWord, ///< ForwardWord. 0087 // View parameters 0088 AddBookmark, ///< Add current page to bookmarks. 0089 ZoomIn, ///< Zoom in. 0090 ZoomOut, ///< Zoom out. 0091 FullScreen, ///< Full Screen mode. 0092 ShowMenubar, ///< Show Menu Bar. 0093 // Tabular navigation 0094 TabNext, ///< Next Tab. 0095 TabPrev, ///< Previous Tab. 0096 // Help menu 0097 Help, ///< Help the user in the current situation. 0098 WhatsThis, ///< What's This button. 0099 // Text completion 0100 TextCompletion, ///< Complete text in input widgets. 0101 PrevCompletion, ///< Iterate through a list when completion returns multiple items. 0102 NextCompletion, ///< Iterate through a list when completion returns multiple items. 0103 SubstringCompletion, ///< Find a string within another string or list of strings. 0104 RotateUp, ///< Help users iterate through a list of entries. 0105 RotateDown, ///< Help users iterate through a list of entries. 0106 OpenRecent, ///< Open a recently used document. 0107 SaveAs, ///< Save the current document under a different name. 0108 Revert, ///< Revert the current document to the last saved version. 0109 PrintPreview, ///< Show a print preview of the current document. 0110 Mail, ///< Send the current document by mail. 0111 Clear, ///< Clear the content of the focus widget. 0112 ActualSize, ///< View the document at its actual size. 0113 FitToPage, ///< Fit the document view to the size of the current window. 0114 FitToWidth, ///< Fit the document view to the width of the current window. 0115 FitToHeight, ///< Fit the document view to the height of the current window. 0116 Zoom, ///< Select the current zoom level. 0117 Goto, ///< Jump to some specific location in the document. 0118 GotoPage, ///< Go to a specific page. 0119 DocumentBack, ///< Move back (document style menu). 0120 DocumentForward, ///< Move forward (document style menu). 0121 EditBookmarks, ///< Edit the application bookmarks. 0122 Spelling, ///< Pop up the spell checker. 0123 ShowToolbar, ///< Show/Hide the toolbar. 0124 ShowStatusbar, ///< Show/Hide the statusbar. 0125 KeyBindings, ///< Display the configure key bindings dialog. 0126 Preferences, ///< Display the preferences/options dialog. 0127 ConfigureToolbars, ///< Display the toolbar configuration dialog. 0128 ConfigureNotifications, ///< Display the notifications configuration dialog. 0129 ReportBug, ///< Display the Report Bug dialog. 0130 SwitchApplicationLanguage, ///< Display the Switch Application Language dialog. 0131 AboutApp, ///< Display the application's About dialog. 0132 AboutKDE, ///< Display the About KDE dialog. 0133 DeleteFile, ///< Permanently delete files or folders. @since 5.25 0134 RenameFile, ///< Rename files or folders. @since 5.25 0135 MoveToTrash, ///< Move files or folders to the trash. @since 5.25 0136 Donate, ///< Open donation page on kde.org. @since 5.26 0137 ShowHideHiddenFiles, ///< Toggle showing or hiding hidden files @since 5.70 0138 CreateFolder, ///< Create a folder. @since 5.74 0139 OpenMainMenu, ///< Open a main menu like the menu bar or a hamburger menu. Necessary for accessibility. @since 6.0 0140 OpenContextMenu, ///< Open a context menu for the object with keyboard focus. Necessary for accessibility. @since 6.0 0141 // Insert new items here! 0142 0143 StandardShortcutCount, // number of standard shortcuts 0144 }; 0145 0146 /** 0147 * Categories in which the standard shortcuts can be classified 0148 * @since 5.74 0149 */ 0150 enum class Category { 0151 InvalidCategory = -1, 0152 File, 0153 Edit, 0154 Navigation, 0155 View, 0156 Settings, 0157 Help, 0158 }; 0159 0160 /** 0161 * Returns the keybinding for @p accel. 0162 * On X11, if QApplication was initialized with GUI disabled, the 0163 * default keybinding will always be returned. 0164 * @param id the id of the accelerator 0165 */ 0166 KCONFIGGUI_EXPORT const QList<QKeySequence> &shortcut(StandardShortcut id); 0167 0168 /** 0169 * Returns a unique name for the given accel. 0170 * @param id the id of the accelerator 0171 * @return the unique name of the accelerator 0172 */ 0173 KCONFIGGUI_EXPORT QString name(StandardShortcut id); 0174 0175 /** 0176 * Returns a localized label for user-visible display. 0177 * @param id the id of the accelerator 0178 * @return a localized label for the accelerator 0179 */ 0180 KCONFIGGUI_EXPORT QString label(StandardShortcut id); 0181 0182 /** 0183 * Returns an extended WhatsThis description for the given accelerator. 0184 * @param id the id of the accelerator 0185 * @return a localized description of the accelerator 0186 */ 0187 KCONFIGGUI_EXPORT QString whatsThis(StandardShortcut id); 0188 0189 /** 0190 * Return the StandardShortcut id of the standard accel action which 0191 * uses this key sequence, or AccelNone if none of them do. 0192 * This is used by class KKeyChooser. 0193 * @param keySeq the key sequence to search 0194 * @return the id of the standard accelerator, or AccelNone if there 0195 * is none 0196 */ 0197 KCONFIGGUI_EXPORT StandardShortcut find(const QKeySequence &keySeq); 0198 0199 /** 0200 * Return the StandardShortcut id of the standard accelerator action which 0201 * has \p name as its name, or AccelNone if none of them do. 0202 * @param name the name as returned by name(StandardShortcut id) 0203 * @return the id of the standard accelerator with the given name or AccelNone 0204 * if there is no such accelerator 0205 * @since 5.71 0206 */ 0207 KCONFIGGUI_EXPORT StandardShortcut findByName(const QString &name); 0208 0209 /** 0210 * Returns the hardcoded default shortcut for @p id. 0211 * This does not take into account the user's configuration. 0212 * @param id the id of the accelerator 0213 * @return the default shortcut of the accelerator 0214 */ 0215 KCONFIGGUI_EXPORT QList<QKeySequence> hardcodedDefaultShortcut(StandardShortcut id); 0216 0217 /** 0218 * Saves the new shortcut \a cut for standard accel \a id. 0219 */ 0220 KCONFIGGUI_EXPORT void saveShortcut(StandardShortcut id, const QList<QKeySequence> &newShortcut); 0221 0222 /** 0223 * Returns the appropriate category for the given StandardShortcut \p id. 0224 * @since 5.73 0225 */ 0226 KCONFIGGUI_EXPORT Category category(StandardShortcut id); 0227 0228 /** 0229 * Open file. Default: Ctrl-o 0230 * @return the shortcut of the standard accelerator 0231 */ 0232 KCONFIGGUI_EXPORT const QList<QKeySequence> &open(); 0233 0234 /** 0235 * Create a new document (or whatever). Default: Ctrl-n 0236 * @return the shortcut of the standard accelerator 0237 */ 0238 KCONFIGGUI_EXPORT const QList<QKeySequence> &openNew(); 0239 0240 /** 0241 * Close current document. Default: Ctrl-w 0242 * @return the shortcut of the standard accelerator 0243 */ 0244 KCONFIGGUI_EXPORT const QList<QKeySequence> &close(); 0245 0246 /** 0247 * Save current document. Default: Ctrl-s 0248 * @return the shortcut of the standard accelerator 0249 */ 0250 KCONFIGGUI_EXPORT const QList<QKeySequence> &save(); 0251 0252 /** 0253 * Print current document. Default: Ctrl-p 0254 * @return the shortcut of the standard accelerator 0255 */ 0256 KCONFIGGUI_EXPORT const QList<QKeySequence> &print(); 0257 0258 /** 0259 * Quit the program. Default: Ctrl-q 0260 * @return the shortcut of the standard accelerator 0261 */ 0262 KCONFIGGUI_EXPORT const QList<QKeySequence> &quit(); 0263 0264 /** 0265 * Undo last operation. Default: Ctrl-z 0266 * @return the shortcut of the standard accelerator 0267 */ 0268 KCONFIGGUI_EXPORT const QList<QKeySequence> &undo(); 0269 0270 /** 0271 * Redo last operation. Default: Shift-Ctrl-z 0272 * @return the shortcut of the standard accelerator 0273 */ 0274 KCONFIGGUI_EXPORT const QList<QKeySequence> &redo(); 0275 0276 /** 0277 * Cut selected area and store it in the clipboard. Default: Ctrl-x 0278 * @return the shortcut of the standard accelerator 0279 */ 0280 KCONFIGGUI_EXPORT const QList<QKeySequence> &cut(); 0281 0282 /** 0283 * Copy selected area into the clipboard. Default: Ctrl-c 0284 * @return the shortcut of the standard accelerator 0285 */ 0286 KCONFIGGUI_EXPORT const QList<QKeySequence> ©(); 0287 0288 /** 0289 * Paste contents of clipboard at mouse/cursor position. Default: Ctrl-v 0290 * @return the shortcut of the standard accelerator 0291 */ 0292 KCONFIGGUI_EXPORT const QList<QKeySequence> &paste(); 0293 0294 /** 0295 * Paste the selection at mouse/cursor position. Default: Ctrl-Shift-Insert 0296 * @return the shortcut of the standard accelerator 0297 */ 0298 KCONFIGGUI_EXPORT const QList<QKeySequence> &pasteSelection(); 0299 0300 /** 0301 * Select all. Default: Ctrl-A 0302 * @return the shortcut of the standard accelerator 0303 **/ 0304 KCONFIGGUI_EXPORT const QList<QKeySequence> &selectAll(); 0305 0306 /** 0307 * Delete a word back from mouse/cursor position. Default: Ctrl-Backspace 0308 * @return the shortcut of the standard accelerator 0309 */ 0310 KCONFIGGUI_EXPORT const QList<QKeySequence> &deleteWordBack(); 0311 0312 /** 0313 * Delete a word forward from mouse/cursor position. Default: Ctrl-Delete 0314 * @return the shortcut of the standard accelerator 0315 */ 0316 KCONFIGGUI_EXPORT const QList<QKeySequence> &deleteWordForward(); 0317 0318 /** 0319 * Initiate a 'find' request in the current document. Default: Ctrl-f 0320 * @return the shortcut of the standard accelerator 0321 */ 0322 KCONFIGGUI_EXPORT const QList<QKeySequence> &find(); 0323 0324 /** 0325 * Find the next instance of a stored 'find' Default: F3 0326 * @return the shortcut of the standard accelerator 0327 */ 0328 KCONFIGGUI_EXPORT const QList<QKeySequence> &findNext(); 0329 0330 /** 0331 * Find a previous instance of a stored 'find'. Default: Shift-F3 0332 * @return the shortcut of the standard accelerator 0333 */ 0334 KCONFIGGUI_EXPORT const QList<QKeySequence> &findPrev(); 0335 0336 /** 0337 * Find and replace matches. Default: Ctrl-r 0338 * @return the shortcut of the standard accelerator 0339 */ 0340 KCONFIGGUI_EXPORT const QList<QKeySequence> &replace(); 0341 0342 /** 0343 * Zoom in. Default: Ctrl-Plus 0344 * @return the shortcut of the standard accelerator 0345 */ 0346 KCONFIGGUI_EXPORT const QList<QKeySequence> &zoomIn(); 0347 0348 /** 0349 * Zoom out. Default: Ctrl-Minus 0350 * @return the shortcut of the standard accelerator 0351 */ 0352 KCONFIGGUI_EXPORT const QList<QKeySequence> &zoomOut(); 0353 0354 /** 0355 * Go to home page. Default: Alt-Home 0356 * @return the shortcut of the standard accelerator 0357 */ 0358 KCONFIGGUI_EXPORT const QList<QKeySequence> &home(); 0359 0360 /** 0361 * Go to beginning of the document. Default: Ctrl-Home 0362 * @return the shortcut of the standard accelerator 0363 */ 0364 KCONFIGGUI_EXPORT const QList<QKeySequence> &begin(); 0365 0366 /** 0367 * Go to end of the document. Default: Ctrl-End 0368 * @return the shortcut of the standard accelerator 0369 */ 0370 KCONFIGGUI_EXPORT const QList<QKeySequence> &end(); 0371 0372 /** 0373 * Go to beginning of current line. Default: Home 0374 * @return the shortcut of the standard accelerator 0375 */ 0376 KCONFIGGUI_EXPORT const QList<QKeySequence> &beginningOfLine(); 0377 0378 /** 0379 * Go to end of current line. Default: End 0380 * @return the shortcut of the standard accelerator 0381 */ 0382 KCONFIGGUI_EXPORT const QList<QKeySequence> &endOfLine(); 0383 0384 /** 0385 * Scroll up one page. Default: Prior 0386 * @return the shortcut of the standard accelerator 0387 */ 0388 KCONFIGGUI_EXPORT const QList<QKeySequence> &prior(); 0389 0390 /** 0391 * Scroll down one page. Default: Next 0392 * @return the shortcut of the standard accelerator 0393 */ 0394 KCONFIGGUI_EXPORT const QList<QKeySequence> &next(); 0395 0396 /** 0397 * Go to line. Default: Ctrl+G 0398 * @return the shortcut of the standard accelerator 0399 */ 0400 KCONFIGGUI_EXPORT const QList<QKeySequence> &gotoLine(); 0401 0402 /** 0403 * Add current page to bookmarks. Default: Ctrl+B 0404 * @return the shortcut of the standard accelerator 0405 */ 0406 KCONFIGGUI_EXPORT const QList<QKeySequence> &addBookmark(); 0407 0408 /** 0409 * Next Tab. Default: Ctrl-< 0410 * @return the shortcut of the standard accelerator 0411 */ 0412 KCONFIGGUI_EXPORT const QList<QKeySequence> &tabNext(); 0413 0414 /** 0415 * Previous Tab. Default: Ctrl-> 0416 * @return the shortcut of the standard accelerator 0417 */ 0418 KCONFIGGUI_EXPORT const QList<QKeySequence> &tabPrev(); 0419 0420 /** 0421 * Full Screen Mode. Default: Ctrl+Shift+F 0422 * @return the shortcut of the standard accelerator 0423 */ 0424 KCONFIGGUI_EXPORT const QList<QKeySequence> &fullScreen(); 0425 0426 /** 0427 * Help the user in the current situation. Default: F1 0428 * @return the shortcut of the standard accelerator 0429 */ 0430 KCONFIGGUI_EXPORT const QList<QKeySequence> &help(); 0431 0432 /** 0433 * Complete text in input widgets. Default Ctrl+E 0434 * @return the shortcut of the standard accelerator 0435 **/ 0436 KCONFIGGUI_EXPORT const QList<QKeySequence> &completion(); 0437 0438 /** 0439 * Iterate through a list when completion returns 0440 * multiple items. Default: Ctrl+Up 0441 * @return the shortcut of the standard accelerator 0442 */ 0443 KCONFIGGUI_EXPORT const QList<QKeySequence> &prevCompletion(); 0444 0445 /** 0446 * Iterate through a list when completion returns 0447 * multiple items. Default: Ctrl+Down 0448 * @return the shortcut of the standard accelerator 0449 */ 0450 KCONFIGGUI_EXPORT const QList<QKeySequence> &nextCompletion(); 0451 0452 /** 0453 * Find a string within another string or list of strings. 0454 * Default: Ctrl-T 0455 * @return the shortcut of the standard accelerator 0456 */ 0457 KCONFIGGUI_EXPORT const QList<QKeySequence> &substringCompletion(); 0458 0459 /** 0460 * Help users iterate through a list of entries. Default: Up 0461 * @return the shortcut of the standard accelerator 0462 */ 0463 KCONFIGGUI_EXPORT const QList<QKeySequence> &rotateUp(); 0464 0465 /** 0466 * Help users iterate through a list of entries. Default: Down 0467 * @return the shortcut of the standard accelerator 0468 */ 0469 KCONFIGGUI_EXPORT const QList<QKeySequence> &rotateDown(); 0470 0471 /** 0472 * What's This button. Default: Shift+F1 0473 * @return the shortcut of the standard accelerator 0474 */ 0475 KCONFIGGUI_EXPORT const QList<QKeySequence> &whatsThis(); 0476 0477 /** 0478 * Reload. Default: F5 0479 * @return the shortcut of the standard accelerator 0480 */ 0481 KCONFIGGUI_EXPORT const QList<QKeySequence> &reload(); 0482 0483 /** 0484 * Up. Default: Alt+Up 0485 * @return the shortcut of the standard accelerator 0486 */ 0487 KCONFIGGUI_EXPORT const QList<QKeySequence> &up(); 0488 0489 /** 0490 * Back. Default: Alt+Left 0491 * @return the shortcut of the standard accelerator 0492 */ 0493 KCONFIGGUI_EXPORT const QList<QKeySequence> &back(); 0494 0495 /** 0496 * Forward. Default: ALT+Right 0497 * @return the shortcut of the standard accelerator 0498 */ 0499 KCONFIGGUI_EXPORT const QList<QKeySequence> &forward(); 0500 0501 /** 0502 * BackwardWord. Default: Ctrl+Left 0503 * @return the shortcut of the standard accelerator 0504 */ 0505 KCONFIGGUI_EXPORT const QList<QKeySequence> &backwardWord(); 0506 0507 /** 0508 * ForwardWord. Default: Ctrl+Right 0509 * @return the shortcut of the standard accelerator 0510 */ 0511 KCONFIGGUI_EXPORT const QList<QKeySequence> &forwardWord(); 0512 0513 /** 0514 * Show Menu Bar. Default: Ctrl-M 0515 * @return the shortcut of the standard accelerator 0516 */ 0517 KCONFIGGUI_EXPORT const QList<QKeySequence> &showMenubar(); 0518 0519 /** 0520 * Permanently delete files or folders. Default: Shift+Delete 0521 * @return the shortcut of the standard accelerator 0522 * @since 5.25 0523 */ 0524 KCONFIGGUI_EXPORT const QList<QKeySequence> &deleteFile(); 0525 0526 /** 0527 * Rename files or folders. Default: F2 0528 * @return the shortcut of the standard accelerator 0529 * @since 5.25 0530 */ 0531 KCONFIGGUI_EXPORT const QList<QKeySequence> &renameFile(); 0532 0533 /** 0534 * Create a folder. Default: Ctrl+Shift+N 0535 * @return the shortcut of the standard accelerator 0536 * @since 5.74 0537 */ 0538 KCONFIGGUI_EXPORT const QList<QKeySequence> &createFolder(); 0539 0540 /** 0541 * Moves files or folders to the trash. Default: Delete 0542 * @return the shortcut of the standard accelerator 0543 * @since 5.25 0544 */ 0545 KCONFIGGUI_EXPORT const QList<QKeySequence> &moveToTrash(); 0546 0547 /** 0548 * Opens the app's settings window. Default: Ctrl+Shift+Comma 0549 * @return the shortcut of the standard accelerator 0550 * @since 5.64 0551 */ 0552 KCONFIGGUI_EXPORT const QList<QKeySequence> &preferences(); 0553 0554 /** 0555 * Shows or hides hidden files. Defaults: Ctrl+H, Alt+. 0556 * @return the shortcut of the standard accelerator 0557 * @since 5.70 0558 */ 0559 KCONFIGGUI_EXPORT const QList<QKeySequence> &showHideHiddenFiles(); 0560 0561 /** 0562 * Open a main menu like the menu bar or a hamburger menu. 0563 * Necessary for accessibility. Default: F10 0564 * @return the shortcut of the standard accelerator 0565 * @since 6.0 0566 */ 0567 KCONFIGGUI_EXPORT const QList<QKeySequence> &openMainMenu(); 0568 0569 /** 0570 * Open a context menu for the object with keyboard focus. 0571 * Necessary for accessibility. Default: Menu, Shift+F10 0572 * @return the shortcut of the standard accelerator 0573 * @since 6.0 0574 */ 0575 KCONFIGGUI_EXPORT const QList<QKeySequence> &openContextMenu(); 0576 } 0577 0578 #endif // KSTANDARDSHORTCUT_H