• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

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 
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., 51 Franklin Street, Fifth Floor,
00022     Boston, MA 02110-1301, USA.
00023 */
00024 //$Id: kaction.h 465272 2005-09-29 09:47:40Z mueller $
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 
00472     virtual QIconSet iconSet( KIcon::Group group, int size=0 ) const;
00476     QIconSet iconSet() const { return iconSet( KIcon::Small ); }
00477 
00478     virtual QString icon() const;
00479 
00480     KActionCollection *parentCollection() const;
00481 
00486     static int getToolButtonID();
00487 
00488 
00489     void unplugAll();
00490 
00494     enum ActivationReason { UnknownActivation, EmulatedActivation, AccelActivation, PopupMenuActivation, ToolBarActivation };
00495 
00496 public slots:
00501     virtual void setText(const QString &text);
00502 
00506     virtual bool setShortcut( const KShortcut& );
00507 
00508     virtual void setGroup( const QString& );
00509 
00517     virtual void setWhatsThis( const QString& text );
00518 
00533     virtual void setToolTip( const QString& );
00534 
00539     virtual void setIconSet( const QIconSet &iconSet );
00540 
00541     virtual void setIcon( const QString& icon );
00542 
00547     virtual void setEnabled(bool enable);
00548 
00553     void setDisabled(bool disable) { return setEnabled(!disable); }
00554 
00558     virtual void setShortcutConfigurable( bool );
00559 
00564     virtual void activate();
00565 
00566 protected slots:
00567     virtual void slotDestroyed();
00568     virtual void slotKeycodeChanged();
00569     virtual void slotActivated();
00571     void slotPopupActivated(); // KDE4: make virtual
00573     void slotButtonClicked( int, Qt::ButtonState state ); // KDE4: make virtual
00574 
00575 protected:
00576     KToolBar* toolBar( int index ) const;
00577     QPopupMenu* popupMenu( int index ) const;
00578     void removeContainer( int index );
00579     int findContainer( const QWidget* widget ) const;
00580     int findContainer( int id ) const;
00581     void plugMainWindowAccel( QWidget *w );
00582 
00583     void addContainer( QWidget* parent, int id );
00584     void addContainer( QWidget* parent, QWidget* representative );
00585 
00586     virtual void updateShortcut( int i );
00587     virtual void updateShortcut( QPopupMenu* menu, int id );
00588     virtual void updateGroup( int id );
00589     virtual void updateText(int i );
00590     virtual void updateEnabled(int i);
00591     virtual void updateIconSet(int i);
00592     virtual void updateIcon( int i);
00593     virtual void updateToolTip( int id );
00594     virtual void updateWhatsThis( int i );
00595 
00596     KActionCollection *m_parentCollection;
00597     QString whatsThisWithIcon() const;
00602     const KGuiItem& guiItem() const;
00603 
00604 signals:
00608     void activated();
00623     void activated( KAction::ActivationReason reason, Qt::ButtonState state );
00624     void enabled( bool );
00625 
00626 private:
00627     void initPrivate( const QString& text, const KShortcut& cut,
00628                   const QObject* receiver, const char* slot );
00629     KAccel* kaccelCurrent();
00630     bool initShortcut( const KShortcut& );
00631     void plugShortcut();
00632     bool updateKAccelShortcut( KAccel* kaccel );
00633     void insertKAccel( KAccel* );
00635     void removeKAccel( KAccel* );
00636 
00637 #ifndef KDE_NO_COMPAT
00638 public:
00643     int accel() const KDE_DEPRECATED;
00644 
00645     QString statusText() const
00646         { return toolTip(); }
00647 
00652     void setAccel( int key ) KDE_DEPRECATED;
00653 
00657     void setStatusText( const QString &text )
00658          { setToolTip( text ); }
00659 
00663     int menuId( int i ) { return itemId( i ); }
00664 #endif // !KDE_NO_COMPAT
00665 
00666 protected:
00667     virtual void virtual_hook( int id, void* data );
00668 private:
00669     class KActionPrivate;
00670     KActionPrivate* const d;
00671 };
00672 
00673 #include <kactioncollection.h>
00674 #include <kactionclasses.h>
00675 
00676 #endif

kdeui

Skip menu "kdeui"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal