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

KDE3Support

Public Types | Public Member Functions | Static Public Member Functions | Protected Slots | Protected Member Functions | List of all members
K3PasswordDialog Class Reference

#include <k3passworddialog.h>

Inheritance diagram for K3PasswordDialog:
KDialog QDialog

Public Types

enum  Types { Password , NewPassword }
 
- Public Types inherited from KDialog
enum  ButtonCode
 
enum  ButtonPopupMode
 
enum  CaptionFlag
 

Public Member Functions

 K3PasswordDialog (Types type, bool enableKeep, ButtonCodes extraBttn, const QString &iconName, QWidget *parent=0)
 
 K3PasswordDialog (Types type, bool enableKeep, ButtonCodes extraBttn, QWidget *parent=0)
 
virtual ~K3PasswordDialog ()
 
virtual void accept ()
 
void addLine (const QString &key, const QString &value)
 
bool allowEmptyPasswords () const
 
void clearPassword ()
 
bool keep () const
 
int maximumPasswordLength () const
 
int minimumPasswordLength () const
 
const char * password () const
 
int passwordStrengthWarningLevel () const
 
QString prompt () const
 
int reasonablePasswordLength () const
 
void setAllowEmptyPasswords (bool allowed)
 
void setMaximumPasswordLength (int maxLength)
 
void setMinimumPasswordLength (int minLength)
 
void setPasswordStrengthWarningLevel (int warningLevel)
 
void setPrompt (const QString &prompt)
 
void setReasonablePasswordLength (int reasonableLength)
 
- 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
 

Static Public Member Functions

static void disableCoreDumps ()
 
static int getNewPassword (QWidget *parent, QByteArray &password, const QString &caption, const QString &prompt)
 
static int getNewPassword (QWidget *parent, QByteArray &password, const QString &prompt)
 
static int getPassword (QWidget *parent, QByteArray &password, const QString &caption, const QString &prompt, bool *keep=0L)
 
static int getPassword (QWidget *parent, QByteArray &password, const QString &prompt, int *keep=0L)
 
- 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 (QLayout *lay, int margin, int spacing)
 
static void resizeLayout (QWidget *widget, int margin, int spacing)
 
static void setAllowEmbeddingInGraphicsView (bool allowEmbedding)
 
static int spacingHint ()
 

Protected Slots

void slotKeep (bool)
 
- Protected Slots inherited from KDialog
virtual void slotButtonClicked (int button)
 
void updateGeometry ()
 

Protected Member Functions

virtual bool checkPassword (const char *password)
 
- 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)
 
- 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 Attributes inherited from KDialog
 Apply
 
 AppNameCaption
 
 Cancel
 
 Close
 
 Default
 
 DelayedPopup
 
 Details
 
 Help
 
 HIGCompliantCaption
 
 InstantPopup
 
 ModifiedCaption
 
 No
 
 NoCaptionFlags
 
 NoDefault
 
 None
 
 Ok
 
 Reset
 
 Try
 
 User1
 
 User2
 
 User3
 
 Yes
 
- Protected Attributes inherited from KDialog
KDialogPrivate *const d_ptr
 

Detailed Description

A password input dialog.

This dialog asks the user to enter a password. The functions you're probably interested in are the static methods, getPassword() and getNewPassword().

Usage example

QCString password;
int result = K3PasswordDialog::getPassword(parent, password, i18n("Prompt message"));
if (result == K3PasswordDialog::Accepted)
use(password);
K3PasswordDialog::getPassword
static int getPassword(QWidget *parent, QByteArray &password, const QString &caption, const QString &prompt, bool *keep=0L)
Pops up the dialog, asks the user for a password, and returns it.
Definition: k3passworddialog.cpp:539
K3PasswordDialog::password
const char * password() const
Returns the password entered.
Definition: k3passworddialog.cpp:727
i18n
QString i18n(const char *text)
KDE Password Dialog

Security notes:
Keeping passwords in memory can be a potential security hole. You should handle this situation with care.

  • You may want to use disableCoreDump() to disable core dumps. Core dumps are dangerous because they are an image of the process memory, and thus include any passwords that were in memory.
  • You should delete passwords as soon as they are not needed anymore. The functions getPassword() and getNewPassword() return the password as a QCString. I believe this is safer than a QString. A QString stores its characters internally as 16-bit wide values, so conversions are needed, both for creating the QString and by using it. The temporary memory used for these conversion is probably not erased. This could lead to stray passwords in memory, even if you think you erased all of them.
