PolkitQt.ActionButton

KDE 4.9 PyKDE API Reference

- KDE's Python API

# ActionButton Class Reference

`from PyKDE4.polkitqt import *`

Inherits: PolkitQt.Action → QAction → QObject
Subclasses: PolkitQt.ActionButtons
Namespace: PolkitQt

## Detailed Description

\class ActionButton actionbutton.h ActionButton

Author:
  Daniel Nicoletti <dantti85-pk@yahoo.com.br>

Author:
  Dario Freddi <drf54321@gmail.com>

Class used to hold and update a QAbstractButton

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.

## Signals
| clicked (QAbstractButton button, bool checked=0)
## Methods
| __init__ (self, QAbstractButton button, QString actionId=QString(), QObject parent=0)
bool | activate (self)
QAbstractButton | button (self)
| setButton (self, QAbstractButton button)

## Signal Documentation

clicked | ( | QAbstractButton | button,
|  | bool | checked=0
| ) |  |  |

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:

  | button | the button that has been clicked

Parameters:

  | checked | the checked state, if applicable. Otherwise false

Signal syntax:
  `QObject.connect(source, SIGNAL("clicked(QAbstractButton*, bool)"), target_slot)`

## Method Documentation

__init__ | ( | self, |
|  | QAbstractButton | button,
|  | QString | actionId=QString(),
|  | QObject | parent=0
| ) |  |  |

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:

  | button | the QAbstractButton to associate to this ActionButton

Parameters:

  | actionId | the action Id to create the underlying Action

Parameters:

  | parent | the parent object

bool activate | ( |  | self ) |

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

Note:
  This slot is reentrant which is likely to only be a problem if you are creating an interface to setup PolicyKit policies.

Note:
  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.

QAbstractButton button | ( |  | self ) |

Returns the current button

Returns:
  the button currently associated with the underlying action

setButton | ( | self, |
|  | 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:

  | button | the new button associated with the underlying action