summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/rotateapplet/rotate.cpp25
-rw-r--r--core/applets/rotateapplet/rotate.h16
2 files changed, 36 insertions, 5 deletions
diff --git a/core/applets/rotateapplet/rotate.cpp b/core/applets/rotateapplet/rotate.cpp
index b490626..04270f1 100644
--- a/core/applets/rotateapplet/rotate.cpp
+++ b/core/applets/rotateapplet/rotate.cpp
@@ -1,139 +1,162 @@
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 "rotate.h" 38#include "rotate.h"
39 39
40 40
41RotateApplet::RotateApplet ( ) 41RotateApplet::RotateApplet ( )
42 : QObject ( 0, "RotateApplet" ), ref ( 0 ), m_flipped( false ) 42 : QObject ( 0, "RotateApplet" ), ref ( 0 ), m_flipped( false )
43{ 43{
44
45#if defined(Q_WS_QWS)
46#if !defined(QT_NO_COP)
47 QCopChannel *rotateChannel = new QCopChannel( "QPE/Rotation" , this );
48 connect ( rotateChannel, SIGNAL( received( const QCString &, const QByteArray &) ),
49 this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) );
50#endif
51#endif
52
44} 53}
45 54
46RotateApplet::~RotateApplet ( ) 55RotateApplet::~RotateApplet ( )
47{ 56{
48} 57}
49 58
59
60/**
61 * Qcop receive method.
62 */
63void RotateApplet::channelReceived( const QCString &msg, const QByteArray & data ) {
64 QDataStream stream( data, IO_ReadOnly );
65 if ( msg == "flip()" ) {
66 activated ( );
67 }
68}
69
70
50int RotateApplet::position ( ) const 71int RotateApplet::position ( ) const
51{ 72{
52 return 3; 73 return 3;
53} 74}
54 75
55QString RotateApplet::name ( ) const 76QString RotateApplet::name ( ) const
56{ 77{
57 return tr( "Rotate shortcut" ); 78 return tr( "Rotate shortcut" );
58} 79}
59 80
60QString RotateApplet::text ( ) const 81QString RotateApplet::text ( ) const
61{ 82{
62 return tr( "Rotate" ); 83 return tr( "Rotate" );
63} 84}
64 85
65QString RotateApplet::tr( const char* s ) const 86/*QString RotateApplet::tr( const char* s ) const
66{ 87{
67 return qApp->translate( "RotateApplet", s, 0 ); 88 return qApp->translate( "RotateApplet", s, 0 );
68} 89}
69 90
70QString RotateApplet::tr( const char* s, const char* p ) const 91QString RotateApplet::tr( const char* s, const char* p ) const
71{ 92{
72 return qApp->translate( "RotateApplet", s, p ); 93 return qApp->translate( "RotateApplet", s, p );
73} 94}
95*/
74 96
75QIconSet RotateApplet::icon ( ) const 97QIconSet RotateApplet::icon ( ) const
76{ 98{
77 QPixmap pix; 99 QPixmap pix;
78 QImage img = Resource::loadImage ( "Rotation" ); 100 QImage img = Resource::loadImage ( "Rotation" );
79 101
80 if ( !img. isNull ( )) 102 if ( !img. isNull ( ))
81 pix. convertFromImage ( img. smoothScale ( 14, 14 )); 103 pix. convertFromImage ( img. smoothScale ( 14, 14 ));
82 return pix; 104 return pix;
83} 105}
84 106
85QPopupMenu *RotateApplet::popup ( QWidget * ) const 107QPopupMenu *RotateApplet::popup ( QWidget * ) const
86{ 108{
87 return 0; 109 return 0;
88} 110}
89 111
90void RotateApplet::activated ( ) 112void RotateApplet::activated ( )
91{ 113{
114
92 int defaultRotation = QPEApplication::defaultRotation(); 115 int defaultRotation = QPEApplication::defaultRotation();
93 116
94 int newRotation; 117 int newRotation;
95 118
96 Config cfg( "qpe" ); 119 Config cfg( "qpe" );
97 cfg.setGroup( "Appearance" ); 120 cfg.setGroup( "Appearance" );
98 121
99 // 0 -> 90° clockwise, 1 -> 90° counterclockwise 122 // 0 -> 90° clockwise, 1 -> 90° counterclockwise
100 int rotDirection = cfg.readNumEntry( "rotatedir", 0 ); 123 int rotDirection = cfg.readNumEntry( "rotatedir", 0 );
101 124
102 // hide inputs methods before rotation 125 // hide inputs methods before rotation
103 QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" ); 126 QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" );
104 127
105 if ( m_flipped ) { 128 if ( m_flipped ) {
106 // if flipped, flip back to the original state, 129 // if flipped, flip back to the original state,
107 // regardless of rotation direction 130 // regardless of rotation direction
108 newRotation = defaultRotation; 131 newRotation = defaultRotation;
109 } else { 132 } else {
110 if ( rotDirection == 1 ) { 133 if ( rotDirection == 1 ) {
111 newRotation = ( defaultRotation + 90 ) % 360; 134 newRotation = ( defaultRotation + 90 ) % 360;
112 } else if ( rotDirection == 0 ) { 135 } else if ( rotDirection == 0 ) {
113 newRotation = ( defaultRotation + 270 ) % 360; 136 newRotation = ( defaultRotation + 270 ) % 360;
114 } else { 137 } else {
115 newRotation = ( defaultRotation + 180 ) % 360; 138 newRotation = ( defaultRotation + 180 ) % 360;
116 } 139 }
117 } 140 }
118 141
119 QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); 142 QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" );
120 env << newRotation; 143 env << newRotation;
121 144
122 m_flipped = !m_flipped; 145 m_flipped = !m_flipped;
123} 146}
124 147
125 148
126QRESULT RotateApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) 149QRESULT RotateApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface )
127{ 150{
128 *iface = 0; 151 *iface = 0;
129 if ( uuid == IID_QUnknown ) 152 if ( uuid == IID_QUnknown )
130 *iface = this; 153 *iface = this;
131 else if ( uuid == IID_MenuApplet ) 154 else if ( uuid == IID_MenuApplet )
132 *iface = this; 155 *iface = this;
133 156
134 if ( *iface ) 157 if ( *iface )
135 (*iface)-> addRef ( ); 158 (*iface)-> addRef ( );
136 return QS_OK; 159 return QS_OK;
137} 160}
138 161
139Q_EXPORT_INTERFACE( ) 162Q_EXPORT_INTERFACE( )
diff --git a/core/applets/rotateapplet/rotate.h b/core/applets/rotateapplet/rotate.h
index 57f9040..5ac7768 100644
--- a/core/applets/rotateapplet/rotate.h
+++ b/core/applets/rotateapplet/rotate.h
@@ -1,61 +1,69 @@
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 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#include <qobject.h>
35 36
36class RotateApplet : public QObject, public MenuAppletInterface 37class RotateApplet : public QObject, public MenuAppletInterface
37{ 38{
39
40 Q_OBJECT
41
38public: 42public:
39 RotateApplet ( ); 43 RotateApplet ( );
40 virtual ~RotateApplet ( ); 44 virtual ~RotateApplet ( );
41 45
42 QRESULT queryInterface( const QUuid&, QUnknownInterface** ); 46 QRESULT queryInterface( const QUuid&, QUnknownInterface** );
43 Q_REFCOUNT 47 Q_REFCOUNT
44 48
45 virtual int position() const; 49 virtual int position() const;
46 50
47 virtual QString name ( ) const; 51 virtual QString name ( ) const;
48 virtual QIconSet icon ( ) const; 52 virtual QIconSet icon ( ) const;
49 virtual QString text ( ) const; 53 virtual QString text ( ) const;
50 virtual QString tr( const char* ) const; 54 /* virtual QString tr( const char* ) const;
51 virtual QString tr( const char*, const char* ) const; 55 virtual QString tr( const char*, const char* ) const;
56 */
52 virtual QPopupMenu *popup ( QWidget *parent ) const; 57 virtual QPopupMenu *popup ( QWidget *parent ) const;
53 58 virtual void activated ( );
54 virtual void activated ( ); 59
60private slots:
61 void channelReceived( const QCString &msg, const QByteArray & data );
55 62
56private: 63private:
57 bool m_flipped;
58 ulong ref; 64 ulong ref;
65 bool m_flipped;
66
59}; 67};
60 68
61#endif 69#endif