KDEUI
kaction.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef KACTION_H
00027 #define KACTION_H
00028
00029 #include <kdeui_export.h>
00030 #include <kguiitem.h>
00031 #include <kshortcut.h>
00032
00033 #include <QtGui/QWidgetAction>
00034
00035 class KIcon;
00036 class KShapeGesture;
00037 class KRockerGesture;
00038
00039 namespace KAuth {
00040 class Action;
00041 }
00042
00043
00044
00216 class KDEUI_EXPORT KAction : public QWidgetAction
00217 {
00218 Q_OBJECT
00219
00220 Q_PROPERTY( KShortcut shortcut READ shortcut WRITE setShortcut )
00221 Q_PROPERTY( bool shortcutConfigurable READ isShortcutConfigurable WRITE setShortcutConfigurable )
00222 Q_PROPERTY( KShortcut globalShortcut READ globalShortcut WRITE setGlobalShortcut )
00223 Q_PROPERTY( bool globalShortcutAllowed READ globalShortcutAllowed WRITE setGlobalShortcutAllowed )
00224 Q_PROPERTY( bool globalShortcutEnabled READ isGlobalShortcutEnabled )
00225 Q_FLAGS( ShortcutType )
00226
00227 public:
00231 enum ShortcutType {
00233 ActiveShortcut = 0x1,
00236 DefaultShortcut = 0x2
00237 };
00238 Q_DECLARE_FLAGS(ShortcutTypes, ShortcutType)
00239
00240
00243
00244
00245 enum GlobalShortcutLoading {
00249 Autoloading = 0x0,
00251 NoAutoloading = 0x4
00252 };
00256 explicit KAction(QObject *parent);
00257
00264 KAction(const QString& text, QObject *parent);
00265
00277 KAction(const KIcon& icon, const QString& text, QObject *parent);
00278
00282 virtual ~KAction();
00283
00301 void setHelpText(const QString& text);
00302
00314 KShortcut shortcut(ShortcutTypes types = ActiveShortcut) const;
00315
00326 void setShortcut(const KShortcut& shortcut, ShortcutTypes type = ShortcutTypes(ActiveShortcut | DefaultShortcut));
00327
00340 void setShortcut(const QKeySequence& shortcut, ShortcutTypes type = ShortcutTypes(ActiveShortcut | DefaultShortcut));
00341
00354 void setShortcuts(const QList<QKeySequence>& shortcuts, ShortcutTypes type = ShortcutTypes(ActiveShortcut | DefaultShortcut));
00355
00359 bool isShortcutConfigurable() const;
00360
00366 void setShortcutConfigurable(bool configurable);
00367
00381 const KShortcut& globalShortcut(ShortcutTypes type = ActiveShortcut) const;
00382
00419 void setGlobalShortcut(const KShortcut& shortcut, ShortcutTypes type =
00420 ShortcutTypes(ActiveShortcut | DefaultShortcut),
00421 GlobalShortcutLoading loading = Autoloading);
00422
00428 KDE_DEPRECATED bool globalShortcutAllowed() const;
00429
00438 KDE_DEPRECATED void setGlobalShortcutAllowed(bool allowed, GlobalShortcutLoading loading = Autoloading);
00439
00445 bool isGlobalShortcutEnabled() const;
00446
00456 void forgetGlobalShortcut();
00457
00458 KShapeGesture shapeGesture(ShortcutTypes type = ActiveShortcut) const;
00459 KRockerGesture rockerGesture(ShortcutTypes type = ActiveShortcut) const;
00460
00461 void setShapeGesture(const KShapeGesture& gest, ShortcutTypes type = ShortcutTypes(ActiveShortcut | DefaultShortcut));
00462 void setRockerGesture(const KRockerGesture& gest, ShortcutTypes type = ShortcutTypes(ActiveShortcut | DefaultShortcut));
00463
00469 KAuth::Action *authAction() const;
00470
00481 void setAuthAction(KAuth::Action *action);
00482
00490 void setAuthAction(const QString &actionName);
00491
00495 bool event(QEvent*);
00496
00497
00498 Q_SIGNALS:
00499 #ifdef KDE3_SUPPORT
00500
00505 QT_MOC_COMPAT void activated();
00506 #endif
00507
00512 void triggered(Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
00513
00529 void authorized(KAuth::Action *action);
00530
00535 void globalShortcutChanged(const QKeySequence&);
00536
00537 private:
00538 friend class KGlobalAccelPrivate;
00539 friend class KActionCollectionPrivate;
00540 friend class KShortcutsEditorDelegate;
00541 Q_PRIVATE_SLOT(d, void slotTriggered())
00542 Q_PRIVATE_SLOT(d, void authStatusChanged(int))
00543 class KActionPrivate* const d;
00544 friend class KActionPrivate;
00545 friend class KGlobalShortcutTest;
00546 };
00547
00548 Q_DECLARE_OPERATORS_FOR_FLAGS(KAction::ShortcutTypes)
00549
00550 #endif