KVIrc  4.9.2
DeveloperAPIs
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes | Friends | List of all members
KviAction Class Reference

Defines an action inside KVIrc. More...

#include <KviAction.h>

+ Inheritance diagram for KviAction:

Public Types

enum  Flags {
  NeedsContext = 1, NeedsConnection = 2, WindowConsole = 4, WindowChannel = 8,
  WindowQuery = 16, WindowDccChat = 32, InternalWindowMask = WindowConsole | WindowChannel | WindowQuery | WindowDccChat, EnableAtLogin = 64,
  WindowOnlyIfUsersSelected = 128
}
 Holds the flags of an action. More...
 
enum  InternalFlags { Enabled = 1, SetupDone = 2 }
 Holds the internal flags of an action. More...
 

Public Slots

virtual void activate ()
 Activates the action. More...
 

Signals

void activated ()
 Emitted when the action is being activated. More...
 

Public Member Functions

virtual QAction * addToCustomToolBar (KviCustomToolBar *pParentToolBar)
 Adds the action to the given toolbar. More...
 
virtual bool addToPopupMenu (QMenu *pMenu)
 Adds the action to the given popup. More...
 
QPixmap * bigIcon ()
 Returns the big icon associated to the action. More...
 
const QString & bigIconId () const
 Returns the id of the big icon associated to the action. More...
 
KviActionCategorycategory () const
 Returns the category of the action. More...
 
virtual const QString & description ()
 Returns the description of the action. More...
 
unsigned int flags ()
 Returns the flag associated to the action. More...
 
bool isEnabled () const
 Returns true if the action is enabled. More...
 
virtual bool isKviUserActionNeverOverrideThis ()
 Returns true if the action is user-defined. More...
 
const QString & keySequence () const
 Returns the shortcut of the action. More...
 
 KviAction (QObject *pParent, const QString &szName, const QString &szVisibleName, const QString &szDescription, KviActionCategory *pCategory=NULL, const QString &szBigIconId=QString(), const QString &szSmallIconId=QString(), unsigned int uFlags=0, const QString &szKeySequence=QString())
 Constructs the action object. More...
 
 KviAction (QObject *pParent, const QString &szName, const QString &szVisibleName, const QString &szDescription, KviActionCategory *pCategory=NULL, const QString &szBigIconId=QString(), KviIconManager::SmallIcon eSmallIcon=KviIconManager::None, unsigned int uFlags=0, const QString &szKeySequence=QString())
 Constructs the action object. More...
 
const QString & name () const
 Returns the name of the action. More...
 
virtual void setEnabled (bool bEnabled)
 Enables the action. More...
 
QPixmap * smallIcon ()
 Returns the small icon associated to the action. More...
 
const QString & smallIconId () const
 Returns the id of the small icon associated to the action. More...
 
void suicide ()
 Destroys itself. Maybe the best function in the whole APIs :) More...
 
virtual const QString & visibleName ()
 Returns the visible name of the action. More...
 
virtual ~KviAction ()
 Destroys the action object. More...
 

Static Public Member Functions

static int validateFlags (int iFlagsToValidate)
 Validates the flags of the action. More...
 

Protected Slots

virtual void actionDestroyed ()
 Removes the action from the list. More...
 
virtual void activeContextChanged ()
 Enables or disables the action upon checking the active context. More...
 
virtual void activeContextStateChanged ()
 Enables or disables the action upon checking the active context. More...
 
virtual void activeWindowChanged ()
 Enables or disables the action upon checking the active window. More...
 
virtual void activeWindowSelectionStateChanged (bool bSelectedNow)
 Enables or disables the action upon checking the active window. More...
 
virtual void reloadImages ()
 Reloads the images. More...
 

Protected Member Functions

KviPointerList< QAction > * actionList ()
 Returns the list of actions associated to the action. More...
 
void registerAccelerator ()
 Registers the action shortcut in the application. More...
 
void registerAction (QAction *pAction)
 Adds the action to the list. More...
 
virtual void setup ()
 Enables or disables the action upon starting KVIrc. More...
 
