File indexing completed on 2024-05-12 15:34:14
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 #if KCONFIGGUI_ENABLE_DEPRECATED_SINCE(5, 39) 0126 SaveOptions ///< @deprecated since 5.39 0127 KCONFIGGUI_ENUMERATOR_DEPRECATED_VERSION_BELATED(5, 82, 5, 39, "No known users"), 0128 #else 0129 SaveOptions_DEPRECATED_DO_NOT_USE, 0130 #endif 0131 KeyBindings, ///< Display the configure key bindings dialog. 0132 Preferences, ///< Display the preferences/options dialog. 0133 ConfigureToolbars, ///< Display the toolbar configuration dialog. 0134 ConfigureNotifications, ///< Display the notifications configuration dialog. 0135 TipofDay, ///< Display the "Tip of the Day". 0136 ReportBug, ///< Display the Report Bug dialog. 0137 SwitchApplicationLanguage, ///< Display the Switch Application Language dialog. 0138 AboutApp, ///< Display the application's About dialog. 0139 AboutKDE, ///< Display the About KDE dialog. 0140 DeleteFile, ///< Permanently delete files or folders. @since 5.25 0141 RenameFile, ///< Rename files or folders. @since 5.25 0142 MoveToTrash, ///< Move files or folders to the trash. @since 5.25 0143 Donate, ///< Open donation page on kde.org. @since 5.26 0144 ShowHideHiddenFiles, ///< Toggle showing or hiding hidden files @since 5.70 0145 CreateFolder, ///< Create a folder. @since 5.74 0146 // Insert new items here! 0147 0148 StandardShortcutCount, // number of standard shortcuts 0149 }; 0150 0151 /** 0152 * Categories in which the standard shortcuts can be classified 0153 * @since 5.74 0154 */ 0155 enum class Category { 0156 InvalidCategory = -1, 0157 File, 0158 Edit, 0159 Navigation, 0160 View, 0161 Settings, 0162 Help, 0163 }; 0164 0165 /** 0166 * Returns the keybinding for @p accel. 0167 * On X11, if QApplication was initialized with GUI disabled, the 0168 * default keybinding will always be returned. 0169 * @param id the id of the accelerator 0170 */ 0171 KCONFIGGUI_EXPORT const QList<QKeySequence> &shortcut(StandardShortcut id); 0172 0173 /** 0174 * Returns a unique name for the given accel. 0175 * @param id the id of the accelerator 0176 * @return the unique name of the accelerator 0177 */ 0178 KCONFIGGUI_EXPORT QString name(StandardShortcut id); 0179 0180 /** 0181 * Returns a localized label for user-visible display. 0182 * @param id the id of the accelerator 0183 * @return a localized label for the accelerator 0184 */ 0185 KCONFIGGUI_EXPORT QString label(StandardShortcut id); 0186 0187 /** 0188 * Returns an extended WhatsThis description for the given accelerator. 0189 * @param id the id of the accelerator 0190 * @return a localized description of the accelerator 0191 */ 0192 KCONFIGGUI_EXPORT QString whatsThis(StandardShortcut id); 0193 0194 /** 0195 * Return the StandardShortcut id of the standard accel action which 0196 * uses this key sequence, or AccelNone if none of them do. 0197 * This is used by class KKeyChooser. 0198 * @param keySeq the key sequence to search 0199 * @return the id of the standard accelerator, or AccelNone if there 0200 * is none 0201 */ 0202 KCONFIGGUI_EXPORT StandardShortcut find(const QKeySequence &keySeq); 0203 0204 #if KCONFIGGUI_ENABLE_DEPRECATED_SINCE(5, 71) 0205 /** 0206 * Return the StandardShortcut id of the standard accel action which 0207 * has \a keyName as its name, or AccelNone if none of them do. 0208 * This is used by class KKeyChooser. 0209 * @param keyName the key sequence to search 0210 * @return the id of the standard accelerator, or AccelNone if there 0211 * is none 0212 * @deprecated since 5.71, use findByName(const QString &name) instead 0213 */ 0214 KCONFIGGUI_EXPORT 0215 KCONFIGGUI_DEPRECATED_VERSION(5, 71, "Use findByName(const QString &name) instead") 0216 StandardShortcut find(const char *keyName); 0217 #endif 0218 0219 /** 0220 * Return the StandardShortcut id of the standard accelerator action which 0221 * has \p name as its name, or AccelNone if none of them do. 0222 * @param name the name as returned by name(StandardShortcut id) 0223 * @return the id of the standard accelerator with the given name or AccelNone 0224 * if there is no such accelerator 0225 * @since 5.71 0226 */ 0227 KCONFIGGUI_EXPORT StandardShortcut findByName(const QString &name); 0228 0229 /** 0230 * Returns the hardcoded default shortcut for @p id. 0231 * This does not take into account the user's configuration. 0232 * @param id the id of the accelerator 0233 * @return the default shortcut of the accelerator 0234 */ 0235 KCONFIGGUI_EXPORT QList<QKeySequence> hardcodedDefaultShortcut(StandardShortcut id); 0236 0237 /** 0238 * Saves the new shortcut \a cut for standard accel \a id. 0239 */ 0240 KCONFIGGUI_EXPORT void saveShortcut(StandardShortcut id, const QList<QKeySequence> &newShortcut); 0241 0242 /** 0243 * Returns the appropriate category for the given StandardShortcut \p id. 0244 * @since 5.73 0245 */ 0246 KCONFIGGUI_EXPORT Category category(StandardShortcut id); 0247 0248 /** 0249 * Open file. Default: Ctrl-o 0250 * @return the shortcut of the standard accelerator 0251 */ 0252 KCONFIGGUI_EXPORT const QList<QKeySequence> &open(); 0253 0254 /** 0255 * Create a new document (or whatever). Default: Ctrl-n 0256 * @return the shortcut of the standard accelerator 0257 */ 0258 KCONFIGGUI_EXPORT const QList<QKeySequence> &openNew(); 0259 0260 /** 0261 * Close current document. Default: Ctrl-w 0262 * @return the shortcut of the standard accelerator 0263 */ 0264 KCONFIGGUI_EXPORT const QList<QKeySequence> &close(); 0265 0266 /** 0267 * Save current document. Default: Ctrl-s 0268 * @return the shortcut of the standard accelerator 0269 */ 0270 KCONFIGGUI_EXPORT const QList<QKeySequence> &save(); 0271 0272 /** 0273 * Print current document. Default: Ctrl-p 0274 * @return the shortcut of the standard accelerator 0275 */ 0276 KCONFIGGUI_EXPORT const QList<QKeySequence> &print(); 0277 0278 /** 0279 * Quit the program. Default: Ctrl-q 0280 * @return the shortcut of the standard accelerator 0281 */ 0282 KCONFIGGUI_EXPORT const QList<QKeySequence> &quit(); 0283 0284 /** 0285 * Undo last operation. Default: Ctrl-z 0286 * @return the shortcut of the standard accelerator 0287 */ 0288 KCONFIGGUI_EXPORT const QList<QKeySequence> &undo(); 0289 0290 /** 0291 * Redo last operation. Default: Shift-Ctrl-z 0292 * @return the shortcut of the standard accelerator 0293 */ 0294 KCONFIGGUI_EXPORT const QList<QKeySequence> &redo(); 0295 0296 /** 0297 * Cut selected area and store it in the clipboard. Default: Ctrl-x 0298 * @return the shortcut of the standard accelerator 0299 */ 0300 KCONFIGGUI_EXPORT const QList<QKeySequence> &cut(); 0301 0302 /** 0303 * Copy selected area into the clipboard. Default: Ctrl-c 0304 * @return the shortcut of the standard accelerator 0305 */ 0306 KCONFIGGUI_EXPORT const QList<QKeySequence> ©(); 0307 0308 /** 0309 * Paste contents of clipboard at mouse/cursor position. Default: Ctrl-v 0310 * @return the shortcut of the standard accelerator 0311 */ 0312 KCONFIGGUI_EXPORT const QList<QKeySequence> &paste(); 0313 0314 /** 0315 * Paste the selection at mouse/cursor position. Default: Ctrl-Shift-Insert 0316 * @return the shortcut of the standard accelerator 0317 */ 0318 KCONFIGGUI_EXPORT const QList<QKeySequence> &pasteSelection(); 0319 0320 /** 0321 * Select all. Default: Ctrl-A 0322 * @return the shortcut of the standard accelerator 0323 **/ 0324 KCONFIGGUI_EXPORT const QList<QKeySequence> &selectAll(); 0325 0326 /** 0327 * Delete a word back from mouse/cursor position. Default: Ctrl-Backspace 0328 * @return the shortcut of the standard accelerator 0329 */ 0330 KCONFIGGUI_EXPORT const QList<QKeySequence> &deleteWordBack(); 0331 0332 /** 0333 * Delete a word forward from mouse/cursor position. Default: Ctrl-Delete 0334 * @return the shortcut of the standard accelerator 0335 */ 0336 KCONFIGGUI_EXPORT const QList<QKeySequence> &deleteWordForward(); 0337 0338 /** 0339 * Initiate a 'find' request in the current document. Default: Ctrl-f 0340 * @return the shortcut of the standard accelerator 0341 */ 0342 KCONFIGGUI_EXPORT const QList<QKeySequence> &find(); 0343 0344 /** 0345 * Find the next instance of a stored 'find' Default: F3 0346 * @return the shortcut of the standard accelerator 0347 */ 0348 KCONFIGGUI_EXPORT const QList<QKeySequence> &findNext(); 0349 0350 /** 0351 * Find a previous instance of a stored 'find'. Default: Shift-F3 0352 * @return the shortcut of the standard accelerator 0353 */ 0354 KCONFIGGUI_EXPORT const QList<QKeySequence> &findPrev(); 0355 0356 /** 0357 * Find and replace matches. Default: Ctrl-r 0358 * @return the shortcut of the standard accelerator 0359 */ 0360 KCONFIGGUI_EXPORT const QList<QKeySequence> &replace(); 0361 0362 /** 0363 * Zoom in. Default: Ctrl-Plus 0364 * @return the shortcut of the standard accelerator 0365 */ 0366 KCONFIGGUI_EXPORT const QList<QKeySequence> &zoomIn(); 0367 0368 /** 0369 * Zoom out. Default: Ctrl-Minus 0370 * @return the shortcut of the standard accelerator 0371 */ 0372 KCONFIGGUI_EXPORT const QList<QKeySequence> &zoomOut(); 0373 0374 /** 0375 * Go to home page. Default: Alt-Home 0376 * @return the shortcut of the standard accelerator 0377 */ 0378 KCONFIGGUI_EXPORT const QList<QKeySequence> &home(); 0379 0380 /** 0381 * Go to beginning of the document. Default: Ctrl-Home 0382 * @return the shortcut of the standard accelerator 0383 */ 0384 KCONFIGGUI_EXPORT const QList<QKeySequence> &begin(); 0385 0386 /** 0387 * Go to end of the document. Default: Ctrl-End 0388 * @return the shortcut of the standard accelerator 0389 */ 0390 KCONFIGGUI_EXPORT const QList<QKeySequence> &end(); 0391 0392 /** 0393 * Go to beginning of current line. Default: Home 0394 * @return the shortcut of the standard accelerator 0395 */ 0396 KCONFIGGUI_EXPORT const QList<QKeySequence> &beginningOfLine(); 0397 0398 /** 0399 * Go to end of current line. Default: End 0400 * @return the shortcut of the standard accelerator 0401 */ 0402 KCONFIGGUI_EXPORT const QList<QKeySequence> &endOfLine(); 0403 0404 /** 0405 * Scroll up one page. Default: Prior 0406 * @return the shortcut of the standard accelerator 0407 */ 0408 KCONFIGGUI_EXPORT const QList<QKeySequence> &prior(); 0409 0410 /** 0411 * Scroll down one page. Default: Next 0412 * @return the shortcut of the standard accelerator 0413 */ 0414 KCONFIGGUI_EXPORT const QList<QKeySequence> &next(); 0415 0416 /** 0417 * Go to line. Default: Ctrl+G 0418 * @return the shortcut of the standard accelerator 0419 */ 0420 KCONFIGGUI_EXPORT const QList<QKeySequence> &gotoLine(); 0421 0422 /** 0423 * Add current page to bookmarks. Default: Ctrl+B 0424 * @return the shortcut of the standard accelerator 0425 */ 0426 KCONFIGGUI_EXPORT const QList<QKeySequence> &addBookmark(); 0427 0428 /** 0429 * Next Tab. Default: Ctrl-< 0430 * @return the shortcut of the standard accelerator 0431 */ 0432 KCONFIGGUI_EXPORT const QList<QKeySequence> &tabNext(); 0433 0434 /** 0435 * Previous Tab. Default: Ctrl-> 0436 * @return the shortcut of the standard accelerator 0437 */ 0438 KCONFIGGUI_EXPORT const QList<QKeySequence> &tabPrev(); 0439 0440 /** 0441 * Full Screen Mode. Default: Ctrl+Shift+F 0442 * @return the shortcut of the standard accelerator 0443 */ 0444 KCONFIGGUI_EXPORT const QList<QKeySequence> &fullScreen(); 0445 0446 /** 0447 * Help the user in the current situation. Default: F1 0448 * @return the shortcut of the standard accelerator 0449 */ 0450 KCONFIGGUI_EXPORT const QList<QKeySequence> &help(); 0451 0452 /** 0453 * Complete text in input widgets. Default Ctrl+E 0454 * @return the shortcut of the standard accelerator 0455 **/ 0456 KCONFIGGUI_EXPORT const QList<QKeySequence> &completion(); 0457 0458 /** 0459 * Iterate through a list when completion returns 0460 * multiple items. Default: Ctrl+Up 0461 * @return the shortcut of the standard accelerator 0462 */ 0463 KCONFIGGUI_EXPORT const QList<QKeySequence> &prevCompletion(); 0464 0465 /** 0466 * Iterate through a list when completion returns 0467 * multiple items. Default: Ctrl+Down 0468 * @return the shortcut of the standard accelerator 0469 */ 0470 KCONFIGGUI_EXPORT const QList<QKeySequence> &nextCompletion(); 0471 0472 /** 0473 * Find a string within another string or list of strings. 0474 * Default: Ctrl-T 0475 * @return the shortcut of the standard accelerator 0476 */ 0477 KCONFIGGUI_EXPORT const QList<QKeySequence> &substringCompletion(); 0478 0479 /** 0480 * Help users iterate through a list of entries. Default: Up 0481 * @return the shortcut of the standard accelerator 0482 */ 0483 KCONFIGGUI_EXPORT const QList<QKeySequence> &rotateUp(); 0484 0485 /** 0486 * Help users iterate through a list of entries. Default: Down 0487 * @return the shortcut of the standard accelerator 0488 */ 0489 KCONFIGGUI_EXPORT const QList<QKeySequence> &rotateDown(); 0490 0491 /** 0492 * What's This button. Default: Shift+F1 0493 * @return the shortcut of the standard accelerator 0494 */ 0495 KCONFIGGUI_EXPORT const QList<QKeySequence> &whatsThis(); 0496 0497 /** 0498 * Reload. Default: F5 0499 * @return the shortcut of the standard accelerator 0500 */ 0501 KCONFIGGUI_EXPORT const QList<QKeySequence> &reload(); 0502 0503 /** 0504 * Up. Default: Alt+Up 0505 * @return the shortcut of the standard accelerator 0506 */ 0507 KCONFIGGUI_EXPORT const QList<QKeySequence> &up(); 0508 0509 /** 0510 * Back. Default: Alt+Left 0511 * @return the shortcut of the standard accelerator 0512 */ 0513 KCONFIGGUI_EXPORT const QList<QKeySequence> &back(); 0514 0515 /** 0516 * Forward. Default: ALT+Right 0517 * @return the shortcut of the standard accelerator 0518 */ 0519 KCONFIGGUI_EXPORT const QList<QKeySequence> &forward(); 0520 0521 /** 0522 * BackwardWord. Default: Ctrl+Left 0523 * @return the shortcut of the standard accelerator 0524 */ 0525 KCONFIGGUI_EXPORT const QList<QKeySequence> &backwardWord(); 0526 0527 /** 0528 * ForwardWord. Default: Ctrl+Right 0529 * @return the shortcut of the standard accelerator 0530 */ 0531 KCONFIGGUI_EXPORT const QList<QKeySequence> &forwardWord(); 0532 0533 /** 0534 * Show Menu Bar. Default: Ctrl-M 0535 * @return the shortcut of the standard accelerator 0536 */ 0537 KCONFIGGUI_EXPORT const QList<QKeySequence> &showMenubar(); 0538 0539 /** 0540 * Permanently delete files or folders. Default: Shift+Delete 0541 * @return the shortcut of the standard accelerator 0542 * @since 5.25 0543 */ 0544 KCONFIGGUI_EXPORT const QList<QKeySequence> &deleteFile(); 0545 0546 /** 0547 * Rename files or folders. Default: F2 0548 * @return the shortcut of the standard accelerator 0549 * @since 5.25 0550 */ 0551 KCONFIGGUI_EXPORT const QList<QKeySequence> &renameFile(); 0552 0553 /** 0554 * Create a folder. Default: F10 0555 * @return the shortcut of the standard accelerator 0556 * @since 5.74 0557 */ 0558 KCONFIGGUI_EXPORT const QList<QKeySequence> &createFolder(); 0559 0560 /** 0561 * Moves files or folders to the trash. Default: Delete 0562 * @return the shortcut of the standard accelerator 0563 * @since 5.25 0564 */ 0565 KCONFIGGUI_EXPORT const QList<QKeySequence> &moveToTrash(); 0566 0567 /** 0568 * Opens the app's settings window. Default: Ctrl+Shift+Comma 0569 * @return the shortcut of the standard accelerator 0570 * @since 5.64 0571 */ 0572 KCONFIGGUI_EXPORT const QList<QKeySequence> &preferences(); 0573 0574 /** 0575 * Shows or hides hidden files. Defaults: Ctrl+H, Alt+. 0576 * @return the shortcut of the standard accelerator 0577 * @since 5.70 0578 */ 0579 KCONFIGGUI_EXPORT const QList<QKeySequence> &showHideHiddenFiles(); 0580 0581 } 0582 0583 #endif // KSTANDARDSHORTCUT_H