From 865225eccc619cbd196d181e80ef27167b124090 Mon Sep 17 00:00:00 2001 From: paule Date: Mon, 29 Jan 2007 05:23:30 +0000 Subject: 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. --- 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 @@ -77,6 +77,12 @@ signals: void input( QString ); friend class PinPlugin; QString text; + + private slots: + void slotInput(); + void slotSkip(); + void slotOK(); + void slotBackspace(); }; @@ -94,6 +100,19 @@ PinDialog::PinDialog( QWidget* parent, const char* name, WFlags fl ) prompt->setFont( f ); } + 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 ); button_1->installEventFilter( this ); button_2->installEventFilter( this ); @@ -106,7 +125,7 @@ PinDialog::PinDialog( QWidget* parent, const char* name, WFlags fl ) button_9->installEventFilter( this ); button_Skip->installEventFilter( this ); button_OK->installEventFilter( this ); - setFocus(); + button_OK->setFocus(); } /// nothing to do @@ -115,25 +134,47 @@ PinDialog::~PinDialog() // no need to delete child widgets, Qt does it all for us } -/// 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; } } return FALSE; } +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 ) { text += c; diff --git a/noncore/securityplugins/pin/pinDialogBase.ui b/noncore/securityplugins/pin/pinDialogBase.ui index f84587b..7fde488 100644 --- a/noncore/securityplugins/pin/pinDialogBase.ui +++ b/noncore/securityplugins/pin/pinDialogBase.ui @@ -11,8 +11,8 @@ 0 0 - 231 - 293 + 257 + 280 @@ -34,70 +34,112 @@ spacing 6 - - QLabel + + QPushButton name - button_4 + button_7 sizePolicy - 5 - 5 + 7 + 7 - frameShape - Box + text + 7 + + + QPushButton - frameShadow - Raised + name + button_1 + + + sizePolicy + + 7 + 7 + text - 4 + 1 + + + QPushButton - alignment - AlignCenter + name + button_3 - - hAlign + + sizePolicy + + 7 + 7 + + + + text + 3 - - QLabel + + QPushButton name - button_7 + button_9 sizePolicy - 5 - 5 + 7 + 7 - frameShape - Box + text + 9 + + + + QPushButton + + name + button_6 - frameShadow - Raised + sizePolicy + + 7 + 7 + text - 7 + 6 + + + QPushButton - alignment - AlignCenter + name + button_0 - - hAlign + + sizePolicy + + 7 + 7 + + + + text + 0 @@ -353,284 +395,8 @@ Password - - QLabel - - name - button_1 - - - sizePolicy - - 5 - 5 - - - - frameShape - Box - - - frameShadow - Raised - - - text - 1 - - - alignment - AlignCenter - - - hAlign - - - - QLabel - - name - button_2 - - - sizePolicy - - 5 - 5 - - - - frameShape - Box - - - frameShadow - Raised - - - text - 2 - - - alignment - AlignCenter - - - hAlign - - - - QLabel - - name - button_5 - - - sizePolicy - - 5 - 5 - - - - frameShape - Box - - - frameShadow - Raised - - - text - 5 - - - alignment - AlignCenter - - - hAlign - - - - QLabel - - name - button_6 - - - sizePolicy - - 5 - 5 - - - - frameShape - Box - - - frameShadow - Raised - - - text - 6 - - - alignment - AlignCenter - - - hAlign - - - - QLabel - - name - button_3 - - - sizePolicy - - 5 - 5 - - - - frameShape - Box - - - frameShadow - Raised - - - text - 3 - - - alignment - AlignCenter - - - hAlign - - - - QLabel - - name - button_0 - - - sizePolicy - - 5 - 5 - - - - frameShape - Box - - - frameShadow - Raised - - - text - 0 - - - alignment - AlignCenter - - - hAlign - - - layoutMargin - - - layoutSpacing - - - - QLabel - - name - button_8 - - - sizePolicy - - 5 - 5 - - - - frameShape - Box - - - frameShadow - Raised - - - text - 8 - - - alignment - AlignCenter - - - hAlign - - - - QLabel - - name - button_9 - - - sizePolicy - - 5 - 5 - - - - frameShape - Box - - - frameShadow - Raised - - - text - 9 - - - alignment - AlignCenter - - - hAlign - - - layoutMargin - - - layoutSpacing - - - QLabel + QPushButton name button_OK @@ -638,8 +404,8 @@ sizePolicy - 5 - 5 + 7 + 7 @@ -652,29 +418,29 @@ 0 - 192 - 192 - 192 + 170 + 255 + 0 - 255 + 212 255 - 255 + 127 - 223 - 223 - 223 + 191 + 255 + 63 - 96 - 96 - 96 + 85 + 127 + 0 - 128 - 128 - 128 + 113 + 170 + 0 0 @@ -697,9 +463,9 @@ 255 - 0 - 170 - 0 + 238 + 238 + 230 0 @@ -707,15 +473,15 @@ 0 + 255 + 221 + 118 + + 0 0 0 - - 255 - 255 - 255 - @@ -724,29 +490,29 @@ 128 - 192 - 192 - 192 + 170 + 255 + 0 - 255 + 212 255 - 255 + 127 - 220 - 220 - 220 + 183 + 255 + 38 - 96 - 96 - 96 + 85 + 127 + 0 - 128 - 128 - 128 + 113 + 170 + 0 0 @@ -769,9 +535,9 @@ 255 - 0 - 170 - 0 + 238 + 238 + 230 0 @@ -779,15 +545,15 @@ 0 + 255 + 221 + 118 + + 0 0 0 - - 255 - 255 - 255 - @@ -796,29 +562,29 @@ 0 - 192 - 192 - 192 + 170 + 255 + 0 - 255 + 212 255 - 255 + 127 - 220 - 220 - 220 + 183 + 255 + 38 - 96 - 96 - 96 + 85 + 127 + 0 - 128 - 128 - 128 + 113 + 170 + 0 0 @@ -841,9 +607,9 @@ 255 - 0 - 170 - 0 + 238 + 238 + 230 0 @@ -851,40 +617,97 @@ 0 + 255 + 221 + 118 + + 0 0 0 - - 255 - 255 - 255 - - frameShape - Box + text + OK + + + + QPushButton + + name + button_4 - frameShadow - Raised + sizePolicy + + 7 + 7 + text - Enter + 4 + + + QPushButton - alignment - AlignCenter + name + button_2 - - hAlign + + sizePolicy + + 7 + 7 + + + + text + 2 + + + + QPushButton + + name + button_5 + + + sizePolicy + + 7 + 7 + + + + text + 5 + + + + QPushButton + + name + button_8 + + + sizePolicy + + 7 + 7 + + + + text + 8 - QLabel + QPushButton name button_Skip @@ -892,8 +715,8 @@ sizePolicy - 5 - 5 + 7 + 7 @@ -906,29 +729,29 @@ 0 - 192 - 192 - 192 + 255 + 255 + 127 255 255 - 255 + 254 - 223 - 223 - 223 + 255 + 255 + 190 - 96 - 96 - 96 + 127 + 127 + 63 - 128 - 128 - 128 + 170 + 170 + 85 0 @@ -951,9 +774,9 @@ 255 - 255 - 255 - 127 + 238 + 238 + 230 0 @@ -961,15 +784,15 @@ 0 + 255 + 221 + 118 + + 0 0 0 - - 255 - 255 - 255 - @@ -978,29 +801,29 @@ 128 - 192 - 192 - 192 + 255 + 255 + 127 255 255 - 255 + 254 - 220 - 220 - 220 + 255 + 255 + 165 - 96 - 96 - 96 + 127 + 127 + 63 - 128 - 128 - 128 + 170 + 170 + 85 0 @@ -1023,9 +846,9 @@ 255 - 255 - 255 - 127 + 238 + 238 + 230 0 @@ -1033,15 +856,15 @@ 0 + 255 + 221 + 118 + + 0 0 0 - - 255 - 255 - 255 - @@ -1050,29 +873,29 @@ 0 - 192 - 192 - 192 + 255 + 255 + 127 255 255 - 255 + 254 - 220 - 220 - 220 + 255 + 255 + 165 - 96 - 96 - 96 + 127 + 127 + 63 - 128 - 128 - 128 + 170 + 170 + 85 0 @@ -1095,9 +918,9 @@ 255 - 255 - 255 - 127 + 238 + 238 + 230 0 @@ -1105,38 +928,64 @@ 0 + 255 + 221 + 118 + + 0 0 0 - - 255 - 255 - 255 - - frameShape - Box - - - frameShadow - Raised - - text Skip - alignment - AlignCenter - - - hAlign + autoResize + false + + + QWidget +
qwidget.h
+ + -1 + -1 + + 0 + + 5 + 5 + + image0 +
+
+ + + image0 + 789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758 + + + + display + button_1 + button_2 + button_3 + button_4 + button_5 + button_6 + button_7 + button_8 + button_9 + button_0 + button_Skip + button_OK + -- cgit v0.9.0.2