summaryrefslogtreecommitdiff
path: root/core
authormickeyl <mickeyl>2004-01-04 16:34:58 (UTC)
committer mickeyl <mickeyl>2004-01-04 16:34:58 (UTC)
commitc076942e5b0cdaa68a467354a563d1071c866d92 (patch) (unidiff)
tree4da1b79ef326101b410dd85f57f25014b618c23c /core
parent6ee1d5d35243f611e0a848d454bfa309b8de0fc9 (diff)
downloadopie-c076942e5b0cdaa68a467354a563d1071c866d92.zip
opie-c076942e5b0cdaa68a467354a563d1071c866d92.tar.gz
opie-c076942e5b0cdaa68a467354a563d1071c866d92.tar.bz2
- implement action on closing the hinge for devices with hinge sensors
- first batch of minor code cleanup
Diffstat (limited to 'core') (more/less context) (show whitespace changes)
-rw-r--r--core/applets/rotateapplet/rotate.cpp116
1 files changed, 70 insertions, 46 deletions
diff --git a/core/applets/rotateapplet/rotate.cpp b/core/applets/rotateapplet/rotate.cpp
index dd71cad..ea114bb 100644
--- a/core/applets/rotateapplet/rotate.cpp
+++ b/core/applets/rotateapplet/rotate.cpp
@@ -1,4 +1,7 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2 This file is part of the OPIE Project
3             .=l. Copyright (c) 2003 Maximilian Reiss <harlekin@handhelds.org> 3 Copyright (C) 2003 Maximilian Reiss <harlekin@handhelds.org>
4 Copyright (C) 2003 Greg Gilbert <ggilbert@treke.net>
5               =. Copyright (C) 2004 Michael Lauer <mickey@Vanille.de>
6             .=l.
4           .>+-= 7           .>+-=
@@ -25,11 +28,16 @@
25 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
26
27*/ 29*/
28 30
31#include "rotate.h"
29 32
30#include <qpe/resource.h> 33/* OPIE */
34#include <opie/odevice.h>
35#include <qpe/applnk.h>
36#include <qpe/config.h>
37#include <qpe/power.h>
38#include <qpe/qpeapplication.h>
31#include <qpe/qcopenvelope_qws.h> 39#include <qpe/qcopenvelope_qws.h>
40#include <qpe/resource.h>
32 41
33#include <qpe/qpeapplication.h> 42/* QT */
34#include <qpe/config.h>
35#include <qiconset.h> 43#include <qiconset.h>
@@ -37,9 +45,4 @@
37 45
38#include <opie/odevice.h>
39
40#include "rotate.h"
41
42using namespace Opie; 46using namespace Opie;
43 47
44
45RotateApplet::RotateApplet ( ) 48RotateApplet::RotateApplet ( )
@@ -57,5 +60,3 @@ RotateApplet::RotateApplet ( )
57RotateApplet::~RotateApplet ( ) 60RotateApplet::~RotateApplet ( )
58{ 61{}
59}
60
61 62
@@ -64,7 +65,32 @@ RotateApplet::~RotateApplet ( )
64 */ 65 */
65void RotateApplet::channelReceived( const QCString &msg, const QByteArray & data ) { 66void RotateApplet::channelReceived( const QCString &msg, const QByteArray & data )
67{
68 qDebug( "RotateApplet::channelReceived( '%s' )", (const char*) msg );
69
70 if ( ODevice::inst()->hasHingeSensor() )
71 {
72 OHingeStatus status = ODevice::inst()->readHingeSensor();
73 qDebug( "RotateApplet::readHingeSensor = %d", (int) status );
74 if ( status == CASE_CLOSED )
75 {
76 Config cfg( "apm" );
77 cfg.setGroup( PowerStatusManager::readStatus().acStatus() == PowerStatus::Online ? "AC" : "Battery" );
78 int action = cfg.readNumEntry( "CloseHingeAction", 0 );
79 switch ( action )
80 {
81 case 1: /* DISPLAY OFF */ ODevice::inst()->setDisplayStatus( false ); ODevice::inst()->setDisplayBrightness( 0 ); break;
82 case 2: /* SUSPEND */ ODevice::inst()->suspend(); break;
83 default: /* IGNORE */ break;
84 }
85 qDebug( "RotateApplet::switchAction %d performed.", cfg.readNumEntry( "CloseHingeAction", 0 ) );
86 }
87 }
88
66 QDataStream stream( data, IO_ReadOnly ); 89 QDataStream stream( data, IO_ReadOnly );
67 if ( msg == "flip()" ) { 90 if ( msg == "flip()" )
91 {
68 activated ( ); 92 activated ( );
69 } else if ( msg == "rotateDefault()") { 93 }
94 else if ( msg == "rotateDefault()")
95 {
70 rotateDefault(); 96 rotateDefault();
@@ -73,3 +99,2 @@ void RotateApplet::channelReceived( const QCString &msg, const QByteArray & data
73 99
74
75int RotateApplet::position ( ) const 100int RotateApplet::position ( ) const
@@ -104,3 +129,2 @@ QIconSet RotateApplet::icon ( ) const
104 QImage img = Resource::loadImage ( "Rotation" ); 129 QImage img = Resource::loadImage ( "Rotation" );
105
106 if ( !img. isNull ( )) 130 if ( !img. isNull ( ))
@@ -117,22 +141,13 @@ void RotateApplet::rotateDefault ( )
117{ 141{
118
119 int rot = ODevice::inst()->rotation(); 142 int rot = ODevice::inst()->rotation();
120 143
121 switch (rot) { 144 switch (rot)
122 case Rot0: 145 {
123 rot=0; 146 case Rot0: rot=0; break;
124 break; 147 case Rot90: rot=90; break;
125 case Rot90: 148 case Rot180: rot=180; break;
126 rot=90; 149 case Rot270: rot=270; break;
127 break; 150 default: rot=0; break;
128 case Rot180:
129 rot=180;
130 break;
131 case Rot270:
132 rot=270;
133 break;
134 default:
135 rot=0;
136 break;
137 } 151 }
152
138 Config cfg( "qpe" ); 153 Config cfg( "qpe" );
@@ -142,4 +157,3 @@ void RotateApplet::rotateDefault ( )
142 157
143 if (rotateEnabled == false) 158 if ( !rotateEnabled) return;
144 return;
145 159
@@ -156,3 +170,2 @@ void RotateApplet::activated ( )
156{ 170{
157
158 int defaultRotation = QPEApplication::defaultRotation(); 171 int defaultRotation = QPEApplication::defaultRotation();
@@ -166,5 +179,8 @@ void RotateApplet::activated ( )
166 179
167 if (rotDirection == -1) { 180 if (rotDirection == -1)
181 {
168 rot = ODevice::inst ( )-> direction ( ); 182 rot = ODevice::inst ( )-> direction ( );
169 } else { 183 }
184 else
185 {
170 rot = (ODirection)rotDirection; 186 rot = (ODirection)rotDirection;
@@ -175,3 +191,4 @@ void RotateApplet::activated ( )
175 191
176 if ( m_flipped ) { 192 if ( m_flipped )
193 {
177 // if flipped, flip back to the original state, 194 // if flipped, flip back to the original state,
@@ -179,8 +196,15 @@ void RotateApplet::activated ( )
179 newRotation = defaultRotation; 196 newRotation = defaultRotation;
180 } else { 197 }
181 if ( rot == CCW ) { 198 else
199 {
200 if ( rot == CCW )
201 {
182 newRotation = ( defaultRotation + 90 ) % 360; 202 newRotation = ( defaultRotation + 90 ) % 360;
183 } else if ( rot == CW ) { 203 }
204 else if ( rot == CW )
205 {
184 newRotation = ( defaultRotation + 270 ) % 360; 206 newRotation = ( defaultRotation + 270 ) % 360;
185 } else if ( rot == Flip ) { 207 }
208 else if ( rot == Flip )
209 {
186 newRotation = ( defaultRotation + 180 ) % 360; 210 newRotation = ( defaultRotation + 180 ) % 360;