KVIrc 5.2.6
Developer APIs
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.
 

Signals

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

Public Member Functions

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

Static Public Member Functions

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

Protected Slots

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

Protected Member Functions

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

Protected Attributes

KviIconManager::SmallIcon m_eSmallIcon
 
QPointer< QShortcut > m_pAccel
 
std::unordered_set< QAction * > m_pActionList
 
KviActionCategorym_pCategory = nullptr
 
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

◆ Flags

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

◆ InternalFlags

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() [1/2]

KviAction::KviAction ( QObject * pParent,
QString szName,
QString szVisibleName,
QString szDescription,
KviActionCategory * pCategory = nullptr,
QString szBigIconId = QString(),
QString szSmallIconId = QString(),
unsigned int uFlags = 0,
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

References Enabled, KviAction(), m_eSmallIcon, m_pAccel, m_pCategory, m_szBigIconId, m_szDescription, m_szKeySequence, m_szName, m_szSmallIconId, m_szVisibleName, m_uFlags, and m_uInternalFlags.

Referenced by KviAction(), KviAction(), KviConnectAction::KviConnectAction(), KviIrcContextDisplayAction::KviIrcContextDisplayAction(), KviKvsAction::KviKvsAction(), KviKvsAction::KviKvsAction(), KviSeparatorAction::KviSeparatorAction(), and setEnabled().

◆ KviAction() [2/2]

KviAction::KviAction ( QObject * pParent,
QString szName,
QString szVisibleName,
QString szDescription,
KviActionCategory * pCategory = nullptr,
QString szBigIconId = QString(),
KviIconManager::SmallIcon eSmallIcon = KviIconManager::None,
unsigned int uFlags = 0,
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

References Enabled, KviAction(), m_eSmallIcon, m_pAccel, m_pCategory, m_szBigIconId, m_szDescription, m_szKeySequence, m_szName, m_szVisibleName, m_uFlags, and m_uInternalFlags.

◆ ~KviAction()

KviAction::~KviAction ( )
virtual

Destroys the action object.

References actionDestroyed(), m_pActionList, and unregisterAccelerator().

Member Function Documentation

◆ actionDestroyed

void KviAction::actionDestroyed ( )
protectedvirtualslot

Removes the action from the list.

Called when the action is being destroyed

Returns
void

References m_pActionList.

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

◆ actionList()

std::unordered_set< QAction * > const & KviAction::actionList ( ) const
inlineprotected

Returns the list of actions associated to the action.

Returns
std::unordered_set<QAction *>

References m_pActionList.

Referenced by KviConnectAction::activeContextStateChanged().

◆ activate

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 KviConnectAction, and KviKvsAction.

References activated(), and isEnabled().

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

◆ activated

void KviAction::activated ( )
signal

Emitted when the action is being activated.

Returns
void

Referenced by activate(), and registerAccelerator().

◆ activeContextChanged

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 KviConnectAction, KviGoAwayAction, and KviIrcContextDisplayAction.

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

Referenced by setup().

◆ activeContextStateChanged

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 KviConnectAction, KviGoAwayAction, and KviIrcContextDisplayAction.

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

Referenced by activeContextChanged(), and setup().

◆ activeWindowChanged

void KviAction::activeWindowChanged ( )
protectedvirtualslot

◆ activeWindowSelectionStateChanged

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(), WindowChannel, WindowConsole, WindowDccChat, and WindowQuery.

Referenced by setup().

◆ addToCustomToolBar()

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 KviConnectAction, KviGoAwayAction, KviIrcContextDisplayAction, KviSeparatorAction, and KviSubmenuAction.

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

Referenced by KviCustomToolBar::dragEnterEvent().

◆ addToPopupMenu()

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 KviConnectAction, KviGoAwayAction, KviIrcContextDisplayAction, KviSeparatorAction, and KviSubmenuAction.

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

◆ bigIcon()

◆ bigIconId()

const QString & KviAction::bigIconId ( ) const
inline

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

Returns
const QString &

References m_szBigIconId.

◆ category()

KviActionCategory * KviAction::category ( ) const
inline

Returns the category of the action.

Returns
const QString &

References m_pCategory.

◆ description()

const QString & KviAction::description ( )
virtual

Returns the description of the action.

Returns
const QString &

Reimplemented in KviKvsUserAction.

References m_szDescription.

Referenced by KviActionDrawerPageListWidgetItem::KviActionDrawerPageListWidgetItem().

◆ flags()

unsigned int KviAction::flags ( ) const
inline

Returns the flag associated to the action.

Returns
unsigned int

References m_uFlags.

◆ isEnabled()

◆ isKviUserActionNeverOverrideThis()

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(), CustomizeToolBarsDialog::exportToolBar(), and KviActionDrawerPageListWidgetItem::KviActionDrawerPageListWidgetItem().

◆ keySequence()

const QString & KviAction::keySequence ( ) const
inline

Returns the shortcut of the action.

Returns
const QString &

References m_szKeySequence.

◆ name()

const QString & KviAction::name ( ) const
inline

Returns the name of the action.

Returns
const QString &

References m_szName.

Referenced by KviSubmenuAction::addToCustomToolBar().

◆ registerAccelerator()

void KviAction::registerAccelerator ( )
protected

Registers the action shortcut in the application.

Returns
void

References activate(), activated(), connect(), g_pMainWindow, m_pAccel, m_szKeySequence, and unregisterAccelerator().

◆ registerAction()

void KviAction::registerAction ( QAction * pAction)
protected

◆ reloadImages

void KviAction::reloadImages ( )
protectedvirtualslot

Reloads the images.

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

Returns
void

Reimplemented in KviConnectAction, and KviGoAwayAction.

References bigIcon(), KVI_OPTION_BOOL, KviOption_boolShowIconsInPopupMenus, m_pActionList, and smallIcon().

Referenced by setup().

◆ setEnabled()

void KviAction::setEnabled ( bool bEnabled)
virtual

Enables the action.

Parameters
bEnabledWhether to enable the action
Returns
void

Reimplemented in KviIrcContextDisplayAction.

References Enabled, KviAction(), m_pActionList, and m_uInternalFlags.

Referenced by activeContextChanged(), activeContextStateChanged(), activeWindowChanged(), activeWindowSelectionStateChanged(), and setup().

◆ setup()

◆ setupDone()

bool KviAction::setupDone ( ) const
inlineprotected

◆ smallIcon()

QPixmap * KviAction::smallIcon ( )

Returns the small icon associated to the action.

Returns
QPixmap *

References g_pIconManager, m_eSmallIcon, m_szSmallIconId, and KviIconManager::None.

Referenced by addToPopupMenu(), KviSubmenuAction::addToPopupMenu(), and reloadImages().

◆ smallIconId()

const QString & KviAction::smallIconId ( ) const
inline

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

Returns
const QString &

References m_szSmallIconId.

◆ suicide()

void KviAction::suicide ( )
inline

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

Returns
void

Referenced by action_kvs_cmd_create().

◆ unregisterAccelerator()

void KviAction::unregisterAccelerator ( )
protected

Removes the action shortcut from the application.

Returns
void

References m_pAccel.

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

◆ validateFlags()

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().

◆ visibleName()

const QString & KviAction::visibleName ( )
virtual

Friends And Related Symbol Documentation

◆ KviActionManager

Member Data Documentation

◆ m_eSmallIcon

KviIconManager::SmallIcon KviAction::m_eSmallIcon
protected

Referenced by KviAction(), KviAction(), and smallIcon().

◆ m_pAccel

QPointer<QShortcut> KviAction::m_pAccel
protected

◆ m_pActionList

◆ m_pCategory

◆ m_szBigIconId

◆ m_szDescription

◆ m_szKeySequence

◆ m_szName

◆ m_szSmallIconId

QString KviAction::m_szSmallIconId
protected

◆ m_szVisibleName

◆ m_uFlags

◆ m_uInternalFlags

unsigned short int KviAction::m_uInternalFlags
protected

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