KDEUI
kaction.h
Go to the documentation of this file.
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org> 00003 (C) 1999 Simon Hausmann <hausmann@kde.org> 00004 (C) 2000 Nicolas Hadacek <haadcek@kde.org> 00005 (C) 2000 Kurt Granroth <granroth@kde.org> 00006 (C) 2000 Michael Koch <koch@kde.org> 00007 (C) 2001 Holger Freyther <freyther@kde.org> 00008 (C) 2002 Ellis Whitehead <ellis@kde.org> 00009 (C) 2005-2006 Hamish Rodda <rodda@kde.org> 00010 00011 This library is free software; you can redistribute it and/or 00012 modify it under the terms of the GNU Library General Public 00013 License version 2 as published by the Free Software Foundation. 00014 00015 This library is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 Library General Public License for more details. 00019 00020 You should have received a copy of the GNU Library General Public License 00021 along with this library; see the file COPYING.LIB. If not, write to 00022 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00023 Boston, MA 02110-1301, USA. 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 //TODO Reduce the word count. This is not very focused and takes too long to read. 00044 //Keep in mind that QAction also has documentation that we don't need to repeat here. 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 #ifndef KDE_NO_DEPRECATED 00224 Q_PROPERTY( bool globalShortcutAllowed READ globalShortcutAllowed WRITE setGlobalShortcutAllowed ) 00225 #endif 00226 Q_PROPERTY( bool globalShortcutEnabled READ isGlobalShortcutEnabled ) 00227 Q_FLAGS( ShortcutType ) 00228 00229 public: 00233 enum ShortcutType { 00235 ActiveShortcut = 0x1, 00238 DefaultShortcut = 0x2 00239 }; 00240 Q_DECLARE_FLAGS(ShortcutTypes, ShortcutType) 00241 00242 00245 //This enum will be ORed with ShortcutType in calls to KGlobalAccel, so it must not contain 00246 //any value equal to a value in ShortcutType. 00247 enum GlobalShortcutLoading { 00251 Autoloading = 0x0, 00253 NoAutoloading = 0x4 00254 }; 00258 explicit KAction(QObject *parent); 00259 00266 KAction(const QString& text, QObject *parent); 00267 00279 KAction(const KIcon& icon, const QString& text, QObject *parent); 00280 00284 virtual ~KAction(); 00285 00303 void setHelpText(const QString& text); 00304 00316 KShortcut shortcut(ShortcutTypes types = ActiveShortcut) const; 00317 00328 void setShortcut(const KShortcut& shortcut, ShortcutTypes type = ShortcutTypes(ActiveShortcut | DefaultShortcut)); 00329 00342 void setShortcut(const QKeySequence& shortcut, ShortcutTypes type = ShortcutTypes(ActiveShortcut | DefaultShortcut)); 00343 00356 void setShortcuts(const QList<QKeySequence>& shortcuts, ShortcutTypes type = ShortcutTypes(ActiveShortcut | DefaultShortcut)); 00357 00361 bool isShortcutConfigurable() const; 00362 00368 void setShortcutConfigurable(bool configurable); 00369 00383 const KShortcut& globalShortcut(ShortcutTypes type = ActiveShortcut) const; 00384 00421 void setGlobalShortcut(const KShortcut& shortcut, ShortcutTypes type = 00422 ShortcutTypes(ActiveShortcut | DefaultShortcut), 00423 GlobalShortcutLoading loading = Autoloading); 00424 00430 #ifndef KDE_NO_DEPRECATED 00431 KDE_DEPRECATED bool globalShortcutAllowed() const; 00432 #endif 00433 00442 #ifndef KDE_NO_DEPRECATED 00443 KDE_DEPRECATED void setGlobalShortcutAllowed(bool allowed, GlobalShortcutLoading loading = Autoloading); 00444 #endif 00445 00451 bool isGlobalShortcutEnabled() const; 00452 00462 void forgetGlobalShortcut(); 00463 00464 KShapeGesture shapeGesture(ShortcutTypes type = ActiveShortcut) const; 00465 KRockerGesture rockerGesture(ShortcutTypes type = ActiveShortcut) const; 00466 00467 void setShapeGesture(const KShapeGesture& gest, ShortcutTypes type = ShortcutTypes(ActiveShortcut | DefaultShortcut)); 00468 void setRockerGesture(const KRockerGesture& gest, ShortcutTypes type = ShortcutTypes(ActiveShortcut | DefaultShortcut)); 00469 00475 KAuth::Action *authAction() const; 00476 00487 void setAuthAction(KAuth::Action *action); 00488 00496 void setAuthAction(const QString &actionName); 00497 00501 bool event(QEvent*); 00502 00503 00504 Q_SIGNALS: 00505 #ifdef KDE3_SUPPORT 00506 00511 QT_MOC_COMPAT void activated(); 00512 #endif 00513 00518 void triggered(Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers); 00519 00535 void authorized(KAuth::Action *action); 00536 00541 void globalShortcutChanged(const QKeySequence&); 00542 00543 private: 00544 friend class KGlobalAccelPrivate; // Needs access to the component 00545 friend class KActionCollectionPrivate; // Needs access to the component 00546 friend class KShortcutsEditorDelegate; // Needs access to the component 00547 Q_PRIVATE_SLOT(d, void slotTriggered()) 00548 Q_PRIVATE_SLOT(d, void authStatusChanged(int)) 00549 class KActionPrivate* const d; 00550 friend class KActionPrivate; 00551 friend class KGlobalShortcutTest; 00552 }; 00553 00554 Q_DECLARE_OPERATORS_FOR_FLAGS(KAction::ShortcutTypes) 00555 00556 #endif
KDE 4.6 API Reference