annotate widgets/KeyReference.h @ 378:22b72f0f6a4e

* More work to abstract out interactive components used in the data library, so that it does not need to depend on QtGui.
author Chris Cannam
date Fri, 14 Mar 2008 17:14:21 +0000
parents 4edaff85875d
children 5f3f5c1e23e8
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@282 26 class QDialog;
Chris@282 27 class QAbstractButton;
Chris@281 28
Chris@281 29 class KeyReference : public QObject
Chris@281 30 {
Chris@281 31 Q_OBJECT
Chris@281 32
Chris@281 33 public:
Chris@281 34 KeyReference();
Chris@281 35 virtual ~KeyReference();
Chris@281 36
Chris@281 37 void setCategory(QString category);
Chris@281 38
Chris@281 39 void registerShortcut(QAction *, QString overrideName = "");
Chris@281 40 void registerAlternativeShortcut(QAction *, QString alternative);
Chris@281 41
Chris@281 42 void registerShortcut(QString actionName, QString shortcut, QString tipText);
Chris@281 43 void registerAlternativeShortcut(QString actionName, QString alternative);
Chris@281 44
Chris@281 45 void show();
Chris@281 46
Chris@282 47 protected slots:
Chris@282 48 void dialogButtonClicked(QAbstractButton *);
Chris@282 49
Chris@281 50 protected:
Chris@281 51 struct KeyDetails {
Chris@281 52 QString actionName;
Chris@281 53 QString shortcut;
Chris@281 54 QString tip;
Chris@281 55 std::vector<QString> alternatives;
Chris@281 56 };
Chris@281 57
Chris@281 58 typedef std::vector<KeyDetails> KeyList;
Chris@281 59 typedef std::map<QString, KeyList> CategoryMap;
Chris@281 60 typedef std::vector<QString> CategoryList;
Chris@281 61
Chris@281 62 QString m_currentCategory;
Chris@281 63 CategoryMap m_map;
Chris@281 64 CategoryList m_categoryOrder;
Chris@281 65
Chris@281 66 QTextEdit *m_text;
Chris@282 67 QDialog *m_dialog;
Chris@281 68 };
Chris@281 69
Chris@281 70 #endif