[1f4adec] | 1 | /* |
---|
| 2 | |
---|
| 3 | Copyright 2013 Adam Reichold |
---|
| 4 | |
---|
| 5 | This file is part of qpdfview. |
---|
| 6 | |
---|
| 7 | qpdfview is free software: you can redistribute it and/or modify |
---|
| 8 | it under the terms of the GNU General Public License as published by |
---|
| 9 | the Free Software Foundation, either version 2 of the License, or |
---|
| 10 | (at your option) any later version. |
---|
| 11 | |
---|
| 12 | qpdfview is distributed in the hope that it will be useful, |
---|
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 15 | GNU General Public License for more details. |
---|
| 16 | |
---|
| 17 | You should have received a copy of the GNU General Public License |
---|
| 18 | along with qpdfview. If not, see <http://www.gnu.org/licenses/>. |
---|
| 19 | |
---|
| 20 | */ |
---|
| 21 | |
---|
| 22 | #ifndef SHORTCUTHANDLER_H |
---|
| 23 | #define SHORTCUTHANDLER_H |
---|
| 24 | |
---|
| 25 | #include <QAbstractTableModel> |
---|
| 26 | #include <QAction> |
---|
| 27 | #include <QKeySequence> |
---|
| 28 | |
---|
| 29 | class QSettings; |
---|
| 30 | |
---|
| 31 | namespace qpdfview |
---|
| 32 | { |
---|
| 33 | |
---|
| 34 | class ShortcutHandler : public QAbstractTableModel |
---|
| 35 | { |
---|
| 36 | Q_OBJECT |
---|
| 37 | |
---|
| 38 | public: |
---|
| 39 | static ShortcutHandler* instance(); |
---|
| 40 | ~ShortcutHandler(); |
---|
| 41 | |
---|
| 42 | void registerAction(QAction* action); |
---|
| 43 | |
---|
| 44 | int columnCount(const QModelIndex& parent) const; |
---|
| 45 | int rowCount(const QModelIndex& parent) const; |
---|
| 46 | |
---|
| 47 | Qt::ItemFlags flags(const QModelIndex& index) const; |
---|
| 48 | |
---|
| 49 | QVariant headerData(int section, Qt::Orientation orientation, int role) const; |
---|
| 50 | |
---|
| 51 | QVariant data(const QModelIndex& index, int role) const; |
---|
| 52 | bool setData(const QModelIndex& index, const QVariant& value, int role); |
---|
| 53 | |
---|
| 54 | bool matchesSkipBackward(const QKeySequence& keySequence) const; |
---|
| 55 | bool matchesSkipForward(const QKeySequence& keySequence) const; |
---|
| 56 | |
---|
| 57 | bool matchesMoveUp(const QKeySequence& keySequence) const; |
---|
| 58 | bool matchesMoveDown(const QKeySequence& keySequence) const; |
---|
| 59 | bool matchesMoveLeft(const QKeySequence& keySequence) const; |
---|
| 60 | bool matchesMoveRight(const QKeySequence& keySequence) const; |
---|
| 61 | |
---|
| 62 | public slots: |
---|
| 63 | bool submit(); |
---|
| 64 | void revert(); |
---|
| 65 | |
---|
| 66 | void reset(); |
---|
| 67 | |
---|
| 68 | private: |
---|
| 69 | Q_DISABLE_COPY(ShortcutHandler) |
---|
| 70 | |
---|
| 71 | static ShortcutHandler* s_instance; |
---|
| 72 | ShortcutHandler(QObject* parent = 0); |
---|
| 73 | |
---|
| 74 | QSettings* m_settings; |
---|
| 75 | |
---|
| 76 | QList< QAction* > m_actions; |
---|
| 77 | |
---|
| 78 | QHash< QAction*, QList< QKeySequence > > m_shortcuts; |
---|
| 79 | QHash< QAction*, QList< QKeySequence > > m_defaultShortcuts; |
---|
| 80 | |
---|
| 81 | QAction* m_skipBackwardAction; |
---|
| 82 | QAction* m_skipForwardAction; |
---|
| 83 | |
---|
| 84 | QAction* m_moveUpAction; |
---|
| 85 | QAction* m_moveDownAction; |
---|
| 86 | QAction* m_moveLeftAction; |
---|
| 87 | QAction* m_moveRightAction; |
---|
| 88 | |
---|
| 89 | }; |
---|
| 90 | |
---|
| 91 | } // qpdfview |
---|
| 92 | |
---|
| 93 | #endif // SHORTCUTHANDLER_H |
---|