PolkitQt.Action

KDE 4.7 PyKDE API Reference

- KDE's Python API

# Action Class Reference

`from PyKDE4.polkitqt import *`

Inherits: QAction → QObject
Namespace: PolkitQt

## Detailed Description

\class Action action.h Action

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

Author:
  Dario Freddi <drf54321@gmail.com>

Class used to manage actions

This class is an interface around PolicyKit Actions. By using this class, you are able to track the result of a given action.

Most of the times, you would want to use this class combined with a QAbstractButton. In this case, you can use the more comfortable ActionButton class that manages button's properties update for you.

See also:
  ActionButton

## Signals
| activated ()
| dataChanged ()
## Methods
| __init__ (self, QString actionId=QString(), QObject parent=0)
QString | actionId (self)
bool | activate (self, int winId=0)
bool | authEnabled (self)
QIcon | authIcon (self)
QString | authText (self)
QString | authToolTip (self)
bool | authVisible (self)
QString | authWhatsThis (self)
bool | is_ (self, QString actionId)
bool | isAllowed (self)
bool | masterEnabled (self)
bool | masterVisible (self)
bool | noEnabled (self)
QIcon | noIcon (self)
QString | noText (self)
QString | noToolTip (self)
bool | noVisible (self)
QString | noWhatsThis (self)
| revoke (self)
bool | selfBlockedEnabled (self)
QIcon | selfBlockedIcon (self)
QString | selfBlockedText (self)
QString | selfBlockedToolTip (self)
bool | selfBlockedVisible (self)
QString | selfBlockedWhatsThis (self)
| setAuthEnabled (self, bool value)
| setAuthIcon (self, QIcon icon)
| setAuthText (self, QString text)
| setAuthToolTip (self, QString toolTip)
| setAuthVisible (self, bool value)
| setAuthWhatsThis (self, QString whatsThis)
| setChecked (self, bool checked)
| setIcon (self, QIcon icon)
| setMasterEnabled (self, bool value)
| setMasterVisible (self, bool value)
| setNoEnabled (self, bool value)
| setNoIcon (self, QIcon icon)
| setNoText (self, QString text)
| setNoToolTip (self, QString toolTip)
| setNoVisible (self, bool value)
| setNoWhatsThis (self, QString whatsThis)
| setPolkitAction (self, QString actionId=QString())
| setSelfBlockedEnabled (self, bool value)
| setSelfBlockedIcon (self, QIcon icon)
| setSelfBlockedText (self, QString text)
| setSelfBlockedToolTip (self, QString toolTip)
| setSelfBlockedVisible (self, bool value)
| setSelfBlockedWhatsThis (self, QString whatsThis)
| setTargetPID (self, long pid)
| setText (self, QString text)
| setToolTip (self, QString toolTip)
| setWhatsThis (self, QString whatsThis)
| setYesEnabled (self, bool value)
| setYesIcon (self, QIcon icon)
| setYesText (self, QString text)
| setYesToolTip (self, QString toolTip)
| setYesVisible (self, bool value)
| setYesWhatsThis (self, QString whatsThis)
long | targetPID (self)
bool | yesEnabled (self)
QIcon | yesIcon (self)
QString | yesText (self)
QString | yesToolTip (self)
bool | yesVisible (self)
QString | yesWhatsThis (self)

## Signal Documentation

activated | ( |  | ) |

Emitted when using this class as a proxy for a given action, It's only emitted if the activate() slot is called and the auth permits the action

See also:
  activate()

Signal syntax:
  `QObject.connect(source, SIGNAL("activated()"), target_slot)`

dataChanged | ( |  | ) |

Emitted when the PolicyKit result (PolKitResult) for the given action or the internal data changes (i.e. the user called one of the set methods). You should connect to this signal if you want to track these changes.

Signal syntax:
  `QObject.connect(source, SIGNAL("dataChanged()"), target_slot)`

