1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
/*
* This file is part of the Polkit-tqt project
* Copyright (C) 2009 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
* Copyright (C) 2009 Dario Freddi <drf@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef POLKIT_TQT_GUI_ACTIONBUTTON_H
#define POLKIT_TQT_GUI_ACTIONBUTTON_H
#include "polkit-tqt-export.h"
#include "polkit-tqt-gui-action.h"
class TQAbstractButton;
namespace PolkitTQt
{
namespace Gui
{
class ActionButtonPrivate;
/**
* \class ActionButton polkit-tqt-gui-actionbutton.h ActionButton
* \author Daniel Nicoletti <dantti85-pk@yahoo.com.br>
* \author Dario Freddi <drf@kde.org>
*
* \brief Class used to hold and update a TQAbstractButton
*
* This class allows you to associate TQAbstractButtons
* (i.e. TQPushButton) 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 \c true it will be emitted when PolKitResult is NO.
*/
class POLKIT_TQT_EXPORT ActionButton : public Action
{
Q_OBJECT
TQ_DECLARE_PRIVATE(ActionButton)
TQ_DISABLE_COPY(ActionButton)
public:
/**
* Constructs a new ActionButton. You need to pass this
* constructor an existing TQAbstractButton, 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 Action
*
* \param button the TQAbstractButton to associate to this ActionButton
* \param actionId the action Id to create the underlying Action
* \param parent the parent object
*/
explicit ActionButton(TQAbstractButton *button, const TQString &actionId = TQString(), TQObject *parent = 0);
virtual ~ActionButton();
/**
* 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-TQt 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 button
*
* \param button the new button associated with the underlying action
*/
void setButton(TQAbstractButton *button);
/**
* Returns the current button
*
* \return the button currently associated with the underlying action
*/
TQAbstractButton *button() const;
public Q_SLOTS:
/**
* 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.
* \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.
*/
bool activate();
Q_SIGNALS:
/**
* 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.
*
* \param button the button that has been clicked
* \param checked the checked state, if applicable. Otherwise \c false
*
*/
void clicked(TQAbstractButton *button, bool checked = false);
protected:
ActionButton(ActionButtonPrivate &dd, const TQString &actionId, TQObject *parent = 0);
ActionButtonPrivate * const d_ptr;
private:
Q_PRIVATE_SLOT(d_func(), void updateButton())
Q_PRIVATE_SLOT(d_func(), void streamClicked(bool))
};
}
}
#endif
|