2016-07-08 03:45:02 +00:00
|
|
|
#ifndef CSM_PREFS_SHORTCUTMANAGER_H
|
|
|
|
#define CSM_PREFS_SHORTCUTMANAGER_H
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
#include <QKeySequence>
|
|
|
|
#include <QObject>
|
|
|
|
|
|
|
|
namespace CSMPrefs
|
|
|
|
{
|
|
|
|
class Shortcut;
|
|
|
|
|
|
|
|
/// Class used to track and update shortcuts/sequences
|
|
|
|
class ShortcutManager : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2016-07-22 05:58:17 +00:00
|
|
|
/// Key Sequence, Modifier (for secondary signal)
|
|
|
|
typedef std::pair<QKeySequence, int> SequenceData;
|
|
|
|
|
2016-07-08 03:45:02 +00:00
|
|
|
/// The shortcut class will do this automatically
|
|
|
|
void addShortcut(Shortcut* shortcut);
|
|
|
|
|
|
|
|
/// The shortcut class will do this automatically
|
|
|
|
void removeShortcut(Shortcut* shortcut);
|
|
|
|
|
2016-07-22 05:58:17 +00:00
|
|
|
SequenceData getSequence(const std::string& name) const;
|
|
|
|
void setSequence(const std::string& name, const SequenceData& sequence);
|
2016-07-08 03:45:02 +00:00
|
|
|
|
2016-07-22 05:58:17 +00:00
|
|
|
std::string sequenceToString(const SequenceData& sequence);
|
|
|
|
SequenceData stringToSequence(const std::string& str);
|
2016-07-08 03:45:02 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
// Need a multimap in case multiple shortcuts share the same name
|
|
|
|
typedef std::multimap<std::string, Shortcut*> ShortcutMap;
|
2016-07-22 05:58:17 +00:00
|
|
|
typedef std::map<std::string, SequenceData> SequenceMap;
|
2016-07-08 03:45:02 +00:00
|
|
|
|
|
|
|
ShortcutMap mShortcuts;
|
|
|
|
SequenceMap mSequences;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|