home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kaction.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  23.2 KB  |  677 lines

  1. /* This file is part of the KDE libraries
  2.     Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org>
  3.               (C) 1999 Simon Hausmann <hausmann@kde.org>
  4.               (C) 2000 Nicolas Hadacek <haadcek@kde.org>
  5.               (C) 2000 Kurt Granroth <granroth@kde.org>
  6.               (C) 2000 Michael Koch <koch@kde.org>
  7.               (C) 2001 Holger Freyther <freyther@kde.org>
  8.               (C) 2002 Ellis Whitehead <ellis@kde.org>
  9.  
  10.     This library is free software; you can redistribute it and/or
  11.     modify it under the terms of the GNU Library General Public
  12.     License version 2 as published by the Free Software Foundation.
  13.  
  14.     This library is distributed in the hope that it will be useful,
  15.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  17.     Library General Public License for more details.
  18.  
  19.     You should have received a copy of the GNU Library General Public License
  20.     along with this library; see the file COPYING.LIB.  If not, write to
  21.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  22.     Boston, MA 02110-1301, USA.
  23. */
  24. //$Id: kaction.h 465272 2005-09-29 09:47:40Z mueller $
  25.  
  26. #ifndef __kaction_h__
  27. #define __kaction_h__
  28.  
  29. #include <qkeysequence.h>
  30. #include <qobject.h>
  31. #include <qvaluelist.h>
  32. #include <qguardedptr.h>
  33. #include <kguiitem.h>
  34. #include <kshortcut.h>
  35. #include <kstdaction.h>
  36. #include <kicontheme.h>
  37.  
  38. class QMenuBar;
  39. class QPopupMenu;
  40. class QComboBox;
  41. class QPoint;
  42. class QIconSet;
  43. class QString;
  44. class KToolBar;
  45.  
  46. class KAccel;
  47. class KAccelActions;
  48. class KConfig;
  49. class KConfigBase;
  50. class KURL;
  51. class KInstance;
  52. class KToolBar;
  53. class KActionCollection;
  54. class KPopupMenu;
  55. class KMainWindow;
  56.  
  57. /**
  58.  * @short Class to encapsulate user-driven action or event
  59.  *
  60.  * The KAction class (and derived and super classes) provides a way to
  61.  * easily encapsulate a "real" user-selected action or event in your
  62.  * program.
  63.  *
  64.  * For instance, a user may want to @p paste the contents of
  65.  * the clipboard or @p scroll @p down a document or @p quit the
  66.  * application.  These are all @p actions -- events that the
  67.  * user causes to happen.  The KAction class allows the developer to
  68.  * deal with these actions in an easy and intuitive manner.
  69.  *
  70.  * Specifically, the KAction class encapsulated the various attributes
  71.  * to an event/action.  For instance, an action might have an icon
  72.  * that goes along with it (a clipboard for a "paste" action or
  73.  * scissors for a "cut" action).  The action might have some text to
  74.  * describe the action.  It will certainly have a method or function
  75.  * that actually @p executes the action!  All these attributes
  76.  * are contained within the KAction object.
  77.  *
  78.  * The advantage of dealing with Actions is that you can manipulate
  79.  * the Action without regard to the GUI representation of it.  For
  80.  * instance, in the "normal" way of dealing with actions like "cut",
  81.  * you would manually insert a item for Cut into a menu and a button
  82.  * into a toolbar.  If you want to disable the cut action for a moment
  83.  * (maybe nothing is selected), you would have to hunt down the pointer
  84.  * to the menu item and the toolbar button and disable both
  85.  * individually.  Setting the menu item and toolbar item up uses very
  86.  * similar code - but has to be done twice!
  87.  *
  88.  * With the Action concept, you simply "plug" the Action into whatever
  89.  * GUI element you want.  The KAction class will then take care of
  90.  * correctly defining the menu item (with icons, accelerators, text,
  91.  * etc) or toolbar button.. or whatever.  From then on, if you
  92.  * manipulate the Action at all, the effect will propogate through all
  93.  * GUI representations of it.  Back to the "cut" example: if you want
  94.  * to disable the Cut Action, you would simply do
  95.  * 'cutAction->setEnabled(false)' and the menuitem and button would
  96.  * instantly be disabled!
  97.  *
  98.  * This is the biggest advantage to the Action concept -- there is a
  99.  * one-to-one relationship between the "real" action and @p all
  100.  * GUI representations of it.
  101.  *
  102.  * KAction emits the activated() signal if the user activated the
  103.  * corresponding GUI element ( menu item, toolbar button, etc. )
  104.  *
  105.  * If you are in the situation of wanting to map the activated()
  106.  * signal of multiple action objects to one slot, with a special
  107.  * argument bound to each action, then you might consider using
  108.  * QSignalMapper . A tiny example:
  109.  *
  110.  * \code
  111.  * QSignalMapper *desktopNumberMapper = new QSignalMapper( this );
  112.  * connect( desktopNumberMapper, SIGNAL( mapped( int ) ),
  113.  *          this, SLOT( moveWindowToDesktop( int ) ) );
  114.  *
  115.  * for ( uint i = 0; i < numberOfDesktops; ++i ) {
  116.  *     KAction *desktopAction = new KAction( i18n( "Move Window to Desktop %i" ).arg( i ), ... );
  117.  *     connect( desktopAction, SIGNAL( activated() ), desktopNumberMapper, SLOT( map() ) );
  118.  *     desktopNumberMapper->setMapping( desktopAction, i );
  119.  * }
  120.  * \endcode
  121.  *
  122.  * <b>General Usage:</b>\n
  123.  *
  124.  * The steps to using actions are roughly as follows
  125.  *
  126.  * @li Decide which attributes you want to associate with a given
  127.  *     action (icons, text, keyboard shortcut, etc)
  128.  * @li Create the action using KAction (or derived or super class).
  129.  * @li "Plug" the Action into whatever GUI element you want.  Typically,
  130.  *      this will be a menu or toolbar.
  131.  *
  132.  * <b>Detailed Example:</b>\n
  133.  *
  134.  * Here is an example of enabling a "New [document]" action
  135.  * \code
  136.  * KAction *newAct = new KAction(i18n("&New"), "filenew",
  137.  *                               KStdAccel::shortcut(KStdAccel::New),
  138.  *                               this, SLOT(fileNew()),
  139.  *                               actionCollection(), "new");
  140.  * \endcode
  141.  * This line creates our action.  It says that wherever this action is
  142.  * displayed, it will use "&New" as the text, the standard icon, and
  143.  * the standard shortcut.  It further says that whenever this action
  144.  * is invoked, it will use the fileNew() slot to execute it.
  145.  *
  146.  * \code
  147.  * QPopupMenu *file = new QPopupMenu;
  148.  * newAct->plug(file);
  149.  * \endcode
  150.  * That just inserted the action into the File menu.  The point is, it's not
  151.  * important in which menu it is: all manipulation of the item is
  152.  * done through the newAct object.
  153.  *
  154.  * \code
  155.  * newAct->plug(toolBar());
  156.  * \endcode
  157.  * And this inserted the Action into the main toolbar as a button.
  158.  *
  159.  * That's it!
  160.  *
  161.  * If you want to disable that action sometime later, you can do so
  162.  * with
  163.  * \code
  164.  * newAct->setEnabled(false)
  165.  * \endcode
  166.  * and both the menuitem in File and the toolbar button will instantly
  167.  * be disabled.
  168.  *
  169.  * Do not delete a KAction object without unplugging it from all its
  170.  * containers. The simplest way to do that is to use the unplugAll()
  171.  * as in the following example:
  172.  * \code
  173.  * newAct->unplugAll();
  174.  * delete newAct;
  175.  * \endcode
  176.  * Normally you will not need to do this as KActionCollection manages
  177.  * everything for you.
  178.  *
  179.  * Note: if you are using a "standard" action like "new", "paste",
  180.  * "quit", or any other action described in the KDE UI Standards,
  181.  * please use the methods in the KStdAction class rather than
  182.  * defining your own.
  183.  *
  184.  * <b>Usage Within the XML Framework:</b>\n
  185.  *
  186.  * If you are using KAction within the context of the XML menu and
  187.  * toolbar building framework, then there are a few tiny changes.  The
  188.  * first is that you must insert your new action into an action
  189.  * collection.  The action collection (a KActionCollection) is,
  190.  * logically enough, a central collection of all of the actions
  191.  * defined in your application.  The XML UI framework code in KXMLGUI
  192.  * classes needs access to this collection in order to build up the
  193.  * GUI (it's how the builder code knows which actions are valid and
  194.  * which aren't).
  195.  *
  196.  * Also, if you use the XML builder framework, then you do not ever
  197.  * have to plug your actions into containers manually.  The framework
  198.  * does that for you.
  199.  *
  200.  * @see KStdAction
  201.  */
  202. class KDEUI_EXPORT KAction : public QObject
  203. {
  204.   friend class KActionCollection;
  205.   Q_OBJECT
  206.   Q_PROPERTY( int containerCount READ containerCount )
  207.   Q_PROPERTY( QString plainText READ plainText )
  208.   Q_PROPERTY( QString text READ text WRITE setText )
  209.   Q_PROPERTY( QString shortcut READ shortcutText WRITE setShortcutText )
  210.   Q_PROPERTY( bool enabled READ isEnabled WRITE setEnabled )
  211.   Q_PROPERTY( QString group READ group WRITE setGroup )
  212.   Q_PROPERTY( QString whatsThis READ whatsThis WRITE setWhatsThis )
  213.   Q_PROPERTY( QString toolTip READ toolTip WRITE setToolTip )
  214.   Q_PROPERTY( QString icon READ icon WRITE setIcon )
  215. public:
  216.     /**
  217.      * Constructs an action with text, potential keyboard
  218.      * shortcut, and a SLOT to call when this action is invoked by
  219.      * the user.
  220.      *
  221.      * If you do not want or have a keyboard shortcut,
  222.      * set the @p cut param to 0.
  223.      *
  224.      * This is the most common KAction used when you do not have a
  225.      * corresponding icon (note that it won't appear in the current version
  226.      * of the "Edit ToolBar" dialog, because an action needs an icon to be
  227.      * plugged in a toolbar...).
  228.      *
  229.      * @param text The text that will be displayed.
  230.      * @param cut The corresponding keyboard shortcut.
  231.      * @param receiver The SLOT's parent.
  232.      * @param slot The SLOT to invoke to execute this action.
  233.      * @param parent This action's parent.
  234.      * @param name An internal name for this action.
  235.      */
  236.     KAction( const QString& text, const KShortcut& cut,
  237.              const QObject* receiver, const char* slot,
  238.              KActionCollection* parent, const char* name );
  239.  
  240.     /**
  241.      * Constructs an action with text, icon, potential keyboard
  242.      * shortcut, and a SLOT to call when this action is invoked by
  243.      * the user.
  244.      *
  245.      * If you do not want or have a keyboard shortcut, set the
  246.      * @p cut param to 0.
  247.      *
  248.      * This is the other common KAction used.  Use it when you
  249.      * @p do have a corresponding icon.
  250.      *
  251.      * @param text The text that will be displayed.
  252.      * @param pix The icon to display.
  253.      * @param cut The corresponding keyboard shortcut.
  254.      * @param receiver The SLOT's parent.
  255.      * @param slot The SLOT to invoke to execute this action.
  256.      * @param parent This action's parent.
  257.      * @param name An internal name for this action.
  258.      */
  259.     KAction( const QString& text, const QIconSet& pix, const KShortcut& cut,
  260.              const QObject* receiver, const char* slot,
  261.              KActionCollection* parent, const char* name );
  262.  
  263.     /**
  264.      * Constructs an action with text, icon, potential keyboard
  265.      * shortcut, and a SLOT to call when this action is invoked by
  266.      * the user.  The icon is loaded on demand later based on where it
  267.      * is plugged in.
  268.      *
  269.      * If you do not want or have a keyboard shortcut, set the
  270.      * @p cut param to 0.
  271.      *
  272.      * This is the other common KAction used.  Use it when you
  273.      * @p do have a corresponding icon.
  274.      *
  275.      * @param text The text that will be displayed.
  276.      * @param pix The icon to display.
  277.      * @param cut The corresponding keyboard shortcut (shortcut).
  278.      * @param receiver The SLOT's parent.
  279.      * @param slot The SLOT to invoke to execute this action.
  280.      * @param parent This action's parent.
  281.      * @param name An internal name for this action.
  282.      */
  283.     KAction( const QString& text, const QString& pix, const KShortcut& cut,
  284.              const QObject* receiver, const char* slot,
  285.              KActionCollection* parent, const char* name );
  286.  
  287.     /**
  288.      * The same as the above constructor, but with a KGuiItem providing
  289.      * the text and icon.
  290.      *
  291.      * @param item The KGuiItem with the label and (optional) icon.
  292.      * @param cut The corresponding keyboard shortcut (shortcut).
  293.      * @param receiver The SLOT's parent.
  294.      * @param slot The SLOT to invoke to execute this action.
  295.      * @param parent This action's parent.
  296.      * @param name An internal name for this action.
  297.      */
  298.     KAction( const KGuiItem& item, const KShortcut& cut,
  299.              const QObject* receiver, const char* slot,
  300.              KActionCollection* parent, const char* name );
  301.  
  302.     /**
  303.      * @obsolete
  304.      */
  305.     KAction( const QString& text, const KShortcut& cut = KShortcut(), QObject* parent = 0, const char* name = 0 );
  306.     /**
  307.      * @obsolete
  308.      */
  309.     KAction( const QString& text, const KShortcut& cut,
  310.         const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 );
  311.     /**
  312.      * @obsolete
  313.      */
  314.     KAction( const QString& text, const QIconSet& pix, const KShortcut& cut = KShortcut(),
  315.         QObject* parent = 0, const char* name = 0 );
  316.     /**
  317.      * @obsolete
  318.      */
  319.     KAction( const QString& text, const QString& pix, const KShortcut& cut = KShortcut(),
  320.         QObject* parent = 0, const char* name = 0 );
  321.     /**
  322.      * @obsolete
  323.      */
  324.     KAction( const QString& text, const QIconSet& pix, const KShortcut& cut,
  325.         const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 );
  326.     /**
  327.      * @obsolete
  328.      */
  329.     KAction( const QString& text, const QString& pix, const KShortcut& cut,
  330.         const QObject* receiver, const char* slot, QObject* parent,
  331.         const char* name = 0 );
  332.     /**
  333.      * @obsolete
  334.      */
  335.     KAction( QObject* parent = 0, const char* name = 0 );
  336.  
  337.     /**
  338.      * Standard destructor
  339.      */
  340.     virtual ~KAction();
  341.  
  342.     /**
  343.      * "Plug" or insert this action into a given widget.
  344.      *
  345.      * This will
  346.      * typically be a menu or a toolbar.  From this point on, you will
  347.      * never need to directly manipulate the item in the menu or
  348.      * toolbar.  You do all enabling/disabling/manipulation directly
  349.      * with your KAction object.
  350.      *
  351.      * @param widget The GUI element to display this action
  352.      * @param index The position into which the action is plugged. If
  353.      * this is negative, the action is inserted at the end.
  354.      */
  355.     virtual int plug( QWidget *widget, int index = -1 );
  356.  
  357.     /**
  358.      * @deprecated.  Shouldn't be used.  No substitute available.
  359.      *
  360.      * "Plug" or insert this action into a given KAccel.
  361.      *
  362.      * @param accel The KAccel collection which holds this accel
  363.      * @param configurable If the shortcut is configurable via
  364.      * the KAccel configuration dialog (this is somehow deprecated since
  365.      * there is now a KAction key configuration dialog).
  366.      */
  367.     virtual void plugAccel(KAccel *accel, bool configurable = true) KDE_DEPRECATED;
  368.  
  369.     /**
  370.      * "Unplug" or remove this action from a given widget.
  371.      *
  372.      * This will typically be a menu or a toolbar.  This is rarely
  373.      * used in "normal" application.  Typically, it would be used if
  374.      * your application has several views or modes, each with a
  375.      * completely different menu structure.  If you simply want to
  376.      * disable an action for a given period, use setEnabled()
  377.      * instead.
  378.      *
  379.      * @param w Remove the action from this GUI element.
  380.      */
  381.     virtual void unplug( QWidget *w );
  382.  
  383.     /**
  384.      * @deprecated.  Complement method to plugAccel().
  385.      * Disconnect this action from the KAccel.
  386.      */
  387.     virtual void unplugAccel() KDE_DEPRECATED;
  388.  
  389.     /**
  390.      * returns whether the action is plugged into any container widget or not.
  391.      * @since 3.1
  392.      */
  393.     virtual bool isPlugged() const;
  394.  
  395.     /**
  396.      * returns whether the action is plugged into the given container
  397.      */
  398.     bool isPlugged( const QWidget *container ) const;
  399.  
  400.     /**
  401.      * returns whether the action is plugged into the given container with the given, container specific, id (often
  402.      * menu or toolbar id ) .
  403.      */
  404.     virtual bool isPlugged( const QWidget *container, int id ) const;
  405.  
  406.     /**
  407.      * returns whether the action is plugged into the given container with the given, container specific, representative
  408.      * container widget item.
  409.      */
  410.     virtual bool isPlugged( const QWidget *container, const QWidget *_representative ) const;
  411.  
  412.     QWidget* container( int index ) const;
  413.     int itemId( int index ) const;
  414.     QWidget* representative( int index ) const;
  415.     int containerCount() const;
  416.     /// @since 3.1
  417.     uint kaccelCount() const;
  418.  
  419.     virtual bool hasIcon() const;
  420. #ifndef KDE_NO_COMPAT
  421.     bool hasIconSet() const { return hasIcon(); }
  422. #endif
  423.     virtual QString plainText() const;
  424.  
  425.     /**
  426.      * Get the text associated with this action.
  427.      */
  428.     virtual QString text() const;
  429.  
  430.     /**
  431.      * Get the keyboard shortcut associated with this action.
  432.      */
  433.     virtual const KShortcut& shortcut() const;
  434.     /**
  435.      * Get the default shortcut for this action.
  436.      */
  437.     virtual const KShortcut& shortcutDefault() const;
  438.  
  439.     // These two methods are for Q_PROPERTY
  440.     QString shortcutText() const;
  441.     void setShortcutText( const QString& );
  442.  
  443.     /**
  444.      * Returns true if this action is enabled.
  445.      */
  446.     virtual bool isEnabled() const;
  447.  
  448.     /**
  449.      * Returns true if this action's shortcut is configurable.
  450.      */
  451.     virtual bool isShortcutConfigurable() const;
  452.  
  453.     virtual QString group() const;
  454.  
  455.     /**
  456.      * Get the What's this text for the action.
  457.      */
  458.     virtual QString whatsThis() const;
  459.  
  460.     /**
  461.      * Get the tooltip text for the action.
  462.      */
  463.     virtual QString toolTip() const;
  464.  
  465.     /**
  466.      * Get the QIconSet from which the icons used to display this action will
  467.      * be chosen.
  468.      *
  469.      * In KDE4 set group default to KIcon::Small while removing the other
  470.      * iconSet() function.
  471.      */
  472.     virtual QIconSet iconSet( KIcon::Group group, int size=0 ) const;
  473.     /**
  474.      * Remove in KDE4
  475.      */
  476.     QIconSet iconSet() const { return iconSet( KIcon::Small ); }
  477.  
  478.     virtual QString icon() const;
  479.  
  480.     KActionCollection *parentCollection() const;
  481.  
  482.     /**
  483.      * @internal
  484.      * Generate a toolbar button id. Made public for reimplementations.
  485.      */
  486.     static int getToolButtonID();
  487.  
  488.  
  489.     void unplugAll();
  490.  
  491.     /**
  492.     * @since 3.4
  493.     */
  494.     enum ActivationReason { UnknownActivation, EmulatedActivation, AccelActivation, PopupMenuActivation, ToolBarActivation };
  495.  
  496. public slots:
  497.     /**
  498.      * Sets the text associated with this action. The text is used for menu
  499.      * and toolbar labels etc.
  500.      */
  501.     virtual void setText(const QString &text);
  502.  
  503.     /**
  504.      * Sets the keyboard shortcut associated with this action.
  505.      */
  506.     virtual bool setShortcut( const KShortcut& );
  507.  
  508.     virtual void setGroup( const QString& );
  509.  
  510.     /**
  511.      * Sets the What's this text for the action. This text will be displayed when
  512.      * a widget that has been created by plugging this action into a container
  513.      * is clicked on in What's this mode.
  514.      *
  515.      * The What's this text can include QML markup as well as raw text.
  516.      */
  517.     virtual void setWhatsThis( const QString& text );
  518.  
  519.     /**
  520.      * Sets the tooltip text for the action.
  521.      * This will be used as a tooltip for a toolbar button, as a
  522.      * statusbar help-text for a menu item, and it also appears
  523.      * in the toolbar editor, to describe the action.
  524.      *
  525.      * For the tooltip to show up on the statusbar you will need to connect
  526.      * a couple of the actionclass signals to the toolbar.
  527.      * The easiest way of doing this is in your main window class, when you create
  528.      * a statusbar.  See the KActionCollection class for more details.
  529.      *
  530.      * @see KActionCollection
  531.      *
  532.      */
  533.     virtual void setToolTip( const QString& );
  534.  
  535.     /**
  536.      * Sets the QIconSet from which the icons used to display this action will
  537.      * be chosen.
  538.      */
  539.     virtual void setIconSet( const QIconSet &iconSet );
  540.  
  541.     virtual void setIcon( const QString& icon );
  542.  
  543.     /**
  544.      * Enables or disables this action. All uses of this action (eg. in menus
  545.      * or toolbars) will be updated to reflect the state of the action.
  546.      */
  547.     virtual void setEnabled(bool enable);
  548.  
  549.     /**
  550.      * Calls setEnabled( !disable ).
  551.      * @since 3.5
  552.      */    
  553.     void setDisabled(bool disable) { return setEnabled(!disable); }
  554.  
  555.     /**
  556.      * Indicate whether the user may configure the action's shortcut.
  557.      */
  558.     virtual void setShortcutConfigurable( bool );
  559.  
  560.     /**
  561.      * Emulate user's interaction programmatically, by activating the action.
  562.      * The implementation simply emits activated().
  563.      */
  564.     virtual void activate();
  565.  
  566. protected slots:
  567.     virtual void slotDestroyed();
  568.     virtual void slotKeycodeChanged();
  569.     virtual void slotActivated();
  570.     /// @since 3.4
  571.     void slotPopupActivated(); // KDE4: make virtual
  572.     /// @since 3.4
  573.     void slotButtonClicked( int, Qt::ButtonState state ); // KDE4: make virtual
  574.  
  575. protected:
  576.     KToolBar* toolBar( int index ) const;
  577.     QPopupMenu* popupMenu( int index ) const;
  578.     void removeContainer( int index );
  579.     int findContainer( const QWidget* widget ) const;
  580.     int findContainer( int id ) const;
  581.     void plugMainWindowAccel( QWidget *w );
  582.  
  583.     void addContainer( QWidget* parent, int id );
  584.     void addContainer( QWidget* parent, QWidget* representative );
  585.  
  586.     virtual void updateShortcut( int i );
  587.     virtual void updateShortcut( QPopupMenu* menu, int id );
  588.     virtual void updateGroup( int id );
  589.     virtual void updateText(int i );
  590.     virtual void updateEnabled(int i);
  591.     virtual void updateIconSet(int i);
  592.     virtual void updateIcon( int i);
  593.     virtual void updateToolTip( int id );
  594.     virtual void updateWhatsThis( int i );
  595.  
  596.     KActionCollection *m_parentCollection;
  597.     QString whatsThisWithIcon() const;
  598.     /**
  599.      * Return the underlying KGuiItem
  600.      * @since 3.3
  601.      */
  602.     const KGuiItem& guiItem() const;
  603.  
  604. signals:
  605.     /**
  606.      * Emitted when this action is activated
  607.      */
  608.     void activated();
  609.     /**
  610.      * This signal allows to know the reason why an action was activated:
  611.      * whether it was due to a toolbar button, popupmenu, keyboard accel, or programmatically.
  612.      * In the first two cases, it also allows to know which mouse button was
  613.      * used (Left or Middle), and whether keyboard modifiers were pressed (e.g. CTRL).
  614.      *
  615.      * Note that this signal is emitted before the normal activated() signal.
  616.      * Yes, BOTH signals are always emitted, so that connecting to activated() still works.
  617.      * Applications which care about reason and state can either ignore the activated()
  618.      * signal for a given action and react to this one instead, or store the
  619.      * reason and state until the activated() signal is emitted.
  620.      *
  621.      * @since 3.4
  622.      */
  623.     void activated( KAction::ActivationReason reason, Qt::ButtonState state );
  624.     void enabled( bool );
  625.  
  626. private:
  627.     void initPrivate( const QString& text, const KShortcut& cut,
  628.                   const QObject* receiver, const char* slot );
  629.     KAccel* kaccelCurrent();
  630.     bool initShortcut( const KShortcut& );
  631.     void plugShortcut();
  632.     bool updateKAccelShortcut( KAccel* kaccel );
  633.     void insertKAccel( KAccel* );
  634.     /** @internal To be used exclusively by KActionCollection::removeWidget(). */
  635.     void removeKAccel( KAccel* );
  636.  
  637. #ifndef KDE_NO_COMPAT
  638. public:
  639.     /**
  640.      * @deprecated.  Use shortcut().
  641.      * Get the keyboard accelerator associated with this action.
  642.      */
  643.     int accel() const KDE_DEPRECATED;
  644.  
  645.     QString statusText() const
  646.         { return toolTip(); }
  647.  
  648.     /**
  649.      * @deprecated.  Use setShortcut().
  650.      * Sets the keyboard accelerator associated with this action.
  651.      */
  652.     void setAccel( int key ) KDE_DEPRECATED;
  653.  
  654.     /**
  655.      * @deprecated. Use setToolTip instead (they do the same thing now).
  656.      */
  657.     void setStatusText( const QString &text )
  658.          { setToolTip( text ); }
  659.  
  660.     /**
  661.      * @deprecated. for backwards compatibility. Use itemId()
  662.      */
  663.     int menuId( int i ) { return itemId( i ); }
  664. #endif // !KDE_NO_COMPAT
  665.  
  666. protected:
  667.     virtual void virtual_hook( int id, void* data );
  668. private:
  669.     class KActionPrivate;
  670.     KActionPrivate* const d;
  671. };
  672.  
  673. #include <kactioncollection.h>
  674. #include <kactionclasses.h>
  675.  
  676. #endif
  677.