summaryrefslogtreecommitdiff
path: root/noncore/securityplugins/pin/pin.cpp
Unidiff
Diffstat (limited to 'noncore/securityplugins/pin/pin.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/securityplugins/pin/pin.cpp61
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
@@ -68,79 +68,120 @@ 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
84PinDialog::PinDialog( QWidget* parent, const char* name, WFlags fl ) 90PinDialog::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
113PinDialog::~PinDialog() 132PinDialog::~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
119bool PinDialog::eventFilter( QObject*o, QEvent*e ) 138bool 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
153void PinDialog::slotInput()
154{
155 QPushButton *l = (QPushButton*)sender();
156 input(l->text().stripWhiteSpace());
124 } 157 }
125 else if ( o == button_Skip ) { 158
159void 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; 165void PinDialog::slotOK()
131 input(l->text()); 166{
167 emit passwordEntered( text );
132 } 168 }
169
170void 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
137void PinDialog::input( QString c ) 178void PinDialog::input( QString c )
138{ 179{
139 text += c; 180 text += c;
140 display->setText( text ); 181 display->setText( text );
141} 182}
142 183
143void PinDialog::setPrompt( const QString& s ) 184void PinDialog::setPrompt( const QString& s )
144{ 185{
145 prompt->setText( s ); 186 prompt->setText( s );
146} 187}