BALL
1.4.1
|
00001 // -*- Mode: C++; tab-width: 2; -*- 00002 // vi: set ts=2: 00003 // 00004 00005 #ifndef BALL_VIEW_KERNEL_SHORTCUTREGISTRY_H 00006 #define BALL_VIEW_KERNEL_SHORTCUTREGISTRY_H 00007 00008 #ifndef BALL_CONCEPT_EMBEDDABLE_H 00009 # include <BALL/CONCEPT/embeddable.h> 00010 #endif 00011 00012 #include <map> 00013 00014 #ifndef BALL_DATATYPE_HASHSET_H 00015 # include <BALL/DATATYPE/hashSet.h> 00016 #endif 00017 00018 #ifndef BALL_VIEW_KERNEL_PREFERENCESENTRY_H 00019 # include <BALL/VIEW/KERNEL/preferencesEntry.h> 00020 #endif 00021 00022 #include <QtCore/QObject> 00023 00024 class QAction; 00025 class QKeySequence; 00026 00027 namespace BALL 00028 { 00029 namespace VIEW 00030 { 00036 class BALL_VIEW_EXPORT ShortcutRegistry 00037 : public QObject, 00038 public Embeddable, 00039 public PreferencesEntry::ExtendedPreferencesObject 00040 { 00041 Q_OBJECT 00042 00043 public: 00044 BALL_EMBEDDABLE(ShortcutRegistry, Embeddable) 00045 00046 00047 ShortcutRegistry(); 00048 00051 virtual ~ShortcutRegistry(); 00052 00054 void registerShortcut(String description, QAction* shortcut); 00055 00057 void clear(); 00058 00060 void clearKeySequences(); 00061 00063 bool readShortcutsFromFile(const String& filename); 00064 00066 bool writeShortcutsToFile(const String& filename); 00067 00069 bool changeShortcut(QAction* shortcut, const String& new_sequence); 00070 bool changeShortcut(int index, const String& new_sequence); 00071 00072 size_t size(); 00073 00074 bool hasDescription(const String& description); 00075 bool hasKey(const QString& key_seq); 00076 bool hasKey(const QKeySequence& key_seq); 00077 bool hasKey(const String& key_seq); 00078 00079 std::pair<String, QAction*> operator[](Index i); 00080 00081 // needed for storing this classes' preferences 00082 virtual bool getValue(String&) const; 00083 virtual bool setValue(const String&); 00084 00085 signals: 00086 void shortcutChanged(); 00087 00088 protected: 00089 static const char* BETWEEN_SC_SEPERATOR; 00090 static const char* IN_SC_SEPERATOR; 00091 00092 std::pair<String, QAction*> getEntry_(Index pos); 00093 00094 std::map<String, QAction*> shortcuts_; 00095 std::map<String, String> unknown_shortcuts_; 00096 HashSet<String> shortcut_keys_; 00097 }; 00098 00099 }// namespace VIEW 00100 }// namespace BALL 00101 00102 #endif // BALL_VIEW_KERNEL_SHORTCUTREGISTRY_H 00103