## Method Documentation

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

Constructs a new Action item

Parameters:

  | actionId | the PolicyKit action Id (e.g.: org.freedesktop.policykit.read)

Parameters:

  | parent | the object parent

QString actionId | ( |  | self ) |

Returns the current action ID.

Returns:
  The action ID

bool activate | ( | self, |
|  | int | winId=0
| ) |  |  |

Use this slot if you want to activate the action. activated() will be emitted if the action gets authorized.

Note:
  This will call the auth dialog if needed. Only use the return value if you want a sync behavior.

Parameters:

  | winId | The window id of the parent window, used for the dialog.

Returns:
  true if the caller can do the action

See also:
  activated()

bool authEnabled | ( |  | self ) |

See also:
  setAuthEnabled

QIcon authIcon | ( |  | self ) |

See also:
  setAuthIcon

QString authText | ( |  | self ) |

See also:
  setAuthText

QString authToolTip | ( |  | self ) |

See also:
  setAuthToolTip

bool authVisible | ( |  | self ) |

See also:
  setAuthVisible

QString authWhatsThis | ( |  | self ) |

See also:
  setAuthWhatsThis

bool is_ | ( | self, |
|  | QString | actionId
| ) |  |  |

This method compares a PolicyKit action Id with the current one of the object.

See also:
  actionId()

Parameters:

  | actionId | the action Id to compare

Returns:
  true if the actionId is the same as this object's one

bool isAllowed | ( |  | self ) |

This method can be used to check the if the current action can be performed (i.e. PolKitResult is YES).

Note:
  This method does not call the authentication dialog, use activate() instead

Returns:
  true if the action can be performed

bool masterEnabled | ( |  | self ) |

See also:
  setMasterEnabled

bool masterVisible | ( |  | self ) |

See also:
  setMasterVisible

bool noEnabled | ( |  | self ) |

See also:
  setNoEnabled

QIcon noIcon | ( |  | self ) |

See also:
  setNoIcon

QString noText | ( |  | self ) |

See also:
  setNoText

QString noToolTip | ( |  | self ) |

See also:
  setNoToolTip

bool noVisible | ( |  | self ) |

See also:
  setNoVisible

QString noWhatsThis | ( |  | self ) |

See also:
  setNoWhatsThis

revoke | ( |  | self ) |

This method can be used to revoke the authorization obtained for this action.

bool selfBlockedEnabled | ( |  | self ) |

See also:
  setSelfBlockedEnabled

QIcon selfBlockedIcon | ( |  | self ) |

See also:
  setSelfBlockedIcon

QString selfBlockedText | ( |  | self ) |

See also:
  setSelfBlockedText

QString selfBlockedToolTip | ( |  | self ) |

See also:
  setSelfBlockedToolTip

bool selfBlockedVisible | ( |  | self ) |

See also:
  setSelfBlockedVisible

QString selfBlockedWhatsThis | ( |  | self ) |

See also:
  setSelfBlockedWhatsThis

setAuthEnabled | ( | self, |
|  | bool | value
| ) |  |  |

This function is used to modify the availability of the action in case PolicyKit evaluates the result as 'Auth'

Parameters:

  | value | true if the action should be enabled

false if the action should be disabled

setAuthIcon | ( | self, |
|  | QIcon | icon
| ) |  |  |

This function is used to modify the icon of the action in case PolicyKit evaluates the result as 'Auth'

See also:
  setIcon

Parameters:

  | icon | the icon the action should display in this case

setAuthText | ( | self, |
|  | QString | text
| ) |  |  |

This function is used to modify the text of the action in case PolicyKit evaluates the result as 'Auth'

Parameters:

  | text | the text the action should display in this case

setAuthToolTip | ( | self, |
|  | QString | toolTip
| ) |  |  |

This function is used to modify the tooltip of the action in case PolicyKit evaluates the result as 'Auth'

