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 | |||
@@ -68,81 +68,122 @@ signals: | |||
68 | /// emitted when we press the Enter button | 68 | /// emitted when we press the Enter button |
69 | void passwordEntered( const QString& ); | 69 | void passwordEntered( const QString& ); |
70 | /// emitted when we press the Skip button | 70 | /// emitted when we press the Skip button |
71 | void skip(); | 71 | void skip(); |
72 | 72 | ||
73 | protected: | 73 | protected: |
74 | bool eventFilter( QObject*, QEvent* ); | 74 | bool eventFilter( QObject*, QEvent* ); |
75 | 75 | ||
76 | private: | 76 | private: |
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 | ||
83 | /// Constructs a PinDialog widget, and initializes things | 89 | /// Constructs a PinDialog widget, and initializes things |
84 | PinDialog::PinDialog( QWidget* parent, const char* name, WFlags fl ) | 90 | PinDialog::PinDialog( QWidget* parent, const char* name, WFlags fl ) |
85 | : PinDialogBase( parent, name, fl ) | 91 | : PinDialogBase( parent, name, fl ) |
86 | { | 92 | { |
87 | QRect desk = oApp->desktop()->geometry(); | 93 | QRect desk = oApp->desktop()->geometry(); |
88 | 94 | ||
89 | if ( desk.width() < 220 ) { | 95 | if ( desk.width() < 220 ) { |
90 | QFont f( font() ); | 96 | QFont f( font() ); |
91 | f.setPointSize( 18 ); | 97 | f.setPointSize( 18 ); |
92 | setFont( f ); | 98 | setFont( f ); |
93 | f.setPointSize( 12 ); | 99 | f.setPointSize( 12 ); |
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 ); |
100 | button_3->installEventFilter( this ); | 119 | button_3->installEventFilter( this ); |
101 | button_4->installEventFilter( this ); | 120 | button_4->installEventFilter( this ); |
102 | button_5->installEventFilter( this ); | 121 | button_5->installEventFilter( this ); |
103 | button_6->installEventFilter( this ); | 122 | button_6->installEventFilter( this ); |
104 | button_7->installEventFilter( this ); | 123 | button_7->installEventFilter( this ); |
105 | button_8->installEventFilter( this ); | 124 | button_8->installEventFilter( this ); |
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 |
113 | PinDialog::~PinDialog() | 132 | PinDialog::~PinDialog() |
114 | { | 133 | { |
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: |
124 | } | 143 | input(((QKeyEvent *)e)->text()); |
125 | else if ( o == button_Skip ) { | 144 | return TRUE; |
126 | isSkip = TRUE; | 145 | case Key_Backspace: |
127 | emit skip(); | 146 | slotBackspace(); |
128 | } | 147 | return TRUE; |
129 | else { | ||
130 | QLabel *l = (QLabel*)o; | ||
131 | input(l->text()); | ||
132 | } | 148 | } |
133 | } | 149 | } |
134 | return FALSE; | 150 | return FALSE; |
135 | } | 151 | } |
136 | 152 | ||
153 | void PinDialog::slotInput() | ||
154 | { | ||
155 | QPushButton *l = (QPushButton*)sender(); | ||
156 | input(l->text().stripWhiteSpace()); | ||
157 | } | ||
158 | |||
159 | void PinDialog::slotSkip() | ||
160 | { | ||
161 | isSkip = TRUE; | ||
162 | emit skip(); | ||
163 | } | ||
164 | |||
165 | void PinDialog::slotOK() | ||
166 | { | ||
167 | emit passwordEntered( text ); | ||
168 | } | ||
169 | |||
170 | void PinDialog::slotBackspace() | ||
171 | { | ||
172 | if(text.length() > 0) { | ||
173 | text.truncate( text.length() - 1 ); | ||
174 | display->setText( text ); | ||
175 | } | ||
176 | } | ||
177 | |||
137 | void PinDialog::input( QString c ) | 178 | void PinDialog::input( QString c ) |
138 | { | 179 | { |
139 | text += c; | 180 | text += c; |
140 | display->setText( text ); | 181 | display->setText( text ); |
141 | } | 182 | } |
142 | 183 | ||
143 | void PinDialog::setPrompt( const QString& s ) | 184 | void PinDialog::setPrompt( const QString& s ) |
144 | { | 185 | { |
145 | prompt->setText( s ); | 186 | prompt->setText( s ); |
146 | } | 187 | } |
147 | 188 | ||
148 | void PinDialog::clear() | 189 | void PinDialog::clear() |