hotkeys.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 file before
  16. * @param default_context Default context to assign if the hotkey wasn't present in the settings file before
  17. * @warning Both the group and action strings will be displayed in the hotkey settings dialog
  18. */
  19. void RegisterHotkey(const QString& group, const QString& action, const QKeySequence& default_keyseq = QKeySequence(), Qt::ShortcutContext default_context = Qt::WindowShortcut);
  20. /**
  21. * Returns a QShortcut object whose activated() signal can be connected to other QObjects' slots.
  22. *
  23. * @param widget Parent widget of the returned QShortcut.
  24. * @warning If multiple QWidgets' call this function for the same action, the returned QShortcut will be the same. Thus, you shouldn't rely on the caller really being the QShortcut's parent.
  25. */
  26. QShortcut* GetHotkey(const QString& group, const QString& action, QWidget* widget);
  27. /**
  28. * Saves all registered hotkeys to the settings file.
  29. *
  30. * @note Each hotkey group will be stored a settings group; For each hotkey inside that group, a settings group will be created to store the key sequence and the hotkey context.
  31. */
  32. void SaveHotkeys();
  33. /**
  34. * Loads hotkeys from the settings file.
  35. *
  36. * @note Yet unregistered hotkeys which are present in the settings will automatically be registered.
  37. */
  38. void LoadHotkeys();
  39. class GHotkeysDialog : public QWidget
  40. {
  41. Q_OBJECT
  42. public:
  43. GHotkeysDialog(QWidget* parent = nullptr);
  44. private:
  45. Ui::hotkeys ui;
  46. };