Parameters:

  | toolTip | the tooltip the action should display in this case

setAuthVisible | ( | self, |
|  | bool | value
| ) |  |  |

This function is used to modify the text of the action in case PolicyKit evaluates the result as 'Auth'

Parameters:

  | value | true if the action should be visible

false if the action shouldn't be visible

setAuthWhatsThis | ( | self, |
|  | QString | whatsThis
| ) |  |  |

This function is used to modify the whatsthis of the action in case PolicyKit evaluates the result as 'Auth'

Parameters:

  | whatsThis | the whatsthis the action should display in this case

setChecked | ( | self, |
|  | bool | checked
| ) |  |  |

Defines the checked state. The opposite state will trigger authentication for this actions. For example, if you set this to true, when the action's checked state will become false, the authentication will be triggered.

Parameters:

  | checked | the new checked state

setIcon | ( | self, |
|  | QIcon | icon
| ) |  |  |

Sets the icon for the current action. This will be shown in all four states.

Note:
  You need to pass a QIcon here. You can easily create one from a Pixmap, or pass a KIcon

Parameters:

  | icon | the new icon for the action

setMasterEnabled | ( | self, |
|  | bool | value
| ) |  |  |

This function allows you to override PolicyKit settings about availability. You can set this to false to force the action being disabled without caring about what PolicyKit reports.

Parameters:

  | value | false if you want to force the action to be disabled

setMasterVisible | ( | self, |
|  | bool | value
| ) |  |  |

This function allows you to override PolicyKit settings about visibility. You can set this to false to force invisibility without caring about what PolicyKit reports.

Parameters:

  | value | false if you want to force invisibility

setNoEnabled | ( | self, |
|  | bool | value
| ) |  |  |

This function is used to modify the availability of the action in case PolicyKit evaluates the result as 'no'

Parameters:

  | value | true if the action should be enabled

false if the action should be disabled

setNoIcon | ( | self, |
|  | QIcon | icon
| ) |  |  |

This function is used to modify the icon of the action in case PolicyKit evaluates the result as 'no'

See also:
  setIcon

Parameters:

  | icon | the icon the action should display in this case

setNoText | ( | self, |
|  | QString | text
| ) |  |  |

This function is used to modify the text of the action in case PolicyKit evaluates the result as 'no'

Parameters:

  | text | the text the action should display in this case

setNoToolTip | ( | self, |
|  | QString | toolTip
| ) |  |  |

This function is used to modify the tooltip of the action in case PolicyKit evaluates the result as 'no'

Parameters:

  | toolTip | the tooltip the action should display in this case

setNoVisible | ( | self, |
|  | bool | value
| ) |  |  |

This function is used to modify the text of the action in case PolicyKit evaluates the result as 'no'

Parameters:

  | value | true if the action should be visible

false if the action shouldn't be visible

setNoWhatsThis | ( | self, |
|  | QString | whatsThis
| ) |  |  |

This function is used to modify the whatsthis of the action in case PolicyKit evaluates the result as 'no'

Parameters:

  | whatsThis | the whatsthis the action should display in this case

setPolkitAction | ( | self, |
|  | QString | actionId=QString()
| ) |  |  |

Changes the action being tracked

Parameters:

  | actionId | The new action ID

setSelfBlockedEnabled | ( | self, |
|  | bool | value
| ) |  |  |

This function is used to modify the availability of the action in case PolicyKit evaluates the result as 'no' because the user has a self-granted negative authorization.

Parameters:

  | value | true if the action should be enabled

false if the action should be disabled

setSelfBlockedIcon | ( | self, |
|  | QIcon | icon
| ) |  |  |

This function is used to modify the icon of the action in case PolicyKit evaluates the result as 'no' because the user has a self-granted negative authorization.

See also:
  setIcon

Parameters:

  | icon | the icon the action should display in this case

setSelfBlockedText | ( | self, |
|  | QString | text
| ) |  |  |

