Diffstat (limited to 'noncore/securityplugins/pin/pin.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/securityplugins/pin/pin.cpp | 61 |
1 files changed, 51 insertions, 10 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 | |||
@@ -77,6 +77,12 @@ signals: | |||
77 | void input( QString ); | 77 | void input( QString ); |
78 | friend class PinPlugin; | 78 | friend class PinPlugin; |
79 | QString text; | 79 | QString text; |
80 | |||
81 | private slots: | ||
82 | void slotInput(); | ||
83 | void slotSkip(); | ||
84 | void slotOK(); | ||
85 | void slotBackspace(); | ||
80 | }; | 86 | }; |
81 | 87 | ||
82 | 88 | ||
@@ -94,6 +100,19 @@ PinDialog::PinDialog( QWidget* parent, const char* name, WFlags fl ) | |||
94 | prompt->setFont( f ); | 100 | prompt->setFont( f ); |
95 | } | 101 | } |
96 | 102 | ||
103 | connect ( button_0, SIGNAL( clicked()), SLOT( slotInput())); | ||
104 | connect ( button_1, SIGNAL( clicked()), SLOT( slotInput())); | ||
105 | connect ( button_2, SIGNAL( clicked()), SLOT( slotInput())); | ||
106 | connect ( button_3, SIGNAL( clicked()), SLOT( slotInput())); | ||
107 | connect ( button_4, SIGNAL( clicked()), SLOT( slotInput())); | ||
108 | connect ( button_5, SIGNAL( clicked()), SLOT( slotInput())); | ||
109 | connect ( button_6, SIGNAL( clicked()), SLOT( slotInput())); | ||
110 | connect ( button_7, SIGNAL( clicked()), SLOT( slotInput())); | ||
111 | connect ( button_8, SIGNAL( clicked()), SLOT( slotInput())); | ||
112 | connect ( button_9, SIGNAL( clicked()), SLOT( slotInput())); | ||
113 | connect ( button_Skip, SIGNAL( clicked()), SLOT( slotSkip())); | ||
114 | connect ( button_OK, SIGNAL( clicked()), SLOT( slotOK())); | ||
115 | |||
97 | button_0->installEventFilter( this ); | 116 | button_0->installEventFilter( this ); |
98 | button_1->installEventFilter( this ); | 117 | button_1->installEventFilter( this ); |
99 | button_2->installEventFilter( this ); | 118 | button_2->installEventFilter( this ); |
@@ -106,7 +125,7 @@ PinDialog::PinDialog( QWidget* parent, const char* name, WFlags fl ) | |||
106 | button_9->installEventFilter( this ); | 125 | button_9->installEventFilter( this ); |
107 | button_Skip->installEventFilter( this ); | 126 | button_Skip->installEventFilter( this ); |
108 | button_OK->installEventFilter( this ); | 127 | button_OK->installEventFilter( this ); |
109 | setFocus(); | 128 | button_OK->setFocus(); |
110 | } | 129 | } |
111 | 130 | ||
112 | /// nothing to do | 131 | /// nothing to do |
@@ -115,23 +134,45 @@ PinDialog::~PinDialog() | |||
115 | // no need to delete child widgets, Qt does it all for us | 134 | // no need to delete child widgets, Qt does it all for us |
116 | } | 135 | } |
117 | 136 | ||
118 | /// Record the pressed numbers, and the Skip and Enter commands | 137 | /// Handle keyboard events |
119 | bool PinDialog::eventFilter( QObject*o, QEvent*e ) | 138 | bool PinDialog::eventFilter( QObject*o, QEvent*e ) |
120 | { | 139 | { |
121 | if ( e->type() == QEvent::MouseButtonRelease ) { | 140 | if(e->type() == QEvent::KeyPress) { |
122 | if ( o == button_OK ) { | 141 | switch(((QKeyEvent *)e)->key()) { |
123 | emit passwordEntered( text ); | 142 | case Key_0...Key_9: |
143 | input(((QKeyEvent *)e)->text()); | ||
144 | return TRUE; | ||
145 | case Key_Backspace: | ||
146 | slotBackspace(); | ||
147 | return TRUE; | ||
148 | } | ||
149 | } | ||
150 | return FALSE; | ||
151 | } | ||
152 | |||
153 | void PinDialog::slotInput() | ||
154 | { | ||
155 | QPushButton *l = (QPushButton*)sender(); | ||
156 | input(l->text().stripWhiteSpace()); | ||
124 | } | 157 | } |
125 | else if ( o == button_Skip ) { | 158 | |
159 | void PinDialog::slotSkip() | ||
160 | { | ||
126 | isSkip = TRUE; | 161 | isSkip = TRUE; |
127 | emit skip(); | 162 | emit skip(); |
128 | } | 163 | } |
129 | else { | 164 | |
130 | QLabel *l = (QLabel*)o; | 165 | void PinDialog::slotOK() |
131 | input(l->text()); | 166 | { |
167 | emit passwordEntered( text ); | ||
132 | } | 168 | } |
169 | |||
170 | void PinDialog::slotBackspace() | ||
171 | { | ||
172 | if(text.length() > 0) { | ||
173 | text.truncate( text.length() - 1 ); | ||
174 | display->setText( text ); | ||
133 | } | 175 | } |
134 | return FALSE; | ||
135 | } | 176 | } |
136 | 177 | ||
137 | void PinDialog::input( QString c ) | 178 | void PinDialog::input( QString c ) |