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 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 __KPassDlg_h_included__ 00022 #define __KPassDlg_h_included__ 00023 00024 #include <tqstring.h> 00025 #include <tqlineedit.h> 00026 #include <kdialogbase.h> 00027 00028 class TQLabel; 00029 class TQGridLayout; 00030 class TQWidget; 00031 00039 class TDEUI_EXPORT KPasswordEdit 00040 : public TQLineEdit 00041 { 00042 Q_OBJECT 00043 00044 public: 00045 enum EchoModes { OneStar, ThreeStars, NoEcho }; 00046 00050 KPasswordEdit(TQWidget *parent=0, const char *name=0); 00051 // KDE4: either of the two must go! add default values for parameters 00052 00058 KPasswordEdit(EchoMode echoMode, TQWidget *parent, const char *name); 00059 00065 KPasswordEdit(EchoModes echoMode, TQWidget *parent, const char *name); 00066 00071 KPasswordEdit(TQWidget *parent, const char *name, int echoMode) KDE_DEPRECATED; 00072 00076 ~KPasswordEdit(); 00077 00081 TQString password() const; 00082 00086 void erase(); 00087 00088 static const int PassLen; 00089 00097 void setMaxPasswordLength(int newLength); 00098 00103 int maxPasswordLength() const; 00104 00105 public slots: 00109 virtual void insert( const TQString &); 00110 00111 protected: 00112 virtual void keyPressEvent(TQKeyEvent *); 00113 virtual void focusInEvent(TQFocusEvent *e); 00114 virtual bool event(TQEvent *e); 00115 00116 private: 00117 void init(); 00118 }; 00119 00120 00151 class TDEUI_EXPORT KPasswordDialog 00152 : public KDialogBase 00153 { 00154 Q_OBJECT 00155 00156 public: 00160 enum Types { 00164 Password, 00165 00171 NewPassword 00172 }; 00173 00188 KPasswordDialog(Types type, bool enableKeep, int extraBttn, 00189 TQWidget *parent=0, const char *name=0); 00190 00195 KPasswordDialog(int type, TQString prompt, bool enableKeep=false, 00196 int extraBttn=0) KDE_DEPRECATED; 00197 // note that this implicitly deprecates the 'prompt' variants of 00198 // getPassword() below. i guess the above constructor needs to be extended. 00199 00215 KPasswordDialog(Types type, bool enableKeep, int extraBttn, const TQString& iconName, 00216 TQWidget *parent = 0, const char *name = 0); 00217 00221 virtual ~KPasswordDialog(); 00222 00226 void setPrompt(TQString prompt); 00227 00231 TQString prompt() const; 00232 00236 void setKeepWarning(TQString warn); 00237 00241 void addLine(TQString key, TQString value); 00242 00247 void setAllowEmptyPasswords(bool allowed); 00248 00253 bool allowEmptyPasswords() const; 00254 00263 void setMinimumPasswordLength(int minLength); 00264 00269 int minimumPasswordLength() const; 00270 00278 void setMaximumPasswordLength(int maxLength); 00279 00284 int maximumPasswordLength() const; 00285 00294 void setReasonablePasswordLength(int reasonableLength); 00295 00300 int reasonablePasswordLength() const; 00301 00312 void setPasswordStrengthWarningLevel(int warningLevel); 00313 00318 int passwordStrengthWarningLevel() const; 00319 00323 TQString password() const { return m_pEdit->password(); } 00324 00330 void clearPassword(); 00331 00335 bool keep() const { return m_Keep; } 00336 00349 static int getPassword(TQString &password, TQString prompt, int *keep=0L); 00350 00361 static int getNewPassword(TQString &password, TQString prompt); 00362 00366 static void disableCoreDumps(); 00367 00368 protected slots: 00369 void slotOk(); 00370 void slotCancel(); 00371 void slotKeep(bool); 00372 void slotLayout(); 00373 00374 protected: 00375 00381 virtual bool checkPassword(const TQString&) { return true; } 00382 00383 private slots: 00384 void enableOkBtn(); 00385 00386 private: 00387 void init(); 00388 void erase(); 00389 00390 int m_Keep; 00391 int m_Type; 00392 int m_Row; 00393 TQLabel *m_pHelpLbl; 00394 TQLabel *m_keepWarnLbl; 00395 TQGridLayout *m_pGrid; 00396 TQWidget *m_pMain; 00397 KPasswordEdit *m_pEdit; 00398 KPasswordEdit *m_pEdit2; 00399 00400 protected: 00401 virtual void virtual_hook( int id, void* data ); 00402 private: 00403 class KPasswordDialogPrivate; 00404 KPasswordDialogPrivate* const d; 00405 }; 00406 00407 00408 #endif // __KPassDlg_h_included__
Trinity API Reference