Author
Geert Jansen janse.nosp@m.n@kd.nosp@m.e.org
Deprecated:
use KPasswordDialog or KNewPasswordDialog

Definition at line 159 of file k3passworddialog.h.

Member Enumeration Documentation

◆ Types

enum K3PasswordDialog::Types

This enum distinguishes the two operation modes of this dialog:

Enumerator
Password 

The user is asked to enter a password.

NewPassword 

The user is asked to enter a password and to confirm it a second time.

This is usually used when the user changes his password.

Definition at line 168 of file k3passworddialog.h.

Constructor & Destructor Documentation

◆ K3PasswordDialog() [1/2]

K3PasswordDialog::K3PasswordDialog ( Types  type,
bool  enableKeep,
ButtonCodes  extraBttn,
QWidget *  parent = 0 
)

Constructs a password dialog.

Parameters
typeif NewPassword is given here, the dialog contains two input fields, so that the user must confirm his password and possible typos are detected immediately.
enableKeepif true, a check box is shown in the dialog which allows the user to keep his password input for later.
extraBttnallows to show additional buttons, KDialog.
parentPassed to lower level constructor.

Definition at line 293 of file k3passworddialog.cpp.

◆ K3PasswordDialog() [2/2]

K3PasswordDialog::K3PasswordDialog ( Types  type,
bool  enableKeep,
ButtonCodes  extraBttn,
const QString &  iconName,
QWidget *  parent = 0 
)

Construct a password dialog.

Essentially the same as above but allows the icon in the password dialog to be set via iconName.

Parameters
typeif NewPassword is given here, the dialog contains two input fields, so that the user must confirm his password and possible typos are detected immediately
enableKeepif true, a check box is shown in the dialog which allows the user to keep his password input for later.
extraBttnallows to show additional buttons.
iconNamethe name of the icon to be shown in the dialog. If empty, a default icon is used
parentPassed to lower level constructor.

Definition at line 305 of file k3passworddialog.cpp.

◆ ~K3PasswordDialog()

K3PasswordDialog::~K3PasswordDialog ( )
virtual

Destructs the password dialog.

Definition at line 442 of file k3passworddialog.cpp.

Member Function Documentation

◆ accept()

void K3PasswordDialog::accept ( )
virtual

Definition at line 495 of file k3passworddialog.cpp.

◆ addLine()

void K3PasswordDialog::addLine ( const QString &  key,
const QString &  value 
)

Adds a line of information to the dialog.

Definition at line 467 of file k3passworddialog.cpp.

◆ allowEmptyPasswords()

bool K3PasswordDialog::allowEmptyPasswords ( ) const

Allow empty passwords?

Definition at line 672 of file k3passworddialog.cpp.

◆ checkPassword()

bool K3PasswordDialog::checkPassword ( const char *  password)
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 533 of file k3passworddialog.cpp.

◆ clearPassword()

void K3PasswordDialog::clearPassword ( )

Clears the password input field.

You might want to use this after the user failed to enter the correct password.

Definition at line 448 of file k3passworddialog.cpp.

◆ disableCoreDumps()

void K3PasswordDialog::disableCoreDumps ( )
static

Static helper function that disables core dumps.

Definition at line 592 of file k3passworddialog.cpp.

◆ getNewPassword() [1/2]

int K3PasswordDialog::getNewPassword ( QWidget *  parent,
QByteArray &  password,
const QString &  caption,
const QString &  prompt 
)
static

Pops up the dialog, asks the user for a password and returns it.

The user has to enter the password twice to make sure it was entered correctly.

Parameters
parentThe widget the dialog belongs too
passwordThe password is returned in this reference parameter.
captionA caption for the dialog.
promptA prompt for the password. This can be a few lines of information. The text is word broken to fit nicely in the dialog.
Returns
Result code: Accepted or Rejected.

Definition at line 572 of file k3passworddialog.cpp.

◆ getNewPassword() [2/2]

int K3PasswordDialog::getNewPassword ( QWidget *  parent,
QByteArray &  password,
const QString &  prompt 
)
static

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Deprecated:
Use the new version with the caption argument

Definition at line 585 of file k3passworddialog.cpp.

◆ getPassword() [1/2]

int K3PasswordDialog::getPassword ( QWidget *  parent,
QByteArray &  password,
const QString &  caption,
const QString &  prompt,
bool *  keep = 0L 
)
static

