author | treke <treke> | 2003-12-08 06:52:35 (UTC) |
---|---|---|
committer | treke <treke> | 2003-12-08 06:52:35 (UTC) |
commit | 7b4e723545a645056156246d27b2c26c78d599f3 (patch) (unidiff) | |
tree | 8b349615fc1441a60bc418e10c53b1799db895e4 /core/applets | |
parent | 3bbeef6702ef80b7506b5393cc51d1fd5b04559d (diff) | |
download | opie-7b4e723545a645056156246d27b2c26c78d599f3.zip opie-7b4e723545a645056156246d27b2c26c78d599f3.tar.gz opie-7b4e723545a645056156246d27b2c26c78d599f3.tar.bz2 |
Automatic rotation. This might break binary compatibility, so beware including
in BRANCH_1_0
-rw-r--r-- | core/applets/rotateapplet/rotate.cpp | 41 | ||||
-rw-r--r-- | core/applets/rotateapplet/rotate.h | 1 |
2 files changed, 42 insertions, 0 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 | |||
@@ -57,24 +57,26 @@ RotateApplet::RotateApplet ( ) | |||
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 | } else if ( msg == "rotateDefault()") { | ||
70 | rotateDefault(); | ||
69 | } | 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" ); |
@@ -102,24 +104,63 @@ QIconSet RotateApplet::icon ( ) const | |||
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 | ||
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 | |||
@@ -49,23 +49,24 @@ public: | |||
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 |