• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDEUI

KPasswordDialog Class Reference

#include <kpassworddialog.h>

Inheritance diagram for KPasswordDialog:

Inheritance graph
[legend]

List of all members.


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

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 95 of file kpassworddialog.h.

enum KPasswordDialog::KPasswordDialogFlag

Enumerator:
NoFlags 
ShowKeepPassword  If this flag is set, the "keep this password" checkbox will been shown, otherwhise, 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 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 (  ) 

Destructor.

Definition at line 79 of file kpassworddialog.cpp.


Member Function Documentation

void KPasswordDialog::accept (  ) 

For internal use only.

Reimplemented from QDialog.

Definition at line 370 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:
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.

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

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

Returns the prompt.

Definition at line 309 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 200 of file kpassworddialog.cpp.

void KPasswordDialog::setDomain ( const QString &  domain  ) 

set the default domain.

Since:
4.1

Definition at line 190 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 211 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:
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  ) 

set an image that appears next to the prompt.

Definition at line 144 of file kpassworddialog.cpp.

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  ) 

set the default username.

Definition at line 166 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:
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:
  • 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
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
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