X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Faction.h;h=81157a22a2e88320bcdec65a597c86e5c3fcd6e9;hp=a26d55cdb1f6a5da5d6f74bacdd67f9aa2786ec6;hb=c64a887d0f05222590299fb2bb8d56fa9fadb16d;hpb=bde6f40f73d85cff300b133a722e4f59bff77f84 diff --git a/src/uisupport/action.h b/src/uisupport/action.h index a26d55cd..81157a22 100644 --- a/src/uisupport/action.h +++ b/src/uisupport/action.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-08 by the Quassel Project * + * Copyright (C) 2005-2012 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -15,36 +15,79 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + *************************************************************************** + * Parts of this API have been shamelessly stolen from KDE's kaction.h * ***************************************************************************/ #ifndef ACTION_H_ #define ACTION_H_ +#ifndef HAVE_KDE + +#include #include -class Action : public QWidgetAction { - Q_OBJECT +/// A specialized QWidgetAction, enhanced by some KDE features +/** This declares/implements a subset of KAction's API (notably we've left out global shortcuts + * for now), which should make it easy to plug in KDE support later on. + */ +class Action : public QWidgetAction +{ + Q_OBJECT - Q_PROPERTY(QShortcut shortcut READ shortcut WRITE setShortcut); - Q_PROPERTY(bool shortcutConfigurable READ isShortcutConfigurable WRITE setShortcutConfigurable); - Q_FLAGS(ShortcutType); + Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut) + Q_PROPERTY(bool shortcutConfigurable READ isShortcutConfigurable WRITE setShortcutConfigurable) + Q_FLAGS(ShortcutType) - public: - enum ShortcutType { - ActiveShortcut = 0x01, - DefaultShortcut = 0x02 +public : + enum ShortcutType { + ActiveShortcut = 0x01, + DefaultShortcut = 0x02 }; - Q_DECLARE_FLAGS(ShortcutTypes, ShortcutType); + Q_DECLARE_FLAGS(ShortcutTypes, ShortcutType) explicit Action(QObject *parent); - Action(const QString &text, QObject *parent); - Action(const QIcon &icon, const QString &text, QObject *parent); + Action(const QString &text, QObject *parent, const QObject *receiver = 0, const char *slot = 0, const QKeySequence &shortcut = 0); + Action(const QIcon &icon, const QString &text, QObject *parent, const QObject *receiver = 0, const char *slot = 0, const QKeySequence &shortcut = 0); + + QKeySequence shortcut(ShortcutTypes types = ActiveShortcut) const; + void setShortcut(const QShortcut &shortcut, ShortcutTypes type = ShortcutTypes(ActiveShortcut | DefaultShortcut)); + void setShortcut(const QKeySequence &shortcut, ShortcutTypes type = ShortcutTypes(ActiveShortcut | DefaultShortcut)); + + bool isShortcutConfigurable() const; + void setShortcutConfigurable(bool configurable); + +signals: + void triggered(Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers); + +private: + void init(); + +private slots: + void slotTriggered(); +}; - QShortcut shortcut(ShortcutTypes types = ActiveShortcut) const; - void setShortcut(const QShortcut &shortcut, ShortcutTypes type = ActiveShortcut); - void setShortcut(const QKeySequence &shortcut, ShortcutTypes type = ActiveShortcut); +Q_DECLARE_OPERATORS_FOR_FLAGS(Action::ShortcutTypes) + +#else /* HAVE_KDE */ +#include + +class Action : public KAction +{ + Q_OBJECT + +public: + explicit Action(QObject *parent); + Action(const QString &text, QObject *parent, const QObject *receiver = 0, const char *slot = 0, const QKeySequence &shortcut = 0); + Action(const QIcon &icon, const QString &text, QObject *parent, const QObject *receiver = 0, const char *slot = 0, const QKeySequence &shortcut = 0); + +private: + void init(); }; -Q_DECLARE_OPERATORS_FOR_FLAGS(ShortcutTypes); \ No newline at end of file + +#endif + +#endif