summaryrefslogtreecommitdiff
authorharlekin <harlekin>2003-03-26 23:19:41 (UTC)
committer harlekin <harlekin>2003-03-26 23:19:41 (UTC)
commiteda6fffbe8ad7e3635985d9b2a8f7b46964aa271 (patch) (unidiff)
tree828bdf054c6f3932c4ac01e5609ee432a0b5b530
parenta99096fa8b72704bcec0b76a6ad2107c3db70f13 (diff)
downloadopie-eda6fffbe8ad7e3635985d9b2a8f7b46964aa271.zip
opie-eda6fffbe8ad7e3635985d9b2a8f7b46964aa271.tar.gz
opie-eda6fffbe8ad7e3635985d9b2a8f7b46964aa271.tar.bz2
adapted to what was discussed today on irc. Direction of rotation is settable in appearance in future
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/rotateapplet/rotate.cpp38
-rw-r--r--core/applets/rotateapplet/rotate.h2
2 files changed, 29 insertions, 11 deletions
diff --git a/core/applets/rotateapplet/rotate.cpp b/core/applets/rotateapplet/rotate.cpp
index e236cd1..4743388 100644
--- a/core/applets/rotateapplet/rotate.cpp
+++ b/core/applets/rotateapplet/rotate.cpp
@@ -1,135 +1,153 @@
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 <qiconset.h> 35#include <qiconset.h>
35#include <qpopupmenu.h> 36#include <qpopupmenu.h>
36 37
37#include "rotate.h" 38#include "rotate.h"
38 39
39 40
40RotateApplet::RotateApplet ( ) 41RotateApplet::RotateApplet ( )
41 : QObject ( 0, "RotateApplet" ), ref ( 0 ) 42 : QObject ( 0, "RotateApplet" ), ref ( 0 )
42{ 43{
43 m_native = true; 44 m_flipped = false;
44} 45}
45 46
46RotateApplet::~RotateApplet ( ) 47RotateApplet::~RotateApplet ( )
47{ 48{
48} 49}
49 50
50int RotateApplet::position ( ) const 51int RotateApplet::position ( ) const
51{ 52{
52 return 2; 53 return 2;
53} 54}
54 55
55QString RotateApplet::name ( ) const 56QString RotateApplet::name ( ) const
56{ 57{
57 return tr( "Rotate shortcut" ); 58 return tr( "Rotate shortcut" );
58} 59}
59 60
60QString RotateApplet::text ( ) const 61QString RotateApplet::text ( ) const
61{ 62{
62 return tr( "Rotate" ); 63 return tr( "Rotate" );
63} 64}
64 65
65QString RotateApplet::tr( const char* s ) const 66QString RotateApplet::tr( const char* s ) const
66{ 67{
67 return qApp->translate( "RotateApplet", s, 0 ); 68 return qApp->translate( "RotateApplet", s, 0 );
68} 69}
69 70
70QString RotateApplet::tr( const char* s, const char* p ) const 71QString RotateApplet::tr( const char* s, const char* p ) const
71{ 72{
72 return qApp->translate( "RotateApplet", s, p ); 73 return qApp->translate( "RotateApplet", s, p );
73} 74}
74 75
75QIconSet RotateApplet::icon ( ) const 76QIconSet RotateApplet::icon ( ) const
76{ 77{
77 QPixmap pix; 78 QPixmap pix;
78 QImage img = Resource::loadImage ( "Rotation" ); 79 QImage img = Resource::loadImage ( "Rotation" );
79 80
80 if ( !img. isNull ( )) 81 if ( !img. isNull ( ))
81 pix. convertFromImage ( img. smoothScale ( 14, 14 )); 82 pix. convertFromImage ( img. smoothScale ( 14, 14 ));
82 return pix; 83 return pix;
83} 84}
84 85
85QPopupMenu *RotateApplet::popup ( QWidget * ) const 86QPopupMenu *RotateApplet::popup ( QWidget * ) const
86{ 87{
87 return 0; 88 return 0;
88} 89}
89 90
90void RotateApplet::activated ( ) 91void RotateApplet::activated ( )
91{ 92{
92 int currentRotation = QPEApplication::defaultRotation(); 93 int currentRotation = QPEApplication::defaultRotation();
93 94
94 int newRotation; 95 int newRotation;
95 if ( m_native == true ) {
96 96
97 newRotation = currentRotation + 90; 97 Config cfg( "qpe" );
98 if(newRotation >= 360) newRotation = 0;//ipaqs like the 36xx have the display 98 cfg.setGroup( "Appearance" );
99 //rotated to 270 as default, so 360 does nothing => handle this here
100 99
101 } else { 100 // 0 -> 90° clockwise, 1 -> 90° counterclockwise
102 newRotation = currentRotation - 90; 101 bool rotDirection = cfg.readBoolEntry( "rotatedir" );
103 if (newRotation <=0) newRotation = 270; 102
103 // hide inputs methods before rotation
104 QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" );
105
106 if ( m_flipped ) {
107 if ( rotDirection ) {
108 newRotation = currentRotation - 90;
109 if (newRotation <=0) newRotation = 270;
104 //ipaqs like the 36xx have the display rotated 110 //ipaqs like the 36xx have the display rotated
105 // to 270 as default, and -90 is invalid => handle this here 111 // to 270 as default, and -90 is invalid => handle this here
112 } else {
113 newRotation = currentRotation + 90;
114 if(newRotation >= 360) newRotation = 0;//ipaqs like the 36xx have the display
115 //rotated to 270 as default, so 360 does nothing => handle this here
116 }
117 } else {
118 if ( rotDirection ) {
119 newRotation = currentRotation + 90;
120 if(newRotation >= 360) newRotation = 0;
121 } else {
122 newRotation = currentRotation - 90;
123 if (newRotation <=0) newRotation = 270;
124 }
106 } 125 }
107 QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); 126 QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" );
108 env << newRotation; 127 env << newRotation;
109 QCopEnvelope env2( "QPE/System", "setDefaultRotation(int)" ); 128 QCopEnvelope env2( "QPE/System", "setDefaultRotation(int)" );
110 env2 << newRotation; 129 env2 << newRotation;
111 130
112 m_native = !m_native; 131 m_flipped = !m_flipped;
113
114} 132}
115 133
116 134
117QRESULT RotateApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) 135QRESULT RotateApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface )
118{ 136{
119 *iface = 0; 137 *iface = 0;
120 if ( uuid == IID_QUnknown ) 138 if ( uuid == IID_QUnknown )
121 *iface = this; 139 *iface = this;
122 else if ( uuid == IID_MenuApplet ) 140 else if ( uuid == IID_MenuApplet )
123 *iface = this; 141 *iface = this;
124 142
125 if ( *iface ) 143 if ( *iface )
126 (*iface)-> addRef ( ); 144 (*iface)-> addRef ( );
127 return QS_OK; 145 return QS_OK;
128} 146}
129 147
130Q_EXPORT_INTERFACE( ) 148Q_EXPORT_INTERFACE( )
131{ 149{
132 Q_CREATE_INSTANCE( RotateApplet ) 150 Q_CREATE_INSTANCE( RotateApplet )
133} 151}
134 152
135 153
diff --git a/core/applets/rotateapplet/rotate.h b/core/applets/rotateapplet/rotate.h
index c4087f9..57f9040 100644
--- a/core/applets/rotateapplet/rotate.h
+++ b/core/applets/rotateapplet/rotate.h
@@ -9,53 +9,53 @@
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 30
31#ifndef __OPIE_ROTATE_APPLET_H__ 31#ifndef __OPIE_ROTATE_APPLET_H__
32#define __OPIE_ROTATE_APPLET_H__ 32#define __OPIE_ROTATE_APPLET_H__
33 33
34#include <qpe/menuappletinterface.h> 34#include <qpe/menuappletinterface.h>
35 35
36class RotateApplet : public QObject, public MenuAppletInterface 36class RotateApplet : public QObject, public MenuAppletInterface
37{ 37{
38public: 38public:
39 RotateApplet ( ); 39 RotateApplet ( );
40 virtual ~RotateApplet ( ); 40 virtual ~RotateApplet ( );
41 41
42 QRESULT queryInterface( const QUuid&, QUnknownInterface** ); 42 QRESULT queryInterface( const QUuid&, QUnknownInterface** );
43 Q_REFCOUNT 43 Q_REFCOUNT
44 44
45 virtual int position() const; 45 virtual int position() const;
46 46
47 virtual QString name ( ) const; 47 virtual QString name ( ) const;
48 virtual QIconSet icon ( ) const; 48 virtual QIconSet icon ( ) const;
49 virtual QString text ( ) const; 49 virtual QString text ( ) const;
50 virtual QString tr( const char* ) const; 50 virtual QString tr( const char* ) const;
51 virtual QString tr( const char*, const char* ) const; 51 virtual QString tr( const char*, const char* ) const;
52 virtual QPopupMenu *popup ( QWidget *parent ) const; 52 virtual QPopupMenu *popup ( QWidget *parent ) const;
53 53
54 virtual void activated ( ); 54 virtual void activated ( );
55 55
56private: 56private:
57 bool m_native; 57 bool m_flipped;
58 ulong ref; 58 ulong ref;
59}; 59};
60 60
61#endif 61#endif