kdeui Library API Documentation

kpassdlg.h

00001 // vi: ts=8 sts=4 sw=4 
00002 /* This file is part of the KDE libraries
00003    Copyright (C) 1998 Pietro Iglio <iglio@fub.it>
00004    Copyright (C) 1999,2000 Geert Jansen <jansen@kde.org>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License version 2 as published by the Free Software Foundation.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018    Boston, MA 02111-1307, USA.
00019 */
00020 #ifndef __KPassDlg_h_included__
00021 #define __KPassDlg_h_included__
00022 
00023 #include <qstring.h>
00024 #include <qlineedit.h>
00025 #include <kdialogbase.h>
00026 
00027 class QLabel;
00028 class QGridLayout;
00029 class QWidget;
00030 
00038 class KPasswordEdit
00039     : public QLineEdit
00040 {
00041     Q_OBJECT
00042 
00043 public:
00044     enum EchoModes { OneStar, ThreeStars, NoEcho };
00045 
00049     KPasswordEdit(QWidget *parent=0, const char *name=0);
00054     KPasswordEdit(EchoMode echoMode, QWidget *parent, const char *name);
00059     KPasswordEdit(QWidget *parent, const char *name, int echoMode);
00063     ~KPasswordEdit();
00064 
00069     const char *password() const { return m_Password; }
00070 
00074     void erase();
00075 
00076     static const int PassLen;
00077 
00078 protected:
00079     virtual void keyPressEvent(QKeyEvent *);
00080     virtual void focusInEvent(QFocusEvent *e);
00081     virtual bool event(QEvent *e);
00082 
00083 private:
00084     void init();
00085     void showPass();
00086 
00087     char *m_Password;
00088     int m_EchoMode, m_Length;
00089 };
00090 
00091 
00127 class KPasswordDialog
00128     : public KDialogBase
00129 {
00130     Q_OBJECT
00131 
00132 public:
00136     enum Types {
00140         Password,
00146         NewPassword
00147     };
00148 
00161     KPasswordDialog(Types type, bool enableKeep, int extraBttn,
00162                     QWidget *parent=0, const char *name=0);
00167     KPasswordDialog(int type, QString prompt, bool enableKeep=false, 
00168         int extraBttn=0);
00172     virtual ~KPasswordDialog();
00173 
00177     void setPrompt(QString prompt);
00181     QString prompt() const;
00182 
00186     void addLine(QString key, QString value);
00191     const char *password() const { return m_pEdit->password(); }
00192 
00196     bool keep() const { return m_Keep; }
00197 
00210     static int getPassword(QCString &password, QString prompt, int *keep=0L);
00211 
00222     static int getNewPassword(QCString &password, QString prompt);
00223 
00227     static void disableCoreDumps();
00228 
00229 protected slots:
00230     void slotOk();
00231     void slotCancel();
00232     void slotKeep(bool);
00233 
00234 protected:
00235 
00241     virtual bool checkPassword(const char *) { return true; }
00242 
00243 private:
00244     void init();
00245     void erase();
00246 
00247     int m_Keep, m_Type, m_Row;
00248     QLabel *m_pHelpLbl;
00249     QGridLayout *m_pGrid;
00250     QWidget *m_pMain;
00251     KPasswordEdit *m_pEdit, *m_pEdit2;
00252 
00253 protected:
00254     virtual void virtual_hook( int id, void* data );
00255 private:
00256     class KPasswordDialogPrivate;
00257     KPasswordDialogPrivate *d;
00258 };
00259 
00260 
00261 #endif // __KPassDlg_h_included__
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.0.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Oct 8 12:21:00 2003 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2001