KAuth 5.109.0
Signals | Public Member Functions | List of all members
KAuth::ObjectDecorator

A decorator to add auth features to a button or an action. More...

#include <KAuth/ObjectDecorator>

Signals

void authorized (const KAuth::Action &action)
 Signal emitted when the action is authorized.
 

Public Member Functions

 ObjectDecorator (QObject *parent)
 Instantiate a new decorator attached to an object.
 
 ~ObjectDecorator () override
 Destructs the decorator.
 
KAuth::Action authAction () const
 Returns the action object associated with this decorator, or an invalid action if it does not have one.
 
void setAuthAction (const KAuth::Action &action)
 Sets the action object associated with this decorator.
 
void setAuthAction (const QString &actionName)
 Sets the action object associated with this decorator.
 

Detailed Description

A decorator to add auth features to a button or an action.

Author
Dario Freddi drf@k.nosp@m.de.o.nosp@m.rg

Constructor & Destructor Documentation

◆ ObjectDecorator()

KAuth::ObjectDecorator::ObjectDecorator ( QObject *  parent)
explicit

Instantiate a new decorator attached to an object.

Parameters
parentThe parent object this decorator will be attached to

◆ ~ObjectDecorator()

KAuth::ObjectDecorator::~ObjectDecorator ( )
override

Destructs the decorator.

Member Function Documentation

◆ authAction()

KAuth::Action KAuth::ObjectDecorator::authAction ( ) const

Returns the action object associated with this decorator, or an invalid action if it does not have one.

Returns
the KAuth::Action associated with this decorator.

◆ authorized

void KAuth::ObjectDecorator::authorized ( const KAuth::Action action)
signal

Signal emitted when the action is authorized.

If the decorator needs authorization, whenever the user triggers it, the authorization process automatically begins. If it succeeds, this signal is emitted. The KAuth::Action object is provided for convenience if you have multiple Action objects, but of course it's always the same set with setAuthAction().

WARNING: If your button or action needs authorization you should connect eventual slots processing stuff to this signal, and NOT clicked/triggered. Clicked/triggered will be emitted even if the user has not been authorized

Parameters
actionThe object set with setAuthAction()

◆ setAuthAction() [1/2]

void KAuth::ObjectDecorator::setAuthAction ( const KAuth::Action action)

Sets the action object associated with this decorator.

By setting a KAuth::Action, this decorator will become associated with it, and whenever the action or button it is attached to gets clicked, it will trigger the authorization and execution process for the action. Pass an invalid action to this function to disassociate the decorator.

Parameters
actionthe KAuth::Action to associate with this decorator.

◆ setAuthAction() [2/2]

void KAuth::ObjectDecorator::setAuthAction ( const QString &  actionName)

Sets the action object associated with this decorator.

Overloaded member to allow creating the action by name

Parameters
actionNamethe name of the action to associate