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

KDEUI

Public Types | Signals | Public Member Functions | Protected Member Functions | List of all members
KPasswordDialog Class Reference

#include <kpassworddialog.h>

Inheritance diagram for KPasswordDialog:
Inheritance graph
[legend]

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
}
 
- Public Types inherited from KDialog
enum  ButtonCode {
  None = 0x00000000, Help = 0x00000001, Default = 0x00000002, Ok = 0x00000004,
  Apply = 0x00000008, Try = 0x00000010, Cancel = 0x00000020, Close = 0x00000040,
  No = 0x00000080, Yes = 0x00000100, Reset = 0x00000200, Details = 0x00000400,
  User1 = 0x00001000, User2 = 0x00002000, User3 = 0x00004000, NoDefault = 0x00008000
}
 
enum  ButtonPopupMode { InstantPopup = 0, DelayedPopup = 1 }
 
enum  CaptionFlag { NoCaptionFlags = 0, AppNameCaption = 1, ModifiedCaption = 2, HIGCompliantCaption = AppNameCaption }
 

Signals

void gotPassword (const QString &password, bool keep)
 
void gotUsernameAndPassword (const QString &username, const QString &password, bool keep)
 
- Signals inherited from KDialog
void aboutToShowDetails ()
 
void applyClicked ()
 
void buttonClicked (KDialog::ButtonCode button)
 
void cancelClicked ()
 
void closeClicked ()
 
void defaultClicked ()
 
void finished ()
 
void helpClicked ()
 
void hidden ()
 
void layoutHintChanged ()
 
void noClicked ()
 
void okClicked ()
 
void resetClicked ()
 
void tryClicked ()
 
void user1Clicked ()
 
void user2Clicked ()
 
void user3Clicked ()
 
void yesClicked ()
 

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
 
- Public Member Functions inherited from KDialog
 KDialog (QWidget *parent=0, Qt::WindowFlags flags=0)
 
 ~KDialog ()
 
KPushButton * button (ButtonCode id) const
 
KIcon buttonIcon (ButtonCode id) const
 
QString buttonText (ButtonCode id) const
 
QString buttonToolTip (ButtonCode id) const
 
QString buttonWhatsThis (ButtonCode id) const
 
ButtonCode defaultButton () const
 
QString helpLinkText () const
 
void incrementInitialSize (const QSize &size)
 
bool isButtonEnabled (ButtonCode id) const
 
QWidget * mainWidget ()
 
virtual QSize minimumSizeHint () const
 
void restoreDialogSize (const KConfigGroup &config)
 
void saveDialogSize (KConfigGroup &config, KConfigGroup::WriteConfigFlags options=KConfigGroup::Normal) const
 
void setButtonFocus (ButtonCode id)
 
void setButtonGuiItem (ButtonCode id, const KGuiItem &item)
 
void setButtonIcon (ButtonCode id, const KIcon &icon)
 
void setButtonMenu (ButtonCode id, QMenu *menu, ButtonPopupMode popupmode=InstantPopup)
 
void setButtons (ButtonCodes buttonMask)
 
void setButtonsOrientation (Qt::Orientation orientation)
 
void setButtonText (ButtonCode id, const QString &text)
 
void setButtonToolTip (ButtonCode id, const QString &text)
 
void setButtonWhatsThis (ButtonCode id, const QString &text)
 
void setDefaultButton (ButtonCode id)
 
void setEscapeButton (ButtonCode id)
 
void setInitialSize (const QSize &size)
 
void setMainWidget (QWidget *widget)
 
void showButton (ButtonCode id, bool state)
 
void showButtonSeparator (bool state)
 
virtual QSize sizeHint () const
 

Protected Member Functions

virtual bool checkPassword ()
 
- Protected Member Functions inherited from KDialog
 KDialog (KDialogPrivate &dd, QWidget *parent, Qt::WindowFlags flags=0)
 
virtual void closeEvent (QCloseEvent *e)
 
virtual void hideEvent (QHideEvent *)
 
virtual void keyPressEvent (QKeyEvent *)
 

Additional Inherited Members

- Public Slots inherited from KDialog
void delayedDestruct ()
 
void enableButton (ButtonCode id, bool state)
 
void enableButtonApply (bool state)
 
void enableButtonCancel (bool state)
 
void enableButtonOk (bool state)
 
void enableLinkedHelp (bool state)
 
bool isDetailsWidgetVisible () const
 
virtual void setCaption (const QString &caption)
 
virtual void setCaption (const QString &caption, bool modified)
 
void setDetailsWidget (QWidget *detailsWidget)
 
void setDetailsWidgetVisible (bool visible)
 
void setHelp (const QString &anchor, const QString &appname=QString())
 
void setHelpLinkText (const QString &text)
 
virtual void setPlainCaption (const QString &caption)
 
- Static Public Member Functions inherited from KDialog
static bool avoidArea (QWidget *widget, const QRect &area, int screen=-1)
 
static void centerOnScreen (QWidget *widget, int screen=-1)
 
static int groupSpacingHint ()
 
static QString makeStandardCaption (const QString &userCaption, QWidget *window=0, CaptionFlags flags=HIGCompliantCaption)
 
static int marginHint ()
 
static void resizeLayout (QWidget *widget, int margin, int spacing)
 
static void resizeLayout (QLayout *lay, int margin, int spacing)
 
static void setAllowEmbeddingInGraphicsView (bool allowEmbedding)
 
static int spacingHint ()
 
- Protected Slots inherited from KDialog
virtual void slotButtonClicked (int button)
 
void updateGeometry ()
 
- Protected Attributes inherited from KDialog
KDialogPrivate *const d_ptr
 

Detailed Description

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

Usage Example

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 379 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 ( )
protectedvirtual

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 411 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 187 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 177 of file kpassworddialog.cpp.

QPixmap KPasswordDialog::pixmap ( ) const

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

void KPasswordDialog::setDomain ( const QString &  domain)

set the default domain.

Since
4.1

Definition at line 182 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 136 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 158 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 172 of file kpassworddialog.cpp.


The documentation for this class was generated from the following files:
  • kpassworddialog.h
  • kpassworddialog.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:49:18 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal