• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • Contact Us
 

KDEUI

Public Types | Signals | Public Member Functions | Protected Member Functions

KPasswordDialog Class Reference

A dialog for requesting a password and optionaly a login from the end user. More...

#include <kpassworddialog.h>

Inheritance diagram for KPasswordDialog:
Inheritance graph
[legend]

List of all members.

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

 KPasswordDialog (QWidget *parent=0L, const KPasswordDialogFlags &flags=0, const KDialog::ButtonCodes otherButtons=0)
 ~KPasswordDialog ()
void accept ()
void addCommentLine (const QString &label, const QString &comment)
bool anonymousMode () const
QString domain () const
bool keepPassword () const
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

Protected Member Functions

virtual bool checkPassword ()

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::ShowUsernameLine);
  dlg.setPrompt(i18n("Enter a login and a password"));
  if( !dlg.exec() )
      return; //the user canceled
  use( dlg.username() , dlg.password() );
kpassworddialog.png

KDE Password Dialog

dialog for requesting login and password from the end user

Definition at line 56 of file kpassworddialog.h.


Member Enumeration Documentation

enum KPasswordDialog::ErrorType
Enumerator:
UnknownError 
UsernameError 

A problem with the user name as entered.

PasswordError 

Incorrect password.

FatalError 

Error preventing further attempts, will result in disabling most of the interface.

DomainError 

A problem with the domain as entered.

Since:
4.1

Definition at line 97 of file kpassworddialog.h.

enum KPasswordDialog::KPasswordDialogFlag
Enumerator:
NoFlags 
ShowKeepPassword 

If this flag is set, the "keep this password" checkbox will been shown, otherwise, it will not be shown and keepPassword will have no effect.

ShowUsernameLine 

If this flag is set, there will be an additional line to let the user enter his login.

otherwise, only the password line will be shown.

UsernameReadOnly 

If this flag is set, the login lineedit will be in read only mode.

ShowAnonymousLoginCheckBox 

If this flag is set, the Anonymous Login checkbox will be displayed.

Since:
4.1
ShowDomainLine 

If this flag is set, there will be an additional line to let the user enter the domain.

Since:
4.1
DomainReadOnly 

If this flag is set, the domain lineedit will be in read only mode.

Since:
4.1

Definition at line 62 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:
parentthe parent widget (default:NULL).
flagsa set of KPasswordDialogFlag flags
otherButtonsbuttons 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 ( )

Destructor.

Definition at line 78 of file kpassworddialog.cpp.


Member Function Documentation

void KPasswordDialog::accept ( )

Definition at line 377 of file kpassworddialog.cpp.

void KPasswordDialog::addCommentLine ( const QString &  label,
const QString &  comment 
)

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:
labellabel for comment (ex:"Command:")
commentthe actual comment text.

Definition at line 222 of file kpassworddialog.cpp.

bool KPasswordDialog::anonymousMode ( ) const
Returns:
anonymous mode has been selected.
Since:
4.1

Definition at line 206 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 407 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 196 of file kpassworddialog.cpp.

void KPasswordDialog::gotPassword ( const QString &  password,
bool  keep 
) [signal]

emitted when the dialog has been accepted

Parameters:
passwordthe entered password
keeptrue if the "remember password" checkbox was checked, false otherwise. 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:
usernamethe entered username
passwordthe entered password
keeptrue if the "remember password" checkbox was checked, false otherwise. 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 217 of file kpassworddialog.cpp.

QString KPasswordDialog::password ( ) const

Returns the password entered by the user.

Returns:
the password

Definition at line 186 of file kpassworddialog.cpp.

QPixmap KPasswordDialog::pixmap ( ) const

Definition at line 157 of file kpassworddialog.cpp.

QString KPasswordDialog::prompt ( ) const

Returns the prompt.

Definition at line 311 of file kpassworddialog.cpp.

void KPasswordDialog::setAnonymousMode ( bool  anonymous)

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

Since:
4.1

Definition at line 201 of file kpassworddialog.cpp.

void KPasswordDialog::setDomain ( const QString &  domain)

set the default domain.

Since:
4.1

Definition at line 191 of file kpassworddialog.cpp.

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 212 of file kpassworddialog.cpp.

void KPasswordDialog::setKnownLogins ( const QMap< QString, QString > &  knownLogins)

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:
knownLoginsmap of known logins: the keys are usernames, the values are passwords.

Definition at line 330 of file kpassworddialog.cpp.

void KPasswordDialog::setPassword ( const QString &  password)

Presets the password.

Parameters:
passwordthe password to set

Definition at line 316 of file kpassworddialog.cpp.

void KPasswordDialog::setPixmap ( const QPixmap &  pixmap)

set an image that appears next to the prompt.

Definition at line 145 of file kpassworddialog.cpp.

void KPasswordDialog::setPrompt ( const QString &  prompt)

Sets the prompt to show to the user.

Parameters:
promptinstructional text to be shown.

Definition at line 304 of file kpassworddialog.cpp.

void KPasswordDialog::setUsername ( const QString &  user)

set the default username.

Definition at line 167 of file kpassworddialog.cpp.

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:
readOnlytrue to set the user field to read-only

Definition at line 321 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:
messagethe error message to show

Definition at line 264 of file kpassworddialog.cpp.

QString KPasswordDialog::username ( ) const

Returns the username entered by the user.

Returns:
the user name

Definition at line 181 of file kpassworddialog.cpp.


The documentation for this class was generated from the following files:
  • kpassworddialog.h
  • kpassworddialog.cpp

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal