-rw-r--r-- | core/launcher/desktop.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index c4c6050..986ae5d 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -154,133 +154,133 @@ void DesktopPowerAlerter::hideEvent( QHideEvent *e ) | |||
154 | class QPEScreenSaver : public QWSScreenSaver | 154 | class QPEScreenSaver : public QWSScreenSaver |
155 | { | 155 | { |
156 | private: | 156 | private: |
157 | int LcdOn; | 157 | int LcdOn; |
158 | 158 | ||
159 | public: | 159 | public: |
160 | QPEScreenSaver() | 160 | QPEScreenSaver() |
161 | { | 161 | { |
162 | m_disable_suspend = 100; | 162 | m_disable_suspend = 100; |
163 | m_enable_dim = false; | 163 | m_enable_dim = false; |
164 | m_enable_lightoff = false; | 164 | m_enable_lightoff = false; |
165 | m_enable_onlylcdoff = false; | 165 | m_enable_onlylcdoff = false; |
166 | 166 | ||
167 | m_disable_suspend_ac = 100; | 167 | m_disable_suspend_ac = 100; |
168 | m_enable_dim_ac = false; | 168 | m_enable_dim_ac = false; |
169 | m_enable_lightoff_ac = false; | 169 | m_enable_lightoff_ac = false; |
170 | m_enable_onlylcdoff_ac = false; | 170 | m_enable_onlylcdoff_ac = false; |
171 | m_disable_apm_ac = false; | 171 | m_disable_apm_ac = false; |
172 | 172 | ||
173 | m_lcd_status = true; | 173 | m_lcd_status = true; |
174 | 174 | ||
175 | m_backlight_normal = -1; | 175 | m_backlight_normal = -1; |
176 | m_backlight_current = -1; | 176 | m_backlight_current = -1; |
177 | m_backlight_forcedoff = false; | 177 | m_backlight_forcedoff = false; |
178 | 178 | ||
179 | // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) | 179 | // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) |
180 | ODevice::inst ( )-> setDisplayStatus ( true ); | 180 | ODevice::inst ( )-> setDisplayStatus ( true ); |
181 | setBacklight ( -1 ); | 181 | setBacklight ( -1 ); |
182 | } | 182 | } |
183 | void restore() | 183 | void restore() |
184 | { | 184 | { |
185 | if ( !m_lcd_status ) { // We must have turned it off | 185 | if ( !m_lcd_status ) { // We must have turned it off |
186 | ODevice::inst ( ) -> setDisplayStatus ( true ); | 186 | ODevice::inst ( ) -> setDisplayStatus ( true ); |
187 | m_lcd_status = true; | 187 | m_lcd_status = true; |
188 | } | 188 | } |
189 | 189 | ||
190 | setBacklightInternal ( -1 ); | 190 | setBacklightInternal ( -1 ); |
191 | } | 191 | } |
192 | bool save( int level ) | 192 | bool save( int level ) |
193 | { | 193 | { |
194 | bool onAC = ( PowerStatusManager::readStatus().acStatus() == PowerStatus::Online ); | 194 | bool onAC = ( PowerStatusManager::readStatus().acStatus() == PowerStatus::Online ); |
195 | 195 | ||
196 | switch ( level ) { | 196 | switch ( level ) { |
197 | case 0: | 197 | case 0: |
198 | 198 | ||
199 | if ( m_disable_suspend_ac > 0 && m_enable_dim_ac && onAC ) { | 199 | if ( m_disable_suspend_ac > 0 && m_enable_dim_ac && onAC ) { |
200 | if ( m_backlight_current > 1 ) | 200 | if ( m_backlight_current > 1 ) |
201 | setBacklight( 1 ); // lowest non-off | 201 | setBacklight( 1 ); // lowest non-off |
202 | } else if ( m_disable_suspend > 0 && m_enable_dim ) { | 202 | } else if ( !onAC && m_disable_suspend > 0 && m_enable_dim ) { |
203 | if ( m_backlight_current > 1 ) | 203 | if ( m_backlight_current > 1 ) |
204 | setBacklightInternal( 1 ); // lowest non-off | 204 | setBacklightInternal( 1 ); // lowest non-off |
205 | } | 205 | } |
206 | return true; | 206 | return true; |
207 | break; | 207 | break; |
208 | case 1: | 208 | case 1: |
209 | 209 | ||
210 | if ( m_disable_suspend_ac > 1 && m_enable_lightoff_ac && onAC ) { | 210 | if ( m_disable_suspend_ac > 1 && m_enable_lightoff_ac && onAC ) { |
211 | setBacklightInternal( 0 ); // off | 211 | setBacklightInternal( 0 ); // off |
212 | } else if ( m_disable_suspend > 1 && m_enable_lightoff ) { | 212 | } else if ( !onAC && m_disable_suspend > 1 && m_enable_lightoff ) { |
213 | setBacklightInternal( 0 ); // off | 213 | setBacklightInternal( 0 ); // off |
214 | } | 214 | } |
215 | return true; | 215 | return true; |
216 | break; | 216 | break; |
217 | case 2: | 217 | case 2: |
218 | if ( m_disable_apm_ac && onAC ) { | 218 | if ( m_disable_apm_ac && onAC ) { |
219 | return true; | 219 | return true; |
220 | } | 220 | } |
221 | 221 | ||
222 | if ( m_enable_onlylcdoff_ac && onAC ) { | 222 | if ( m_enable_onlylcdoff_ac && onAC ) { |
223 | ODevice::inst ( ) -> setDisplayStatus ( false ); | 223 | ODevice::inst ( ) -> setDisplayStatus ( false ); |
224 | m_lcd_status = false; | 224 | m_lcd_status = false; |
225 | return true; | 225 | return true; |
226 | } | 226 | } |
227 | else if ( m_enable_onlylcdoff ) { | 227 | else if ( !onAC && m_enable_onlylcdoff ) { |
228 | ODevice::inst ( ) -> setDisplayStatus ( false ); | 228 | ODevice::inst ( ) -> setDisplayStatus ( false ); |
229 | m_lcd_status = false; | 229 | m_lcd_status = false; |
230 | return true; | 230 | return true; |
231 | } | 231 | } |
232 | else // We're going to suspend the whole machine | 232 | else // We're going to suspend the whole machine |
233 | { | 233 | { |
234 | if ( ( m_disable_suspend_ac > 2 && onAC ) && ( !Network::networkOnline ( ) ) ) { | 234 | if ( ( m_disable_suspend_ac > 2 && onAC ) && ( !Network::networkOnline ( ) ) ) { |
235 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); | 235 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); |
236 | return true; | 236 | return true; |
237 | } | 237 | } |
238 | if ( ( m_disable_suspend > 2 ) && ( !Network::networkOnline ( ) ) ) { | 238 | if ( !onAC && ( m_disable_suspend > 2 ) && ( !Network::networkOnline ( ) ) ) { |
239 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); | 239 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); |
240 | return true; | 240 | return true; |
241 | } | 241 | } |
242 | } | 242 | } |
243 | break; | 243 | break; |
244 | } | 244 | } |
245 | return false; | 245 | return false; |
246 | } | 246 | } |
247 | 247 | ||
248 | private: | 248 | private: |
249 | static int ssi( int interval, Config & config, const QString & enable, const QString & value, int def ) | 249 | static int ssi( int interval, Config & config, const QString & enable, const QString & value, int def ) |
250 | { | 250 | { |
251 | if ( !enable.isEmpty() && config.readNumEntry( enable, 0 ) == 0 ) | 251 | if ( !enable.isEmpty() && config.readNumEntry( enable, 0 ) == 0 ) |
252 | return 0; | 252 | return 0; |
253 | 253 | ||
254 | if ( interval < 0 ) { | 254 | if ( interval < 0 ) { |
255 | // Restore screen blanking and power saving state | 255 | // Restore screen blanking and power saving state |
256 | interval = config.readNumEntry( value, def ); | 256 | interval = config.readNumEntry( value, def ); |
257 | } | 257 | } |
258 | return interval; | 258 | return interval; |
259 | } | 259 | } |
260 | 260 | ||
261 | public: | 261 | public: |
262 | void setIntervals( int i1, int i2, int i3 ) | 262 | void setIntervals( int i1, int i2, int i3 ) |
263 | { | 263 | { |
264 | Config config( "qpe" ); | 264 | Config config( "qpe" ); |
265 | config.setGroup( "Screensaver" ); | 265 | config.setGroup( "Screensaver" ); |
266 | 266 | ||
267 | int v[ 4 ]; | 267 | int v[ 4 ]; |
268 | i1 = ssi( i1, config, "Dim", "Interval_Dim", 30 ); | 268 | i1 = ssi( i1, config, "Dim", "Interval_Dim", 30 ); |
269 | i2 = ssi( i2, config, "LightOff", "Interval_LightOff", 20 ); | 269 | i2 = ssi( i2, config, "LightOff", "Interval_LightOff", 20 ); |
270 | i3 = ssi( i3, config, "", "Interval", 60 ); | 270 | i3 = ssi( i3, config, "", "Interval", 60 ); |
271 | 271 | ||
272 | //qDebug("screen saver intervals: %d %d %d", i1, i2, i3); | 272 | //qDebug("screen saver intervals: %d %d %d", i1, i2, i3); |
273 | 273 | ||
274 | v [ 0 ] = QMAX( 1000 * i1, 100 ); | 274 | v [ 0 ] = QMAX( 1000 * i1, 100 ); |
275 | v [ 1 ] = QMAX( 1000 * i2, 100 ); | 275 | v [ 1 ] = QMAX( 1000 * i2, 100 ); |
276 | v [ 2 ] = QMAX( 1000 * i3, 100 ); | 276 | v [ 2 ] = QMAX( 1000 * i3, 100 ); |
277 | v [ 3 ] = 0; | 277 | v [ 3 ] = 0; |
278 | m_enable_dim = ( ( i1 != 0 ) ? config. readNumEntry ( "Dim", 1 ) : false ); | 278 | m_enable_dim = ( ( i1 != 0 ) ? config. readNumEntry ( "Dim", 1 ) : false ); |
279 | m_enable_lightoff = ( ( i2 != 0 ) ? config. readNumEntry ( "LightOff", 1 ) : false ); | 279 | m_enable_lightoff = ( ( i2 != 0 ) ? config. readNumEntry ( "LightOff", 1 ) : false ); |
280 | m_enable_onlylcdoff = config.readNumEntry ( "LcdOffOnly", 0 ); | 280 | m_enable_onlylcdoff = config.readNumEntry ( "LcdOffOnly", 0 ); |
281 | 281 | ||
282 | if ( !i1 && !i2 && !i3 ) | 282 | if ( !i1 && !i2 && !i3 ) |
283 | QWSServer::setScreenSaverInterval( 0 ); | 283 | QWSServer::setScreenSaverInterval( 0 ); |
284 | else | 284 | else |
285 | QWSServer::setScreenSaverIntervals( v ); | 285 | QWSServer::setScreenSaverIntervals( v ); |
286 | } | 286 | } |
@@ -600,107 +600,107 @@ bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | |||
600 | if ( ke->simpleData.keycode == Key_F32 ) { | 600 | if ( ke->simpleData.keycode == Key_F32 ) { |
601 | if ( press ) | 601 | if ( press ) |
602 | QCopEnvelope e( "QPE/Desktop", "startSync()" ); | 602 | QCopEnvelope e( "QPE/Desktop", "startSync()" ); |
603 | return TRUE; | 603 | return TRUE; |
604 | } | 604 | } |
605 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { | 605 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { |
606 | if ( press ) | 606 | if ( press ) |
607 | emit symbol(); | 607 | emit symbol(); |
608 | return TRUE; | 608 | return TRUE; |
609 | } | 609 | } |
610 | if ( ke->simpleData.keycode == Key_NumLock ) { | 610 | if ( ke->simpleData.keycode == Key_NumLock ) { |
611 | if ( press ) | 611 | if ( press ) |
612 | emit numLockStateToggle(); | 612 | emit numLockStateToggle(); |
613 | } | 613 | } |
614 | if ( ke->simpleData.keycode == Key_CapsLock ) { | 614 | if ( ke->simpleData.keycode == Key_CapsLock ) { |
615 | if ( press ) | 615 | if ( press ) |
616 | emit capsLockStateToggle(); | 616 | emit capsLockStateToggle(); |
617 | } | 617 | } |
618 | if ( ( press && !autoRepeat ) || ( !press && autoRepeat ) ) | 618 | if ( ( press && !autoRepeat ) || ( !press && autoRepeat ) ) |
619 | qpedesktop->keyClick(); | 619 | qpedesktop->keyClick(); |
620 | } | 620 | } |
621 | else { | 621 | else { |
622 | if ( e->type == QWSEvent::Mouse ) { | 622 | if ( e->type == QWSEvent::Mouse ) { |
623 | QWSMouseEvent * me = ( QWSMouseEvent * ) e; | 623 | QWSMouseEvent * me = ( QWSMouseEvent * ) e; |
624 | static bool up = TRUE; | 624 | static bool up = TRUE; |
625 | if ( me->simpleData.state & LeftButton ) { | 625 | if ( me->simpleData.state & LeftButton ) { |
626 | if ( up ) { | 626 | if ( up ) { |
627 | up = FALSE; | 627 | up = FALSE; |
628 | qpedesktop->screenClick(); | 628 | qpedesktop->screenClick(); |
629 | } | 629 | } |
630 | } | 630 | } |
631 | else { | 631 | else { |
632 | up = TRUE; | 632 | up = TRUE; |
633 | } | 633 | } |
634 | } | 634 | } |
635 | } | 635 | } |
636 | 636 | ||
637 | return QPEApplication::qwsEventFilter( e ); | 637 | return QPEApplication::qwsEventFilter( e ); |
638 | } | 638 | } |
639 | #endif | 639 | #endif |
640 | 640 | ||
641 | void DesktopApplication::psTimeout( int batRemaining ) | 641 | void DesktopApplication::psTimeout( int batRemaining ) |
642 | { | 642 | { |
643 | *ps = PowerStatusManager::readStatus(); | 643 | *ps = PowerStatusManager::readStatus(); |
644 | 644 | ||
645 | // maybe now since its triggered by apm change there might be to few warnings | 645 | // maybe now since its triggered by apm change there might be to few warnings |
646 | // if ( ( ps->batteryStatus() == PowerStatus::VeryLow ) ) { | 646 | // if ( ( ps->batteryStatus() == PowerStatus::VeryLow ) ) { |
647 | if ( ( batRemaining == m_powerVeryLow ) ) { | 647 | if ( ( batRemaining == m_powerVeryLow ) ) { |
648 | pa->alert( tr( "Battery is running very low." ), 6 ); | 648 | pa->alert( tr( "Battery is running very low." ), 2 ); |
649 | } | 649 | } |
650 | 650 | ||
651 | // if ( ps->batteryStatus() == PowerStatus::Critical ) { | 651 | // if ( ps->batteryStatus() == PowerStatus::Critical ) { |
652 | if ( batRemaining == m_powerCritical ) { | 652 | if ( batRemaining == m_powerCritical ) { |
653 | pa->alert( tr( "Battery level is critical!\n" | 653 | pa->alert( tr( "Battery level is critical!\n" |
654 | "Keep power off until power restored!" ), 1 ); | 654 | "Keep power off until power restored!" ), 1 ); |
655 | } | 655 | } |
656 | 656 | ||
657 | if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { | 657 | if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { |
658 | pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); | 658 | pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 2 ); |
659 | } | 659 | } |
660 | } | 660 | } |
661 | 661 | ||
662 | void DesktopApplication::apmTimeout() | 662 | void DesktopApplication::apmTimeout() |
663 | { | 663 | { |
664 | qpedesktop->checkMemory(); // in case no events are being generated | 664 | qpedesktop->checkMemory(); // in case no events are being generated |
665 | 665 | ||
666 | *ps = PowerStatusManager::readStatus(); | 666 | *ps = PowerStatusManager::readStatus(); |
667 | 667 | ||
668 | if ( m_currentPowerLevel != ps->batteryPercentRemaining() ) { | 668 | if ( m_currentPowerLevel != ps->batteryPercentRemaining() ) { |
669 | // not very nice, since psTimeout parses the again | 669 | // not very nice, since psTimeout parses the again |
670 | m_currentPowerLevel = ps->batteryPercentRemaining(); | 670 | m_currentPowerLevel = ps->batteryPercentRemaining(); |
671 | psTimeout( m_currentPowerLevel ); | 671 | psTimeout( m_currentPowerLevel ); |
672 | } | 672 | } |
673 | } | 673 | } |
674 | 674 | ||
675 | void DesktopApplication::sendCard() | 675 | void DesktopApplication::sendCard() |
676 | { | 676 | { |
677 | delete cardSendTimer; | 677 | delete cardSendTimer; |
678 | cardSendTimer = 0; | 678 | cardSendTimer = 0; |
679 | QString card = getenv( "HOME" ); | 679 | QString card = getenv( "HOME" ); |
680 | card += "/Applications/addressbook/businesscard.vcf"; | 680 | card += "/Applications/addressbook/businesscard.vcf"; |
681 | 681 | ||
682 | if ( QFile::exists( card ) ) { | 682 | if ( QFile::exists( card ) ) { |
683 | QCopEnvelope e( "QPE/Obex", "send(QString,QString,QString)" ); | 683 | QCopEnvelope e( "QPE/Obex", "send(QString,QString,QString)" ); |
684 | QString mimetype = "text/x-vCard"; | 684 | QString mimetype = "text/x-vCard"; |
685 | e << tr( "business card" ) << card << mimetype; | 685 | e << tr( "business card" ) << card << mimetype; |
686 | } | 686 | } |
687 | } | 687 | } |
688 | 688 | ||
689 | #if defined(QPE_HAVE_MEMALERTER) | 689 | #if defined(QPE_HAVE_MEMALERTER) |
690 | QPE_MEMALERTER_IMPL | 690 | QPE_MEMALERTER_IMPL |
691 | #endif | 691 | #endif |
692 | 692 | ||
693 | //=========================================================================== | 693 | //=========================================================================== |
694 | 694 | ||
695 | Desktop::Desktop() : | 695 | Desktop::Desktop() : |
696 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), | 696 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), |
697 | qcopBridge( 0 ), | 697 | qcopBridge( 0 ), |
698 | transferServer( 0 ), | 698 | transferServer( 0 ), |
699 | packageSlave( 0 ) | 699 | packageSlave( 0 ) |
700 | { | 700 | { |
701 | qpedesktop = this; | 701 | qpedesktop = this; |
702 | 702 | ||
703 | // bg = new Info( this ); | 703 | // bg = new Info( this ); |
704 | tb = new TaskBar; | 704 | tb = new TaskBar; |
705 | 705 | ||
706 | launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); | 706 | launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); |