2015-01-04 17:36:57 +00:00
|
|
|
// Copyright 2014 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2016-01-24 20:54:04 +00:00
|
|
|
#pragma once
|
|
|
|
|
2014-04-01 03:26:50 +01:00
|
|
|
#include "ui_hotkeys.h"
|
|
|
|
|
2015-06-21 14:58:59 +01:00
|
|
|
class QDialog;
|
2014-04-01 03:26:50 +01:00
|
|
|
class QKeySequence;
|
|
|
|
class QSettings;
|
2015-06-21 14:58:59 +01:00
|
|
|
class QShortcut;
|
2014-04-01 03:26:50 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Register a hotkey.
|
|
|
|
*
|
|
|
|
* @param group General group this hotkey belongs to (e.g. "Main Window", "Debugger")
|
|
|
|
* @param action Name of the action (e.g. "Start Emulation", "Load Image")
|
2016-09-18 01:38:01 +01:00
|
|
|
* @param default_keyseq Default key sequence to assign if the hotkey wasn't present in the settings
|
|
|
|
* file before
|
|
|
|
* @param default_context Default context to assign if the hotkey wasn't present in the settings
|
|
|
|
* file before
|
2014-04-01 03:26:50 +01:00
|
|
|
* @warning Both the group and action strings will be displayed in the hotkey settings dialog
|
|
|
|
*/
|
2016-09-18 01:38:01 +01:00
|
|
|
void RegisterHotkey(const QString& group, const QString& action,
|
|
|
|
const QKeySequence& default_keyseq = QKeySequence(),
|
|
|
|
Qt::ShortcutContext default_context = Qt::WindowShortcut);
|
2014-04-01 03:26:50 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a QShortcut object whose activated() signal can be connected to other QObjects' slots.
|
|
|
|
*
|
2017-02-27 01:58:51 +00:00
|
|
|
* @param group General group this hotkey belongs to (e.g. "Main Window", "Debugger").
|
|
|
|
* @param action Name of the action (e.g. "Start Emulation", "Load Image").
|
2014-04-01 03:26:50 +01:00
|
|
|
* @param widget Parent widget of the returned QShortcut.
|
2016-09-18 01:38:01 +01:00
|
|
|
* @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.
|
2014-04-01 03:26:50 +01:00
|
|
|
*/
|
|
|
|
QShortcut* GetHotkey(const QString& group, const QString& action, QWidget* widget);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Saves all registered hotkeys to the settings file.
|
|
|
|
*
|
2016-09-18 01:38:01 +01:00
|
|
|
* @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.
|
2014-04-01 03:26:50 +01:00
|
|
|
*/
|
2016-01-24 20:23:55 +00:00
|
|
|
void SaveHotkeys();
|
2014-04-01 03:26:50 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Loads hotkeys from the settings file.
|
|
|
|
*
|
2016-09-18 01:38:01 +01:00
|
|
|
* @note Yet unregistered hotkeys which are present in the settings will automatically be
|
|
|
|
* registered.
|
2014-04-01 03:26:50 +01:00
|
|
|
*/
|
2016-01-24 20:23:55 +00:00
|
|
|
void LoadHotkeys();
|
2014-04-01 03:26:50 +01:00
|
|
|
|
2016-09-18 01:38:01 +01:00
|
|
|
class GHotkeysDialog : public QWidget {
|
2014-04-01 03:26:50 +01:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2016-12-11 12:22:10 +00:00
|
|
|
explicit GHotkeysDialog(QWidget* parent = nullptr);
|
2018-07-24 05:23:38 +01:00
|
|
|
void retranslateUi();
|
2014-04-01 03:26:50 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
Ui::hotkeys ui;
|
|
|
|
};
|