This function is used to modify the text of the action in case PolicyKit evaluates the result as 'no' because the user has a self-granted negative authorization.

Parameters:

  | text | the text the action should display in this case

setSelfBlockedToolTip | ( | self, |
|  | QString | toolTip
| ) |  |  |

This function is used to modify the tooltip of the action in case PolicyKit evaluates the result as 'no' because the user has a self-granted negative authorization.

Parameters:

  | toolTip | the tooltip the action should display in this case

setSelfBlockedVisible | ( | self, |
|  | bool | value
| ) |  |  |

This function is used to modify the visibility of the action in case PolicyKit evaluates the result as 'no' because the user has a self-granted negative authorization.

Parameters:

  | value | true if the action should be visible

false if the action shouldn't be visible

setSelfBlockedWhatsThis | ( | self, |
|  | QString | whatsThis
| ) |  |  |

This function is used to modify the whatsthis of the action in case PolicyKit evaluates the result as 'no' because the user has a self-granted negative authorization.

Parameters:

  | whatsThis | the whatsthis the action should display in this case

setTargetPID | ( | self, |
|  | long | pid
| ) |  |  |

This function sets the process id of the target that should receive the authorization. Set this to 0 to set the current process as the target.

Parameters:

  | pid | The target process id; 0 if it is the current process

setText | ( | self, |
|  | QString | text
| ) |  |  |

Sets the text for the current action. This will be shown in all four states.

Parameters:

  | text | the new text for the action

setToolTip | ( | self, |
|  | QString | toolTip
| ) |  |  |

Sets the tooltip for the current action. This will be shown in all four states.

Parameters:

  | toolTip | the new tooltip for the action

setWhatsThis | ( | self, |
|  | QString | whatsThis
| ) |  |  |

Sets the whatsthis for the current action. This will be shown in all four states.

Parameters:

  | whatsThis | the new whatsthis for the action

setYesEnabled | ( | self, |
|  | bool | value
| ) |  |  |

This function is used to modify the availability of the action in case PolicyKit evaluates the result as 'Yes'

Parameters:

  | value | true if the action should be enabled

false if the action should be disabled

setYesIcon | ( | self, |
|  | QIcon | icon
| ) |  |  |

This function is used to modify the icon of the action in case PolicyKit evaluates the result as 'Yes'

See also:
  setIcon

Parameters:

  | icon | the icon the action should display in this case

setYesText | ( | self, |
|  | QString | text
| ) |  |  |

This function is used to modify the text of the action in case PolicyKit evaluates the result as 'Yes'

Parameters:

  | text | the text the action should display in this case

setYesToolTip | ( | self, |
|  | QString | toolTip
| ) |  |  |

This function is used to modify the tooltip of the action in case PolicyKit evaluates the result as 'Yes'

Parameters:

  | toolTip | the tooltip the action should display in this case

setYesVisible | ( | self, |
|  | bool | value
| ) |  |  |

This function is used to modify the text of the action in case PolicyKit evaluates the result as 'Yes'

Parameters:

  | value | true if the action should be visible

false if the action shouldn't be visible

setYesWhatsThis | ( | self, |
|  | QString | whatsThis
| ) |  |  |

This function is used to modify the whatsthis of the action in case PolicyKit evaluates the result as 'Yes'

Parameters:

  | whatsThis | the whatsthis the action should display in this case

long targetPID | ( |  | self ) |

See also:
  setTargetPID

bool yesEnabled | ( |  | self ) |

See also:
  setYesEnabled

QIcon yesIcon | ( |  | self ) |

See also:
  setYesIcon

QString yesText | ( |  | self ) |

See also:
  setYesText

QString yesToolTip | ( |  | self ) |

See also:
  setYesToolTip

bool yesVisible | ( |  | self ) |

See also:
  setYesVisible

QString yesWhatsThis | ( |  | self ) |

See also:
  setYesWhatsThis