bool setupDone () const
 Returns true if the setup is finished. More...
 
void unregisterAccelerator ()
 Removes the action shortcut from the application. More...
 

Protected Attributes

KviIconManager::SmallIcon m_eSmallIcon
 
QPointer< QShortcut > m_pAccel
 
KviPointerList< QAction > * m_pActionList
 
KviActionCategorym_pCategory
 
QString m_szBigIconId
 
QString m_szDescription
 
QString m_szKeySequence
 
QString m_szName
 
QString m_szSmallIconId
 
QString m_szVisibleName
 
unsigned int m_uFlags
 
unsigned short int m_uInternalFlags
 

Friends

class KviActionManager
 

Detailed Description

Defines an action inside KVIrc.

Member Enumeration Documentation

Holds the flags of an action.

Enumerator
NeedsContext 

the action needs a context

NeedsConnection 

the action needs a connection; implies NeedsContext

WindowConsole 

the action is bound to a console window

WindowChannel 

the action is bound to a channel window

WindowQuery 

the action is bound to a query window

WindowDccChat 

the action is bound to a DCC Chat window

InternalWindowMask 

the action is bound to a window

EnableAtLogin 

the action is enabled at login; implies NeedsConnection

WindowOnlyIfUsersSelected 

the action is bound to a window only if it's selected by the user; implies at least one of WindowConsole | WindowChannel | WindowQuery

Holds the internal flags of an action.

Enumerator
Enabled 

the action is enabled

SetupDone 

the setup of the action is done

Constructor & Destructor Documentation

KviAction::KviAction ( QObject *  pParent,
const QString &  szName,
const QString &  szVisibleName,
const QString &  szDescription,
KviActionCategory pCategory = NULL,
const QString &  szBigIconId = QString(),
const QString &  szSmallIconId = QString(),
unsigned int  uFlags = 0,
const QString &  szKeySequence = QString() 
)

Constructs the action object.

Parameters
pParentThe parent object

It can be 0, but using a QObject will help in deleting this action :)

Parameters
szNameInternal name of this action, in form [module.]name
szVisibleNamePermanent visible name, visible at least in the action drawer
szDescriptionWhat this action does
pCategoryOne of KviActionManager::category*() or 0 (default category), not owned!
szBigIconIdThe big icon associated to the action (32x32)
szSmallIconIdThe small icon associated to the action (16x16)
uFlagsThe flags of the action, like needs and configuration
szKeySequenceThe shortcut to activate the action
Note
The action name is INTERNAL: it should be never shown to the user. If it contains a dot then the part before the dot is considered to be a module name to be loaded when the module is loaded.
Returns
KviAction
KviAction::KviAction ( QObject *  pParent,
const QString &  szName,
const QString &  szVisibleName,
const QString &  szDescription,
KviActionCategory pCategory = NULL,
const QString &  szBigIconId = QString(),
KviIconManager::SmallIcon  eSmallIcon = KviIconManager::None,
unsigned int  uFlags = 0,
const QString &  szKeySequence = QString() 
)

Constructs the action object.

Parameters
pParentThe parent object

It can be 0, but using a QObject will help in deleting this action :)

Parameters
szNameInternal name of this action, in form [module.]name
szVisibleNamePermanent visible name, visible at least in the action drawer
szDescriptionWhat this action does
pCategoryOne of KviActionManager::category*() or 0 (default category), not owned!
szBigIconIdThe big icon associated to the action (32x32)
eIconThe small icon associated to the action (16x16)
uFlagsThe flags of the action, like needs and configuration
szKeySequenceThe shortcut to activate the action
Note
The action name is INTERNAL: it should be never shown to the user. If it contains a dot then the part before the dot is considered to be a module name to be loaded when the module is loaded.
Returns
KviAction
KviAction::~KviAction ( )
virtual

Member Function Documentation

void KviAction::actionDestroyed ( )
protectedvirtualslot

Removes the action from the list.

Called when the action is being destroyed

Returns
void

References m_pActionList, and KviPointerList< T >::removeRef().

Referenced by registerAction(), and ~KviAction().

KviPointerList<QAction>* KviAction::actionList ( )
inlineprotected

Returns the list of actions associated to the action.

Returns
KviPointerList<QAction> *

Referenced by KviConnectAction::activeContextStateChanged(), and KviGoAwayAction::activeContextStateChanged().

void KviAction::activate ( )
virtualslot

Activates the action.

It's called when the user activates the action clicking on the toolbar, the menu or by hitting its shortcut.

Returns
void

Reimplemented in KviKvsAction, and KviConnectAction.

References activated(), and isEnabled().

Referenced by action_kvs_cmd_trigger(), addToCustomToolBar(), addToPopupMenu(), and registerAccelerator().

void KviAction::activated ( )
signal

Emitted when the action is being activated.

Returns
void

Referenced by activate(), and registerAccelerator().

void KviAction::activeContextChanged ( )
protectedvirtualslot

Enables or disables the action upon checking the active context.

If the context doesn't exist, the action is disabled

Called when the frame changes the active context.

Note
It works only if NeedsContext is specified
Returns
void

Reimplemented in KviGoAwayAction, KviIrcContextDisplayAction, and KviConnectAction.

References KviMainWindow::activeContext(), activeContextStateChanged(), g_pMainWindow, isEnabled(), m_uFlags, NeedsConnection, and setEnabled().

Referenced by setup().

void KviAction::activeContextStateChanged ( )
protectedvirtualslot

Enables or disables the action upon checking the active context.

Called when the frame changes the state of the context

Returns
void

Reimplemented in KviGoAwayAction, KviIrcContextDisplayAction, and KviConnectAction.

References KviMainWindow::activeContext(), KviIrcContext::Connected, KviIrcContext::Connecting, EnableAtLogin, g_pMainWindow, KviIrcContext::Idle, isEnabled(), KviIrcContext::LoggingIn, m_uFlags, setEnabled(), and KviIrcContext::state().

Referenced by activeContextChanged(), and setup().

void KviAction::activeWindowChanged ( )
protectedvirtualslot
void KviAction::activeWindowSelectionStateChanged ( bool  bSelectedNow)
protectedvirtualslot

Enables or disables the action upon checking the active window.

Called when the frame changes the active window.

Note
We jump here ONLY if m_uFlags & WindowOnlyIfUsersSelected and thus also m_uFlags & InternalWindowMask
Returns
void

References KviWindow::Channel, KviWindow::Console, KviWindow::DccChat, g_pActiveWindow, isEnabled(), m_uFlags, KviWindow::Query, setEnabled(), KviWindow::type(), WindowChannel, WindowConsole, WindowDccChat, and WindowQuery.

Referenced by setup().

QAction * KviAction::addToCustomToolBar ( KviCustomToolBar pParentToolBar)
virtual

Adds the action to the given toolbar.

Parameters
pParentToolBarThe toolbar where to add the action
Returns
QAction *

Reimplemented in KviGoAwayAction, KviIrcContextDisplayAction, KviSubmenuAction, KviSeparatorAction, and KviConnectAction.

References activate(), bigIcon(), connect(), isEnabled(), m_szName, registerAction(), setup(), setupDone(), and visibleName().

Referenced by KviCustomToolBarDescriptor::addAction(), KviCustomToolBar::dragEnterEvent(), and KviCustomToolBarDescriptor::fillToolBar().

bool KviAction::addToPopupMenu ( QMenu *  pMenu)
virtual

Adds the action to the given popup.

Parameters
pMenuThe menu where to add the action
Returns
bool

Reimplemented in KviGoAwayAction, KviIrcContextDisplayAction, KviSubmenuAction, KviSeparatorAction, and KviConnectAction.

References activate(), isEnabled(), m_szKeySequence, registerAction(), setup(), setupDone(), smallIcon(), and visibleName().

Referenced by KviIrcToolsAction::popupAboutToShow(), and KviIrcOperationsAction::popupAboutToShow().

QPixmap * KviAction::bigIcon ( )
const QString& KviAction::bigIconId ( ) const
inline

Returns the id of the big icon associated to the action.

