[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-usability
Subject: Re: Allowing No Hide mode in passwords
From: bj () altern ! org
Date: 2004-01-19 12:55:23
Message-ID: 200401191354.34160.bj () altern ! org
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
[Attachment #4 (multipart/mixed)]
Hi!
> It could however be a useful feature to be able to see the password as you
> type. You also may want to consider to show only the last letter a user has
> typed, or only the letter at the cursor. Hide the rest with stars.
I've been thinking about it again and came with an improved version:
In the Passwords module from Control Center, I add an "Easy mode" checkbox.
When activated, you can press the "Ctrl" key to see the real text in the
password field. Releasing the "Ctrl" key hides the password again. I added a
warning in the QWhat'sthis field, since it is done in the same way for "keep
password in memory"...
I tried it and it is actually quite nice I think.
Patches attached below. If you think it is ok, i will submit it to the file
maintainer.
["passwd.patch" (text/x-diff)]
Index: kdeui/kpassdlg.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kpassdlg.cpp,v
retrieving revision 1.29
diff -u -3 -r1.29 kpassdlg.cpp
--- kdeui/kpassdlg.cpp 7 Dec 2003 23:27:14 -0000 1.29
+++ kdeui/kpassdlg.cpp 19 Jan 2004 12:44:04 -0000
@@ -57,11 +57,11 @@
KPasswordEdit::KPasswordEdit(QWidget *parent, const char *name)
: QLineEdit(parent, name)
{
- init();
KConfig *cfg = KGlobal::config();
KConfigGroupSaver saver(cfg, "Passwords");
-
+
+ m_EasyMode=cfg->readBoolEntry("Easy", "false");
QString val = cfg->readEntry("EchoMode", "OneStar");
if (val == "ThreeStars")
m_EchoMode = ThreeStars;
@@ -69,6 +69,8 @@
m_EchoMode = NoEcho;
else
m_EchoMode = OneStar;
+
+ init();
}
KPasswordEdit::KPasswordEdit(QWidget *parent, const char *name, int echoMode)
@@ -92,7 +94,8 @@
void KPasswordEdit::init()
{
- setEchoMode(QLineEdit::Password); // Just in case
+ if (m_EasyMode) setEchoMode(QLineEdit::Normal); // No Hide mode
+ else setEchoMode(QLineEdit::Password); // Just in case
setAcceptDrops(false);
m_Password = new char[PassLen];
m_Password[0] = '\000';
@@ -138,6 +141,10 @@
setText(txt);
}
+void KPasswordEdit::keyReleaseEvent(QKeyEvent *)
+{
+if (m_EasyMode) showPass();
+}
void KPasswordEdit::keyPressEvent(QKeyEvent *e)
{
@@ -147,6 +154,9 @@
case Key_Escape:
e->ignore();
break;
+ case Key_Control:
+ if (m_EasyMode) setText(m_Password);
+ break;
case Key_Backspace:
case Key_Delete:
case 0x7f: // Delete
@@ -209,7 +219,6 @@
void KPasswordEdit::showPass()
{
QString tmp;
-
switch (m_EchoMode) {
case OneStar:
tmp.fill('*', m_Length);
@@ -220,7 +229,8 @@
setText(tmp);
break;
case NoEcho: default:
- emit textChanged(QString::null); //To update the password comparison if need be.
+ setText(QString::null);
+ //emit textChanged(QString::null); //To update the password comparison if need be.
break;
}
}
Index: kdeui/kpassdlg.h
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kpassdlg.h,v
retrieving revision 1.31
diff -u -3 -r1.31 kpassdlg.h
--- kdeui/kpassdlg.h 3 Oct 2003 18:15:33 -0000 1.31
+++ kdeui/kpassdlg.h 19 Jan 2004 12:44:05 -0000
@@ -41,7 +41,7 @@
Q_OBJECT
public:
- enum EchoModes { OneStar, ThreeStars, NoEcho };
+ enum EchoModes { OneStar, ThreeStars, NoEcho};
/**
* Constructs a password input widget using the user's global "echo mode" setting.
@@ -91,6 +91,7 @@
protected:
virtual void keyPressEvent(QKeyEvent *);
+ virtual void keyReleaseEvent(QKeyEvent *);
virtual void focusInEvent(QFocusEvent *e);
virtual bool event(QEvent *e);
@@ -100,6 +101,7 @@
char *m_Password;
int m_EchoMode, m_Length;
+ bool m_EasyMode;
};
Index: kdesu/defaults.h
===================================================================
RCS file: /home/kde/kdelibs/kdesu/defaults.h,v
retrieving revision 1.2
diff -u -3 -r1.2 defaults.h
--- kdesu/defaults.h 14 Mar 2000 14:39:33 -0000 1.2
+++ kdesu/defaults.h 19 Jan 2004 12:47:21 -0000
@@ -16,5 +16,6 @@
const int defTimeout = 120*60;
const int defEchoMode = 0;
const int defKeep = false;
+const int defEasy = false;
#endif
["passwd2.patch" (text/x-diff)]
Index: kcontrol/passwords/passwords.cpp
===================================================================
RCS file: /home/kde/kdebase/kcontrol/passwords/passwords.cpp,v
retrieving revision 1.26
diff -u -3 -r1.26 passwords.cpp
--- kcontrol/passwords/passwords.cpp 8 Nov 2003 23:43:52 -0000 1.26
+++ kcontrol/passwords/passwords.cpp 19 Jan 2004 12:45:34 -0000
@@ -50,7 +50,13 @@
new QRadioButton(i18n("&3 stars"), m_EMGroup);
new QRadioButton(i18n("&No echo"), m_EMGroup);
connect(m_EMGroup, SIGNAL(clicked(int)), SLOT(slotEchoMode(int)));
-
+
+
+ // Easy Mode
+
+ m_Easy = new QCheckBox(i18n("&Easy mode (Ctrl key shows the real text)"), this);
+ QWhatsThis::add( m_Easy, i18n("If this option is checked, you can press the Ctrl \
key to see the text you have entered in the password field. Beware that if you leave \
your computer with a password dialog opened, anybody could use the Ctrl key to see \
what is typed in the password dialog.") ); + connect(m_Easy, \
SIGNAL(toggled(bool)), SLOT(slotEasy(bool))); // Keep password
m_KeepBut = new QCheckBox(i18n("&Remember passwords"), this);
@@ -62,6 +68,7 @@
" This option does not affect passwords explicitly set in other applications, \
for example," " your email account password in KMail.") );
connect(m_KeepBut, SIGNAL(toggled(bool)), SLOT(slotKeep(bool)));
+ top->addWidget(m_Easy);
top->addWidget(m_KeepBut);
QHBoxLayout *hbox = new QHBoxLayout();
top->addLayout(hbox);
@@ -104,7 +111,8 @@
m_Echo = KPasswordEdit::NoEcho;
else
m_Echo = defEchoMode;
-
+
+ m_bEasy=m_pConfig->readBoolEntry("Easy", defEasy);
m_bKeep = m_pConfig->readBoolEntry("Keep", defKeep);
m_Timeout = m_pConfig->readNumEntry("Timeout", defTimeout);
slotKeep(m_bKeep);
@@ -127,6 +135,7 @@
val = "NoEcho";
m_pConfig->writeEntry("EchoMode", val, true, true);
+ m_pConfig->writeEntry("Easy", m_bEasy, true, true);
m_pConfig->writeEntry("Keep", m_bKeep, true, true);
m_Timeout = m_TimeoutEdit->value()*60;
m_pConfig->writeEntry("Timeout", m_Timeout, true, true);
@@ -148,7 +157,7 @@
m_Echo = defEchoMode;
m_bKeep = defKeep;
m_Timeout = defTimeout;
-
+ m_bEasy=defEasy;
apply();
emit changed(true);
}
@@ -158,6 +167,7 @@
{
m_EMGroup->setButton(m_Echo);
m_KeepBut->setChecked(m_bKeep);
+ m_Easy->setChecked(m_bEasy);
m_TimeoutEdit->setValue(m_Timeout/60);
m_TimeoutEdit->setEnabled(m_bKeep);
@@ -178,6 +188,11 @@
emit changed(true);
}
+void KPasswordConfig::slotEasy(bool easy)
+{
+ m_bEasy = easy;
+ emit changed(true);
+}
int KPasswordConfig::buttons()
{
Index: kcontrol/passwords/passwords.h
===================================================================
RCS file: /home/kde/kdebase/kcontrol/passwords/passwords.h,v
retrieving revision 1.11
diff -u -3 -r1.11 passwords.h
--- kcontrol/passwords/passwords.h 8 Nov 2003 23:43:52 -0000 1.11
+++ kcontrol/passwords/passwords.h 19 Jan 2004 12:45:34 -0000
@@ -40,15 +40,16 @@
void slotEchoMode(int);
void slotKeep(bool);
+ void slotEasy(bool);
void configChanged(){emit changed(true);}
private:
QButtonGroup *m_EMGroup;
- QCheckBox *m_KeepBut;
+ QCheckBox *m_KeepBut,*m_Easy;
KIntNumInput *m_TimeoutEdit;
KConfig *m_pConfig;
int m_Echo, m_Timeout;
- bool m_bKeep;
+ bool m_bKeep,m_bEasy;
};
#endif
[Attachment #9 (application/pgp-signature)]
_______________________________________________
kde-usability mailing list
kde-usability@kde.org
https://mail.kde.org/mailman/listinfo/kde-usability
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic