a26d55cdb1f6a5da5d6f74bacdd67f9aa2786ec6
[quassel.git] / src / uisupport / action.h
1 /***************************************************************************
2  *   Copyright (C) 2005-08 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  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20
21 #ifndef ACTION_H_
22 #define ACTION_H_
23
24 #include <QWidgetAction>
25
26 class Action : public QWidgetAction {
27   Q_OBJECT
28
29   Q_PROPERTY(QShortcut shortcut READ shortcut WRITE setShortcut);
30   Q_PROPERTY(bool shortcutConfigurable READ isShortcutConfigurable WRITE setShortcutConfigurable);
31   Q_FLAGS(ShortcutType);
32
33   public:
34     enum ShortcutType {
35       ActiveShortcut = 0x01,
36       DefaultShortcut = 0x02
37     };
38     Q_DECLARE_FLAGS(ShortcutTypes, ShortcutType);
39
40     explicit Action(QObject *parent);
41     Action(const QString &text, QObject *parent);
42     Action(const QIcon &icon, const QString &text, QObject *parent);
43
44     QShortcut shortcut(ShortcutTypes types = ActiveShortcut) const;
45     void setShortcut(const QShortcut &shortcut, ShortcutTypes type = ActiveShortcut);
46     void setShortcut(const QKeySequence &shortcut, ShortcutTypes type = ActiveShortcut);
47
48 };
49
50 Q_DECLARE_OPERATORS_FOR_FLAGS(ShortcutTypes);