1 | /* This file is part of the KDE libraries |
2 | Copyright (C) 2007 Andreas Hartmetz <ahartmetz@gmail.com> |
3 | |
4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public |
6 | License as published by the Free Software Foundation; either |
7 | version 2 of the License, or (at your option) any later version. |
8 | |
9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. |
13 | |
14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 | Boston, MA 02110-1301, USA. |
18 | */ |
19 | #ifndef KSHORTCUTWIDGET_H |
20 | #define KSHORTCUTWIDGET_H |
21 | |
22 | #include <QtGui/QWidget> |
23 | #include "kshortcut.h" |
24 | |
25 | class KActionCollection; |
26 | class KShortcutWidgetPrivate; |
27 | |
28 | /** |
29 | * \image html kshortcutwidget.png "KDE Shortcut Widget" |
30 | */ |
31 | class KDEUI_EXPORT KShortcutWidget : public QWidget |
32 | { |
33 | Q_OBJECT |
34 | Q_PROPERTY(bool modifierlessAllowed READ isModifierlessAllowed WRITE setModifierlessAllowed) |
35 | public: |
36 | KShortcutWidget(QWidget *parent = 0); |
37 | ~KShortcutWidget(); |
38 | |
39 | void setModifierlessAllowed(bool allow); |
40 | bool isModifierlessAllowed(); |
41 | |
42 | void setClearButtonsShown(bool show); |
43 | |
44 | KShortcut shortcut() const; |
45 | |
46 | /** |
47 | * Set a list of action collections to check against for conflictuous shortcut. |
48 | * |
49 | * If there is a conflictuous shortcut with a KAction, and that his shortcut can be configured |
50 | * (KAction::isShortcutConfigurable() returns true) the user will be prompted for eventually steal |
51 | * the shortcut from this action |
52 | * |
53 | * Global shortcuts are automatically checked for conflicts |
54 | * |
55 | * Don't forget to call applyStealShortcut to actually steal the shortcut. |
56 | * |
57 | * @since 4.1 |
58 | */ |
59 | void setCheckActionCollections(const QList<KActionCollection *>& actionCollections); |
60 | |
61 | /** |
62 | * @deprecated since 4.1 |
63 | * Use setCheckActionCollections so that KShortcutWidget knows |
64 | * in which action collection to call the writeSettings method after stealing |
65 | * a shortcut from an action. |
66 | */ |
67 | #ifndef KDE_NO_DEPRECATED |
68 | KDE_DEPRECATED void setCheckActionList(const QList<QAction*> &checkList); |
69 | #endif |
70 | |
71 | Q_SIGNALS: |
72 | void shortcutChanged(const KShortcut &cut); |
73 | |
74 | public Q_SLOTS: |
75 | void setShortcut(const KShortcut &cut); |
76 | void clearShortcut(); |
77 | |
78 | /** |
79 | * Actually remove the shortcut that the user wanted to steal, from the |
80 | * action that was using it. |
81 | * |
82 | * To be called before you apply your changes. |
83 | * No shortcuts are stolen until this function is called. |
84 | */ |
85 | void applyStealShortcut(); |
86 | |
87 | private: |
88 | Q_PRIVATE_SLOT(d, void priKeySequenceChanged(const QKeySequence &)) |
89 | Q_PRIVATE_SLOT(d, void altKeySequenceChanged(const QKeySequence &)) |
90 | |
91 | private: |
92 | friend class KShortcutWidgetPrivate; |
93 | KShortcutWidgetPrivate *const d; |
94 | }; |
95 | |
96 | #endif //KSHORTCUTWIDGET_H |
97 | |