PageRenderTime 49ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/quassel-0.7.3/src/uisupport/action.h

#
C Header | 88 lines | 45 code | 18 blank | 25 comment | 0 complexity | 0146868f0f33c4fcd7b9f3422b7fb329 MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0
  1. /***************************************************************************
  2. * Copyright (C) 2005-09 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. * Parts of this API have been shamelessly stolen from KDE's kaction.h *
  21. ***************************************************************************/
  22. #ifndef ACTION_H_
  23. #define ACTION_H_
  24. #ifndef HAVE_KDE
  25. #include <QShortcut>
  26. #include <QWidgetAction>
  27. /// A specialized QWidgetAction, enhanced by some KDE features
  28. /** This declares/implements a subset of KAction's API (notably we've left out global shortcuts
  29. * for now), which should make it easy to plug in KDE support later on.
  30. */
  31. class Action : public QWidgetAction {
  32. Q_OBJECT
  33. Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut)
  34. Q_PROPERTY(bool shortcutConfigurable READ isShortcutConfigurable WRITE setShortcutConfigurable)
  35. Q_FLAGS(ShortcutType)
  36. public:
  37. enum ShortcutType {
  38. ActiveShortcut = 0x01,
  39. DefaultShortcut = 0x02
  40. };
  41. Q_DECLARE_FLAGS(ShortcutTypes, ShortcutType)
  42. explicit Action(QObject *parent);
  43. Action(const QString &text, QObject *parent, const QObject *receiver = 0, const char *slot = 0, const QKeySequence &shortcut = 0);
  44. Action(const QIcon &icon, const QString &text, QObject *parent, const QObject *receiver = 0, const char *slot = 0, const QKeySequence &shortcut = 0);
  45. QKeySequence shortcut(ShortcutTypes types = ActiveShortcut) const;
  46. void setShortcut(const QShortcut &shortcut, ShortcutTypes type = ShortcutTypes(ActiveShortcut | DefaultShortcut));
  47. void setShortcut(const QKeySequence &shortcut, ShortcutTypes type = ShortcutTypes(ActiveShortcut | DefaultShortcut));
  48. bool isShortcutConfigurable() const;
  49. void setShortcutConfigurable(bool configurable);
  50. signals:
  51. void triggered(Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
  52. private:
  53. void init();
  54. private slots:
  55. void slotTriggered();
  56. };
  57. Q_DECLARE_OPERATORS_FOR_FLAGS(Action::ShortcutTypes)
  58. #else /* HAVE_KDE */
  59. #include <KAction>
  60. class Action : public KAction {
  61. Q_OBJECT
  62. public:
  63. explicit Action(QObject *parent);
  64. Action(const QString &text, QObject *parent, const QObject *receiver = 0, const char *slot = 0, const QKeySequence &shortcut = 0);
  65. Action(const QIcon &icon, const QString &text, QObject *parent, const QObject *receiver = 0, const char *slot = 0, const QKeySequence &shortcut = 0);
  66. private:
  67. void init();
  68. };
  69. #endif
  70. #endif