summaryrefslogtreecommitdiff
path: root/core/applets/rotateapplet/rotate.cpp
Unidiff
Diffstat (limited to 'core/applets/rotateapplet/rotate.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/rotateapplet/rotate.cpp43
1 files changed, 42 insertions, 1 deletions
diff --git a/core/applets/rotateapplet/rotate.cpp b/core/applets/rotateapplet/rotate.cpp
index ac6b259..0da2f0c 100644
--- a/core/applets/rotateapplet/rotate.cpp
+++ b/core/applets/rotateapplet/rotate.cpp
@@ -45,93 +45,134 @@ using namespace Opie;
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(QT_NO_COP) 49#if !defined(QT_NO_COP)
50 QCopChannel *rotateChannel = new QCopChannel( "QPE/Rotation" , this ); 50 QCopChannel *rotateChannel = new QCopChannel( "QPE/Rotation" , this );
51 connect ( rotateChannel, SIGNAL( received( const QCString &, const QByteArray &) ), 51 connect ( rotateChannel, SIGNAL( received( const QCString &, const QByteArray &) ),
52 this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) ); 52 this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) );
53#endif 53#endif
54 54
55} 55}
56 56
57RotateApplet::~RotateApplet ( ) 57RotateApplet::~RotateApplet ( )
58{ 58{
59} 59}
60 60
61 61
62/** 62/**
63 * Qcop receive method. 63 * Qcop receive method.
64 */ 64 */
65void RotateApplet::channelReceived( const QCString &msg, const QByteArray & data ) { 65void RotateApplet::channelReceived( const QCString &msg, const QByteArray & data ) {
66 QDataStream stream( data, IO_ReadOnly ); 66 QDataStream stream( data, IO_ReadOnly );
67 if ( msg == "flip()" ) { 67 if ( msg == "flip()" ) {
68 activated ( ); 68 activated ( );
69 } 69 } else if ( msg == "rotateDefault()") {
70 rotateDefault();
71 }
70} 72}
71 73
72 74
73int RotateApplet::position ( ) const 75int RotateApplet::position ( ) const
74{ 76{
75 return 3; 77 return 3;
76} 78}
77 79
78QString RotateApplet::name ( ) const 80QString RotateApplet::name ( ) const
79{ 81{
80 return tr( "Rotate shortcut" ); 82 return tr( "Rotate shortcut" );
81} 83}
82 84
83QString RotateApplet::text ( ) const 85QString RotateApplet::text ( ) const
84{ 86{
85 return tr( "Rotate" ); 87 return tr( "Rotate" );
86} 88}
87 89
88/*QString RotateApplet::tr( const char* s ) const 90/*QString RotateApplet::tr( const char* s ) const
89{ 91{
90 return qApp->translate( "RotateApplet", s, 0 ); 92 return qApp->translate( "RotateApplet", s, 0 );
91} 93}
92 94
93QString RotateApplet::tr( const char* s, const char* p ) const 95QString RotateApplet::tr( const char* s, const char* p ) const
94{ 96{
95 return qApp->translate( "RotateApplet", s, p ); 97 return qApp->translate( "RotateApplet", s, p );
96} 98}
97*/ 99*/
98 100
99QIconSet RotateApplet::icon ( ) const 101QIconSet RotateApplet::icon ( ) const
100{ 102{
101 QPixmap pix; 103 QPixmap pix;
102 QImage img = Resource::loadImage ( "Rotation" ); 104 QImage img = Resource::loadImage ( "Rotation" );
103 105
104 if ( !img. isNull ( )) 106 if ( !img. isNull ( ))
105 pix. convertFromImage ( img. smoothScale ( 14, 14 )); 107 pix. convertFromImage ( img. smoothScale ( 14, 14 ));
106 return pix; 108 return pix;
107} 109}
108 110
109QPopupMenu *RotateApplet::popup ( QWidget * ) const 111QPopupMenu *RotateApplet::popup ( QWidget * ) const
110{ 112{
111 return 0; 113 return 0;
112} 114}
113 115
116void RotateApplet::rotateDefault ( )
117{
118
119 int rot = ODevice::inst()->rotation();
120
121 switch (rot) {
122 case Rot0:
123 rot=0;
124 break;
125 case Rot90:
126 rot=90;
127 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 }
138 Config cfg( "qpe" );
139 cfg.setGroup( "Appearance" );
140
141 bool rotateDisabled = cfg.readBoolEntry( "rotateEnabled",false );
142
143 if (rotateDisabled == true)
144 return;
145
146 // hide inputs methods before rotation
147 QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" );
148
149 QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" );
150 env << rot;
151
152 m_flipped = false;
153
154}
114void RotateApplet::activated ( ) 155void RotateApplet::activated ( )
115{ 156{
116 157
117 int defaultRotation = QPEApplication::defaultRotation(); 158 int defaultRotation = QPEApplication::defaultRotation();
118 int newRotation = defaultRotation; 159 int newRotation = defaultRotation;
119 160
120 Config cfg( "qpe" ); 161 Config cfg( "qpe" );
121 cfg.setGroup( "Appearance" ); 162 cfg.setGroup( "Appearance" );
122 163
123 int rotDirection = cfg.readNumEntry( "rotatedir" ); 164 int rotDirection = cfg.readNumEntry( "rotatedir" );
124 ODirection rot = CW; 165 ODirection rot = CW;
125 166
126 if (rotDirection == -1) { 167 if (rotDirection == -1) {
127 rot = ODevice::inst ( )-> direction ( ); 168 rot = ODevice::inst ( )-> direction ( );
128 } else { 169 } else {
129 rot = (ODirection)rotDirection; 170 rot = (ODirection)rotDirection;
130 } 171 }
131 172
132 // hide inputs methods before rotation 173 // hide inputs methods before rotation
133 QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" ); 174 QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" );
134 175
135 if ( m_flipped ) { 176 if ( m_flipped ) {
136 // if flipped, flip back to the original state, 177 // if flipped, flip back to the original state,
137 // regardless of rotation direction 178 // regardless of rotation direction