1 /* This file is part of the KDE libraries
2 Copyright (c) 1999 Preston Brown <pbrown@kde.org>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
16 Boston, MA 02110-1301, USA.
19 #define _KAUTHICON_H "$Id$"
21 #include <qfileinfo.h>
26 #include <kdelibs_export.h>
30 class KAuthIconPrivate
;
33 * @short A base class for authorization icon widgets
35 * This is the base class from which different authorization icon widget
36 * which actually do something should be derived. You can use these
37 * widgets to show that the user has (or doesn't have) the ability to do
38 * something, and why that is.
40 * One of the most useful things you can do with this is connect
41 * authChanged(bool) to setEnabled(bool) for a widget to turn it on and
42 * off depending on the status of whatever it is you are monitoring.
44 * @see KRootPermsIcon, KWritePermsIcon
45 * @author Preston Brown <pbrown@kde.org>
47 class KDEUI_EXPORT KAuthIcon
: public QWidget
55 KAuthIcon(QWidget
*parent
= 0, const char *name
= 0);
58 virtual QSize
sizeHint() const;
60 * return the status of whatever is being monitored.
62 virtual bool status() const = 0;
66 * Re-implement this method if you want the icon to update itself
67 * when something external has changed (i.e. a file on disk, uid/gid).
69 virtual void updateStatus() = 0;
73 * this signal is emitted when authorization has changed from
75 * @param authorized will be true if the type of authorization
76 * described by the icon is true, otherwise it will be false.
78 void authChanged(bool authorized
);
91 virtual void virtual_hook( int id
, void* data
);
96 class KRootPermsIconPrivate
;
98 * Icon to show whether or not a user has root permissions.
101 * @author Preston Brown <pbrown@kde.org>
103 class KDEUI_EXPORT KRootPermsIcon
: public KAuthIcon
108 KRootPermsIcon(QWidget
*parent
= 0, const char *name
= 0);
112 * return whether or not the current user has root permissions.
114 bool status() const { return root
; }
123 virtual void virtual_hook( int id
, void* data
);
125 KRootPermsIconPrivate
*d
;
128 class KWritePermsIconPrivate
;
130 * Auth icon for write permission display.
133 * @author Preston Brown <pbrown@kde.org>
135 class KDEUI_EXPORT KWritePermsIcon
: public KAuthIcon
138 Q_PROPERTY( QString fileName READ fileName WRITE setFileName
)
141 KWritePermsIcon(const QString
& fileName
, QWidget
*parent
= 0, const char *name
= 0);
144 * @return whether or not the monitored file is writable.
146 bool status() const { return writable
; }
149 * make the icon watch a new filename.
150 * @param fileName the new file to monitor / display status for.
152 void setFileName(const QString
& fileName
) { fi
.setFile(fileName
); updateStatus(); }
155 * return the filename of the currently watched file.
158 QString
fileName() const { return fi
.fileName(); }
168 virtual void virtual_hook( int id
, void* data
);
170 KWritePermsIconPrivate
*d
;