Pops up the dialog, asks the user for a password, and returns it.

Parameters
parentThe widget the dialog belongs too
passwordThe password is returned in this reference parameter.
captionA caption for the dialog.
promptA prompt for the password. This can be a few lines of information. The text is word broken to fit nicely in the dialog.
keepEnable/disable a checkbox controlling password keeping. If you pass a null pointer, or a pointer to the value false, the checkbox is not shown. If you pass a pointer to a true value, the checkbox is shown and the result is stored in *keep.
Returns
Result code: Accepted or Rejected.

Definition at line 539 of file k3passworddialog.cpp.

◆ getPassword() [2/2]

int K3PasswordDialog::getPassword ( QWidget *  parent,
QByteArray &  password,
const QString &  prompt,
int *  keep = 0L 
)
static

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Deprecated:
Use the new version with the caption argument

Definition at line 556 of file k3passworddialog.cpp.

◆ keep()

bool K3PasswordDialog::keep ( ) const

Returns true if the user wants to keep the password.

Definition at line 732 of file k3passworddialog.cpp.

◆ maximumPasswordLength()

int K3PasswordDialog::maximumPasswordLength ( ) const

Maximum acceptable password length.

Definition at line 697 of file k3passworddialog.cpp.

◆ minimumPasswordLength()

int K3PasswordDialog::minimumPasswordLength ( ) const

Minimum acceptable password length.

Definition at line 681 of file k3passworddialog.cpp.

◆ password()

const char * K3PasswordDialog::password ( ) const

Returns the password entered.

The memory is freed in the destructor, so you should make a copy.

Definition at line 727 of file k3passworddialog.cpp.

◆ passwordStrengthWarningLevel()

int K3PasswordDialog::passwordStrengthWarningLevel ( ) const

Password strength level below which a warning is given.

Definition at line 723 of file k3passworddialog.cpp.

◆ prompt()

QString K3PasswordDialog::prompt ( ) const

Returns the password prompt.

Definition at line 460 of file k3passworddialog.cpp.

◆ reasonablePasswordLength()

int K3PasswordDialog::reasonablePasswordLength ( ) const

Password length that is expected to be reasonably safe.

Definition at line 712 of file k3passworddialog.cpp.

◆ setAllowEmptyPasswords()

void K3PasswordDialog::setAllowEmptyPasswords ( bool  allowed)

Allow empty passwords? - Default: false.

Definition at line 666 of file k3passworddialog.cpp.

◆ setMaximumPasswordLength()

void K3PasswordDialog::setMaximumPasswordLength ( int  maxLength)

Maximum acceptable password length.

Limited to 199. Default: No limit, i.e. -1

Parameters
maxLengthThe new maximum password length.

Definition at line 685 of file k3passworddialog.cpp.

◆ setMinimumPasswordLength()

void K3PasswordDialog::setMinimumPasswordLength ( int  minLength)

Minimum acceptable password length.

Default: If empty passwords are forbidden, 1; Otherwise, 0.

Parameters
minLengthThe new minimum password length

Definition at line 676 of file k3passworddialog.cpp.

◆ setPasswordStrengthWarningLevel()

void K3PasswordDialog::setPasswordStrengthWarningLevel ( int  warningLevel)

Set the password strength level below which a warning is given Value is in the range 0 to 99.

Empty passwords score 0; non-empty passwords score up to 100, depending on their length and whether they contain numbers, mixed case letters and punctuation.

Default: 1 - warn if the password has no discernable strength whatsoever

Parameters
warningLevelThe level below which a warning should be given.

Definition at line 717 of file k3passworddialog.cpp.

◆ setPrompt()

void K3PasswordDialog::setPrompt ( const QString &  prompt)

Sets the password prompt.

Definition at line 453 of file k3passworddialog.cpp.

◆ setReasonablePasswordLength()

void K3PasswordDialog::setReasonablePasswordLength ( int  reasonableLength)

Password length that is expected to be reasonably safe.

Default: 8 - the standard UNIX password length

Parameters
reasonableLengthThe new reasonable password length.

Definition at line 703 of file k3passworddialog.cpp.

◆ slotKeep

void K3PasswordDialog::slotKeep ( bool  keep)
protectedslot

Definition at line 528 of file k3passworddialog.cpp.


The documentation for this class was generated from the following files:
  • k3passworddialog.h
  • k3passworddialog.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDE3Support

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

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 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
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
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