[PATCH] Fix KPasswordDialog to show ok button only when passwords match
Willy De la Court
Willy.DelaCourt at pandora.be
Mon Apr 7 15:52:32 BST 2003
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Since nobody had strong objections to applying this patch wait another day or
so and then apply it.
On Friday 04 April 2003 20:13, Ravikiran Rajagopal wrote:
> Hello,
> The following patch disables the ok button when the two passwords do not
> match. We do it at the end anyway, but this is more user-friendly. (Thanks
> to Willy for the suggestion.) Is it ok to commit?
>
> Regards,
> Ravi
>
> Index: kpassdlg.cpp
> ===================================================================
> RCS file: /home/kde/kdelibs/kdeui/kpassdlg.cpp,v
> retrieving revision 1.20
> diff -u -p -w -r1.20 kpassdlg.cpp
> --- kpassdlg.cpp 27 Feb 2003 22:35:05 -0000 1.20
> +++ kpassdlg.cpp 4 Apr 2003 18:09:20 -0000
> @@ -46,6 +46,12 @@
> * Password line editor.
> */
>
> +class KPasswordDialog::KPasswordDialogPrivate
> +{
> +public:
> + QLabel *m_MatchLabel;
> +};
> +
> const int KPasswordEdit::PassLen = 100;
>
> KPasswordEdit::KPasswordEdit(QWidget *parent, const char *name)
> @@ -208,7 +214,7 @@ KPasswordDialog::KPasswordDialog(Types t
> KPasswordDialog::KPasswordDialog(int type, QString prompt, bool
> enableKeep, int extraBttn)
>
> : KDialogBase(0L, "Password Dialog", true, "", Ok|Cancel|extraBttn,
>
> - Ok, true), m_Keep(enableKeep? 1 : 0), m_Type(type)
> + Ok, true), m_Keep(enableKeep? 1 : 0), m_Type(type),
> d(new KPasswordDialogPrivate)
> {
> init();
> setPrompt(prompt);
> @@ -297,6 +303,17 @@ void KPasswordDialog::init()
> m_pEdit2->setMinimumWidth(size.width());
> h_lay->addWidget(m_pEdit2, 12);
> h_lay->addStretch(4);
> +
> + // Row 5: Label saying whether the passwords match
> + m_pGrid->addRowSpacing(10, 10);
> + m_pGrid->setRowStretch(10, 12);
> + d->m_MatchLabel = new QLabel(m_pMain);
> + d->m_MatchLabel->setAlignment(AlignLeft|AlignVCenter|WordBreak);
> + m_pGrid->addMultiCellWidget(d->m_MatchLabel, 11, 11, 0, 2);
> + d->m_MatchLabel->setText(i18n("Passwords do not match"));
> + connect( m_pEdit, SIGNAL(textChanged(const QString&)),
> SLOT(enableOkBtn()) );
> + connect( m_pEdit2, SIGNAL(textChanged(const QString&)),
> SLOT(enableOkBtn()) );
> + enableOkBtn();
> }
>
> erase();
> @@ -422,5 +439,15 @@ void KPasswordDialog::disableCoreDumps()
>
> void KPasswordDialog::virtual_hook( int id, void* data )
> { KDialogBase::virtual_hook( id, data ); }
> +
> +void KPasswordDialog::enableOkBtn()
> +{
> + if (m_Type == NewPassword) {
> + bool match = ((strcmp(m_pEdit->password(),
> m_pEdit2->password()))==0) + &&
> (strcmp(m_pEdit->password(), "") != 0);
> + enableButtonOK( match );
> + d->m_MatchLabel->setText( match?QString(i18n("Passwords
> match")):QString(i18n("Passwords do not match")) );
> + }
> +}
>
> #include "kpassdlg.moc"
> Index: kpassdlg.h
> ===================================================================
> RCS file: /home/kde/kdelibs/kdeui/kpassdlg.h,v
> retrieving revision 1.19
> diff -u -p -w -r1.19 kpassdlg.h
> --- kpassdlg.h 5 Mar 2002 23:13:27 -0000 1.19
> +++ kpassdlg.h 4 Apr 2003 18:09:20 -0000
> @@ -239,6 +239,9 @@ protected:
> * password is valid, @p false otherwise.
> */
> virtual bool checkPassword(const char *) { return true; }
> +
> +private slots:
> + void enableOkBtn();
>
> private:
> void init();
- --
Simple things make people happy.
Willy De la Court
PGP Public Key at http://www.linux-lovers.be/download/public_key.asc
PGP Key fingerprint = 784E E18F 7F85 9C7C AC1A D5FB FE08 686C 37C7 A689
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQE+kZCw/ghobDfHpokRAsn8AKDpGf+13mDeq8FxgLOx1noPuFYT6ACgtTu1
/Dp+yNvhltBSRJWxr2vG2Cg=
=RygM
-----END PGP SIGNATURE-----
More information about the kde-core-devel
mailing list