kaction.h
/* This file is part of the KDE libraries
Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org>
(C) 1999 Simon Hausmann <hausmann@kde.org>
(C) 2000 Nicolas Hadacek <haadcek@kde.org>
(C) 2000 Kurt Granroth <granroth@kde.org>
(C) 2000 Michael Koch <koch@kde.org>
(C) 2001 Holger Freyther <freyther@kde.org>
(C) 2002 Ellis Whitehead <ellis@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
//$Id: kaction.h 465272 2005-09-29 09:47:40Z mueller $
#ifndef __kaction_h__
#define __kaction_h__
#include <qkeysequence.h>
#include <qobject.h>
#include <qvaluelist.h>
#include <qguardedptr.h>
#include <kguiitem.h>
#include <kshortcut.h>
#include <kstdaction.h>
#include <kicontheme.h>
class QMenuBar;
class QPopupMenu;
class QComboBox;
class QPoint;
class QIconSet;
class QString;
class KToolBar;
class KAccel;
class KAccelActions;
class KConfig;
class KConfigBase;
class KURL;
class KInstance;
class KToolBar;
class KActionCollection;
class KPopupMenu;
class KMainWindow;
class KDEUI_EXPORT KAction : public QObject
{
friend class KActionCollection;
Q_OBJECT
Q_PROPERTY( int containerCount READ containerCount )
Q_PROPERTY( QString plainText READ plainText )
Q_PROPERTY( QString text READ text WRITE setText )
Q_PROPERTY( QString shortcut READ shortcutText WRITE setShortcutText )
Q_PROPERTY( bool enabled READ isEnabled WRITE setEnabled )
Q_PROPERTY( QString group READ group WRITE setGroup )
Q_PROPERTY( QString whatsThis READ whatsThis WRITE setWhatsThis )
Q_PROPERTY( QString toolTip READ toolTip WRITE setToolTip )
Q_PROPERTY( QString icon READ icon WRITE setIcon )
public:
KAction( const QString& text, const KShortcut& cut,
const QObject* receiver, const char* slot,
KActionCollection* parent, const char* name );
KAction( const QString& text, const QIconSet& pix, const KShortcut& cut,
const QObject* receiver, const char* slot,
KActionCollection* parent, const char* name );
KAction( const QString& text, const QString& pix, const KShortcut& cut,
const QObject* receiver, const char* slot,
KActionCollection* parent, const char* name );
KAction( const KGuiItem& item, const KShortcut& cut,
const QObject* receiver, const char* slot,
KActionCollection* parent, const char* name );
KAction( const QString& text, const KShortcut& cut = KShortcut(), QObject* parent = 0, const char* name = 0 );
KAction( const QString& text, const KShortcut& cut,
const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 );
KAction( const QString& text, const QIconSet& pix, const KShortcut& cut = KShortcut(),
QObject* parent = 0, const char* name = 0 );
KAction( const QString& text, const QString& pix, const KShortcut& cut = KShortcut(),
QObject* parent = 0, const char* name = 0 );
KAction( const QString& text, const QIconSet& pix, const KShortcut& cut,
const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 );
KAction( const QString& text, const QString& pix, const KShortcut& cut,
const QObject* receiver, const char* slot, QObject* parent,
const char* name = 0 );
KAction( QObject* parent = 0, const char* name = 0 );
virtual ~KAction();
virtual int plug( QWidget *widget, int index = -1 );
virtual void plugAccel(KAccel *accel, bool configurable = true) KDE_DEPRECATED;
virtual void unplug( QWidget *w );
virtual void unplugAccel() KDE_DEPRECATED;
virtual bool isPlugged() const;
bool isPlugged( const QWidget *container ) const;
virtual bool isPlugged( const QWidget *container, int id ) const;
virtual bool isPlugged( const QWidget *container, const QWidget *_representative ) const;
QWidget* container( int index ) const;
int itemId( int index ) const;
QWidget* representative( int index ) const;
int containerCount() const;
uint kaccelCount() const;
virtual bool hasIcon() const;
#ifndef KDE_NO_COMPAT
bool hasIconSet() const { return hasIcon(); }
#endif
virtual QString plainText() const;
virtual QString text() const;
virtual const KShortcut& shortcut() const;
virtual const KShortcut& shortcutDefault() const;
// These two methods are for Q_PROPERTY
QString shortcutText() const;
void setShortcutText( const QString& );
virtual bool isEnabled() const;
virtual bool isShortcutConfigurable() const;
virtual QString group() const;
virtual QString whatsThis() const;
virtual QString toolTip() const;
virtual QIconSet iconSet( KIcon::Group group, int size=0 ) const;
QIconSet iconSet() const { return iconSet( KIcon::Small ); }
virtual QString icon() const;
KActionCollection *parentCollection() const;
static int getToolButtonID();
void unplugAll();
enum ActivationReason { UnknownActivation, EmulatedActivation, AccelActivation, PopupMenuActivation, ToolBarActivation };
public slots:
virtual void setText(const QString &text);
virtual bool setShortcut( const KShortcut& );
virtual void setGroup( const QString& );
virtual void setWhatsThis( const QString& text );
virtual void setToolTip( const QString& );
virtual void setIconSet( const QIconSet &iconSet );
virtual void setIcon( const QString& icon );
virtual void setEnabled(bool enable);
void setDisabled(bool disable) { return setEnabled(!disable); }
virtual void setShortcutConfigurable( bool );
virtual void activate();
protected slots:
virtual void slotDestroyed();
virtual void slotKeycodeChanged();
virtual void slotActivated();
void slotPopupActivated(); // KDE4: make virtual
void slotButtonClicked( int, Qt::ButtonState state ); // KDE4: make virtual
protected:
KToolBar* toolBar( int index ) const;
QPopupMenu* popupMenu( int index ) const;
void removeContainer( int index );
int findContainer( const QWidget* widget ) const;
int findContainer( int id ) const;
void plugMainWindowAccel( QWidget *w );
void addContainer( QWidget* parent, int id );
void addContainer( QWidget* parent, QWidget* representative );
virtual void updateShortcut( int i );
virtual void updateShortcut( QPopupMenu* menu, int id );
virtual void updateGroup( int id );
virtual void updateText(int i );
virtual void updateEnabled(int i);
virtual void updateIconSet(int i);
virtual void updateIcon( int i);
virtual void updateToolTip( int id );
virtual void updateWhatsThis( int i );
KActionCollection *m_parentCollection;
QString whatsThisWithIcon() const;
const KGuiItem& guiItem() const;
signals:
void activated();
void activated( KAction::ActivationReason reason, Qt::ButtonState state );
void enabled( bool );
private:
void initPrivate( const QString& text, const KShortcut& cut,
const QObject* receiver, const char* slot );
KAccel* kaccelCurrent();
bool initShortcut( const KShortcut& );
void plugShortcut();
bool updateKAccelShortcut( KAccel* kaccel );
void insertKAccel( KAccel* );
void removeKAccel( KAccel* );
#ifndef KDE_NO_COMPAT
public:
int accel() const KDE_DEPRECATED;
QString statusText() const
{ return toolTip(); }
void setAccel( int key ) KDE_DEPRECATED;
void setStatusText( const QString &text )
{ setToolTip( text ); }
int menuId( int i ) { return itemId( i ); }
#endif // !KDE_NO_COMPAT
protected:
virtual void virtual_hook( int id, void* data );
private:
class KActionPrivate;
KActionPrivate* const d;
};
#include <kactioncollection.h>
#include <kactionclasses.h>
#endif
KURL
KActionCollection
A managed set of KAction objects.
Definition: kactioncollection.h:78
KAccel
KAction::menuId
int menuId(int i)
Definition: kaction.h:663
KIcon::Small
KIcon::Group
Group
KAction::ActivationReason
ActivationReason
Definition: kaction.h:494
KAction::setStatusText
void setStatusText(const QString &text)
Definition: kaction.h:657
KActionCollection::kaccel
KAccel * kaccel()
Returns the KAccel object of the most recently set widget.
Definition: kactioncollection.cpp:282
KShortcut
KMainWindow
KDE top level main window
Definition: kmainwindow.h:98
KGuiItem
An abstract class for GUI data such as ToolTip and Icon.
Definition: kguiitem.h:38
KAction::setDisabled
void setDisabled(bool disable)
Calls setEnabled( !disable ).
Definition: kaction.h:553
KInstance
KAction::iconSet
QIconSet iconSet() const
Remove in KDE4.
Definition: kaction.h:476
KConfigBase
KConfig
KToolBar
Floatable toolbar with auto resize.
Definition: ktoolbar.h:103
KAction
Class to encapsulate user-driven action or event.
Definition: kaction.h:202
KActionCollection::accel
virtual KAccel * accel() KDE_DEPRECATED
Returns the number of widgets which this collection is associated with.
Definition: kactioncollection.cpp:369

KDE Home | KDE Accessibility Home | Description of Access Keys