-rw-r--r-- | core/launcher/desktop.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index 4587ec6..da535d9 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -78,193 +78,197 @@ static void login(bool at_poweron) | |||
78 | if ( !loggedin ) { | 78 | if ( !loggedin ) { |
79 | Global::terminateBuiltin("calibrate"); | 79 | Global::terminateBuiltin("calibrate"); |
80 | Password::authenticate(at_poweron); | 80 | Password::authenticate(at_poweron); |
81 | loggedin=1; | 81 | loggedin=1; |
82 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); | 82 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); |
83 | } | 83 | } |
84 | } | 84 | } |
85 | 85 | ||
86 | bool Desktop::screenLocked() | 86 | bool Desktop::screenLocked() |
87 | { | 87 | { |
88 | return loggedin == 0; | 88 | return loggedin == 0; |
89 | } | 89 | } |
90 | 90 | ||
91 | /* | 91 | /* |
92 | Priority is number of alerts that are needed to pop up | 92 | Priority is number of alerts that are needed to pop up |
93 | alert. | 93 | alert. |
94 | */ | 94 | */ |
95 | class DesktopPowerAlerter : public QMessageBox | 95 | class DesktopPowerAlerter : public QMessageBox |
96 | { | 96 | { |
97 | public: | 97 | public: |
98 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) | 98 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) |
99 | : QMessageBox( tr("Battery Status"), "Low Battery", | 99 | : QMessageBox( tr("Battery Status"), "Low Battery", |
100 | QMessageBox::Critical, | 100 | QMessageBox::Critical, |
101 | QMessageBox::Ok | QMessageBox::Default, | 101 | QMessageBox::Ok | QMessageBox::Default, |
102 | QMessageBox::NoButton, QMessageBox::NoButton, | 102 | QMessageBox::NoButton, QMessageBox::NoButton, |
103 | parent, name, FALSE ) | 103 | parent, name, FALSE ) |
104 | { | 104 | { |
105 | currentPriority = INT_MAX; | 105 | currentPriority = INT_MAX; |
106 | alertCount = 0; | 106 | alertCount = 0; |
107 | } | 107 | } |
108 | 108 | ||
109 | void alert( const QString &text, int priority ); | 109 | void alert( const QString &text, int priority ); |
110 | void hideEvent( QHideEvent * ); | 110 | void hideEvent( QHideEvent * ); |
111 | private: | 111 | private: |
112 | int currentPriority; | 112 | int currentPriority; |
113 | int alertCount; | 113 | int alertCount; |
114 | }; | 114 | }; |
115 | 115 | ||
116 | void DesktopPowerAlerter::alert( const QString &text, int priority ) | 116 | void DesktopPowerAlerter::alert( const QString &text, int priority ) |
117 | { | 117 | { |
118 | alertCount++; | 118 | alertCount++; |
119 | if ( alertCount < priority ) | 119 | if ( alertCount < priority ) |
120 | return; | 120 | return; |
121 | if ( priority > currentPriority ) | 121 | if ( priority > currentPriority ) |
122 | return; | 122 | return; |
123 | currentPriority = priority; | 123 | currentPriority = priority; |
124 | setText( text ); | 124 | setText( text ); |
125 | show(); | 125 | show(); |
126 | } | 126 | } |
127 | 127 | ||
128 | 128 | ||
129 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) | 129 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) |
130 | { | 130 | { |
131 | QMessageBox::hideEvent( e ); | 131 | QMessageBox::hideEvent( e ); |
132 | alertCount = 0; | 132 | alertCount = 0; |
133 | currentPriority = INT_MAX; | 133 | currentPriority = INT_MAX; |
134 | } | 134 | } |
135 | 135 | ||
136 | 136 | ||
137 | 137 | ||
138 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type t ) | 138 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type t ) |
139 | : QPEApplication( argc, argv, t ) | 139 | : QPEApplication( argc, argv, t ) |
140 | { | 140 | { |
141 | 141 | ||
142 | QTimer *t = new QTimer( this ); | 142 | QTimer *t = new QTimer( this ); |
143 | connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) ); | 143 | connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) ); |
144 | t->start( 10000 ); | 144 | t->start( 10000 ); |
145 | ps = new PowerStatus; | 145 | ps = new PowerStatus; |
146 | pa = new DesktopPowerAlerter( 0 ); | 146 | pa = new DesktopPowerAlerter( 0 ); |
147 | 147 | ||
148 | channel = new QCopChannel( "QPE/Desktop", this ); | 148 | channel = new QCopChannel( "QPE/Desktop", this ); |
149 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 149 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
150 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 150 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
151 | } | 151 | } |
152 | 152 | ||
153 | 153 | ||
154 | DesktopApplication::~DesktopApplication() | 154 | DesktopApplication::~DesktopApplication() |
155 | { | 155 | { |
156 | delete ps; | 156 | delete ps; |
157 | delete pa; | 157 | delete pa; |
158 | } | 158 | } |
159 | 159 | ||
160 | void DesktopApplication::receive( const QCString &msg, const QByteArray &data ) | 160 | void DesktopApplication::receive( const QCString &msg, const QByteArray &data ) |
161 | { | 161 | { |
162 | QDataStream stream( data, IO_ReadOnly ); | 162 | QDataStream stream( data, IO_ReadOnly ); |
163 | if (msg == "keyRegister(int key, QString channel, QString message)") | 163 | if (msg == "keyRegister(int key, QString channel, QString message)") |
164 | { | 164 | { |
165 | int k; | 165 | int k; |
166 | QString c, m; | 166 | QString c, m; |
167 | 167 | ||
168 | stream >> k; | 168 | stream >> k; |
169 | stream >> c; | 169 | stream >> c; |
170 | stream >> m; | 170 | stream >> m; |
171 | 171 | ||
172 | qWarning("KeyRegisterRecieved: %i, %s, %s", k, (const char*)c, (const char *)m); | 172 | qWarning("KeyRegisterRecieved: %i, %s, %s", k, (const char*)c, (const char *)m); |
173 | keyRegisterList.append(QCopKeyRegister(k,c,m)); | 173 | keyRegisterList.append(QCopKeyRegister(k,c,m)); |
174 | } | 174 | } |
175 | else if (msg == "suspend()"){ | ||
176 | emit power(); | ||
177 | } | ||
178 | |||
175 | } | 179 | } |
176 | 180 | ||
177 | enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; | 181 | enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; |
178 | 182 | ||
179 | #ifdef Q_WS_QWS | 183 | #ifdef Q_WS_QWS |
180 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | 184 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) |
181 | { | 185 | { |
182 | qpedesktop->checkMemory(); | 186 | qpedesktop->checkMemory(); |
183 | 187 | ||
184 | if ( e->type == QWSEvent::Key ) { | 188 | if ( e->type == QWSEvent::Key ) { |
185 | QWSKeyEvent *ke = (QWSKeyEvent *)e; | 189 | QWSKeyEvent *ke = (QWSKeyEvent *)e; |
186 | if ( !loggedin && ke->simpleData.keycode != Key_F34 ) | 190 | if ( !loggedin && ke->simpleData.keycode != Key_F34 ) |
187 | return TRUE; | 191 | return TRUE; |
188 | bool press = ke->simpleData.is_press; | 192 | bool press = ke->simpleData.is_press; |
189 | 193 | ||
190 | if (!keyRegisterList.isEmpty()) | 194 | if (!keyRegisterList.isEmpty()) |
191 | { | 195 | { |
192 | KeyRegisterList::Iterator it; | 196 | KeyRegisterList::Iterator it; |
193 | for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) | 197 | for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) |
194 | { | 198 | { |
195 | if ((*it).getKeyCode() == ke->simpleData.keycode) | 199 | if ((*it).getKeyCode() == ke->simpleData.keycode) |
196 | QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8()); | 200 | QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8()); |
197 | } | 201 | } |
198 | } | 202 | } |
199 | 203 | ||
200 | if ( !keyboardGrabbed() ) { | 204 | if ( !keyboardGrabbed() ) { |
201 | if ( ke->simpleData.keycode == Key_F9 ) { | 205 | if ( ke->simpleData.keycode == Key_F9 ) { |
202 | if ( press ) emit datebook(); | 206 | if ( press ) emit datebook(); |
203 | return TRUE; | 207 | return TRUE; |
204 | } | 208 | } |
205 | if ( ke->simpleData.keycode == Key_F10 ) { | 209 | if ( ke->simpleData.keycode == Key_F10 ) { |
206 | if ( !press && cardSendTimer ) { | 210 | if ( !press && cardSendTimer ) { |
207 | emit contacts(); | 211 | emit contacts(); |
208 | delete cardSendTimer; | 212 | delete cardSendTimer; |
209 | } else if ( press ) { | 213 | } else if ( press ) { |
210 | cardSendTimer = new QTimer(); | 214 | cardSendTimer = new QTimer(); |
211 | cardSendTimer->start( 2000, TRUE ); | 215 | cardSendTimer->start( 2000, TRUE ); |
212 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); | 216 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); |
213 | } | 217 | } |
214 | return TRUE; | 218 | return TRUE; |
215 | } | 219 | } |
216 | /* menu key now opens application menu/toolbar | 220 | /* menu key now opens application menu/toolbar |
217 | if ( ke->simpleData.keycode == Key_F11 ) { | 221 | if ( ke->simpleData.keycode == Key_F11 ) { |
218 | if ( press ) emit menu(); | 222 | if ( press ) emit menu(); |
219 | return TRUE; | 223 | return TRUE; |
220 | } | 224 | } |
221 | */ | 225 | */ |
222 | if ( ke->simpleData.keycode == Key_F12 ) { | 226 | if ( ke->simpleData.keycode == Key_F12 ) { |
223 | while( activePopupWidget() ) | 227 | while( activePopupWidget() ) |
224 | activePopupWidget()->close(); | 228 | activePopupWidget()->close(); |
225 | if ( press ) emit launch(); | 229 | if ( press ) emit launch(); |
226 | return TRUE; | 230 | return TRUE; |
227 | } | 231 | } |
228 | if ( ke->simpleData.keycode == Key_F13 ) { | 232 | if ( ke->simpleData.keycode == Key_F13 ) { |
229 | if ( press ) emit email(); | 233 | if ( press ) emit email(); |
230 | return TRUE; | 234 | return TRUE; |
231 | } | 235 | } |
232 | } | 236 | } |
233 | 237 | ||
234 | if ( ke->simpleData.keycode == Key_F34 ) { | 238 | if ( ke->simpleData.keycode == Key_F34 ) { |
235 | if ( press ) emit power(); | 239 | if ( press ) emit power(); |
236 | return TRUE; | 240 | return TRUE; |
237 | } | 241 | } |
238 | if ( ke->simpleData.keycode == Key_F35 ) { | 242 | if ( ke->simpleData.keycode == Key_F35 ) { |
239 | if ( press ) emit backlight(); | 243 | if ( press ) emit backlight(); |
240 | return TRUE; | 244 | return TRUE; |
241 | } | 245 | } |
242 | if ( ke->simpleData.keycode == Key_F32 ) { | 246 | if ( ke->simpleData.keycode == Key_F32 ) { |
243 | if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); | 247 | if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); |
244 | return TRUE; | 248 | return TRUE; |
245 | } | 249 | } |
246 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { | 250 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { |
247 | if ( press ) emit symbol(); | 251 | if ( press ) emit symbol(); |
248 | return TRUE; | 252 | return TRUE; |
249 | } | 253 | } |
250 | if ( ke->simpleData.keycode == Key_NumLock ) { | 254 | if ( ke->simpleData.keycode == Key_NumLock ) { |
251 | if ( press ) emit numLockStateToggle(); | 255 | if ( press ) emit numLockStateToggle(); |
252 | } | 256 | } |
253 | if ( ke->simpleData.keycode == Key_CapsLock ) { | 257 | if ( ke->simpleData.keycode == Key_CapsLock ) { |
254 | if ( press ) emit capsLockStateToggle(); | 258 | if ( press ) emit capsLockStateToggle(); |
255 | } | 259 | } |
256 | if ( press ) | 260 | if ( press ) |
257 | qpedesktop->keyClick(); | 261 | qpedesktop->keyClick(); |
258 | } else { | 262 | } else { |
259 | if ( e->type == QWSEvent::Mouse ) { | 263 | if ( e->type == QWSEvent::Mouse ) { |
260 | QWSMouseEvent *me = (QWSMouseEvent *)e; | 264 | QWSMouseEvent *me = (QWSMouseEvent *)e; |
261 | static bool up = TRUE; | 265 | static bool up = TRUE; |
262 | if ( me->simpleData.state&LeftButton ) { | 266 | if ( me->simpleData.state&LeftButton ) { |
263 | if ( up ) { | 267 | if ( up ) { |
264 | up = FALSE; | 268 | up = FALSE; |
265 | qpedesktop->screenClick(); | 269 | qpedesktop->screenClick(); |
266 | } | 270 | } |
267 | } else { | 271 | } else { |
268 | up = TRUE; | 272 | up = TRUE; |
269 | } | 273 | } |
270 | } | 274 | } |