hotkeys.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include "ui_hotkeys.h"
  6. class QDialog;
  7. class QKeySequence;
  8. class QSettings;
  9. class QShortcut;
  10. /**
  11. * Register a hotkey.
  12. *
  13. * @param group General group this hotkey belongs to (e.g. "Main Window", "Debugger")
  14. * @param action Name of the action (e.g. "Start Emulation", "Load Image")
  15. * @param default_keyseq Default key sequence to assign if the hotkey wasn't present in the settings
  16. * file before
  17. * @param default_context Default context to assign if the hotkey wasn't present in the settings
  18. * file before
  19. * @warning Both the group and action strings will be displayed in the hotkey settings dialog
  20. */
  21. void RegisterHotkey(const QString& group, const QString& action,
  22. const QKeySequence& default_keyseq = QKeySequence(),
  23. Qt::ShortcutContext default_context = Qt::WindowShortcut);
  24. /**
  25. * Returns a QShortcut object whose activated() signal can be connected to other QObjects' slots.
  26. *
  27. * @param widget Parent widget of the returned QShortcut.
  28. * @warning If multiple QWidgets' call this function for the same action, the returned QShortcut
  29. * will be the same. Thus, you shouldn't rely on the caller really being the QShortcut's parent.
  30. */
  31. QShortcut* GetHotkey(const QString& group, const QString& action, QWidget* widget);
  32. /**
  33. * Saves all registered hotkeys to the settings file.
  34. *
  35. * @note Each hotkey group will be stored a settings group; For each hotkey inside that group, a
  36. * settings group will be created to store the key sequence and the hotkey context.
  37. */
  38. void SaveHotkeys();
  39. /**
  40. * Loads hotkeys from the settings file.
  41. *
  42. * @note Yet unregistered hotkeys which are present in the settings will automatically be
  43. * registered.
  44. */
  45. void LoadHotkeys();
  46. class GHotkeysDialog : public QWidget {
  47. Q_OBJECT
  48. public:
  49. explicit GHotkeysDialog(QWidget* parent = nullptr);
  50. private:
  51. Ui::hotkeys ui;
  52. };