author | paule <paule> | 2007-01-29 05:23:30 (UTC) |
---|---|---|
committer | paule <paule> | 2007-01-29 05:23:30 (UTC) |
commit | 865225eccc619cbd196d181e80ef27167b124090 (patch) (side-by-side diff) | |
tree | bac8ca323c2af7c3b40c044271db619de2649c0c /noncore/securityplugins/pin/pin.cpp | |
parent | 7c04a4a9ceb843a3ca52b27840145ed598210068 (diff) | |
download | opie-865225eccc619cbd196d181e80ef27167b124090.zip opie-865225eccc619cbd196d181e80ef27167b124090.tar.gz opie-865225eccc619cbd196d181e80ef27167b124090.tar.bz2 |
Change buttons from QLabel to QPushButton, which enables entering the PIN using directional buttons and space/enter (which is all that is available on some PDAs if the screen is uncalibrated). In addition, you can now enter numbers using number keys if your device has them.
Diffstat (limited to 'noncore/securityplugins/pin/pin.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/securityplugins/pin/pin.cpp | 67 |
1 files changed, 54 insertions, 13 deletions
diff --git a/noncore/securityplugins/pin/pin.cpp b/noncore/securityplugins/pin/pin.cpp index 2accb9c..f1c52c5 100644 --- a/noncore/securityplugins/pin/pin.cpp +++ b/noncore/securityplugins/pin/pin.cpp @@ -79,2 +79,8 @@ signals: QString text; + + private slots: + void slotInput(); + void slotSkip(); + void slotOK(); + void slotBackspace(); }; @@ -96,2 +102,15 @@ PinDialog::PinDialog( QWidget* parent, const char* name, WFlags fl ) + connect ( button_0, SIGNAL( clicked()), SLOT( slotInput())); + connect ( button_1, SIGNAL( clicked()), SLOT( slotInput())); + connect ( button_2, SIGNAL( clicked()), SLOT( slotInput())); + connect ( button_3, SIGNAL( clicked()), SLOT( slotInput())); + connect ( button_4, SIGNAL( clicked()), SLOT( slotInput())); + connect ( button_5, SIGNAL( clicked()), SLOT( slotInput())); + connect ( button_6, SIGNAL( clicked()), SLOT( slotInput())); + connect ( button_7, SIGNAL( clicked()), SLOT( slotInput())); + connect ( button_8, SIGNAL( clicked()), SLOT( slotInput())); + connect ( button_9, SIGNAL( clicked()), SLOT( slotInput())); + connect ( button_Skip, SIGNAL( clicked()), SLOT( slotSkip())); + connect ( button_OK, SIGNAL( clicked()), SLOT( slotOK())); + button_0->installEventFilter( this ); @@ -108,3 +127,3 @@ PinDialog::PinDialog( QWidget* parent, const char* name, WFlags fl ) button_OK->installEventFilter( this ); - setFocus(); + button_OK->setFocus(); } @@ -117,16 +136,13 @@ PinDialog::~PinDialog() -/// Record the pressed numbers, and the Skip and Enter commands +/// Handle keyboard events bool PinDialog::eventFilter( QObject*o, QEvent*e ) { - if ( e->type() == QEvent::MouseButtonRelease ) { - if ( o == button_OK ) { - emit passwordEntered( text ); - } - else if ( o == button_Skip ) { - isSkip = TRUE; - emit skip(); - } - else { - QLabel *l = (QLabel*)o; - input(l->text()); + if(e->type() == QEvent::KeyPress) { + switch(((QKeyEvent *)e)->key()) { + case Key_0...Key_9: + input(((QKeyEvent *)e)->text()); + return TRUE; + case Key_Backspace: + slotBackspace(); + return TRUE; } @@ -136,2 +152,27 @@ bool PinDialog::eventFilter( QObject*o, QEvent*e ) +void PinDialog::slotInput() +{ + QPushButton *l = (QPushButton*)sender(); + input(l->text().stripWhiteSpace()); +} + +void PinDialog::slotSkip() +{ + isSkip = TRUE; + emit skip(); +} + +void PinDialog::slotOK() +{ + emit passwordEntered( text ); +} + +void PinDialog::slotBackspace() +{ + if(text.length() > 0) { + text.truncate( text.length() - 1 ); + display->setText( text ); + } +} + void PinDialog::input( QString c ) |