Warning, file /libraries/polkit-qt-1/gui/polkitqt1-gui-actionbutton.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 This file is part of the Polkit-qt project 0003 SPDX-FileCopyrightText: 2009 Daniel Nicoletti <dantti85-pk@yahoo.com.br> 0004 SPDX-FileCopyrightText: 2009 Dario Freddi <drf@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #ifndef POLKITQT1_GUI_ACTIONBUTTON_H 0010 #define POLKITQT1_GUI_ACTIONBUTTON_H 0011 0012 #include "polkitqt1-gui-action.h" 0013 0014 class QAbstractButton; 0015 0016 namespace PolkitQt1 0017 { 0018 0019 namespace Gui 0020 { 0021 0022 class ActionButtonPrivate; 0023 /** 0024 * \class ActionButton polkitqt1-gui-actionbutton.h ActionButton 0025 * \author Daniel Nicoletti <dantti85-pk@yahoo.com.br> 0026 * \author Dario Freddi <drf@kde.org> 0027 * 0028 * \brief Class used to hold and update a QAbstractButton 0029 * 0030 * This class allows you to associate QAbstractButtons 0031 * (i.e. QPushButton) to a PolicyKit Action. It will update the 0032 * button properties according to the PolicyKit Action automatically. 0033 * 0034 * \note You should connect the activated() signal to receive 0035 * a notification when the user clicked the button and gets 0036 * permission to perform the given action. If you set 'noEnabled' 0037 * to \c true it will be emitted when PolKitResult is NO. 0038 */ 0039 class POLKITQT1_GUI_EXPORT ActionButton : public Action 0040 { 0041 Q_OBJECT 0042 Q_DECLARE_PRIVATE(ActionButton) 0043 Q_DISABLE_COPY(ActionButton) 0044 0045 public: 0046 /** 0047 * Constructs a new ActionButton. You need to pass this 0048 * constructor an existing QAbstractButton, whose properties 0049 * will be modified according to the underlying Action 0050 * object. As ActionButton inherits from Action, you can 0051 * define your button's behavior right through this wrapper. 0052 * 0053 * \see Action 0054 * 0055 * \param button the QAbstractButton to associate to this ActionButton 0056 * \param actionId the action Id to create the underlying Action 0057 * \param parent the parent object 0058 */ 0059 explicit ActionButton(QAbstractButton *button, const QString &actionId = QString(), QObject *parent = nullptr); 0060 ~ActionButton() override; 0061 0062 /** 0063 * Sets the button associated to the underlying action. 0064 * 0065 * \note If you are calling this function, you're probably 0066 * changing the button the action is referring to. If this 0067 * is the case, please note that Polkit-Qt does not handle 0068 * the previous button's memory, so you should take care of 0069 * deleting it yourself (if needed). You can retrieve it by 0070 * using button() 0071 * 0072 * \see button 0073 * 0074 * \param button the new button associated with the underlying action 0075 */ 0076 void setButton(QAbstractButton *button); 0077 0078 /** 0079 * Returns the current button 0080 * 0081 * \return the button currently associated with the underlying action 0082 */ 0083 QAbstractButton *button() const; 0084 0085 public Q_SLOTS: 0086 /** 0087 * Connect clicked() signals to this slot. This should be 0088 * manually done, as in some cases we might want 0089 * to manually call this. Calling this will emit authorized(). 0090 * 0091 * \note This slot is reentrant which is likely to only be a problem 0092 * if you are creating an interface to setup PolicyKit policies. 0093 * \note If you have a checkbox, connect to its' clicked() signal 0094 * to avoid an infinite loop as this function internally calls setChecked(). 0095 * You can always use the clicked(bool) signal in this class to 0096 * connect to here. 0097 * \warning if you use this class take care to not call Action::activate 0098 * otherwise your checkable buttons won't be properly updated. 0099 */ 0100 bool activate(); 0101 0102 Q_SIGNALS: 0103 /** 0104 * Emitted when the abstract button clicked(bool) signal 0105 * is emitted. This allows you to use qobject_cast<ActionButton *>(sender()) 0106 * in a slot connected to this signal and call activate() on it. 0107 * 0108 * \note you will normally want to connect this signal 0109 * to the activate slot. 0110 * 0111 * \param button the button that has been clicked 0112 * \param checked the checked state, if applicable. Otherwise \c false 0113 * 0114 */ 0115 void clicked(QAbstractButton *button, bool checked = false); 0116 0117 protected: 0118 ActionButton(ActionButtonPrivate &dd, const QString &actionId, QObject *parent = nullptr); 0119 0120 ActionButtonPrivate * const d_ptr; 0121 0122 private: 0123 Q_PRIVATE_SLOT(d_func(), void updateButton()) 0124 Q_PRIVATE_SLOT(d_func(), void streamClicked(bool)) 0125 }; 0126 0127 } 0128 0129 } 0130 0131 #endif