home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kauthicon.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  4.3 KB  |  174 lines

  1. /* This file is part of the KDE libraries
  2.    Copyright (c) 1999 Preston Brown <pbrown@kde.org>
  3.  
  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.
  7.  
  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.
  12.  
  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 Street, Fifth Floor,
  16.    Boston, MA 02110-1301, USA.
  17. */
  18. #ifndef _KAUTHICON_H
  19. #define _KAUTHICON_H "$Id: kauthicon.h 465272 2005-09-29 09:47:40Z mueller $"
  20.  
  21. #include <qfileinfo.h>
  22. #include <qpixmap.h>
  23. #include <qstring.h>
  24. #include <qwidget.h>
  25.  
  26. #include <kdelibs_export.h>
  27.  
  28. class QHBoxLayout;
  29. class QLabel;
  30. class KAuthIconPrivate;
  31.  
  32. /**
  33.  * @short A base class for authorization icon widgets
  34.  *
  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.
  39.  *
  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.
  43.  *
  44.  * @see KRootPermsIcon, KWritePermsIcon
  45.  * @author Preston Brown <pbrown@kde.org>
  46.  */
  47. class KDEUI_EXPORT KAuthIcon : public QWidget
  48. {
  49.   Q_OBJECT
  50.  
  51. public:
  52.   /**
  53.    * Constructor.
  54.    */
  55.   KAuthIcon(QWidget *parent = 0, const char *name = 0);
  56.   ~KAuthIcon();
  57.  
  58.   virtual QSize sizeHint() const;
  59.   /**
  60.    * return the status of whatever is being monitored.
  61.    */
  62.   virtual bool status() const = 0;
  63.  
  64. public slots:
  65.   /**
  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).
  68.    */
  69.   virtual void updateStatus() = 0;
  70.  
  71. signals:
  72.   /**
  73.    * this signal is emitted when authorization has changed from
  74.    * its previous state.
  75.    * @param authorized will be true if the type of authorization
  76.    * described by the icon is true, otherwise it will be false.
  77.    */
  78.   void authChanged(bool authorized);
  79.  
  80. protected:
  81.   QHBoxLayout *layout;
  82.  
  83.   QLabel *lockBox;
  84.   QLabel *lockLabel;
  85.   QPixmap lockPM;
  86.   QPixmap openLockPM;
  87.   QString lockText;
  88.   QString openLockText;
  89.  
  90. protected:
  91.   virtual void virtual_hook( int id, void* data );
  92. private:
  93.   KAuthIconPrivate *d;
  94. };
  95.  
  96. class KRootPermsIconPrivate;
  97. /**
  98.  * Icon to show whether or not a user has root permissions.
  99.  *
  100.  * @see KAuthIcon
  101.  * @author Preston Brown <pbrown@kde.org>
  102.  */
  103. class KDEUI_EXPORT KRootPermsIcon : public KAuthIcon
  104. {
  105.   Q_OBJECT
  106.  
  107. public:
  108.   KRootPermsIcon(QWidget *parent = 0, const char *name = 0);
  109.   ~KRootPermsIcon();
  110.  
  111.   /**
  112.    * return whether or not the current user has root permissions.
  113.    */
  114.   bool status() const { return root; }
  115.  
  116. public slots:
  117.   void updateStatus();
  118.  
  119. protected:
  120.   bool root;
  121.  
  122. protected:
  123.   virtual void virtual_hook( int id, void* data );
  124. private:
  125.   KRootPermsIconPrivate *d;
  126. };
  127.  
  128. class KWritePermsIconPrivate;
  129. /**
  130.  * Auth icon for write permission display.
  131.  *
  132.  * @see KAuthIcon
  133.  * @author Preston Brown <pbrown@kde.org>
  134.  */
  135. class KDEUI_EXPORT KWritePermsIcon : public KAuthIcon
  136. {
  137.   Q_OBJECT
  138.   Q_PROPERTY( QString fileName READ fileName WRITE setFileName )
  139.  
  140. public:
  141.   KWritePermsIcon(const QString & fileName, QWidget *parent = 0, const char *name = 0);
  142.   ~KWritePermsIcon();
  143.   /**
  144.    * @return whether or not the monitored file is writable.
  145.    */
  146.   bool status() const { return writable; }
  147.  
  148.   /**
  149.    * make the icon watch a new filename.
  150.    * @param fileName the new file to monitor / display status for.
  151.    */
  152.   void setFileName(const QString & fileName) { fi.setFile(fileName); updateStatus(); }
  153.  
  154.   /**
  155.   * return the filename of the currently watched file.
  156.   * @since 3.4
  157.   */
  158.   QString fileName() const { return fi.fileName(); }
  159.  
  160. public slots:
  161.   void updateStatus();
  162.  
  163. protected:
  164.   bool writable;
  165.   QFileInfo fi;
  166.  
  167. protected:
  168.   virtual void virtual_hook( int id, void* data );
  169. private:
  170.   KWritePermsIconPrivate *d;
  171. };
  172.  
  173. #endif
  174.