svgui
1.9
|
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 00002 00003 /* 00004 Sonic Visualiser 00005 An audio file viewer and annotation editor. 00006 Centre for Digital Music, Queen Mary, University of London. 00007 This file copyright 2007 QMUL. 00008 00009 This program is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU General Public License as 00011 published by the Free Software Foundation; either version 2 of the 00012 License, or (at your option) any later version. See the file 00013 COPYING included with this distribution for more information. 00014 */ 00015 00016 #ifndef _KEY_REFERENCE_H_ 00017 #define _KEY_REFERENCE_H_ 00018 00019 #include <QObject> 00020 #include <QString> 00021 #include <vector> 00022 #include <map> 00023 #include <QKeySequence> 00024 00025 class QAction; 00026 class QTextEdit; 00027 class QDialog; 00028 class QAbstractButton; 00029 00030 class KeyReference : public QObject 00031 { 00032 Q_OBJECT 00033 00034 public: 00035 KeyReference(); 00036 virtual ~KeyReference(); 00037 00038 void setCategory(QString category); 00039 00040 void registerShortcut(QAction *, QString overrideName = ""); 00041 void registerAlternativeShortcut(QAction *, QString alternative); 00042 void registerAlternativeShortcut(QAction *, QKeySequence alternative); 00043 00044 void registerShortcut(QString actionName, QString shortcut, QString tipText); 00045 void registerAlternativeShortcut(QString actionName, QString alternative); 00046 void registerAlternativeShortcut(QString actionName, QKeySequence alternative); 00047 00048 void show(); 00049 void hide(); 00050 00051 protected slots: 00052 void dialogButtonClicked(QAbstractButton *); 00053 00054 protected: 00055 struct KeyDetails { 00056 QString actionName; 00057 QString shortcut; 00058 QString tip; 00059 std::vector<QString> alternatives; 00060 }; 00061 00062 typedef std::vector<KeyDetails> KeyList; 00063 typedef std::map<QString, KeyList> CategoryMap; 00064 typedef std::vector<QString> CategoryList; 00065 00066 QString m_currentCategory; 00067 CategoryMap m_map; 00068 CategoryList m_categoryOrder; 00069 00070 QTextEdit *m_text; 00071 QDialog *m_dialog; 00072 }; 00073 00074 #endif