Polkit-Qt-1  0.95.0
polkitqt1-gui-action.h
1 /*
2  * This file is part of the Polkit-qt project
3  * Copyright (C) 2009 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
4  * Copyright (C) 2009 Dario Freddi <drf@kde.org>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 #ifndef POLKITQT1_GUI_ACTION_H
23 #define POLKITQT1_GUI_ACTION_H
24 
25 #include "polkitqt1-export.h"
26 
27 #include <QAction>
28 
29 namespace PolkitQt1
30 {
31 
32 namespace Gui
33 {
34 
53 class POLKITQT1_EXPORT Action : public QAction
54 {
55  Q_OBJECT
56  Q_DISABLE_COPY(Action)
57 public:
58 
59  enum State {
60  None = 0,
61  SelfBlocked = 1,
62  Yes = 2,
63  No = 4,
64  Auth = 8,
65  // Future usage = 16,
66  // Future usage = 32,
67  // Future usage = 64,
68  // Future usage = 128,
69  // Future usage = 256,
70  All = 512
71  };
72  Q_DECLARE_FLAGS(States, State)
73 
74 
80  explicit Action(const QString &actionId = QString(), QObject *parent = 0);
81  ~Action();
82 
83 Q_SIGNALS:
91  void dataChanged();
92 
101  void authorized();
102 
103 public Q_SLOTS:
113  bool activate();
114 
123  void setChecked(bool checked);
124 
129  void revoke();
130 
131 public:
137  void setPolkitAction(const QString &actionId);
138 
145  QString actionId() const;
146 
154  void setText(const QString &text, States states = All);
155 
163  void setToolTip(const QString &toolTip, States states = All);
164 
172  void setWhatsThis(const QString &whatsThis, States states = All);
173 
183  void setIcon(const QIcon &icon, States states = All);
184 
192  void setVisible(bool visible, States states = All);
193 
201  void setEnabled(bool enabled, States states = All);
202 
210  void setTargetPID(qint64 pid);
211 
219  QString text(State state = None) const;
220 
228  QString toolTip(State state = None) const;
229 
236  QString whatsThis(State state = None) const;
237 
245  QIcon icon(State state = None) const;
246 
254  bool isVisible(State state = None) const;
255 
263  bool isEnabled(State state = None) const;
264 
268  qint64 targetPID() const;
269 
277  bool isAllowed() const;
278 
289  bool is(const QString &actionId) const;
290 
291 private:
292  class Private;
293  Private * const d;
294 
295  Q_PRIVATE_SLOT(d, void configChanged())
296 };
297 
298 }
299 
300 }
301 
302 Q_DECLARE_OPERATORS_FOR_FLAGS(PolkitQt1::Gui::Action::States)
303 
304 #endif
Class used to manage actions.
Definition: polkitqt1-gui-action.h:53
Contains Macros for exporting symbols.
Namespace wrapping Polkit-Qt classes.
Definition: listeneradapter.cpp:26