summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/rotateapplet/rotate.cpp2
1 files changed, 0 insertions, 2 deletions
diff --git a/core/applets/rotateapplet/rotate.cpp b/core/applets/rotateapplet/rotate.cpp
index 62567ed..ac6b259 100644
--- a/core/applets/rotateapplet/rotate.cpp
+++ b/core/applets/rotateapplet/rotate.cpp
@@ -1,174 +1,172 @@
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             .=l. Copyright (c) 2003 Maximilian Reiss <harlekin@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <,   >  .   <= redistribute it and/or modify it under 6.> <,   >  .   <= redistribute it and/or modify it under
7:=1 )Y*s>-.--   : the terms of the GNU Library General Public 7:=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%+i>       _;_. 11    .%+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=| MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=| MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .     .: details. 18++=   -.     .     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-= this library; see the file COPYING.LIB. 22    --        :-= this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29 29
30#include <qpe/resource.h> 30#include <qpe/resource.h>
31#include <qpe/qcopenvelope_qws.h> 31#include <qpe/qcopenvelope_qws.h>
32 32
33#include <qpe/qpeapplication.h> 33#include <qpe/qpeapplication.h>
34#include <qpe/config.h> 34#include <qpe/config.h>
35#include <qiconset.h> 35#include <qiconset.h>
36#include <qpopupmenu.h> 36#include <qpopupmenu.h>
37 37
38#include <opie/odevice.h> 38#include <opie/odevice.h>
39 39
40#include "rotate.h" 40#include "rotate.h"
41 41
42using namespace Opie; 42using namespace Opie;
43 43
44 44
45RotateApplet::RotateApplet ( ) 45RotateApplet::RotateApplet ( )
46 : QObject ( 0, "RotateApplet" ), ref ( 0 ), m_flipped( false ) 46 : QObject ( 0, "RotateApplet" ), ref ( 0 ), m_flipped( false )
47{ 47{
48 48
49#if defined(Q_WS_QWS)
50#if !defined(QT_NO_COP) 49#if !defined(QT_NO_COP)
51 QCopChannel *rotateChannel = new QCopChannel( "QPE/Rotation" , this ); 50 QCopChannel *rotateChannel = new QCopChannel( "QPE/Rotation" , this );
52 connect ( rotateChannel, SIGNAL( received( const QCString &, const QByteArray &) ), 51 connect ( rotateChannel, SIGNAL( received( const QCString &, const QByteArray &) ),
53 this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) ); 52 this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) );
54#endif 53#endif
55#endif
56 54
57} 55}
58 56
59RotateApplet::~RotateApplet ( ) 57RotateApplet::~RotateApplet ( )
60{ 58{
61} 59}
62 60
63 61
64/** 62/**
65 * Qcop receive method. 63 * Qcop receive method.
66 */ 64 */
67void RotateApplet::channelReceived( const QCString &msg, const QByteArray & data ) { 65void RotateApplet::channelReceived( const QCString &msg, const QByteArray & data ) {
68 QDataStream stream( data, IO_ReadOnly ); 66 QDataStream stream( data, IO_ReadOnly );
69 if ( msg == "flip()" ) { 67 if ( msg == "flip()" ) {
70 activated ( ); 68 activated ( );
71 } 69 }
72} 70}
73 71
74 72
75int RotateApplet::position ( ) const 73int RotateApplet::position ( ) const
76{ 74{
77 return 3; 75 return 3;
78} 76}
79 77
80QString RotateApplet::name ( ) const 78QString RotateApplet::name ( ) const
81{ 79{
82 return tr( "Rotate shortcut" ); 80 return tr( "Rotate shortcut" );
83} 81}
84 82
85QString RotateApplet::text ( ) const 83QString RotateApplet::text ( ) const
86{ 84{
87 return tr( "Rotate" ); 85 return tr( "Rotate" );
88} 86}
89 87
90/*QString RotateApplet::tr( const char* s ) const 88/*QString RotateApplet::tr( const char* s ) const
91{ 89{
92 return qApp->translate( "RotateApplet", s, 0 ); 90 return qApp->translate( "RotateApplet", s, 0 );
93} 91}
94 92
95QString RotateApplet::tr( const char* s, const char* p ) const 93QString RotateApplet::tr( const char* s, const char* p ) const
96{ 94{
97 return qApp->translate( "RotateApplet", s, p ); 95 return qApp->translate( "RotateApplet", s, p );
98} 96}
99*/ 97*/
100 98
101QIconSet RotateApplet::icon ( ) const 99QIconSet RotateApplet::icon ( ) const
102{ 100{
103 QPixmap pix; 101 QPixmap pix;
104 QImage img = Resource::loadImage ( "Rotation" ); 102 QImage img = Resource::loadImage ( "Rotation" );
105 103
106 if ( !img. isNull ( )) 104 if ( !img. isNull ( ))
107 pix. convertFromImage ( img. smoothScale ( 14, 14 )); 105 pix. convertFromImage ( img. smoothScale ( 14, 14 ));
108 return pix; 106 return pix;
109} 107}
110 108
111QPopupMenu *RotateApplet::popup ( QWidget * ) const 109QPopupMenu *RotateApplet::popup ( QWidget * ) const
112{ 110{
113 return 0; 111 return 0;
114} 112}
115 113
116void RotateApplet::activated ( ) 114void RotateApplet::activated ( )
117{ 115{
118 116
119 int defaultRotation = QPEApplication::defaultRotation(); 117 int defaultRotation = QPEApplication::defaultRotation();
120 int newRotation = defaultRotation; 118 int newRotation = defaultRotation;
121 119
122 Config cfg( "qpe" ); 120 Config cfg( "qpe" );
123 cfg.setGroup( "Appearance" ); 121 cfg.setGroup( "Appearance" );
124 122
125 int rotDirection = cfg.readNumEntry( "rotatedir" ); 123 int rotDirection = cfg.readNumEntry( "rotatedir" );
126 ODirection rot = CW; 124 ODirection rot = CW;
127 125
128 if (rotDirection == -1) { 126 if (rotDirection == -1) {
129 rot = ODevice::inst ( )-> direction ( ); 127 rot = ODevice::inst ( )-> direction ( );
130 } else { 128 } else {
131 rot = (ODirection)rotDirection; 129 rot = (ODirection)rotDirection;
132 } 130 }
133 131
134 // hide inputs methods before rotation 132 // hide inputs methods before rotation
135 QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" ); 133 QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" );
136 134
137 if ( m_flipped ) { 135 if ( m_flipped ) {
138 // if flipped, flip back to the original state, 136 // if flipped, flip back to the original state,
139 // regardless of rotation direction 137 // regardless of rotation direction
140 newRotation = defaultRotation; 138 newRotation = defaultRotation;
141 } else { 139 } else {
142 if ( rot == CCW ) { 140 if ( rot == CCW ) {
143 newRotation = ( defaultRotation + 90 ) % 360; 141 newRotation = ( defaultRotation + 90 ) % 360;
144 } else if ( rot == CW ) { 142 } else if ( rot == CW ) {
145 newRotation = ( defaultRotation + 270 ) % 360; 143 newRotation = ( defaultRotation + 270 ) % 360;
146 } else if ( rot == Flip ) { 144 } else if ( rot == Flip ) {
147 newRotation = ( defaultRotation + 180 ) % 360; 145 newRotation = ( defaultRotation + 180 ) % 360;
148 } 146 }
149 } 147 }
150 148
151 QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); 149 QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" );
152 env << newRotation; 150 env << newRotation;
153 151
154 m_flipped = !m_flipped; 152 m_flipped = !m_flipped;
155} 153}
156 154
157 155
158QRESULT RotateApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) 156QRESULT RotateApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface )
159{ 157{
160 *iface = 0; 158 *iface = 0;
161 if ( uuid == IID_QUnknown ) 159 if ( uuid == IID_QUnknown )
162 *iface = this; 160 *iface = this;
163 else if ( uuid == IID_MenuApplet ) 161 else if ( uuid == IID_MenuApplet )
164 *iface = this; 162 *iface = this;
165 163
166 if ( *iface ) 164 if ( *iface )
167 (*iface)-> addRef ( ); 165 (*iface)-> addRef ( );
168 return QS_OK; 166 return QS_OK;
169} 167}
170 168
171Q_EXPORT_INTERFACE( ) 169Q_EXPORT_INTERFACE( )
172{ 170{
173 Q_CREATE_INSTANCE( RotateApplet ) 171 Q_CREATE_INSTANCE( RotateApplet )
174} 172}