summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/rotateapplet/rotate.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/core/applets/rotateapplet/rotate.cpp b/core/applets/rotateapplet/rotate.cpp
index ea114bb..79098d4 100644
--- a/core/applets/rotateapplet/rotate.cpp
+++ b/core/applets/rotateapplet/rotate.cpp
@@ -1,237 +1,237 @@
1/* 1/*
2 This file is part of the OPIE Project 2 This file is part of the OPIE Project
3 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> 4 Copyright (C) 2003 Greg Gilbert <ggilbert@treke.net>
5               =. Copyright (C) 2004 Michael Lauer <mickey@Vanille.de> 5               =. Copyright (C) 2004 Michael Lauer <mickey@Vanille.de>
6             .=l. 6             .=l.
7           .>+-= 7           .>+-=
8 _;:,     .>    :=|. This library is free software; you can 8 _;:,     .>    :=|. This library is free software; you can
9.> <,   >  .   <= redistribute it and/or modify it under 9.> <,   >  .   <= redistribute it and/or modify it under
10:=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%+i>       _;_. 14    .%+i>       _;_.
15    .i_,=:_.      -<s. This library is distributed in the hope that 15    .i_,=:_.      -<s. This library is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=| MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=| MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .     .: details. 21++=   -.     .     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-= this library; see the file COPYING.LIB. 25    --        :-= this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include "rotate.h" 31#include "rotate.h"
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie/odevice.h> 34#include <opie/odevice.h>
35#include <qpe/applnk.h> 35#include <qpe/applnk.h>
36#include <qpe/config.h> 36#include <qpe/config.h>
37#include <qpe/power.h> 37#include <qpe/power.h>
38#include <qpe/qpeapplication.h> 38#include <qpe/qpeapplication.h>
39#include <qpe/qcopenvelope_qws.h> 39#include <qpe/qcopenvelope_qws.h>
40#include <qpe/resource.h> 40#include <qpe/resource.h>
41 41
42/* QT */ 42/* QT */
43#include <qiconset.h> 43#include <qiconset.h>
44#include <qpopupmenu.h> 44#include <qpopupmenu.h>
45 45
46using namespace Opie; 46using namespace Opie;
47 47
48RotateApplet::RotateApplet() 48RotateApplet::RotateApplet()
49 :QObject( 0, "RotateApplet" ), ref( 0 ), m_flipped( false ) 49 :QObject( 0, "RotateApplet" ), ref( 0 ), m_flipped( false )
50{ 50{
51 51
52#if !defined(QT_NO_COP) 52#if !defined(QT_NO_COP)
53 QCopChannel *rotateChannel = new QCopChannel( "QPE/Rotation" , this ); 53 QCopChannel *rotateChannel = new QCopChannel( "QPE/Rotation" , this );
54 connect ( rotateChannel, SIGNAL( received( const QCString &, const QByteArray &) ), 54 connect ( rotateChannel, SIGNAL( received( const QCString &, const QByteArray &) ),
55 this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) ); 55 this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) );
56#endif 56#endif
57 57
58} 58}
59 59
60RotateApplet::~RotateApplet ( ) 60RotateApplet::~RotateApplet ( )
61{} 61{}
62 62
63/** 63/**
64 * Qcop receive method. 64 * Qcop receive method.
65 */ 65 */
66void RotateApplet::channelReceived( const QCString &msg, const QByteArray & data ) 66void RotateApplet::channelReceived( const QCString &msg, const QByteArray & data )
67{ 67{
68 qDebug( "RotateApplet::channelReceived( '%s' )", (const char*) msg ); 68 qDebug( "RotateApplet::channelReceived( '%s' )", (const char*) msg );
69 69
70 if ( ODevice::inst()->hasHingeSensor() ) 70 if ( ODevice::inst()->hasHingeSensor() )
71 { 71 {
72 OHingeStatus status = ODevice::inst()->readHingeSensor(); 72 OHingeStatus status = ODevice::inst()->readHingeSensor();
73 qDebug( "RotateApplet::readHingeSensor = %d", (int) status ); 73 qDebug( "RotateApplet::readHingeSensor = %d", (int) status );
74 if ( status == CASE_CLOSED ) 74 if ( status == CASE_CLOSED )
75 { 75 {
76 Config cfg( "apm" ); 76 Config cfg( "apm" );
77 cfg.setGroup( PowerStatusManager::readStatus().acStatus() == PowerStatus::Online ? "AC" : "Battery" ); 77 cfg.setGroup( PowerStatusManager::readStatus().acStatus() == PowerStatus::Online ? "AC" : "Battery" );
78 int action = cfg.readNumEntry( "CloseHingeAction", 0 ); 78 int action = cfg.readNumEntry( "CloseHingeAction", 0 );
79 switch ( action ) 79 switch ( action )
80 { 80 {
81 case 1: /* DISPLAY OFF */ ODevice::inst()->setDisplayStatus( false ); ODevice::inst()->setDisplayBrightness( 0 ); break; 81 case 1: /* DISPLAY OFF */ ODevice::inst()->setDisplayBrightness( 0 ); break;
82 case 2: /* SUSPEND */ ODevice::inst()->suspend(); break; 82 case 2: /* SUSPEND */ ODevice::inst()->suspend(); break;
83 default: /* IGNORE */ break; 83 default: /* IGNORE */ break;
84 } 84 }
85 qDebug( "RotateApplet::switchAction %d performed.", cfg.readNumEntry( "CloseHingeAction", 0 ) ); 85 qDebug( "RotateApplet::switchAction %d performed.", cfg.readNumEntry( "CloseHingeAction", 0 ) );
86 } 86 }
87 } 87 }
88 88
89 QDataStream stream( data, IO_ReadOnly ); 89 QDataStream stream( data, IO_ReadOnly );
90 if ( msg == "flip()" ) 90 if ( msg == "flip()" )
91 { 91 {
92 activated ( ); 92 activated ( );
93 } 93 }
94 else if ( msg == "rotateDefault()") 94 else if ( msg == "rotateDefault()")
95 { 95 {
96 rotateDefault(); 96 rotateDefault();
97 } 97 }
98} 98}
99 99
100int RotateApplet::position() const 100int RotateApplet::position() const
101{ 101{
102 return 3; 102 return 3;
103} 103}
104 104
105QString RotateApplet::name() const 105QString RotateApplet::name() const
106{ 106{
107 return tr( "Rotate shortcut" ); 107 return tr( "Rotate shortcut" );
108} 108}
109 109
110QString RotateApplet::text() const 110QString RotateApplet::text() const
111{ 111{
112 return tr( "Rotate" ); 112 return tr( "Rotate" );
113} 113}
114 114
115/*QString RotateApplet::tr( const char* s ) const 115/*QString RotateApplet::tr( const char* s ) const
116{ 116{
117 return qApp->translate( "RotateApplet", s, 0 ); 117 return qApp->translate( "RotateApplet", s, 0 );
118} 118}
119 119
120QString RotateApplet::tr( const char* s, const char* p ) const 120QString RotateApplet::tr( const char* s, const char* p ) const
121{ 121{
122 return qApp->translate( "RotateApplet", s, p ); 122 return qApp->translate( "RotateApplet", s, p );
123} 123}
124*/ 124*/
125 125
126QIconSet RotateApplet::icon() const 126QIconSet RotateApplet::icon() const
127{ 127{
128 QPixmap pix; 128 QPixmap pix;
129 QImage img = Resource::loadImage( "Rotation" ); 129 QImage img = Resource::loadImage( "Rotation" );
130 if ( !img.isNull() ) 130 if ( !img.isNull() )
131 pix.convertFromImage( img.smoothScale( 14, 14 ) ); 131 pix.convertFromImage( img.smoothScale( 14, 14 ) );
132 return pix; 132 return pix;
133} 133}
134 134
135QPopupMenu* RotateApplet::popup(QWidget*) const 135QPopupMenu* RotateApplet::popup(QWidget*) const
136{ 136{
137 return 0; 137 return 0;
138} 138}
139 139
140void RotateApplet::rotateDefault() 140void RotateApplet::rotateDefault()
141{ 141{
142 int rot = ODevice::inst()->rotation(); 142 int rot = ODevice::inst()->rotation();
143 143
144 switch (rot) 144 switch (rot)
145 { 145 {
146 case Rot0: rot=0; break; 146 case Rot0: rot=0; break;
147 case Rot90: rot=90; break; 147 case Rot90: rot=90; break;
148 case Rot180: rot=180; break; 148 case Rot180: rot=180; break;
149 case Rot270: rot=270; break; 149 case Rot270: rot=270; break;
150 default: rot=0; break; 150 default: rot=0; break;
151 } 151 }
152 152
153 Config cfg( "qpe" ); 153 Config cfg( "qpe" );
154 cfg.setGroup( "Appearance" ); 154 cfg.setGroup( "Appearance" );
155 155
156 bool rotateEnabled = cfg.readBoolEntry( "rotateEnabled",true ); 156 bool rotateEnabled = cfg.readBoolEntry( "rotateEnabled",true );
157 157
158 if ( !rotateEnabled) return; 158 if ( !rotateEnabled) return;
159 159
160 // hide inputs methods before rotation 160 // hide inputs methods before rotation
161 QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" ); 161 QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" );
162 162
163 QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); 163 QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" );
164 env << rot; 164 env << rot;
165 165
166 m_flipped = false; 166 m_flipped = false;
167 167
168} 168}
169void RotateApplet::activated() 169void RotateApplet::activated()
170{ 170{
171 int defaultRotation = QPEApplication::defaultRotation(); 171 int defaultRotation = QPEApplication::defaultRotation();
172 int newRotation = defaultRotation; 172 int newRotation = defaultRotation;
173 173
174 Config cfg( "qpe" ); 174 Config cfg( "qpe" );
175 cfg.setGroup( "Appearance" ); 175 cfg.setGroup( "Appearance" );
176 176
177 int rotDirection = cfg.readNumEntry( "rotatedir" ); 177 int rotDirection = cfg.readNumEntry( "rotatedir" );
178 ODirection rot = CW; 178 ODirection rot = CW;
179 179
180 if (rotDirection == -1) 180 if (rotDirection == -1)
181 { 181 {
182 rot = ODevice::inst()->direction(); 182 rot = ODevice::inst()->direction();
183 } 183 }
184 else 184 else
185 { 185 {
186 rot = (ODirection) rotDirection; 186 rot = (ODirection) rotDirection;
187 } 187 }
188 188
189 // hide inputs methods before rotation 189 // hide inputs methods before rotation
190 QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" ); 190 QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" );
191 191
192 if ( m_flipped ) 192 if ( m_flipped )
193 { 193 {
194 // if flipped, flip back to the original state, 194 // if flipped, flip back to the original state,
195 // regardless of rotation direction 195 // regardless of rotation direction
196 newRotation = defaultRotation; 196 newRotation = defaultRotation;
197 } 197 }
198 else 198 else
199 { 199 {
200 if ( rot == CCW ) 200 if ( rot == CCW )
201 { 201 {
202 newRotation = ( defaultRotation + 90 ) % 360; 202 newRotation = ( defaultRotation + 90 ) % 360;
203 } 203 }
204 else if ( rot == CW ) 204 else if ( rot == CW )
205 { 205 {
206 newRotation = ( defaultRotation + 270 ) % 360; 206 newRotation = ( defaultRotation + 270 ) % 360;
207 } 207 }
208 else if ( rot == Flip ) 208 else if ( rot == Flip )
209 { 209 {
210 newRotation = ( defaultRotation + 180 ) % 360; 210 newRotation = ( defaultRotation + 180 ) % 360;
211 } 211 }
212 } 212 }
213 213
214 QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); 214 QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" );
215 env << newRotation; 215 env << newRotation;
216 216
217 m_flipped = !m_flipped; 217 m_flipped = !m_flipped;
218} 218}
219 219
220 220
221QRESULT RotateApplet::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) 221QRESULT RotateApplet::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
222{ 222{
223 *iface = 0; 223 *iface = 0;
224 if ( uuid == IID_QUnknown ) 224 if ( uuid == IID_QUnknown )
225 *iface = this; 225 *iface = this;
226 else if ( uuid == IID_MenuApplet ) 226 else if ( uuid == IID_MenuApplet )
227 *iface = this; 227 *iface = this;
228 228
229 if ( *iface ) 229 if ( *iface )
230 (*iface)->addRef(); 230 (*iface)->addRef();
231 return QS_OK; 231 return QS_OK;
232} 232}
233 233
234Q_EXPORT_INTERFACE() 234Q_EXPORT_INTERFACE()
235{ 235{
236 Q_CREATE_INSTANCE( RotateApplet ) 236 Q_CREATE_INSTANCE( RotateApplet )
237} 237}