• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDEUI

  • sources
  • kde-4.14
  • kdelibs
  • kdeui
  • actions
kaction.h
Go to the documentation of this file.
1 /* This file is part of the KDE libraries
2  Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org>
3  (C) 1999 Simon Hausmann <hausmann@kde.org>
4  (C) 2000 Nicolas Hadacek <haadcek@kde.org>
5  (C) 2000 Kurt Granroth <granroth@kde.org>
6  (C) 2000 Michael Koch <koch@kde.org>
7  (C) 2001 Holger Freyther <freyther@kde.org>
8  (C) 2002 Ellis Whitehead <ellis@kde.org>
9  (C) 2005-2006 Hamish Rodda <rodda@kde.org>
10 
11  This library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU Library General Public
13  License version 2 as published by the Free Software Foundation.
14 
15  This library is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Library General Public License for more details.
19 
20  You should have received a copy of the GNU Library General Public License
21  along with this library; see the file COPYING.LIB. If not, write to
22  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23  Boston, MA 02110-1301, USA.
24 */
25 
26 #ifndef KACTION_H
27 #define KACTION_H
28 
29 #include <kdeui_export.h>
30 #include <kguiitem.h>
31 #include <kshortcut.h>
32 
33 #include <QtGui/QWidgetAction>
34 
35 class KIcon;
36 class KShapeGesture;
37 class KRockerGesture;
38 
39 namespace KAuth {
40  class Action;
41 }
42 
43 //TODO Reduce the word count. This is not very focused and takes too long to read.
44 //Keep in mind that QAction also has documentation that we don't need to repeat here.
216 class KDEUI_EXPORT KAction : public QWidgetAction
217 {
218  Q_OBJECT
219 
220  Q_PROPERTY( KShortcut shortcut READ shortcut WRITE setShortcut )
221  Q_PROPERTY( bool shortcutConfigurable READ isShortcutConfigurable WRITE setShortcutConfigurable )
222  Q_PROPERTY( KShortcut globalShortcut READ globalShortcut WRITE setGlobalShortcut )
223 #ifndef KDE_NO_DEPRECATED
224  Q_PROPERTY( bool globalShortcutAllowed READ globalShortcutAllowed WRITE setGlobalShortcutAllowed )
225 #endif
226  Q_PROPERTY( bool globalShortcutEnabled READ isGlobalShortcutEnabled )
227  Q_FLAGS( ShortcutType )
228 
229 public:
233  enum ShortcutType {
235  ActiveShortcut = 0x1,
238  DefaultShortcut = 0x2
239  };
240  Q_DECLARE_FLAGS(ShortcutTypes, ShortcutType)
241 
242 
245  //This enum will be ORed with ShortcutType in calls to KGlobalAccel, so it must not contain
246  //any value equal to a value in ShortcutType.
247  enum GlobalShortcutLoading {
251  Autoloading = 0x0,
253  NoAutoloading = 0x4
254  };
258  explicit KAction(QObject *parent);
259 
266  KAction(const QString& text, QObject *parent);
267 
279  KAction(const KIcon& icon, const QString& text, QObject *parent);
280 
284  virtual ~KAction();
285 
303  void setHelpText(const QString& text);
304 
316  KShortcut shortcut(ShortcutTypes types = ActiveShortcut) const;
317 
328  void setShortcut(const KShortcut& shortcut, ShortcutTypes type = ShortcutTypes(ActiveShortcut | DefaultShortcut));
329 
342  void setShortcut(const QKeySequence& shortcut, ShortcutTypes type = ShortcutTypes(ActiveShortcut | DefaultShortcut));
343 
356  void setShortcuts(const QList<QKeySequence>& shortcuts, ShortcutTypes type = ShortcutTypes(ActiveShortcut | DefaultShortcut));
357 
361  bool isShortcutConfigurable() const;
362 
368  void setShortcutConfigurable(bool configurable);
369 
383  const KShortcut& globalShortcut(ShortcutTypes type = ActiveShortcut) const;
384 
421  void setGlobalShortcut(const KShortcut& shortcut, ShortcutTypes type =
422  ShortcutTypes(ActiveShortcut | DefaultShortcut),
423  GlobalShortcutLoading loading = Autoloading);
424 
430 #ifndef KDE_NO_DEPRECATED
431  KDE_DEPRECATED bool globalShortcutAllowed() const;
432 #endif
433 
442 #ifndef KDE_NO_DEPRECATED
443  KDE_DEPRECATED void setGlobalShortcutAllowed(bool allowed, GlobalShortcutLoading loading = Autoloading);
444 #endif
445 
451  bool isGlobalShortcutEnabled() const;
452 
462  void forgetGlobalShortcut();
463 
464  KShapeGesture shapeGesture(ShortcutTypes type = ActiveShortcut) const;
465  KRockerGesture rockerGesture(ShortcutTypes type = ActiveShortcut) const;
466 
467  void setShapeGesture(const KShapeGesture& gest, ShortcutTypes type = ShortcutTypes(ActiveShortcut | DefaultShortcut));
468  void setRockerGesture(const KRockerGesture& gest, ShortcutTypes type = ShortcutTypes(ActiveShortcut | DefaultShortcut));
469 
475  KAuth::Action *authAction() const;
476 
487  void setAuthAction(KAuth::Action *action);
488 
496  void setAuthAction(const QString &actionName);
497 
501  bool event(QEvent*);
502 
503 
504 Q_SIGNALS:
505 #ifdef KDE3_SUPPORT
506 
511  QT_MOC_COMPAT void activated();
512 #endif
513 
518  void triggered(Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
519 
535  void authorized(KAuth::Action *action);
536 
541  void globalShortcutChanged(const QKeySequence&);
542 
543 private:
544  friend class KGlobalAccelPrivate; // Needs access to the component
545  friend class KActionCollectionPrivate; // Needs access to the component
546  friend class KShortcutsEditorDelegate; // Needs access to the component
547  Q_PRIVATE_SLOT(d, void slotTriggered())
548  Q_PRIVATE_SLOT(d, void authStatusChanged(int))
549  class KActionPrivate* const d;
550  friend class KActionPrivate;
551  friend class KGlobalShortcutTest;
552 };
553 
554 Q_DECLARE_OPERATORS_FOR_FLAGS(KAction::ShortcutTypes)
555 
556 #endif
QEvent
QAction::triggered
void triggered(bool checked)
KAction::ShortcutType
ShortcutType
An enumeration about the two types of shortcuts in a KAction.
Definition: kaction.h:233
QAction::activated
void activated(int i)
KRockerGesture
Definition: kgesture.h:152
KStandardShortcut::shortcut
const KShortcut & shortcut(StandardShortcut id)
Returns the keybinding for accel.
Definition: kstandardshortcut.cpp:285
kshortcut.h
Defines platform-independent classes for keyboard shortcut handling.
KShortcut
Represents a keyboard shortcut.
Definition: kshortcut.h:57
QAction::setShortcuts
void setShortcuts(const QList< QKeySequence > &shortcuts)
QWidgetAction
QObject
KIcon
A wrapper around QIcon that provides KDE icon features.
Definition: kicon.h:40
QString
QList
Action
QAction::shortcut
QKeySequence shortcut() const
Qt::MouseButtons
typedef MouseButtons
QKeySequence
KShapeGesture
Definition: kgesture.h:37
KAction
Class to encapsulate user-driven action or event.
Definition: kaction.h:216
kdeui_export.h
QWidgetAction::event
virtual bool event(QEvent *event)
KAuth::Action
kguiitem.h
KAction::GlobalShortcutLoading
GlobalShortcutLoading
An enum about global shortcut setter semantics.
Definition: kaction.h:247
Qt::KeyboardModifiers
typedef KeyboardModifiers
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:23:58 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal