KDEUI
KPasswordDialog Class Reference
#include <kpassworddialog.h>

Detailed Description
A dialog for requesting a password and optionaly a login from the end user.
Usage Exemple
Requesting a simple password, assynchronous
KPasswordDialog *dlg = new KPasswordDialog( parent ); dlg->setPrompt( i18n( "Enter a password" ); connect( dlg, SIGNAL( gotPassword( const QString& , bool ) ) , this, SLOT( setPassword( const QString &) ) ); connect( dlg, SIGNAL( rejected() ) , this, SLOT( slotCancel() ) ); dlg->show();
Requesting a login and a password, synchronous
KPasswordDialog dlg( parent , KPasswordDialog::showUsername ); dlg.setPrompt( i18n( "Enter a login and a password" ); if( !dlg.exec() ) return; //the user canceled use( dlg.username() , dlg.password() );
dialog for requesting login and password from the end user
Definition at line 54 of file kpassworddialog.h.
Public Types | |
enum | ErrorType { UnknownError = 0, UsernameError, PasswordError, FatalError, DomainError } |
enum | KPasswordDialogFlag { NoFlags = 0x00, ShowKeepPassword = 0x01, ShowUsernameLine = 0x02, UsernameReadOnly = 0x04, ShowAnonymousLoginCheckBox = 0x08, ShowDomainLine = 0x10, DomainReadOnly = 0x20 } |
Signals | |
void | gotPassword (const QString &password, bool keep) |
void | gotUsernameAndPassword (const QString &username, const QString &password, bool keep) |
Public Member Functions | |
void | accept () |
void | addCommentLine (const QString &label, const QString &comment) |
bool | anonymousMode () const |
QString | domain () const |
bool | keepPassword () const |
KPasswordDialog (QWidget *parent=0L, const KPasswordDialogFlags &flags=0, const KDialog::ButtonCodes otherButtons=0) | |
QString | password () const |
QPixmap | pixmap () const |
QString | prompt () const |
void | setAnonymousMode (bool anonymous) |
void | setDomain (const QString &) |
void | setKeepPassword (bool b) |
void | setKnownLogins (const QMap< QString, QString > &knownLogins) |
void | setPassword (const QString &password) |
void | setPixmap (const QPixmap &) |
void | setPrompt (const QString &prompt) |
void | setUsername (const QString &) |
void | setUsernameReadOnly (bool readOnly) |
void | showErrorMessage (const QString &message, const ErrorType type=PasswordError) |
QString | username () const |
~KPasswordDialog () | |
Protected Member Functions | |
virtual bool | checkPassword () |
Member Enumeration Documentation
- Enumerator:
Definition at line 95 of file kpassworddialog.h.
- Enumerator:
Definition at line 60 of file kpassworddialog.h.
Constructor & Destructor Documentation
KPasswordDialog::KPasswordDialog | ( | QWidget * | parent = 0L , |
|
const KPasswordDialogFlags & | flags = 0 , |
|||
const KDialog::ButtonCodes | otherButtons = 0 | |||
) | [explicit] |
create a password dialog
- Parameters:
-
parent the parent widget (default:NULL). flags a set of KPasswordDialogFlag flags otherButtons buttons to show in the dialog besides Ok and Cancel. Useful for adding application-specific buttons like "ignore" or "skip".
Definition at line 65 of file kpassworddialog.cpp.
KPasswordDialog::~KPasswordDialog | ( | ) |
Member Function Documentation
void KPasswordDialog::accept | ( | ) |
For internal use only.
Reimplemented from QDialog.
Definition at line 370 of file kpassworddialog.cpp.
Adds a comment line to the dialog.
This function allows you to add one additional comment line to this widget. Calling this function after a comment has already been added will not have any effect.
- Parameters:
-
label label for comment (ex:"Command:") comment the actual comment text.
Definition at line 221 of file kpassworddialog.cpp.
bool KPasswordDialog::anonymousMode | ( | ) | const |
- Returns:
- anonymous mode has been selected.
- Since:
- 4.1
Definition at line 205 of file kpassworddialog.cpp.
bool KPasswordDialog::checkPassword | ( | ) | [protected, virtual] |
Virtual function that can be overridden to provide password checking in derived classes.
It should return true
if the password is valid, false
otherwise.
Definition at line 400 of file kpassworddialog.cpp.
QString KPasswordDialog::domain | ( | ) | const |
Returns the domain entered by the user.
- Returns:
- the domain name
- Since:
- 4.1
Definition at line 195 of file kpassworddialog.cpp.
emitted when the dialog has been accepted
- Parameters:
-
password the entered password keep true if the "remember password" checkbox was checked, false otherwhise. false if ShowKeepPassword was not set in the constructor
void KPasswordDialog::gotUsernameAndPassword | ( | const QString & | username, | |
const QString & | password, | |||
bool | keep | |||
) | [signal] |
emitted when the dialog has been accepted, and ShowUsernameLine was set on the constructor
- Parameters:
-
username the entered username password the entered password keep true if the "remember password" checkbox was checked, false otherwhise. false if ShowKeepPassword was not set in the constructor
bool KPasswordDialog::keepPassword | ( | ) | const |
Determines whether supplied authorization should persist even after the application has been closed.
this is set with the check password checkbox is the ShowKeepCheckBox flag is set in the constructor, if it is not set, this function return false
- Returns:
- true to keep the password
Definition at line 216 of file kpassworddialog.cpp.
QString KPasswordDialog::password | ( | ) | const |
Returns the password entered by the user.
- Returns:
- the password
Definition at line 185 of file kpassworddialog.cpp.
QPixmap KPasswordDialog::pixmap | ( | ) | const |
Definition at line 156 of file kpassworddialog.cpp.
QString KPasswordDialog::prompt | ( | ) | const |
void KPasswordDialog::setAnonymousMode | ( | bool | anonymous | ) |
set anonymous mode (all other fields will be grayed out)
- Since:
- 4.1
Definition at line 200 of file kpassworddialog.cpp.
void KPasswordDialog::setDomain | ( | const QString & | domain | ) |
void KPasswordDialog::setKeepPassword | ( | bool | b | ) |
Check or uncheck the "keep password" checkbox.
This can be used to check it before showing the dialog, to tell the user that the password is stored already (e.g. in the wallet). enableKeep must have been set to true in the constructor.
has only effect if ShowKeepCheckBox is set in the constructor
Definition at line 211 of file kpassworddialog.cpp.
Presets a number of login+password pairs that the user can choose from.
The passwords can be empty if you simply want to offer usernames to choose from.
This require the flag ShowUnernameLine to be set in the constructoe, and not the flag UsernameReadOnly
- Parameters:
-
knownLogins map of known logins: the keys are usernames, the values are passwords.
Definition at line 328 of file kpassworddialog.cpp.
void KPasswordDialog::setPassword | ( | const QString & | password | ) |
Presets the password.
- Parameters:
-
password the password to set
Definition at line 314 of file kpassworddialog.cpp.
void KPasswordDialog::setPixmap | ( | const QPixmap & | pixmap | ) |
void KPasswordDialog::setPrompt | ( | const QString & | prompt | ) |
Sets the prompt to show to the user.
- Parameters:
-
prompt instructional text to be shown.
Definition at line 302 of file kpassworddialog.cpp.
void KPasswordDialog::setUsername | ( | const QString & | user | ) |
void KPasswordDialog::setUsernameReadOnly | ( | bool | readOnly | ) |
Sets the username field read-only and sets the focus to the password field.
this can also be set by passing UsernameReadOnly as flag in the constructor
- Parameters:
-
readOnly true to set the user field to read-only
Definition at line 319 of file kpassworddialog.cpp.
void KPasswordDialog::showErrorMessage | ( | const QString & | message, | |
const ErrorType | type = PasswordError | |||
) |
Shows an error message in the dialog box.
Prevents having to show a dialog-on-a-dialog.
- Parameters:
-
message the error message to show
Definition at line 262 of file kpassworddialog.cpp.
QString KPasswordDialog::username | ( | ) | const |
Returns the username entered by the user.
- Returns:
- the user name
Definition at line 180 of file kpassworddialog.cpp.
The documentation for this class was generated from the following files: