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