1 /***************************************************************************
2 * Copyright (C) 2005-08 by the Quassel Project *
3 * devel@quassel-irc.org *
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. *
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. *
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 * Parts of this API have been shamelessly stolen from KDE's kaction.h *
21 ***************************************************************************/
27 #include <QWidgetAction>
29 /// A specialized QWidgetAction, enhanced by some KDE features
30 /** This declares/implements a subset of KAction's API (notably we've left out global shortcuts
31 * for now), which should make it easy to plug in KDE support later on.
33 class Action : public QWidgetAction {
36 Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut)
37 Q_PROPERTY(bool shortcutConfigurable READ isShortcutConfigurable WRITE setShortcutConfigurable)
42 ActiveShortcut = 0x01,
43 DefaultShortcut = 0x02
45 Q_DECLARE_FLAGS(ShortcutTypes, ShortcutType)
47 explicit Action(QObject *parent);
48 Action(const QString &text, QObject *parent, const QObject *receiver = 0, const char *slot = 0, const QKeySequence &shortcut = 0);
49 Action(const QIcon &icon, const QString &text, QObject *parent, const QObject *receiver = 0, const char *slot = 0, const QKeySequence &shortcut = 0);
51 QKeySequence shortcut(ShortcutTypes types = ActiveShortcut) const;
52 void setShortcut(const QShortcut &shortcut, ShortcutTypes type = ShortcutTypes(ActiveShortcut | DefaultShortcut));
53 void setShortcut(const QKeySequence &shortcut, ShortcutTypes type = ShortcutTypes(ActiveShortcut | DefaultShortcut));
55 bool isShortcutConfigurable() const;
56 void setShortcutConfigurable(bool configurable);
59 void triggered(Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
68 Q_DECLARE_OPERATORS_FOR_FLAGS(Action::ShortcutTypes)