comparison widgets/KeyReference.h @ 281:ac58acbd7482

* Add key reference window to Help menu (also needs mouse reference)
author Chris Cannam
date Wed, 04 Jul 2007 17:22:12 +0000
parents
children 4edaff85875d
comparison
equal deleted inserted replaced
280:3c402c6052f6 281:ac58acbd7482
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 Sonic Visualiser
5 An audio file viewer and annotation editor.
6 Centre for Digital Music, Queen Mary, University of London.
7 This file copyright 2007 QMUL.
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information.
14 */
15
16 #ifndef _KEY_REFERENCE_H_
17 #define _KEY_REFERENCE_H_
18
19 #include <QObject>
20 #include <QString>
21 #include <vector>
22 #include <map>
23
24 class QAction;
25 class QTextEdit;
26
27 class KeyReference : public QObject
28 {
29 Q_OBJECT
30
31 public:
32 KeyReference();
33 virtual ~KeyReference();
34
35 void setCategory(QString category);
36
37 void registerShortcut(QAction *, QString overrideName = "");
38 void registerAlternativeShortcut(QAction *, QString alternative);
39
40 void registerShortcut(QString actionName, QString shortcut, QString tipText);
41 void registerAlternativeShortcut(QString actionName, QString alternative);
42
43 void show();
44
45 protected:
46 struct KeyDetails {
47 QString actionName;
48 QString shortcut;
49 QString tip;
50 std::vector<QString> alternatives;
51 };
52
53 typedef std::vector<KeyDetails> KeyList;
54 typedef std::map<QString, KeyList> CategoryMap;
55 typedef std::vector<QString> CategoryList;
56
57 QString m_currentCategory;
58 CategoryMap m_map;
59 CategoryList m_categoryOrder;
60
61 QTextEdit *m_text;
62 };
63
64 #endif