X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Faction.h;h=378d45da177b2703bdc24df511c69930483f59e6;hp=8748ae9a1a18ad6482ffedaaf6ac6e14a5128f74;hb=952da9aeecc6c778a7c3cd62b1ecfdc13b24bc8b;hpb=41dd93ccb2696dced0e27e213ee7a3a75c9044a8 diff --git a/src/uisupport/action.h b/src/uisupport/action.h index 8748ae9a..378d45da 100644 --- a/src/uisupport/action.h +++ b/src/uisupport/action.h @@ -16,17 +16,24 @@ * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + *************************************************************************** + * Parts of this API have been shamelessly stolen from KDE's kaction.h * ***************************************************************************/ #ifndef ACTION_H_ #define ACTION_H_ +#include #include +/// 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(QKeySequence shortcut READ shortcut WRITE setShortcut) Q_PROPERTY(bool shortcutConfigurable READ isShortcutConfigurable WRITE setShortcutConfigurable) Q_FLAGS(ShortcutType) @@ -41,10 +48,23 @@ class Action : public QWidgetAction { Action(const QString &text, QObject *parent); Action(const QIcon &icon, const QString &text, QObject *parent); - QShortcut shortcut(ShortcutTypes types = ActiveShortcut) const; - void setShortcut(const QShortcut &shortcut, ShortcutTypes type = ActiveShortcut); - void setShortcut(const QKeySequence &shortcut, ShortcutTypes type = ActiveShortcut); + 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(); }; -Q_DECLARE_OPERATORS_FOR_FLAGS(ShortcutTypes) +Q_DECLARE_OPERATORS_FOR_FLAGS(Action::ShortcutTypes) + +#endif