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.178 2003/10/07 22:53:26 mueller 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 #include <kdemacros.h>
00038 
00039 class QMenuBar;
00040 class QPopupMenu;
00041 class QComboBox;
00042 class QPoint;
00043 class QIconSet;
00044 class QString;
00045 class KToolBar;
00046 
00047 class KAccel;
00048 class KAccelActions;
00049 class KConfig;
00050 class KConfigBase;
00051 class KURL;
00052 class KInstance;
00053 class KToolBar;
00054 class KActionCollection;
00055 class KPopupMenu;
00056 class KMainWindow;
00057 
00203 class KAction : public QObject
00204 {
00205   friend class KActionCollection;
00206   Q_OBJECT
00207   Q_PROPERTY( int containerCount READ containerCount )
00208   Q_PROPERTY( QString plainText READ plainText )
00209   Q_PROPERTY( QString text READ text WRITE setText )
00210   Q_PROPERTY( QString shortcut READ shortcutText WRITE setShortcutText )
00211   Q_PROPERTY( bool enabled READ isEnabled WRITE setEnabled )
00212   Q_PROPERTY( QString group READ group WRITE setGroup )
00213   Q_PROPERTY( QString whatsThis READ whatsThis WRITE setWhatsThis )
00214   Q_PROPERTY( QString toolTip READ toolTip WRITE setToolTip )
00215   Q_PROPERTY( QString icon READ icon WRITE setIcon )
00216 public:
00237     KAction( const QString& text, const KShortcut& cut,
00238              const QObject* receiver, const char* slot,
00239              KActionCollection* parent, const char* name );
00240 
00260     KAction( const QString& text, const QIconSet& pix, const KShortcut& cut,
00261              const QObject* receiver, const char* slot,
00262              KActionCollection* parent, const char* name );
00263 
00284     KAction( const QString& text, const QString& pix, const KShortcut& cut,
00285              const QObject* receiver, const char* slot,
00286              KActionCollection* parent, const char* name );
00287 
00299     KAction( const KGuiItem& item, const KShortcut& cut,
00300              const QObject* receiver, const char* slot,
00301              KActionCollection* parent, const char* name );
00302 
00306     KAction( const QString& text, const KShortcut& cut = KShortcut(), QObject* parent = 0, const char* name = 0 );
00310     KAction( const QString& text, const KShortcut& cut,
00311         const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 );
00315     KAction( const QString& text, const QIconSet& pix, const KShortcut& cut = KShortcut(),
00316         QObject* parent = 0, const char* name = 0 );
00320     KAction( const QString& text, const QString& pix, const KShortcut& cut = KShortcut(),
00321         QObject* parent = 0, const char* name = 0 );
00325     KAction( const QString& text, const QIconSet& pix, const KShortcut& cut,
00326         const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 );
00330     KAction( const QString& text, const QString& pix, const KShortcut& cut,
00331         const QObject* receiver, const char* slot, QObject* parent,
00332         const char* name = 0 );
00336     KAction( QObject* parent = 0, const char* name = 0 );
00337 
00341     virtual ~KAction();
00342 
00356     virtual int plug( QWidget *widget, int index = -1 );
00357 
00368     virtual void plugAccel(KAccel *accel, bool configurable = true) KDE_DEPRECATED;
00369 
00382     virtual void unplug( QWidget *w );
00383 
00388     virtual void unplugAccel() KDE_DEPRECATED;
00389 
00394     virtual bool isPlugged() const;
00395 
00399     bool isPlugged( const QWidget *container ) const;
00400 
00405     virtual bool isPlugged( const QWidget *container, int id ) const;
00406 
00411     virtual bool isPlugged( const QWidget *container, const QWidget *_representative ) const;
00412 
00413     QWidget* container( int index ) const;
00414     int itemId( int index ) const;
00415     QWidget* representative( int index ) const;
00416     int containerCount() const;
00418     uint kaccelCount() const;
00419 
00420     virtual bool hasIcon() const;
00421 #ifndef KDE_NO_COMPAT
00422     bool hasIconSet() const { return hasIcon(); }
00423 #endif
00424     virtual QString plainText() const;
00425 
00429     virtual QString text() const;
00430 
00434     virtual const KShortcut& shortcut() const;
00438     virtual const KShortcut& shortcutDefault() const;
00439 
00440     // These two methods are for Q_PROPERTY
00441     QString shortcutText() const;
00442     void setShortcutText( const QString& );
00443 
00447     virtual bool isEnabled() const;
00448 
00452     virtual bool isShortcutConfigurable() const;
00453 
00454     virtual QString group() const;
00455 
00459     virtual QString whatsThis() const;
00460 
00464     virtual QString toolTip() const;
00465 
00470     virtual QIconSet iconSet( KIcon::Group group, int size=0 ) const;
00471 #ifndef KDE_NO_COMPAT
00472     QIconSet iconSet() const { return iconSet( KIcon::Small ); }
00473 #endif
00474 
00475     virtual QString icon() const;
00476 
00477     KActionCollection *parentCollection() const;
00478 
00483     static int getToolButtonID();
00484 
00485 
00486     void unplugAll();
00487 
00488 public slots:
00493     virtual void setText(const QString &text);
00494 
00498     virtual bool setShortcut( const KShortcut& );
00499 
00500     virtual void setGroup( const QString& );
00501 
00509     virtual void setWhatsThis( const QString& text );
00510 
00517     virtual void setToolTip( const QString& );
00518 
00523     virtual void setIconSet( const QIconSet &iconSet );
00524 
00525     virtual void setIcon( const QString& icon );
00526 
00531     virtual void setEnabled(bool enable);
00532 
00536     virtual void setShortcutConfigurable( bool );
00537 
00542     virtual void activate();
00543 
00544 protected slots:
00545     virtual void slotDestroyed();
00546     virtual void slotKeycodeChanged();
00547     virtual void slotActivated();
00548 
00549 protected:
00550     KToolBar* toolBar( int index ) const;
00551     QPopupMenu* popupMenu( int index ) const;
00552     void removeContainer( int index );
00553     int findContainer( const QWidget* widget ) const;
00554     void plugMainWindowAccel( QWidget *w );
00555 
00556     void addContainer( QWidget* parent, int id );
00557     void addContainer( QWidget* parent, QWidget* representative );
00558 
00559     virtual void updateShortcut( int i );
00560     virtual void updateShortcut( QPopupMenu* menu, int id );
00561     virtual void updateGroup( int id );
00562     virtual void updateText(int i );
00563     virtual void updateEnabled(int i);
00564     virtual void updateIconSet(int i);
00565     virtual void updateIcon( int i);
00566     virtual void updateToolTip( int id );
00567     virtual void updateWhatsThis( int i );
00568 
00569     KActionCollection *m_parentCollection;
00570     QString whatsThisWithIcon() const;
00571 
00572 signals:
00573     void activated();
00574     void enabled( bool );
00575 
00576 private:
00577     void initPrivate( const QString& text, const KShortcut& cut,
00578                   const QObject* receiver, const char* slot );
00579     KAccel* kaccelCurrent();
00580     bool initShortcut( const KShortcut& );
00581     void plugShortcut();
00582     bool updateKAccelShortcut( KAccel* kaccel );
00583     void insertKAccel( KAccel* );
00585     void removeKAccel( KAccel* );
00586 
00587 #ifndef KDE_NO_COMPAT
00588 public:
00593     int accel() const KDE_DEPRECATED;
00594 
00595     QString statusText() const
00596         { return toolTip(); }
00597 
00602     void setAccel( int key ) KDE_DEPRECATED;
00603 
00607     void setStatusText( const QString &text )
00608          { setToolTip( text ); }
00609 
00613     int menuId( int i ) { return itemId( i ); }
00614 #endif // !KDE_NO_COMPAT
00615 
00616 protected:
00617     virtual void virtual_hook( int id, void* data );
00618 private:
00619     class KActionPrivate;
00620     KActionPrivate *d;
00621 };
00622 
00623 #include <kactioncollection.h>
00624 #include <kactionclasses.h>
00625 
00626 #endif
KDE Logo
This file is part of the documentation for kdeui Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sun May 16 22:01:56 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003