Returns
const QString &
KviActionCategory* KviAction::category ( ) const
inline

Returns the category of the action.

Returns
const QString &
const QString & KviAction::description ( )
virtual

Returns the description of the action.

Returns
const QString &

Reimplemented in KviKvsUserAction.

References m_szDescription.

Referenced by KviActionDrawerPageListWidgetItem::KviActionDrawerPageListWidgetItem().

unsigned int KviAction::flags ( )
inline

Returns the flag associated to the action.

Returns
unsigned int
bool KviAction::isEnabled ( ) const
inline
bool KviAction::isKviUserActionNeverOverrideThis ( )
virtual

Returns true if the action is user-defined.

Warning
By default, this function returns always false
Returns
bool

Reimplemented in KviKvsUserAction.

Referenced by action_kvs_cmd_create(), action_kvs_cmd_destroy(), KviActionManager::coreActionExists(), CustomizeToolBarsDialog::exportToolBar(), and KviActionDrawerPageListWidgetItem::KviActionDrawerPageListWidgetItem().

const QString& KviAction::keySequence ( ) const
inline

Returns the shortcut of the action.

Returns
const QString &
const QString& KviAction::name ( ) const
inline
void KviAction::registerAccelerator ( )
protected

Registers the action shortcut in the application.

Returns
void

References activate(), activated(), connect(), KviMainWindow::freeAccelleratorKeySequence(), g_pMainWindow, m_pAccel, and m_szKeySequence.

Referenced by KviActionManager::registerAction().

void KviAction::registerAction ( QAction *  pAction)
protected
void KviAction::reloadImages ( )
protectedvirtualslot

Reloads the images.

Called when the application wants to refresh the images in the toolbar

Returns
void

Reimplemented in KviGoAwayAction, and KviConnectAction.

References bigIcon(), KviPointerList< T >::first(), KVI_OPTION_BOOL, KviOption_boolShowIconsInPopupMenus, m_pActionList, KviPointerList< T >::next(), and smallIcon().

Referenced by setup().

void KviAction::setEnabled ( bool  bEnabled)
virtual
void KviAction::setup ( )
protectedvirtual
bool KviAction::setupDone ( ) const
inlineprotected
QPixmap * KviAction::smallIcon ( )
const QString& KviAction::smallIconId ( ) const
inline

Returns the id of the small icon associated to the action.

Returns
const QString &
void KviAction::suicide ( )
inline

Destroys itself. Maybe the best function in the whole APIs :)

Returns
void

Referenced by action_kvs_cmd_create(), and action_kvs_cmd_destroy().

void KviAction::unregisterAccelerator ( )
protected

Removes the action shortcut from the application.

Returns
void

References m_pAccel.

Referenced by KviActionManager::unregisterAction(), and ~KviAction().

int KviAction::validateFlags ( int  iFlagsToValidate)
static

Validates the flags of the action.

Parameters
iFlagsToValidateThe flags to validate
Returns
int

References EnableAtLogin, InternalWindowMask, NeedsConnection, NeedsContext, and WindowOnlyIfUsersSelected.

Referenced by action_kvs_cmd_create(), SingleActionEditor::commit(), and SingleActionEditor::setActionData().

const QString & KviAction::visibleName ( )
virtual

Friends And Related Function Documentation

friend class KviActionManager
friend

Member Data Documentation

KviIconManager::SmallIcon KviAction::m_eSmallIcon
protected

Referenced by smallIcon().

QPointer<QShortcut> KviAction::m_pAccel
protected
KviPointerList<QAction>* KviAction::m_pActionList
protected
KviActionCategory* KviAction::m_pCategory
protected
QString KviAction::m_szBigIconId
protected
QString KviAction::m_szDescription
protected
QString KviAction::m_szKeySequence
protected
QString KviAction::m_szName
protected
QString KviAction::m_szSmallIconId
protected
QString KviAction::m_szVisibleName
protected
unsigned int KviAction::m_uFlags
protected
unsigned short int KviAction::m_uInternalFlags
protected

The documentation for this class was generated from the following files: