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.187 2004/12/20 01:59:43 bmeyer 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 
00487 public slots:
00492     virtual void setText(const QString &text);
00493 
00497     virtual bool setShortcut( const KShortcut& );
00498 
00499     virtual void setGroup( const QString& );
00500 
00508     virtual void setWhatsThis( const QString& text );
00509 
00516     virtual void setToolTip( const QString& );
00517 
00522     virtual void setIconSet( const QIconSet &iconSet );
00523 
00524     virtual void setIcon( const QString& icon );
00525 
00530     virtual void setEnabled(bool enable);
00531 
00535     virtual void setShortcutConfigurable( bool );
00536 
00541     virtual void activate();
00542 
00543 protected slots:
00544     virtual void slotDestroyed();
00545     virtual void slotKeycodeChanged();
00546     virtual void slotActivated();
00547 
00548 protected:
00549     KToolBar* toolBar( int index ) const;
00550     QPopupMenu* popupMenu( int index ) const;
00551     void removeContainer( int index );
00552     int findContainer( const QWidget* widget ) const;
00553     void plugMainWindowAccel( QWidget *w );
00554 
00555     void addContainer( QWidget* parent, int id );
00556     void addContainer( QWidget* parent, QWidget* representative );
00557 
00558     virtual void updateShortcut( int i );
00559     virtual void updateShortcut( QPopupMenu* menu, int id );
00560     virtual void updateGroup( int id );
00561     virtual void updateText(int i );
00562     virtual void updateEnabled(int i);
00563     virtual void updateIconSet(int i);
00564     virtual void updateIcon( int i);
00565     virtual void updateToolTip( int id );
00566     virtual void updateWhatsThis( int i );
00567 
00568     KActionCollection *m_parentCollection;
00569     QString whatsThisWithIcon() const;
00574     const KGuiItem& guiItem() const;
00575 
00576 signals:
00580     void activated();
00581     void enabled( bool );
00582 
00583 private:
00584     void initPrivate( const QString& text, const KShortcut& cut,
00585                   const QObject* receiver, const char* slot );
00586     KAccel* kaccelCurrent();
00587     bool initShortcut( const KShortcut& );
00588     void plugShortcut();
00589     bool updateKAccelShortcut( KAccel* kaccel );
00590     void insertKAccel( KAccel* );
00592     void removeKAccel( KAccel* );
00593 
00594 #ifndef KDE_NO_COMPAT
00595 public:
00600     int accel() const KDE_DEPRECATED;
00601 
00602     QString statusText() const
00603         { return toolTip(); }
00604 
00609     void setAccel( int key ) KDE_DEPRECATED;
00610 
00614     void setStatusText( const QString &text )
00615          { setToolTip( text ); }
00616 
00620     int menuId( int i ) { return itemId( i ); }
00621 #endif // !KDE_NO_COMPAT
00622 
00623 protected:
00624     virtual void virtual_hook( int id, void* data );
00625 private:
00626     class KActionPrivate;
00627     KActionPrivate* d;
00628 };
00629 
00630 #include <kactioncollection.h>
00631 #include <kactionclasses.h>
00632 
00633 #endif
KDE Logo
This file is part of the documentation for kdeui Library Version 3.3.90.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 30 10:11:58 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003