Diffstat (limited to 'noncore/tools/euroconv/calckeypad.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/tools/euroconv/calckeypad.cpp | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/noncore/tools/euroconv/calckeypad.cpp b/noncore/tools/euroconv/calckeypad.cpp index 4156570..f1d61c0 100644 --- a/noncore/tools/euroconv/calckeypad.cpp +++ b/noncore/tools/euroconv/calckeypad.cpp | |||
@@ -18,12 +18,14 @@ | |||
18 | #include "calckeypad.h" | 18 | #include "calckeypad.h" |
19 | 19 | ||
20 | 20 | ||
21 | KeyPad::KeyPad(LCDDisplay *lcd, QWidget *parent, const char *name ) | 21 | KeyPad::KeyPad(LCDDisplay *lcd, QWidget *parent, const char *name ) |
22 | : QGrid(5, parent, name){ | 22 | : QGrid(5, parent, name){ |
23 | 23 | ||
24 | int i; | ||
25 | QButton *btnButton; | ||
24 | 26 | ||
25 | // save lcd at init | 27 | // save lcd at init |
26 | display = lcd; | 28 | display = lcd; |
27 | // Init variable | 29 | // Init variable |
28 | dCurrent = 0; | 30 | dCurrent = 0; |
29 | iLenCurrent = 1; | 31 | iLenCurrent = 1; |
@@ -67,19 +69,36 @@ grpbtnDigits->insert(btn4, 4); | |||
67 | grpbtnDigits->insert(btn5, 5); | 69 | grpbtnDigits->insert(btn5, 5); |
68 | grpbtnDigits->insert(btn6, 6); | 70 | grpbtnDigits->insert(btn6, 6); |
69 | grpbtnDigits->insert(btn7, 7); | 71 | grpbtnDigits->insert(btn7, 7); |
70 | grpbtnDigits->insert(btn8, 8); | 72 | grpbtnDigits->insert(btn8, 8); |
71 | grpbtnDigits->insert(btn9, 9); | 73 | grpbtnDigits->insert(btn9, 9); |
72 | 74 | ||
75 | // set appearance of buttons | ||
76 | for(i=0; i<10; i++){ | ||
77 | btnButton = grpbtnDigits->find(i); | ||
78 | btnButton->setFixedSize(30,30); | ||
79 | } | ||
80 | |||
73 | // Operator key | 81 | // Operator key |
74 | grpbtnOperators = new QButtonGroup(0, "operator"); | 82 | grpbtnOperators = new QButtonGroup(0, "operator"); |
75 | grpbtnOperators->insert(btnPlus, 1); | 83 | grpbtnOperators->insert(btnPlus, 1); |
76 | grpbtnOperators->insert(btnMinus,2); | 84 | grpbtnOperators->insert(btnMinus,2); |
77 | grpbtnOperators->insert(btnMultiply,3); | 85 | grpbtnOperators->insert(btnMultiply,3); |
78 | grpbtnOperators->insert(btnDivide,4); | 86 | grpbtnOperators->insert(btnDivide,4); |
79 | grpbtnOperators->insert(btnEqual,5); | 87 | grpbtnOperators->insert(btnEqual,5); |
88 | // set appearance of buttons | ||
89 | for(i=1; i<6; i++){ | ||
90 | btnButton = grpbtnOperators->find(i); | ||
91 | btnButton->setFixedSize(30,30); | ||
92 | } | ||
93 | btnClear->setFixedSize(30,30); | ||
94 | btnClear->setPalette(QPalette( QColor(255, 99, 71) ) ); | ||
95 | btnDot->setFixedSize(30,30); | ||
96 | btnPercent->setFixedSize(30,30); | ||
97 | btnF1->setFixedSize(30,30); | ||
98 | btnAbout->setFixedSize(30,30); | ||
80 | 99 | ||
81 | 100 | ||
82 | // SIGNALS AND SLOTS | 101 | // SIGNALS AND SLOTS |
83 | connect(grpbtnDigits, SIGNAL(clicked(int) ), this, SLOT(enterDigits(int))); | 102 | connect(grpbtnDigits, SIGNAL(clicked(int) ), this, SLOT(enterDigits(int))); |
84 | connect(grpbtnOperators, SIGNAL(clicked(int)), this, SLOT(operatorPressed(int))); | 103 | connect(grpbtnOperators, SIGNAL(clicked(int)), this, SLOT(operatorPressed(int))); |
85 | connect(btnClear, SIGNAL(clicked()), this, SLOT(clearLCD())); | 104 | connect(btnClear, SIGNAL(clicked()), this, SLOT(clearLCD())); |
@@ -132,29 +151,22 @@ if(iPreviousOperator){ | |||
132 | dCurrent = dPreviousValue / dCurrent; | 151 | dCurrent = dPreviousValue / dCurrent; |
133 | break; | 152 | break; |
134 | 153 | ||
135 | } | 154 | } |
136 | display->setValue(dCurrent); | 155 | display->setValue(dCurrent); |
137 | } | 156 | } |
138 | if(i == 5){ | 157 | |
139 | // key '=' pressed | ||
140 | dPreviousValue = 0; | ||
141 | iPreviousOperator = 0; | ||
142 | // We don't want to add digits | ||
143 | iLenCurrent = 100; | ||
144 | }else{ | ||
145 | dPreviousValue = dCurrent; | 158 | dPreviousValue = dCurrent; |
146 | iPreviousOperator = i; | 159 | iPreviousOperator = i; |
160 | |||
147 | // reset LCD for next digit | 161 | // reset LCD for next digit |
148 | dCurrent = 0; | 162 | dCurrent = 0; |
149 | iLenCurrent = 1; | 163 | iLenCurrent = 1; |
150 | bIsDec = false; | 164 | bIsDec = false; |
151 | dDecCurrent = 0; | 165 | dDecCurrent = 0; |
152 | } | 166 | } |
153 | |||
154 | } | ||
155 | /*********************************************************************** | 167 | /*********************************************************************** |
156 | * SLOT: clearLCD CE/C has been pressed | 168 | * SLOT: clearLCD CE/C has been pressed |
157 | **********************************************************************/ | 169 | **********************************************************************/ |
158 | void KeyPad::clearLCD(void){ | 170 | void KeyPad::clearLCD(void){ |
159 | 171 | ||
160 | dCurrent = 0; | 172 | dCurrent = 0; |
@@ -184,8 +196,12 @@ void KeyPad::aboutDialog(void){ | |||
184 | 196 | ||
185 | QMessageBox::about( this, "About Euroconv", | 197 | QMessageBox::about( this, "About Euroconv", |
186 | "Euroconv is an Euro converter\n\n" | 198 | "Euroconv is an Euro converter\n\n" |
187 | "Copyright 2003 TALC Informatique.\n" | 199 | "Copyright 2003 TALC Informatique.\n" |
188 | "Under GPL license\n\n" | 200 | "Under GPL license\n\n" |
189 | "Written by Eric Santonacci for Opie\n" | 201 | "Written by Eric Santonacci for Opie\n" |
190 | "http://opie.handhelds.org\n" ); | 202 | "http://opie.handhelds.org\n\n" |
203 | "Version 0.2\n\n" | ||
204 | "Any comment or feedback to:\n" | ||
205 | "Eric.Santonacci@talc.fr\n"); | ||
206 | |||
191 | } | 207 | } |