kstandardshortcut.h 18 KB
Newer Older
1 2 3 4 5
/*
    This file is part of the KDE libraries
    SPDX-FileCopyrightText: 1997 Stefan Taferner <taferner@kde.org>
    SPDX-FileCopyrightText: 2000 Nicolas Hadacek <hadacek@kde.org>
    SPDX-FileCopyrightText: 2001, 2002 Ellis Whitehead <ellis@kde.org>
6

7
    SPDX-License-Identifier: LGPL-2.0-only
8 9 10 11
*/
#ifndef KSTANDARDSHORTCUT_H
#define KSTANDARDSHORTCUT_H

12
#include <QString>
13 14 15 16 17 18 19 20 21 22 23 24
#include <QKeySequence>

#include <kconfiggui_export.h>

/**
 * \namespace KStandardShortcut
 * Convenient methods for access to the common accelerator keys in
 * the key configuration. These are the standard keybindings that should
 * be used in all KDE applications. They will be configurable,
 * so do not hardcode the default behavior.
 */
namespace KStandardShortcut
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
{
// STUFF WILL BREAK IF YOU DON'T READ THIS!!!
/*
 *Always add new std-accels to the end of this enum, never in the middle!
 *Don't forget to add the corresponding entries in g_infoStandardShortcut[] in kstandardshortcut.cpp, too.
 *Values of elements here and positions of the corresponding entries in
 *the big array g_infoStandardShortcut[] ABSOLUTELY MUST BE THE SAME.
 * !!!    !!!!   !!!!!    !!!!
 *    !!!!    !!!     !!!!    !!!!
 * Remember to also update kdoctools/genshortcutents.cpp.
 *
 * Other Rules:
 *
 * - Never change the name of an existing shortcut
 * - Never translate the name of a shortcut
 */

/**
 * Defines the identifier of all standard accelerators.
 */
enum StandardShortcut {
46
    //C++ requires that the value of an enum symbol be one more than the previous one.
47 48
    //This means that everything will be well-ordered from here on.
    AccelNone = 0,
49
    // File menu
50 51 52 53
    Open, ///< Open file.
    New, ///< Create a new document.
    Close, ///< Close current document.
    Save, ///< Save current document.
54
    // The Print item
55 56
    Print, ///< Print current document.
    Quit, ///< Quit the program.
57
    // Edit menu
58 59 60 61 62 63 64 65 66 67 68 69 70 71
    Undo, ///< Undo last operation.
    Redo, ///< Redo last operation.
    Cut, ///< Cut selected area and store it in the clipboard.
    Copy, ///< Copy selected area into the clipboard.
    Paste, ///< Paste contents of clipboard at mouse/cursor position.
    PasteSelection, ///< Paste the selection at mouse/cursor position.
    SelectAll, ///< Select all.
    Deselect, ///< Deselect any selected elements.
    DeleteWordBack, ///< Delete a word back from mouse/cursor position.
    DeleteWordForward, ///< Delete a word forward from mouse/cursor position.
    Find, ///< Initiate a 'find' request in the current document.
    FindNext, ///< Find the next instance of a stored 'find'.
    FindPrev, ///< Find a previous instance of a stored 'find'.
    Replace, ///< Find and replace matches.
72
    // Navigation
73 74 75 76 77 78 79 80 81
    Home, ///< Go to home page.
    Begin, ///< Go to beginning of the document.
    End, ///< Go to end of the document.
    Prior, ///< Scroll up one page.
    Next, ///< Scroll down one page.
    Up, ///< Up.
    Back, ///< Back.
    Forward, ///< Forward.
    Reload, ///< Reload.
82
    // Text Navigation
83 84 85 86 87
    BeginningOfLine, ///< Go to beginning of current line.
    EndOfLine, ///< Go to end of current line.
    GotoLine, ///< Go to line.
    BackwardWord, ///< BackwardWord.
    ForwardWord, ///< ForwardWord.
88
    // View parameters
89 90 91 92 93
    AddBookmark, ///< Add current page to bookmarks.
    ZoomIn, ///< Zoom in.
    ZoomOut, ///< Zoom out.
    FullScreen, ///< Full Screen mode.
    ShowMenubar, ///< Show Menu Bar.
94
    // Tabular navigation
95 96
    TabNext, ///< Next Tab.
    TabPrev, ///< Previous Tab.
97
    // Help menu
98 99
    Help, ///< Help the user in the current situation.
    WhatsThis, ///< What's This button.
100
    // Text completion
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
    TextCompletion, ///< Complete text in input widgets.
    PrevCompletion, ///< Iterate through a list when completion returns multiple items.
    NextCompletion, ///< Iterate through a list when completion returns multiple items.
    SubstringCompletion, ///< Find a string within another string or list of strings.
    RotateUp, ///< Help users iterate through a list of entries.
    RotateDown, ///< Help users iterate through a list of entries.
    OpenRecent, ///< Open a recently used document.
    SaveAs, ///< Save the current document under a different name.
    Revert, ///< Revert the current document to the last saved version.
    PrintPreview, ///< Show a print preview of the current document.
    Mail, ///< Send the current document by mail.
    Clear, ///< Clear the content of the focus widget.
    ActualSize, ///< View the document at its actual size.
    FitToPage, ///< Fit the document view to the size of the current window.
    FitToWidth, ///< Fit the document view to the width of the current window.
    FitToHeight, ///< Fit the document view to the height of the current window.
    Zoom, ///< Select the current zoom level.
    Goto, ///< Jump to some specific location in the document.
    GotoPage, ///< Go to a specific page.
    DocumentBack, ///< Move back (document style menu).
    DocumentForward, ///< Move forward (document style menu).
    EditBookmarks, ///< Edit the application bookmarks.
    Spelling, ///< Pop up the spell checker.
    ShowToolbar, ///< Show/Hide the toolbar.
    ShowStatusbar, ///< Show/Hide the statusbar.
126
#if KCONFIGGUI_ENABLE_DEPRECATED_SINCE(5, 39)
127
    SaveOptions, ///< @deprecated since 5.39
128 129 130
#else
    SaveOptions_DEPRECATED_DO_NOT_USE,
#endif
131 132 133 134 135 136 137 138 139 140 141 142 143
    KeyBindings, ///< Display the configure key bindings dialog.
    Preferences, ///< Display the preferences/options dialog.
    ConfigureToolbars, ///< Display the toolbar configuration dialog.
    ConfigureNotifications, ///< Display the notifications configuration dialog.
    TipofDay, ///< Display the "Tip of the Day".
    ReportBug, ///< Display the Report Bug dialog.
    SwitchApplicationLanguage, ///< Display the Switch Application Language dialog.
    AboutApp, ///< Display the application's About dialog.
    AboutKDE, ///< Display the About KDE dialog.
    DeleteFile, ///< Permanently delete files or folders. @since 5.25
    RenameFile, ///< Rename files or folders. @since 5.25
    MoveToTrash, ///< Move files or folders to the trash. @since 5.25
    Donate, ///< Open donation page on kde.org. @since 5.26
144
    ShowHideHiddenFiles, ///< Toggle showing or hiding hidden files @since 5.70
145 146 147
    // Insert new items here!

    StandardShortcutCount // number of standard shortcuts
148 149
};

David Redondo's avatar
David Redondo committed
150 151 152 153 154 155 156 157 158 159 160 161 162 163
/**
 * Categories in which the standard shortcuts can be classified
 * @since 5.74
 */
enum class Category {
    InvalidCategory = -1,
    File,
    Edit,
    Navigation,
    View,
    Settings,
    Help,
};

164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
/**
 * Returns the keybinding for @p accel.
 * On X11, if QApplication was initialized with GUI disabled, the
 * default keybinding will always be returned.
 * @param id the id of the accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &shortcut(StandardShortcut id);

/**
 * Returns a unique name for the given accel.
 * @param id the id of the accelerator
 * @return the unique name of the accelerator
 */
KCONFIGGUI_EXPORT QString name(StandardShortcut id);

/**
 * Returns a localized label for user-visible display.
 * @param id the id of the accelerator
 * @return a localized label for the accelerator
 */
KCONFIGGUI_EXPORT QString label(StandardShortcut id);

/**
 * Returns an extended WhatsThis description for the given accelerator.
 * @param id the id of the accelerator
 * @return a localized description of the accelerator
 */
KCONFIGGUI_EXPORT QString whatsThis(StandardShortcut id);

/**
 * Return the StandardShortcut id of the standard accel action which
 * uses this key sequence, or AccelNone if none of them do.
 * This is used by class KKeyChooser.
 * @param keySeq the key sequence to search
 * @return the id of the standard accelerator, or AccelNone if there
 *          is none
 */
KCONFIGGUI_EXPORT StandardShortcut find(const QKeySequence &keySeq);

203
#if KCONFIGGUI_ENABLE_DEPRECATED_SINCE(5, 71)
204 205 206 207 208 209 210
/**
 * Return the StandardShortcut id of the standard accel action which
 * has \a keyName as its name, or AccelNone if none of them do.
 * This is used by class KKeyChooser.
 * @param keyName the key sequence to search
 * @return the id of the standard accelerator, or AccelNone if there
 *          is none
211
 * @deprecated since 5.71, use findByName(const QString &name) instead
212
 */
213
KCONFIGGUI_DEPRECATED_VERSION(5, 71, "Use findByName(const QString &name) instead")
214
KCONFIGGUI_EXPORT StandardShortcut find(const char *keyName);
215 216 217 218 219 220 221 222 223 224 225
#endif

/**
 * Return the StandardShortcut id of the standard accelerator action which
 * has \p name as its name, or AccelNone if none of them do.
 * @param name the name as returned by  name(StandardShortcut id)
 * @return the id of the standard accelerator with the given name or AccelNone
 * if there is no such accelerator
 * @since 5.71
 */
KCONFIGGUI_EXPORT StandardShortcut findByName(const QString &name);
226 227 228 229 230 231 232 233 234 235 236 237 238 239

/**
 * Returns the hardcoded default shortcut for @p id.
 * This does not take into account the user's configuration.
 * @param id the id of the accelerator
 * @return the default shortcut of the accelerator
 */
KCONFIGGUI_EXPORT QList<QKeySequence> hardcodedDefaultShortcut(StandardShortcut id);

/**
 * Saves the new shortcut \a cut for standard accel \a id.
 */
KCONFIGGUI_EXPORT void saveShortcut(StandardShortcut id, const QList<QKeySequence> &newShortcut);

David Redondo's avatar
David Redondo committed
240 241 242 243 244 245
/**
 * Returns the appropriate category for the given StandardShortcut \p id.
 * @since 5.73
 */
KCONFIGGUI_EXPORT Category category(StandardShortcut id);

246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288
/**
 * Open file. Default: Ctrl-o
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &open();

/**
 * Create a new document (or whatever). Default: Ctrl-n
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &openNew();

/**
 * Close current document. Default: Ctrl-w
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &close();

/**
 * Save current document. Default: Ctrl-s
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &save();

/**
 * Print current document. Default: Ctrl-p
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &print();

/**
 * Quit the program. Default: Ctrl-q
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &quit();

/**
 * Undo last operation. Default: Ctrl-z
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &undo();

/**
289
 * Redo last operation. Default: Shift-Ctrl-z
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &redo();

/**
 * Cut selected area and store it in the clipboard. Default: Ctrl-x
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &cut();

/**
 * Copy selected area into the clipboard. Default: Ctrl-c
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &copy();

/**
 * Paste contents of clipboard at mouse/cursor position. Default: Ctrl-v
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &paste();

/**
 * Paste the selection at mouse/cursor position. Default: Ctrl-Shift-Insert
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &pasteSelection();

/**
 * Select all. Default: Ctrl-A
 * @return the shortcut of the standard accelerator
 **/
KCONFIGGUI_EXPORT const QList<QKeySequence> &selectAll();

/**
 * Delete a word back from mouse/cursor position. Default: Ctrl-Backspace
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &deleteWordBack();

/**
 * Delete a word forward from mouse/cursor position. Default: Ctrl-Delete
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &deleteWordForward();

/**
337
 * Initiate a 'find' request in the current document. Default: Ctrl-f
338 339 340 341 342
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &find();

/**
343
 * Find the next instance of a stored 'find' Default: F3
344 345 346 347 348
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &findNext();

/**
349
 * Find a previous instance of a stored 'find'. Default: Shift-F3
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &findPrev();

/**
 * Find and replace matches. Default: Ctrl-r
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &replace();

/**
 * Zoom in. Default: Ctrl-Plus
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &zoomIn();

/**
 * Zoom out. Default: Ctrl-Minus
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &zoomOut();

/**
373
 * Go to home page. Default: Alt-Home
374 375 376 377 378
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &home();

/**
379
 * Go to beginning of the document. Default: Ctrl-Home
380 381 382 383 384
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &begin();

/**
385
 * Go to end of the document. Default: Ctrl-End
386 387 388 389 390
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &end();

/**
391
 * Go to beginning of current line. Default: Home
392 393 394 395 396
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &beginningOfLine();

/**
397
 * Go to end of current line. Default: End
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &endOfLine();

/**
 * Scroll up one page. Default: Prior
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &prior();

/**
 * Scroll down one page. Default: Next
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &next();

/**
 * Go to line. Default: Ctrl+G
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &gotoLine();

/**
 * Add current page to bookmarks. Default: Ctrl+B
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &addBookmark();

/**
 * Next Tab. Default: Ctrl-<
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &tabNext();

/**
 * Previous Tab. Default: Ctrl->
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &tabPrev();

/**
 * Full Screen Mode. Default: Ctrl+Shift+F
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &fullScreen();

/**
 * Help the user in the current situation. Default: F1
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &help();

/**
 * Complete text in input widgets. Default Ctrl+E
 * @return the shortcut of the standard accelerator
 **/
KCONFIGGUI_EXPORT const QList<QKeySequence> &completion();

/**
 * Iterate through a list when completion returns
 * multiple items. Default: Ctrl+Up
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &prevCompletion();

/**
 * Iterate through a list when completion returns
 * multiple items. Default: Ctrl+Down
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &nextCompletion();

/**
 * Find a string within another string or list of strings.
 * Default: Ctrl-T
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &substringCompletion();

/**
 * Help users iterate through a list of entries. Default: Up
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &rotateUp();

/**
 * Help users iterate through a list of entries. Default: Down
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &rotateDown();

/**
 * What's This button. Default: Shift+F1
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &whatsThis();

/**
 * Reload. Default: F5
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &reload();

/**
 * Up. Default: Alt+Up
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &up();

/**
 * Back. Default: Alt+Left
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &back();

/**
 * Forward. Default: ALT+Right
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &forward();

/**
 * BackwardWord. Default: Ctrl+Left
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &backwardWord();

/**
 * ForwardWord. Default: Ctrl+Right
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &forwardWord();

/**
 * Show Menu Bar.  Default: Ctrl-M
 * @return the shortcut of the standard accelerator
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &showMenubar();
536

537
/**
538
 * Permanently delete files or folders. Default: Shift+Delete
539 540 541 542 543 544
 * @return the shortcut of the standard accelerator
 * @since 5.25
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &deleteFile();

/**
545
 * Rename files or folders. Default: F2
546 547 548 549 550 551
 * @return the shortcut of the standard accelerator
 * @since 5.25
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &renameFile();

/**
552
 * Moves files or folders to the trash. Default: Delete
553 554 555 556 557
 * @return the shortcut of the standard accelerator
 * @since 5.25
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &moveToTrash();

558 559 560 561 562 563
/**
 * Opens the app's settings window. Default: Ctrl+Shift+Comma
 * @return the shortcut of the standard accelerator
 * @since 5.64
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &preferences();
564 565 566 567 568 569 570 571

/**
 * Shows or hides hidden files. Defaults: Ctrl+H, Alt+.
 * @return the shortcut of the standard accelerator
 * @since 5.70
 */
KCONFIGGUI_EXPORT const QList<QKeySequence> &showHideHiddenFiles();

572 573 574
}

#endif // KSTANDARDSHORTCUT_H