KDE3Support
k3passworddialog.h
Go to the documentation of this file.
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 Copyright (C) 2004,2005 Andrew Coles <andrew_coles@yahoo.co.uk> 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Library General Public 00009 License version 2 as published by the Free Software Foundation. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. 00020 */ 00021 #ifndef K3PASSWORDDIALOG_H 00022 #define K3PASSWORDDIALOG_H 00023 00024 #include <kde3support_export.h> 00025 #include <kdialog.h> 00026 00027 #include <QtGui/QLineEdit> 00028 00029 class QLabel; 00030 class QGridLayout; 00031 class QWidget; 00032 00041 class KDE3SUPPORT_EXPORT K3PasswordEdit 00042 : public QLineEdit 00043 { 00044 Q_OBJECT 00045 00046 public: 00047 enum EchoModes { OneStar, ThreeStars, NoEcho }; 00048 00052 explicit K3PasswordEdit(QWidget *parent=0); 00053 // KDE4: either of the two must go! add default values for parameters 00054 00059 explicit K3PasswordEdit(EchoMode echoMode, QWidget *parent = 0); 00060 00065 explicit K3PasswordEdit(EchoModes echoMode, QWidget *parent = 0); 00066 00070 ~K3PasswordEdit(); 00071 00076 const char *password() const; 00077 00081 void erase(); 00082 00083 static const int PassLen; 00084 00093 void setMaxPasswordLength(int newLength); 00094 00098 int maxPasswordLength() const; 00099 00100 public Q_SLOTS: 00104 virtual void insert( const QString &); 00105 00106 protected: 00107 virtual void keyPressEvent(QKeyEvent *); 00108 virtual void focusInEvent(QFocusEvent *e); 00109 virtual bool event(QEvent *e); 00110 00111 private: 00112 void init(); 00113 void showPass(); 00114 00115 char *m_Password; 00116 int m_EchoMode, m_Length; 00117 }; 00118 00119 00159 class KDE3SUPPORT_EXPORT K3PasswordDialog 00160 : public KDialog 00161 { 00162 Q_OBJECT 00163 00164 public: 00168 enum Types { 00172 Password, 00173 00179 NewPassword 00180 }; 00181 00193 K3PasswordDialog(Types type, bool enableKeep, ButtonCodes extraBttn, QWidget *parent=0); 00194 00195 00209 K3PasswordDialog(Types type, bool enableKeep, ButtonCodes extraBttn, const QString& iconName, 00210 QWidget *parent = 0); 00211 00215 virtual ~K3PasswordDialog(); 00216 00220 void setPrompt(const QString &prompt); 00221 00225 QString prompt() const; 00226 00230 void addLine(const QString &key, const QString &value); 00231 00235 void setAllowEmptyPasswords(bool allowed); 00236 00240 bool allowEmptyPasswords() const; 00241 00249 void setMinimumPasswordLength(int minLength); 00250 00254 int minimumPasswordLength() const; 00255 00262 void setMaximumPasswordLength(int maxLength); 00263 00267 int maximumPasswordLength() const; 00268 00276 void setReasonablePasswordLength(int reasonableLength); 00277 00281 int reasonablePasswordLength() const; 00282 00292 void setPasswordStrengthWarningLevel(int warningLevel); 00293 00297 int passwordStrengthWarningLevel() const; 00298 00303 const char *password() const; 00304 00309 void clearPassword(); 00310 00314 bool keep() const; 00315 00330 static int getPassword(QWidget *parent, QByteArray &password, const QString &caption, const QString &prompt, bool *keep = 0L); 00331 00337 static KDE_DEPRECATED int getPassword(QWidget *parent, QByteArray &password, const QString &prompt, int *keep = 0L); 00338 00351 static int getNewPassword(QWidget *parent, QByteArray &password, const QString &caption, const QString &prompt); 00352 00358 static KDE_DEPRECATED int getNewPassword(QWidget *parent, QByteArray &password, const QString &prompt); 00359 00363 static void disableCoreDumps(); 00364 00365 virtual void accept(); 00366 00367 protected Q_SLOTS: 00368 void slotKeep(bool); 00369 00370 protected: 00371 00377 virtual bool checkPassword(const char *password); 00378 00379 00380 private Q_SLOTS: 00381 void enableOkBtn(); 00382 00383 private: 00384 void init(); 00385 void erase(); 00386 00387 int m_Keep, m_Type, m_Row; 00388 QLabel *m_pHelpLbl; 00389 QGridLayout *m_pGrid; 00390 QWidget *m_pMain; 00391 K3PasswordEdit *m_pEdit, *m_pEdit2; 00392 00393 private: 00394 class K3PasswordDialogPrivate; 00395 K3PasswordDialogPrivate* const d; 00396 }; 00397 00398 #endif // K3PasswordDialog_H 00399
KDE 4.6 API Reference