summaryrefslogtreecommitdiff
authorgroucho <groucho>2003-03-26 08:48:04 (UTC)
committer groucho <groucho>2003-03-26 08:48:04 (UTC)
commit174bf901c2a59bbf1980ea3e770bfb33c50f1c08 (patch) (unidiff)
tree0e73b0b445fc8bd91288d8f96351aa3b54bc7f04
parent77aa3a82f511038d81705af30a169b809ff29002 (diff)
downloadopie-174bf901c2a59bbf1980ea3e770bfb33c50f1c08.zip
opie-174bf901c2a59bbf1980ea3e770bfb33c50f1c08.tar.gz
opie-174bf901c2a59bbf1980ea3e770bfb33c50f1c08.tar.bz2
On older ipaqs the display is rotated to 270 as default so adding 90 does nothing => fixed by rotating the values (270+90=0, 0-90=370)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/rotateapplet/rotate.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/core/applets/rotateapplet/rotate.cpp b/core/applets/rotateapplet/rotate.cpp
index 653c61f..e236cd1 100644
--- a/core/applets/rotateapplet/rotate.cpp
+++ b/core/applets/rotateapplet/rotate.cpp
@@ -1,127 +1,135 @@
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 <qiconset.h> 34#include <qiconset.h>
35#include <qpopupmenu.h> 35#include <qpopupmenu.h>
36 36
37#include "rotate.h" 37#include "rotate.h"
38 38
39 39
40RotateApplet::RotateApplet ( ) 40RotateApplet::RotateApplet ( )
41 : QObject ( 0, "RotateApplet" ), ref ( 0 ) 41 : QObject ( 0, "RotateApplet" ), ref ( 0 )
42{ 42{
43 m_native = true; 43 m_native = true;
44} 44}
45 45
46RotateApplet::~RotateApplet ( ) 46RotateApplet::~RotateApplet ( )
47{ 47{
48} 48}
49 49
50int RotateApplet::position ( ) const 50int RotateApplet::position ( ) const
51{ 51{
52 return 2; 52 return 2;
53} 53}
54 54
55QString RotateApplet::name ( ) const 55QString RotateApplet::name ( ) const
56{ 56{
57 return tr( "Rotate shortcut" ); 57 return tr( "Rotate shortcut" );
58} 58}
59 59
60QString RotateApplet::text ( ) const 60QString RotateApplet::text ( ) const
61{ 61{
62 return tr( "Rotate" ); 62 return tr( "Rotate" );
63} 63}
64 64
65QString RotateApplet::tr( const char* s ) const 65QString RotateApplet::tr( const char* s ) const
66{ 66{
67 return qApp->translate( "RotateApplet", s, 0 ); 67 return qApp->translate( "RotateApplet", s, 0 );
68} 68}
69 69
70QString RotateApplet::tr( const char* s, const char* p ) const 70QString RotateApplet::tr( const char* s, const char* p ) const
71{ 71{
72 return qApp->translate( "RotateApplet", s, p ); 72 return qApp->translate( "RotateApplet", s, p );
73} 73}
74 74
75QIconSet RotateApplet::icon ( ) const 75QIconSet RotateApplet::icon ( ) const
76{ 76{
77 QPixmap pix; 77 QPixmap pix;
78 QImage img = Resource::loadImage ( "Rotation" ); 78 QImage img = Resource::loadImage ( "Rotation" );
79 79
80 if ( !img. isNull ( )) 80 if ( !img. isNull ( ))
81 pix. convertFromImage ( img. smoothScale ( 14, 14 )); 81 pix. convertFromImage ( img. smoothScale ( 14, 14 ));
82 return pix; 82 return pix;
83} 83}
84 84
85QPopupMenu *RotateApplet::popup ( QWidget * ) const 85QPopupMenu *RotateApplet::popup ( QWidget * ) const
86{ 86{
87 return 0; 87 return 0;
88} 88}
89 89
90void RotateApplet::activated ( ) 90void RotateApplet::activated ( )
91{ 91{
92 int currentRotation = QPEApplication::defaultRotation(); 92 int currentRotation = QPEApplication::defaultRotation();
93
93 int newRotation; 94 int newRotation;
94 if ( m_native == true ) { 95 if ( m_native == true ) {
96
95 newRotation = currentRotation + 90; 97 newRotation = currentRotation + 90;
98 if(newRotation >= 360) newRotation = 0;//ipaqs like the 36xx have the display
99 //rotated to 270 as default, so 360 does nothing => handle this here
100
96 } else { 101 } else {
97 newRotation = currentRotation - 90; 102 newRotation = currentRotation - 90;
103 if (newRotation <=0) newRotation = 270;
104 //ipaqs like the 36xx have the display rotated
105 // to 270 as default, and -90 is invalid => handle this here
98 } 106 }
99 QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); 107 QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" );
100 env << newRotation; 108 env << newRotation;
101 QCopEnvelope env2( "QPE/System", "setDefaultRotation(int)" ); 109 QCopEnvelope env2( "QPE/System", "setDefaultRotation(int)" );
102 env2 << newRotation; 110 env2 << newRotation;
103 111
104 m_native = !m_native; 112 m_native = !m_native;
105 113
106} 114}
107 115
108 116
109QRESULT RotateApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) 117QRESULT RotateApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface )
110{ 118{
111 *iface = 0; 119 *iface = 0;
112 if ( uuid == IID_QUnknown ) 120 if ( uuid == IID_QUnknown )
113 *iface = this; 121 *iface = this;
114 else if ( uuid == IID_MenuApplet ) 122 else if ( uuid == IID_MenuApplet )
115 *iface = this; 123 *iface = this;
116 124
117 if ( *iface ) 125 if ( *iface )
118 (*iface)-> addRef ( ); 126 (*iface)-> addRef ( );
119 return QS_OK; 127 return QS_OK;
120} 128}
121 129
122Q_EXPORT_INTERFACE( ) 130Q_EXPORT_INTERFACE( )
123{ 131{
124 Q_CREATE_INSTANCE( RotateApplet ) 132 Q_CREATE_INSTANCE( RotateApplet )
125} 133}
126 134
127 135