-rw-r--r-- | core/applets/rotateapplet/rotate.cpp | 43 | ||||
-rw-r--r-- | core/applets/rotateapplet/rotate.h | 1 |
2 files changed, 43 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; | |||
45 | RotateApplet::RotateApplet ( ) | 45 | RotateApplet::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 | ||
57 | RotateApplet::~RotateApplet ( ) | 57 | RotateApplet::~RotateApplet ( ) |
58 | { | 58 | { |
59 | } | 59 | } |
60 | 60 | ||
61 | 61 | ||
62 | /** | 62 | /** |
63 | * Qcop receive method. | 63 | * Qcop receive method. |
64 | */ | 64 | */ |
65 | void RotateApplet::channelReceived( const QCString &msg, const QByteArray & data ) { | 65 | void 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 | ||
73 | int RotateApplet::position ( ) const | 75 | int RotateApplet::position ( ) const |
74 | { | 76 | { |
75 | return 3; | 77 | return 3; |
76 | } | 78 | } |
77 | 79 | ||
78 | QString RotateApplet::name ( ) const | 80 | QString RotateApplet::name ( ) const |
79 | { | 81 | { |
80 | return tr( "Rotate shortcut" ); | 82 | return tr( "Rotate shortcut" ); |
81 | } | 83 | } |
82 | 84 | ||
83 | QString RotateApplet::text ( ) const | 85 | QString 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 | ||
93 | QString RotateApplet::tr( const char* s, const char* p ) const | 95 | QString 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 | ||
99 | QIconSet RotateApplet::icon ( ) const | 101 | QIconSet 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 | ||
109 | QPopupMenu *RotateApplet::popup ( QWidget * ) const | 111 | QPopupMenu *RotateApplet::popup ( QWidget * ) const |
110 | { | 112 | { |
111 | return 0; | 113 | return 0; |
112 | } | 114 | } |
113 | 115 | ||
116 | void 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 | } | ||
114 | void RotateApplet::activated ( ) | 155 | void 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 |
diff --git a/core/applets/rotateapplet/rotate.h b/core/applets/rotateapplet/rotate.h index de2a707..572b82a 100644 --- a/core/applets/rotateapplet/rotate.h +++ b/core/applets/rotateapplet/rotate.h | |||
@@ -37,35 +37,36 @@ | |||
37 | #include <qobject.h> | 37 | #include <qobject.h> |
38 | 38 | ||
39 | class RotateApplet : public QObject, public MenuAppletInterface | 39 | class RotateApplet : public QObject, public MenuAppletInterface |
40 | { | 40 | { |
41 | 41 | ||
42 | Q_OBJECT | 42 | Q_OBJECT |
43 | 43 | ||
44 | public: | 44 | public: |
45 | RotateApplet ( ); | 45 | RotateApplet ( ); |
46 | virtual ~RotateApplet ( ); | 46 | virtual ~RotateApplet ( ); |
47 | 47 | ||
48 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | 48 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); |
49 | Q_REFCOUNT | 49 | Q_REFCOUNT |
50 | 50 | ||
51 | virtual int position() const; | 51 | virtual int position() const; |
52 | 52 | ||
53 | virtual QString name ( ) const; | 53 | virtual QString name ( ) const; |
54 | virtual QIconSet icon ( ) const; | 54 | virtual QIconSet icon ( ) const; |
55 | virtual QString text ( ) const; | 55 | virtual QString text ( ) const; |
56 | /* virtual QString tr( const char* ) const; | 56 | /* virtual QString tr( const char* ) const; |
57 | virtual QString tr( const char*, const char* ) const; | 57 | virtual QString tr( const char*, const char* ) const; |
58 | */ | 58 | */ |
59 | virtual QPopupMenu *popup ( QWidget *parent ) const; | 59 | virtual QPopupMenu *popup ( QWidget *parent ) const; |
60 | virtual void activated ( ); | 60 | virtual void activated ( ); |
61 | virtual void rotateDefault ( ); | ||
61 | 62 | ||
62 | private slots: | 63 | private slots: |
63 | void channelReceived( const QCString &msg, const QByteArray & data ); | 64 | void channelReceived( const QCString &msg, const QByteArray & data ); |
64 | 65 | ||
65 | private: | 66 | private: |
66 | ulong ref; | 67 | ulong ref; |
67 | bool m_flipped; | 68 | bool m_flipped; |
68 | 69 | ||
69 | }; | 70 | }; |
70 | 71 | ||
71 | #endif | 72 | #endif |