Polkit-Qt-1  0.95.0
Public Slots | Signals | Public Member Functions | Protected Member Functions | Protected Attributes
PolkitQt1::Gui::ActionButton Class Reference

Class used to hold and update a QAbstractButton. More...

#include <ActionButton>

Inheritance diagram for PolkitQt1::Gui::ActionButton:
PolkitQt1::Gui::Action PolkitQt1::Gui::ActionButtons

Public Slots

bool activate ()
 
- Public Slots inherited from PolkitQt1::Gui::Action
bool activate ()
 
void setChecked (bool checked)
 
void revoke ()
 

Signals

void clicked (QAbstractButton *button, bool checked=false)
 
- Signals inherited from PolkitQt1::Gui::Action
void dataChanged ()
 
void authorized ()
 

Public Member Functions

 ActionButton (QAbstractButton *button, const QString &actionId=QString(), QObject *parent=0)
 
void setButton (QAbstractButton *button)
 
QAbstractButton * button () const
 
- Public Member Functions inherited from PolkitQt1::Gui::Action
 Action (const QString &actionId=QString(), QObject *parent=0)
 
void setPolkitAction (const QString &actionId)
 
QString actionId () const
 
void setText (const QString &text, States states=All)
 
void setToolTip (const QString &toolTip, States states=All)
 
void setWhatsThis (const QString &whatsThis, States states=All)
 
void setIcon (const QIcon &icon, States states=All)
 
void setVisible (bool visible, States states=All)
 
void setEnabled (bool enabled, States states=All)
 
void setTargetPID (qint64 pid)
 
QString text (State state=None) const
 
QString toolTip (State state=None) const
 
QString whatsThis (State state=None) const
 
QIcon icon (State state=None) const
 
bool isVisible (State state=None) const
 
bool isEnabled (State state=None) const
 
qint64 targetPID () const
 
bool isAllowed () const
 
bool is (const QString &actionId) const
 

Protected Member Functions

 ActionButton (ActionButtonPrivate &dd, const QString &actionId, QObject *parent=0)
 

Protected Attributes

ActionButtonPrivate *const d_ptr
 

Additional Inherited Members

- Public Types inherited from PolkitQt1::Gui::Action
enum  State {
  None = 0, SelfBlocked = 1, Yes = 2, No = 4,
  Auth = 8, All = 512
}
 

Detailed Description

Class used to hold and update a QAbstractButton.

Author
Daniel Nicoletti dantt.nosp@m.i85-.nosp@m.pk@ya.nosp@m.hoo..nosp@m.com.b.nosp@m.r
Dario Freddi drf@k.nosp@m.de.o.nosp@m.rg

This class allows you to associate QAbstractButtons (i.e. QPushButton) to a PolicyKit Action. It will update the button properties according to the PolicyKit Action automatically.

Note
You should connect the activated() signal to receive a notification when the user clicked the button and gets permission to perform the given action. If you set 'noEnabled' to true it will be emitted when PolKitResult is NO.

Constructor & Destructor Documentation

◆ ActionButton()

PolkitQt1::Gui::ActionButton::ActionButton ( QAbstractButton *  button,
const QString &  actionId = QString(),
QObject *  parent = 0 
)
explicit

Constructs a new ActionButton. You need to pass this constructor an existing QAbstractButton, whose properties will be modified according to the underlying Action object. As ActionButton inherits from Action, you can define your button's behavior right through this wrapper.

See also
Action
Parameters
buttonthe QAbstractButton to associate to this ActionButton
actionIdthe action Id to create the underlying Action
parentthe parent object

Member Function Documentation

◆ activate

bool PolkitQt1::Gui::ActionButton::activate ( )
slot

Connect clicked() signals to this slot. This should be manually done, as in some cases we might want to manually call this. Calling this will emit authorized().

Note
This slot is reentrant which is likely to only be a problem if you are creating an interface to setup PolicyKit policies.
If you have a checkbox, connect to its' clicked() signal to avoid an infinite loop as this function internally calls setChecked(). You can always use the clicked(bool) signal in this class to connect to here.
Warning
if you use this class take care to not call Action::activate otherwise your checkable buttons won't be properly updated.

◆ button()

QAbstractButton * PolkitQt1::Gui::ActionButton::button ( ) const

Returns the current button

Returns
the button currently associated with the underlying action

◆ clicked

void PolkitQt1::Gui::ActionButton::clicked ( QAbstractButton *  button,
bool  checked = false 
)
signal

Emitted when the abstract button clicked(bool) signal is emitted. This allows you to use qobject_cast<ActionButton *>(sender()) in a slot connected to this signal and call activate() on it.

Note
you will normally want to connect this signal to the activate slot.
Parameters
buttonthe button that has been clicked
checkedthe checked state, if applicable. Otherwise false

◆ setButton()

void PolkitQt1::Gui::ActionButton::setButton ( QAbstractButton *  button)

Sets the button associated to the underlying action.

Note
If you are calling this function, you're probably changing the button the action is referring to. If this is the case, please note that Polkit-Qt does not handle the previous button's memory, so you should take care of deleting it yourself (if needed). You can retrieve it by using button()
See also
button
Parameters
buttonthe new button associated with the underlying action

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