kdeui Library API Documentation

kaction.h

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 00010 This library is free software; you can redistribute it and/or 00011 modify it under the terms of the GNU Library General Public 00012 License version 2 as published by the Free Software Foundation. 00013 00014 This library is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 Library General Public License for more details. 00018 00019 You should have received a copy of the GNU Library General Public License 00020 along with this library; see the file COPYING.LIB. If not, write to 00021 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00022 Boston, MA 02111-1307, USA. 00023 */ 00024 //$Id: kaction.h,v 1.188 2005/01/29 19:20:07 johnflux Exp $ 00025 00026 #ifndef __kaction_h__ 00027 #define __kaction_h__ 00028 00029 #include <qkeysequence.h> 00030 #include <qobject.h> 00031 #include <qvaluelist.h> 00032 #include <qguardedptr.h> 00033 #include <kguiitem.h> 00034 #include <kshortcut.h> 00035 #include <kstdaction.h> 00036 #include <kicontheme.h> 00037 00038 class QMenuBar; 00039 class QPopupMenu; 00040 class QComboBox; 00041 class QPoint; 00042 class QIconSet; 00043 class QString; 00044 class KToolBar; 00045 00046 class KAccel; 00047 class KAccelActions; 00048 class KConfig; 00049 class KConfigBase; 00050 class KURL; 00051 class KInstance; 00052 class KToolBar; 00053 class KActionCollection; 00054 class KPopupMenu; 00055 class KMainWindow; 00056 00202 class KDEUI_EXPORT KAction : public QObject 00203 { 00204 friend class KActionCollection; 00205 Q_OBJECT 00206 Q_PROPERTY( int containerCount READ containerCount ) 00207 Q_PROPERTY( QString plainText READ plainText ) 00208 Q_PROPERTY( QString text READ text WRITE setText ) 00209 Q_PROPERTY( QString shortcut READ shortcutText WRITE setShortcutText ) 00210 Q_PROPERTY( bool enabled READ isEnabled WRITE setEnabled ) 00211 Q_PROPERTY( QString group READ group WRITE setGroup ) 00212 Q_PROPERTY( QString whatsThis READ whatsThis WRITE setWhatsThis ) 00213 Q_PROPERTY( QString toolTip READ toolTip WRITE setToolTip ) 00214 Q_PROPERTY( QString icon READ icon WRITE setIcon ) 00215 public: 00236 KAction( const QString& text, const KShortcut& cut, 00237 const QObject* receiver, const char* slot, 00238 KActionCollection* parent, const char* name ); 00239 00259 KAction( const QString& text, const QIconSet& pix, const KShortcut& cut, 00260 const QObject* receiver, const char* slot, 00261 KActionCollection* parent, const char* name ); 00262 00283 KAction( const QString& text, const QString& pix, const KShortcut& cut, 00284 const QObject* receiver, const char* slot, 00285 KActionCollection* parent, const char* name ); 00286 00298 KAction( const KGuiItem& item, const KShortcut& cut, 00299 const QObject* receiver, const char* slot, 00300 KActionCollection* parent, const char* name ); 00301 00305 KAction( const QString& text, const KShortcut& cut = KShortcut(), QObject* parent = 0, const char* name = 0 ); 00309 KAction( const QString& text, const KShortcut& cut, 00310 const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 ); 00314 KAction( const QString& text, const QIconSet& pix, const KShortcut& cut = KShortcut(), 00315 QObject* parent = 0, const char* name = 0 ); 00319 KAction( const QString& text, const QString& pix, const KShortcut& cut = KShortcut(), 00320 QObject* parent = 0, const char* name = 0 ); 00324 KAction( const QString& text, const QIconSet& pix, const KShortcut& cut, 00325 const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 ); 00329 KAction( const QString& text, const QString& pix, const KShortcut& cut, 00330 const QObject* receiver, const char* slot, QObject* parent, 00331 const char* name = 0 ); 00335 KAction( QObject* parent = 0, const char* name = 0 ); 00336 00340 virtual ~KAction(); 00341 00355 virtual int plug( QWidget *widget, int index = -1 ); 00356 00367 virtual void plugAccel(KAccel *accel, bool configurable = true) KDE_DEPRECATED; 00368 00381 virtual void unplug( QWidget *w ); 00382 00387 virtual void unplugAccel() KDE_DEPRECATED; 00388 00393 virtual bool isPlugged() const; 00394 00398 bool isPlugged( const QWidget *container ) const; 00399 00404 virtual bool isPlugged( const QWidget *container, int id ) const; 00405 00410 virtual bool isPlugged( const QWidget *container, const QWidget *_representative ) const; 00411 00412 QWidget* container( int index ) const; 00413 int itemId( int index ) const; 00414 QWidget* representative( int index ) const; 00415 int containerCount() const; 00417 uint kaccelCount() const; 00418 00419 virtual bool hasIcon() const; 00420 #ifndef KDE_NO_COMPAT 00421 bool hasIconSet() const { return hasIcon(); } 00422 #endif 00423 virtual QString plainText() const; 00424 00428 virtual QString text() const; 00429 00433 virtual const KShortcut& shortcut() const; 00437 virtual const KShortcut& shortcutDefault() const; 00438 00439 // These two methods are for Q_PROPERTY 00440 QString shortcutText() const; 00441 void setShortcutText( const QString& ); 00442 00446 virtual bool isEnabled() const; 00447 00451 virtual bool isShortcutConfigurable() const; 00452 00453 virtual QString group() const; 00454 00458 virtual QString whatsThis() const; 00459 00463 virtual QString toolTip() const; 00464 00469 virtual QIconSet iconSet( KIcon::Group group, int size=0 ) const; 00470 #ifndef KDE_NO_COMPAT 00471 QIconSet iconSet() const { return iconSet( KIcon::Small ); } 00472 #endif 00473 00474 virtual QString icon() const; 00475 00476 KActionCollection *parentCollection() const; 00477 00482 static int getToolButtonID(); 00483 00484 00485 void unplugAll(); 00486 00490 enum ActivationReason { UnknownActivation, EmulatedActivation, AccelActivation, PopupMenuActivation, ToolBarActivation }; 00491 00492 public slots: 00497 virtual void setText(const QString &text); 00498 00502 virtual bool setShortcut( const KShortcut& ); 00503 00504 virtual void setGroup( const QString& ); 00505 00513 virtual void setWhatsThis( const QString& text ); 00514 00529 virtual void setToolTip( const QString& ); 00530 00535 virtual void setIconSet( const QIconSet &iconSet ); 00536 00537 virtual void setIcon( const QString& icon ); 00538 00543 virtual void setEnabled(bool enable); 00544 00548 virtual void setShortcutConfigurable( bool ); 00549 00554 virtual void activate(); 00555 00556 protected slots: 00557 virtual void slotDestroyed(); 00558 virtual void slotKeycodeChanged(); 00559 virtual void slotActivated(); 00561 void slotPopupActivated(); // KDE4: make virtual 00563 void slotButtonClicked( int, Qt::ButtonState state ); // KDE4: make virtual 00564 00565 protected: 00566 KToolBar* toolBar( int index ) const; 00567 QPopupMenu* popupMenu( int index ) const; 00568 void removeContainer( int index ); 00569 int findContainer( const QWidget* widget ) const; 00570 int findContainer( int id ) const; 00571 void plugMainWindowAccel( QWidget *w ); 00572 00573 void addContainer( QWidget* parent, int id ); 00574 void addContainer( QWidget* parent, QWidget* representative ); 00575 00576 virtual void updateShortcut( int i ); 00577 virtual void updateShortcut( QPopupMenu* menu, int id ); 00578 virtual void updateGroup( int id ); 00579 virtual void updateText(int i ); 00580 virtual void updateEnabled(int i); 00581 virtual void updateIconSet(int i); 00582 virtual void updateIcon( int i); 00583 virtual void updateToolTip( int id ); 00584 virtual void updateWhatsThis( int i ); 00585 00586 KActionCollection *m_parentCollection; 00587 QString whatsThisWithIcon() const; 00592 const KGuiItem& guiItem() const; 00593 00594 signals: 00598 void activated(); 00613 void activated( KAction::ActivationReason reason, Qt::ButtonState state ); 00614 void enabled( bool ); 00615 00616 private: 00617 void initPrivate( const QString& text, const KShortcut& cut, 00618 const QObject* receiver, const char* slot ); 00619 KAccel* kaccelCurrent(); 00620 bool initShortcut( const KShortcut& ); 00621 void plugShortcut(); 00622 bool updateKAccelShortcut( KAccel* kaccel ); 00623 void insertKAccel( KAccel* ); 00625 void removeKAccel( KAccel* ); 00626 00627 #ifndef KDE_NO_COMPAT 00628 public: 00633 int accel() const KDE_DEPRECATED; 00634 00635 QString statusText() const 00636 { return toolTip(); } 00637 00642 void setAccel( int key ) KDE_DEPRECATED; 00643 00647 void setStatusText( const QString &text ) 00648 { setToolTip( text ); } 00649 00653 int menuId( int i ) { return itemId( i ); } 00654 #endif // !KDE_NO_COMPAT 00655 00656 protected: 00657 virtual void virtual_hook( int id, void* data ); 00658 private: 00659 class KActionPrivate; 00660 KActionPrivate* const d; 00661 }; 00662 00663 #include <kactioncollection.h> 00664 #include <kactionclasses.h> 00665 00666 #endif
KDE Logo
This file is part of the documentation for kdeui Library Version 3.4.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Apr 14 00:10:06 2005 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003