# class KPasswordDialog

###

Module | kdeui
Namespace |
Class | KPasswordDialog
Inherits | KDialog

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

### enums

- ErrorType { UnknownError, UsernameError, PasswordError, FatalError, DomainError }
- ErrorType { UnknownError, UsernameError, PasswordError, FatalError }
- KPasswordDialogFlag { NoFlags, ShowKeepPassword, ShowUsernameLine, UsernameReadOnly, ShowAnonymousLoginCheckBox, ShowDomainLine, DomainReadOnly }
  typesafe object: KPasswordDialogFlags
- KPasswordDialogFlag { NoFlags, ShowKeepPassword, ShowUsernameLine, UsernameReadOnly }
  typesafe object: KPasswordDialogFlags

enum details

### methods

- KPasswordDialog (parent, flags, otherButtons)

  returns ctor
  KDE 4.1.0 and later only

  Argument | Type | Default
  --- | --- | ---
  parent | QWidget | 0
  flags | KPasswordDialog.KPasswordDialogFlags | 0
  otherButtons | KDialog.ButtonCodes | 0

  create a password dialog

  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".

- KPasswordDialog (a0)

  returns ctor
  Not implemented

  Argument | Type | Default
  --- | --- | ---
  a0 | KPasswordDialog |

- KPasswordDialog (a0, a1, a2)

  returns ctor
  before KDE 4.1.0 only

  Argument | Type | Default
  --- | --- | ---
  a0 | QWidget | 0
  a1 | KPasswordDialog.KPasswordDialogFlags | 0
  a2 | KDialog.ButtonCodes | 0

- accept ( )

  returns Nothing

  Internal

- addCommentLine (label, comment)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  label | QString |
  comment | QString |

  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.

  label - label for comment (ex:"Command:")

  comment - the actual comment text.

- anonymousMode ( )

  returns bool
  KDE 4.1.0 and later only

  Returns anonymous mode has been selected. @since 4.1

- checkPassword ( )

  returns bool

  Virtual function that can be overridden to provide password checking in derived classes. It should return true if the password is valid, false otherwise.

- domain ( )

  returns QString
  KDE 4.1.0 and later only

  Returns the domain entered by the user. Returns the domain name @since 4.1

- gotPassword (password, keep)

  returns Nothing
  SIGNAL ("gotPassword (const QString&, bool)")

  Argument | Type | Default
  --- | --- | ---
  password | QString |
  keep | bool |

  emitted when the dialog has been accepted

  password - the entered password

  keep - true if the "remember password" checkbox was checked, false otherwhise. false if ShowKeepPassword was not set in the constructor

- gotUsernameAndPassword (username, password, keep)

  returns Nothing
  SIGNAL ("gotUsernameAndPassword (const QString&, const QString&, bool)")

  Argument | Type | Default
  --- | --- | ---
  username | QString |
  password | QString |
  keep | bool |

  emitted when the dialog has been accepted, and ShowUsernameLine was set on the constructor

  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

- keepPassword ( )

  returns bool

  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

- password ( )

  returns QString

  Returns the password entered by the user. Returns the password

- pixmap ( )

  returns QPixmap

- prompt ( )

  returns QString

  Returns the prompt

- setAnonymousMode (anonymous)

  returns Nothing
  KDE 4.1.0 and later only

  Argument | Type | Default
  --- | --- | ---
  anonymous | bool |

  set anonymous mode (all other fields will be grayed out) @since 4.1

- setDomain (a0)

  returns Nothing
  KDE 4.1.0 and later only

  Argument | Type | Default
  --- | --- | ---
  a0 | QString |

  set the default domain. @since 4.1

- setKeepPassword (b)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  b | bool |

  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

- setKnownLogins (knownLogins)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  knownLogins | QMap<QString,QString> |

  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

  knownLogins - map of known logins: the keys are usernames, the values are passwords.

- setPassword (password)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  password | QString |

  Presets the password.

  password - the password to set

- setPixmap (a0)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  a0 | QPixmap |

  set an image that appears next to the prompt.

- setPrompt (prompt)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  prompt | QString |

  Sets the prompt to show to the user.

  prompt - instructional text to be shown.

- setUsername (a0)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  a0 | QString |

  set the default username.

- setUsernameReadOnly (readOnly)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  readOnly | bool |

  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

  readOnly - true to set the user field to read-only

- showErrorMessage (message, type)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  message | QString |
  type | KPasswordDialog.ErrorType | KPasswordDialog.PasswordError

  Shows an error message in the dialog box. Prevents having to show a dialog-on-a-dialog.

  message - the error message to show

- username ( )

  returns QString

  Returns the username entered by the user. Returns the user name

### enums - detail

- ErrorType { UnknownError, UsernameError, PasswordError, FatalError, DomainError }

  | UnknownError | - 0 | - |
  | UsernameError | - | - |
  | PasswordError | - | - |
  | FatalError | - | - |
  | DomainError | - | - |

- ErrorType { UnknownError, UsernameError, PasswordError, FatalError }

  | UnknownError | - | - |
  | UsernameError | - | - |
  | PasswordError | - | - |
  | FatalError | - | - |

- KPasswordDialogFlag { NoFlags, ShowKeepPassword, ShowUsernameLine, UsernameReadOnly, ShowAnonymousLoginCheckBox, ShowDomainLine, DomainReadOnly }

  typesafe object: KPasswordDialogFlags

NoFlags - 0x00 -
ShowKeepPassword - 0x01 -
ShowUsernameLine - 0x02 -
UsernameReadOnly - 0x04 -
ShowAnonymousLoginCheckBox - 0x08 -
ShowDomainLine - 0x10 -
DomainReadOnly - 0x20 -

- KPasswordDialogFlag { NoFlags, ShowKeepPassword, ShowUsernameLine, UsernameReadOnly }

  typesafe object: KPasswordDialogFlags

NoFlags - -
ShowKeepPassword - -
ShowUsernameLine - -
UsernameReadOnly - -