Quassel IRC  Pre-Release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
action.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2015 by the Quassel Project *
3  * devel@quassel-irc.org *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************
20  * Parts of this API have been shamelessly stolen from KDE's kaction.h *
21  ***************************************************************************/
22 
23 #ifndef ACTION_H_
24 #define ACTION_H_
25 
26 #ifndef HAVE_KDE4
27 
28 #include <QShortcut>
29 #include <QWidgetAction>
30 
32 
35 class Action : public QWidgetAction
36 {
37  Q_OBJECT
38 
39  Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut)
41  Q_FLAGS(ShortcutType)
42 
43 public :
44  enum ShortcutType {
45  ActiveShortcut = 0x01,
46  DefaultShortcut = 0x02
47  };
48  Q_DECLARE_FLAGS(ShortcutTypes, ShortcutType)
49 
50  explicit Action(QObject *parent);
51  Action(const QString &text, QObject *parent, const QObject *receiver = 0, const char *slot = 0, const QKeySequence &shortcut = 0);
52  Action(const QIcon &icon, const QString &text, QObject *parent, const QObject *receiver = 0, const char *slot = 0, const QKeySequence &shortcut = 0);
53 
54  QKeySequence shortcut(ShortcutTypes types = ActiveShortcut) const;
55  void setShortcut(const QShortcut &shortcut, ShortcutTypes type = ShortcutTypes(ActiveShortcut | DefaultShortcut));
56  void setShortcut(const QKeySequence &shortcut, ShortcutTypes type = ShortcutTypes(ActiveShortcut | DefaultShortcut));
57 
58  bool isShortcutConfigurable() const;
59  void setShortcutConfigurable(bool configurable);
60 
61 signals:
62  void triggered(Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
63 
64 private:
65  void init();
66 
67 private slots:
68  void slotTriggered();
69 };
70 
71 
73 
74 #else /* HAVE_KDE4 */
75 #include <KAction>
76 
77 class Action : public KAction
78 {
79  Q_OBJECT
80 
81 public:
82  explicit Action(QObject *parent);
83  Action(const QString &text, QObject *parent, const QObject *receiver = 0, const char *slot = 0, const QKeySequence &shortcut = 0);
84  Action(const QIcon &icon, const QString &text, QObject *parent, const QObject *receiver = 0, const char *slot = 0, const QKeySequence &shortcut = 0);
85 
86 private:
87  void init();
88 };
89 
90 
91 #endif
92 
93 #endif