kactionclasses.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>
(C) 2003 Andras Mantia <amantia@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$
#ifndef __kactionclasses_h__
#define __kactionclasses_h__
#include <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 KToggleAction : public KAction
{
Q_OBJECT
Q_PROPERTY( bool checked READ isChecked WRITE setChecked )
Q_PROPERTY( QString exclusiveGroup READ exclusiveGroup WRITE setExclusiveGroup )
public:
KToggleAction( const QString& text, const KShortcut& cut = KShortcut(), QObject* parent = 0, const char* name = 0 );
KToggleAction( const QString& text, const KShortcut& cut,
const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 );
KToggleAction( const QString& text, const QIconSet& pix, const KShortcut& cut = KShortcut(),
QObject* parent = 0, const char* name = 0 );
KToggleAction( const QString& text, const QString& pix, const KShortcut& cut = KShortcut(),
QObject* parent = 0, const char* name = 0 );
KToggleAction( const QString& text, const QIconSet& pix, const KShortcut& cut,
const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 );
KToggleAction( const QString& text, const QString& pix, const KShortcut& cut,
const QObject* receiver, const char* slot,
QObject* parent, const char* name = 0 );
KToggleAction( QObject* parent = 0, const char* name = 0 );
virtual ~KToggleAction();
virtual int plug( QWidget* widget, int index = -1 );
bool isChecked() const;
QString exclusiveGroup() const;
virtual void setExclusiveGroup( const QString& name );
void setCheckedState( const KGuiItem& checkedItem );
virtual QString toolTip() const;
public slots:
virtual void setChecked( bool );
protected slots:
virtual void slotActivated();
protected:
virtual void updateChecked( int id );
signals:
void toggled( bool );
protected:
virtual void virtual_hook( int id, void* data );
private:
class KToggleActionPrivate;
KToggleActionPrivate *d;
};
class KDEUI_EXPORT KRadioAction : public KToggleAction
{
Q_OBJECT
public:
KRadioAction( const QString& text, const KShortcut& cut = KShortcut(), QObject* parent = 0, const char* name = 0 );
KRadioAction( const QString& text, const KShortcut& cut,
const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 );
KRadioAction( const QString& text, const QIconSet& pix, const KShortcut& cut = KShortcut(),
QObject* parent = 0, const char* name = 0 );
KRadioAction( const QString& text, const QString& pix, const KShortcut& cut = KShortcut(),
QObject* parent = 0, const char* name = 0 );
KRadioAction( const QString& text, const QIconSet& pix, const KShortcut& cut,
const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 );
KRadioAction( const QString& text, const QString& pix, const KShortcut& cut,
const QObject* receiver, const char* slot,
QObject* parent, const char* name = 0 );
KRadioAction( QObject* parent = 0, const char* name = 0 );
protected:
virtual void slotActivated();
protected:
virtual void virtual_hook( int id, void* data );
private:
class KRadioActionPrivate;
KRadioActionPrivate *d;
};
class KDEUI_EXPORT KSelectAction : public KAction
{
Q_OBJECT
Q_PROPERTY( int currentItem READ currentItem WRITE setCurrentItem )
Q_PROPERTY( QStringList items READ items WRITE setItems )
Q_PROPERTY( bool editable READ isEditable WRITE setEditable )
Q_PROPERTY( int comboWidth READ comboWidth WRITE setComboWidth )
Q_PROPERTY( QString currentText READ currentText )
Q_PROPERTY( bool menuAccelsEnabled READ menuAccelsEnabled WRITE setMenuAccelsEnabled )
public:
KSelectAction( const QString& text, const KShortcut& cut = KShortcut(), QObject* parent = 0, const char* name = 0 );
KSelectAction( const QString& text, const KShortcut& cut,
const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 );
KSelectAction( const QString& text, const QIconSet& pix, const KShortcut& cut = KShortcut(),
QObject* parent = 0, const char* name = 0 );
KSelectAction( const QString& text, const QString& pix, const KShortcut& cut = KShortcut(),
QObject* parent = 0, const char* name = 0 );
KSelectAction( const QString& text, const QIconSet& pix, const KShortcut& cut,
const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 );
KSelectAction( const QString& text, const QString& pix, const KShortcut& cut,
const QObject* receiver, const char* slot,
QObject* parent, const char* name = 0 );
KSelectAction( QObject* parent = 0, const char* name = 0 );
virtual ~KSelectAction();
virtual int plug( QWidget* widget, int index = -1 );
virtual bool isEditable() const;
virtual QStringList items() const;
virtual void changeItem( int index, const QString& text );
virtual QString currentText() const;
virtual int currentItem() const;
virtual int comboWidth() const;
void setMaxComboViewCount( int n );
QPopupMenu* popupMenu() const;
void setRemoveAmpersandsInCombo( bool b ) KDE_DEPRECATED;
bool removeAmpersandsInCombo() const;
void setMenuAccelsEnabled( bool b );
bool menuAccelsEnabled() const;
virtual bool isShortcutConfigurable() const { return false; }
public slots:
virtual void setCurrentItem( int index );
virtual void setItems( const QStringList &lst );
virtual void clear();
virtual void setEditable( bool );
virtual void setComboWidth( int width );
protected:
virtual void changeItem( int id, int index, const QString& text );
QStringList comboItems() const;
protected slots:
virtual void slotActivated( int id );
virtual void slotActivated( const QString &text );
virtual void slotActivated();
signals:
void activated( int index );
void activated( const QString& text );
protected:
virtual void updateCurrentItem( int id );
virtual void updateComboWidth( int id );
virtual void updateItems( int id );
virtual void updateClear( int id );
protected:
virtual void virtual_hook( int id, void* data );
private:
void setupMenu() const;
class KSelectActionPrivate;
KSelectActionPrivate *d;
};
class KDEUI_EXPORT_DEPRECATED KListAction : public KSelectAction
{
Q_OBJECT
public:
KListAction( const QString& text, const KShortcut& cut = KShortcut(), QObject* parent = 0,
const char* name = 0 );
KListAction( const QString& text, const KShortcut& cut, const QObject* receiver,
const char* slot, QObject* parent, const char* name = 0 );
KListAction( const QString& text, const QIconSet& pix, const KShortcut& cut = KShortcut(),
QObject* parent = 0, const char* name = 0 );
KListAction( const QString& text, const QString& pix, const KShortcut& cut = KShortcut(),
QObject* parent = 0, const char* name = 0 );
KListAction( const QString& text, const QIconSet& pix, const KShortcut& cut,
const QObject* receiver, const char* slot, QObject* parent,
const char* name = 0 );
KListAction( const QString& text, const QString& pix, const KShortcut& cut,
const QObject* receiver, const char* slot, QObject* parent,
const char* name = 0 );
KListAction( QObject* parent = 0, const char* name = 0 );
virtual ~KListAction();
virtual QString currentText() const;
virtual int currentItem() const;
public slots:
virtual void setCurrentItem( int index );
protected:
virtual void virtual_hook( int id, void* data );
private:
class KListActionPrivate;
KListActionPrivate *d;
};
class KDEUI_EXPORT KRecentFilesAction : public KListAction // TODO public KSelectAction
{
Q_OBJECT
Q_PROPERTY( uint maxItems READ maxItems WRITE setMaxItems )
public:
KRecentFilesAction( const QString& text, const KShortcut& cut,
QObject* parent, const char* name = 0,
uint maxItems = 10 );
KRecentFilesAction( const QString& text, const KShortcut& cut,
const QObject* receiver, const char* slot,
QObject* parent, const char* name = 0,
uint maxItems = 10 );
KRecentFilesAction( const QString& text, const QIconSet& pix, const KShortcut& cut,
QObject* parent, const char* name = 0,
uint maxItems = 10 );
KRecentFilesAction( const QString& text, const QString& pix, const KShortcut& cut,
QObject* parent, const char* name = 0,
uint maxItems = 10 );
KRecentFilesAction( const QString& text, const QIconSet& pix, const KShortcut& cut,
const QObject* receiver, const char* slot,
QObject* parent, const char* name = 0,
uint maxItems = 10 );
KRecentFilesAction( const QString& text, const QString& pix, const KShortcut& cut,
const QObject* receiver, const char* slot,
QObject* parent, const char* name = 0,
uint maxItems = 10 );
KRecentFilesAction( QObject* parent = 0, const char* name = 0,
uint maxItems = 10 );
virtual ~KRecentFilesAction();
virtual int plug( QWidget *widget, int index = -1 );
uint maxItems() const;
//KDE4: remove completeItems() and rename items() to urls(), to get the list of URLs added to
// the action.
virtual QStringList items() const;
QStringList completeItems() const;
public slots:
void setMaxItems( uint maxItems );
void loadEntries( KConfig* config, QString groupname=QString::null );
void saveEntries( KConfig* config, QString groupname=QString::null );
void addURL( const KURL& url );
void addURL( const KURL& url, const QString& name ); //KDE4: Combine the above two methods
void removeURL( const KURL& url );
void clearURLList();
signals:
void urlSelected( const KURL& url );
protected slots:
void itemSelected( const QString& string );
void menuAboutToShow();
void menuItemActivated( int id );
void slotClicked();
virtual void slotActivated(int);
virtual void slotActivated(const QString& );
virtual void slotActivated();
protected:
virtual void virtual_hook( int id, void* data );
private:
void init();
class KRecentFilesActionPrivate;
KRecentFilesActionPrivate *d;
};
class KDEUI_EXPORT KFontAction : public KSelectAction
{
Q_OBJECT
Q_PROPERTY( QString font READ font WRITE setFont )
public:
KFontAction( const QString& text, const KShortcut& cut = KShortcut(), QObject* parent = 0,
const char* name = 0 );
KFontAction( const QString& text, const KShortcut& cut,
const QObject* receiver, const char* slot, QObject* parent,
const char* name = 0 );
KFontAction( const QString& text, const QIconSet& pix, const KShortcut& cut = KShortcut(),
QObject* parent = 0, const char* name = 0 );
KFontAction( const QString& text, const QString& pix, const KShortcut& cut = KShortcut(),
QObject* parent = 0, const char* name = 0 );
KFontAction( const QString& text, const QIconSet& pix, const KShortcut& cut,
const QObject* receiver, const char* slot, QObject* parent,
const char* name = 0 );
KFontAction( const QString& text, const QString& pix, const KShortcut& cut,
const QObject* receiver, const char* slot, QObject* parent,
const char* name = 0 );
// The ctors with fontListCriteria were added after 3.3-beta1.
// This define is used in koffice. Remove when koffice has a dependency on kdelibs-3.3 or more.
#define KFONTACTION_HAS_CRITERIA_ARG
KFontAction( uint fontListCriteria, const QString& text,
const KShortcut& cut = KShortcut(), QObject* parent = 0,
const char* name = 0 );
KFontAction( uint fontListCriteria, const QString& text, const QString& pix,
const KShortcut& cut = KShortcut(),
QObject* parent = 0, const char* name = 0 );
KFontAction( QObject* parent = 0, const char* name = 0 );
~KFontAction();
QString font() const {
return currentText();
}
int plug( QWidget*widget, int index = -1 );
public slots:
void setFont( const QString &family );
protected:
virtual void virtual_hook( int id, void* data );
private:
class KFontActionPrivate;
KFontActionPrivate *d;
};
class KDEUI_EXPORT KFontSizeAction : public KSelectAction
{
Q_OBJECT
Q_PROPERTY( int fontSize READ fontSize WRITE setFontSize )
public:
KFontSizeAction( const QString& text, const KShortcut& cut = KShortcut(), QObject* parent = 0,
const char* name = 0 );
KFontSizeAction( const QString& text, const KShortcut& cut, const QObject* receiver,
const char* slot, QObject* parent, const char* name = 0 );
KFontSizeAction( const QString& text, const QIconSet& pix, const KShortcut& cut = KShortcut(),
QObject* parent = 0, const char* name = 0 );
KFontSizeAction( const QString& text, const QString& pix, const KShortcut& cut = KShortcut(),
QObject* parent = 0, const char* name = 0 );
KFontSizeAction( const QString& text, const QIconSet& pix, const KShortcut& cut,
const QObject* receiver, const char* slot,
QObject* parent, const char* name = 0 );
KFontSizeAction( const QString& text, const QString& pix, const KShortcut& cut,
const QObject* receiver, const char* slot,
QObject* parent, const char* name = 0 );
KFontSizeAction( QObject* parent = 0, const char* name = 0 );
virtual ~KFontSizeAction();
virtual int fontSize() const;
public slots:
virtual void setFontSize( int size );
protected slots:
virtual void slotActivated( int );
virtual void slotActivated( const QString& );
virtual void slotActivated() { KAction::slotActivated(); }
signals:
void fontSizeChanged( int );
private:
void init();
protected:
virtual void virtual_hook( int id, void* data );
private:
class KFontSizeActionPrivate;
KFontSizeActionPrivate *d;
};
class KDEUI_EXPORT KActionMenu : public KAction
{
Q_OBJECT
Q_PROPERTY( bool delayed READ delayed WRITE setDelayed )
Q_PROPERTY( bool stickyMenu READ stickyMenu WRITE setStickyMenu )
public:
KActionMenu( const QString& text, QObject* parent = 0,
const char* name = 0 );
KActionMenu( const QString& text, const QIconSet& icon,
QObject* parent = 0, const char* name = 0 );
KActionMenu( const QString& text, const QString& icon,
QObject* parent = 0, const char* name = 0 );
KActionMenu( QObject* parent = 0, const char* name = 0 );
virtual ~KActionMenu();
virtual void insert( KAction*, int index = -1 );
virtual void remove( KAction* );
KPopupMenu* popupMenu() const;
void popup( const QPoint& global );
bool delayed() const;
void setDelayed(bool _delayed);
bool stickyMenu() const;
void setStickyMenu(bool sticky);
virtual int plug( QWidget* widget, int index = -1 );
protected:
virtual void virtual_hook( int id, void* data );
private:
class KActionMenuPrivate;
KActionMenuPrivate *d;
};
class KDEUI_EXPORT KToolBarPopupAction : public KAction
{
Q_OBJECT
Q_PROPERTY( bool delayed READ delayed WRITE setDelayed )
Q_PROPERTY( bool stickyMenu READ stickyMenu WRITE setStickyMenu )
public:
//Not all constructors - because we need an icon, since this action only makes
// sense when being plugged at least in a toolbar.
KToolBarPopupAction( const QString& text, const QString& icon, const KShortcut& cut = KShortcut(),
QObject* parent = 0, const char* name = 0 );
KToolBarPopupAction( const QString& text, const QString& icon, const KShortcut& cut,
const QObject* receiver, const char* slot,
QObject* parent = 0, const char* name = 0 );
KToolBarPopupAction( const KGuiItem& item, const KShortcut& cut,
const QObject* receiver, const char* slot,
KActionCollection* parent, const char* name );
virtual ~KToolBarPopupAction();
virtual int plug( QWidget *widget, int index = -1 );
KPopupMenu *popupMenu() const;
bool delayed() const;
void setDelayed(bool delayed);
bool stickyMenu() const;
void setStickyMenu(bool sticky);
private:
KPopupMenu *m_popup;
bool m_delayed:1;
bool m_stickyMenu:1;
protected:
virtual void virtual_hook( int id, void* data );
private:
class KToolBarPopupActionPrivate;
KToolBarPopupActionPrivate *d;
};
class KDEUI_EXPORT KToggleToolBarAction : public KToggleAction
{
Q_OBJECT
public:
KToggleToolBarAction( const char* toolBarName, const QString& text,
KActionCollection* parent, const char* name );
KToggleToolBarAction( KToolBar *toolBar, const QString &text,
KActionCollection *parent, const char *name );
virtual ~KToggleToolBarAction();
virtual int plug( QWidget * widget, int index = -1 );
KToolBar *toolBar() { return m_toolBar; }
public slots:
virtual void setChecked( bool );
private:
QCString m_toolBarName;
QGuardedPtr<KToolBar> m_toolBar;
protected:
virtual void virtual_hook( int id, void* data );
private:
class KToggleToolBarActionPrivate;
KToggleToolBarActionPrivate *d;
};
class KDEUI_EXPORT KToggleFullScreenAction : public KToggleAction
{
Q_OBJECT
public:
KToggleFullScreenAction( const KShortcut &cut,
const QObject* receiver, const char* slot,
QObject* parent, QWidget* window,
const char* name );
virtual ~KToggleFullScreenAction();
void setWindow( QWidget* window );
public slots:
virtual void setChecked( bool );
protected:
virtual bool eventFilter( QObject* o, QEvent* e );
private:
QWidget* window;
protected:
virtual void virtual_hook( int id, void* data );
private:
class KToggleFullScreenActionPrivate;
KToggleFullScreenActionPrivate *d;
};
class KDEUI_EXPORT KWidgetAction : public KAction
{
Q_OBJECT
public:
KWidgetAction( QWidget* widget, const QString& text,
const KShortcut& cut,
const QObject* receiver, const char* slot,
KActionCollection* parent, const char* name );
virtual ~KWidgetAction();
QWidget* widget() { return m_widget; }
void setAutoSized( bool );
virtual int plug( QWidget* widget, int index = -1 );
virtual void unplug( QWidget *w );
protected slots:
void slotToolbarDestroyed();
private:
QGuardedPtr<QWidget> m_widget;
bool m_autoSized;
protected:
virtual void virtual_hook( int id, void* data );
private:
class KWidgetActionPrivate;
KWidgetActionPrivate *d;
};
class KDEUI_EXPORT KActionSeparator : public KAction
{
Q_OBJECT
public:
KActionSeparator( QObject* parent = 0, const char* name = 0 );
virtual ~KActionSeparator();
virtual int plug( QWidget *widget, int index = -1 );
protected:
virtual void virtual_hook( int id, void* data );
private:
class KActionSeparatorPrivate;
KActionSeparatorPrivate *d;
};
class KDEUI_EXPORT KPasteTextAction: public KAction
{
Q_OBJECT
public:
KPasteTextAction( const QString& text, const QString& icon, const KShortcut& cut,
const QObject* receiver, const char* slot,
QObject* parent = 0, const char* name = 0 );
virtual ~KPasteTextAction();
void setMixedMode(bool mode);
virtual int plug( QWidget *widget, int index = -1 );
protected slots:
void menuAboutToShow();
void menuItemActivated( int id);
virtual void slotActivated();
protected:
virtual void virtual_hook( int id, void* data );
private:
KPopupMenu *m_popup;
bool m_mixedMode;
class KPasteTextActionPrivate;
KPasteTextActionPrivate *d;
};
#endif
KURL
KActionCollection
A managed set of KAction objects.
Definition: kactioncollection.h:78
KAccel
KWidgetAction::widget
QWidget * widget()
Returns the widget associated with this action.
Definition: kactionclasses.h:1316
KListAction
Remove this class in KDE-4.0. It doesn't add anything to KSelectAction.
Definition: kactionclasses.h:581
KSelectAction::isShortcutConfigurable
virtual bool isShortcutConfigurable() const
Returns true if this action's shortcut is configurable.
Definition: kactionclasses.h:497
KWidgetAction
An action that automatically embeds a widget into a toolbar.
Definition: kactionclasses.h:1298
KAction::unplug
virtual void unplug(QWidget *w)
"Unplug" or remove this action from a given widget.
Definition: kaction.cpp:735
KToggleAction::setChecked
virtual void setChecked(bool)
Sets the state of the action.
Definition: kactionclasses.cpp:162
KShortcut
KSelectAction
Action for selecting one of several items.
Definition: kactionclasses.h:329
KSelectAction::plug
virtual int plug(QWidget *widget, int index=-1)
"Plug" or insert this action into a given widget.
Definition: kactionclasses.cpp:636
KToggleToolBarAction
An action that takes care of everything associated with showing or hiding a toolbar by a menu action...
Definition: kactionclasses.h:1208
KSelectAction::currentText
virtual QString currentText() const
Returns the text of the currently selected item.
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
KRadioAction
Radiobox like action.
Definition: kactionclasses.h:230
KInstance
KConfigBase
KSelectAction::setCurrentItem
virtual void setCurrentItem(int index)
Sets the currently checked item.
Definition: kactionclasses.cpp:437
KConfig
KPasteTextAction
An action for pasting text from the clipboard.
Definition: kactionclasses.h:1368
KToggleAction::plug
virtual int plug(QWidget *widget, int index=-1)
"Plug" or insert this action into a given widget.
Definition: kactionclasses.cpp:135
KRecentFilesAction
Recent files action.
Definition: kactionclasses.h:696
KToolBar
Floatable toolbar with auto resize.
Definition: ktoolbar.h:103
KAction
Class to encapsulate user-driven action or event.
Definition: kaction.h:202
KAction::toolTip
virtual QString toolTip() const
Get the tooltip text for the action.
KToggleAction
Checkbox like action.
Definition: kactionclasses.h:68
KToolBarPopupAction
This action is a normal action everywhere, except in a toolbar where it also has a popupmenu (optionn...
Definition: kactionclasses.h:1086
KToggleFullScreenAction
An action for switching between to/from full screen mode.
Definition: kactionclasses.h:1254
KAction::activated
void activated()
Emitted when this action is activated.
KSelectAction::currentItem
virtual int currentItem() const
Returns the index of the current item.
KSelectAction::items
virtual QStringList items() const
KAction::plug
virtual int plug(QWidget *widget, int index=-1)
"Plug" or insert this action into a given widget.
Definition: kaction.cpp:618

KDE Home | KDE Accessibility Home | Description of Access Keys