Diffstat (limited to 'core/applets/rotateapplet/rotate.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/applets/rotateapplet/rotate.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/core/applets/rotateapplet/rotate.cpp b/core/applets/rotateapplet/rotate.cpp index dcbf809..0488c36 100644 --- a/core/applets/rotateapplet/rotate.cpp +++ b/core/applets/rotateapplet/rotate.cpp | |||
@@ -1,148 +1,148 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | Copyright (C) 2003 Maximilian Reiss <harlekin@handhelds.org> | 3 | Copyright (C) 2003 Maximilian Reiss <harlekin@handhelds.org> |
4 | Copyright (C) 2003 Greg Gilbert <ggilbert@treke.net> | 4 | Copyright (C) 2003 Greg Gilbert <ggilbert@treke.net> |
5 | =. Copyright (C) 2004 Michael Lauer <mickey@Vanille.de> | 5 | =. Copyright (C) 2004 Michael Lauer <mickey@Vanille.de> |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This library is free software; you can | 8 | _;:, .> :=|. This library is free software; you can |
9 | .> <, > . <= redistribute it and/or modify it under | 9 | .> <, > . <= redistribute it and/or modify it under |
10 | :=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%+i> _;_. | 14 | .%+i> _;_. |
15 | .i_,=:_. -<s. This library is distributed in the hope that | 15 | .i_,=:_. -<s. This library is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=| MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=| MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. . .: details. | 21 | ++= -. . .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-= this library; see the file COPYING.LIB. | 25 | -- :-= this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include "rotate.h" | 31 | #include "rotate.h" |
32 | 32 | ||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | #include <opie/odevice.h> | 34 | #include <opie/odevice.h> |
35 | #include <qpe/config.h> | 35 | #include <qpe/config.h> |
36 | #include <qpe/power.h> | 36 | #include <qpe/power.h> |
37 | #include <qpe/qcopenvelope_qws.h> | 37 | #include <qpe/qcopenvelope_qws.h> |
38 | #include <qpe/resource.h> | 38 | #include <qpe/resource.h> |
39 | using namespace Opie; | 39 | using namespace Opie; |
40 | 40 | ||
41 | /* QT */ | 41 | /* QT */ |
42 | 42 | ||
43 | #include <time.h> | 43 | #include <time.h> |
44 | 44 | ||
45 | RotateApplet::RotateApplet() | 45 | RotateApplet::RotateApplet() |
46 | :QObject( 0, "RotateApplet" ), m_flipped( false ) | 46 | :QObject( 0, "RotateApplet" ), 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 | * Qcop receive method. | 61 | * Qcop receive method. |
62 | */ | 62 | */ |
63 | void RotateApplet::channelReceived( const QCString &msg, const QByteArray & data ) | 63 | void RotateApplet::channelReceived( const QCString &msg, const QByteArray & data ) |
64 | { | 64 | { |
65 | qDebug( "RotateApplet::channelReceived( '%s' )", (const char*) msg ); | 65 | qDebug( "RotateApplet::channelReceived( '%s' )", (const char*) msg ); |
66 | 66 | ||
67 | if ( ODevice::inst()->hasHingeSensor() ) | 67 | if ( ODevice::inst()->hasHingeSensor() ) |
68 | { | 68 | { |
69 | struct timespec interval; | 69 | struct timespec interval; |
70 | struct timespec remain; | 70 | struct timespec remain; |
71 | interval.tv_sec = 0; | 71 | interval.tv_sec = 0; |
72 | interval.tv_nsec = 600000; | 72 | interval.tv_nsec = 600000; |
73 | ::nanosleep( &interval, &remain ); | 73 | ::nanosleep( &interval, &remain ); |
74 | OHingeStatus status = ODevice::inst()->readHingeSensor(); | 74 | OHingeStatus status = ODevice::inst()->readHingeSensor(); |
75 | qDebug( "RotateApplet::readHingeSensor = %d", (int) status ); | 75 | qDebug( "RotateApplet::readHingeSensor = %d", (int) status ); |
76 | 76 | ||
77 | Config cfg( "apm" ); | 77 | Config cfg( "apm" ); |
78 | cfg.setGroup( PowerStatusManager::readStatus().acStatus() == PowerStatus::Online ? "AC" : "Battery" ); | 78 | cfg.setGroup( PowerStatusManager::readStatus().acStatus() == PowerStatus::Online ? "AC" : "Battery" ); |
79 | int action = cfg.readNumEntry( "CloseHingeAction", 0 ); | 79 | int action = cfg.readNumEntry( "CloseHingeAction", 0 ); |
80 | 80 | ||
81 | if ( status == CASE_CLOSED ) | 81 | if ( status == CASE_CLOSED ) |
82 | { | 82 | { |
83 | switch ( action ) | 83 | switch ( action ) |
84 | { | 84 | { |
85 | case 1: /* DISPLAY OFF */ ODevice::inst()->setDisplayBrightness( 0 ); break; | 85 | case 1: /* DISPLAY OFF */ ODevice::inst()->setDisplayBrightness( 0 ); break; |
86 | case 2: /* SUSPEND */ ODevice::inst()->suspend(); break; | 86 | case 2: /* SUSPEND */ ODevice::inst()->suspend(); break; |
87 | default: /* IGNORE */ break; | 87 | default: /* IGNORE */ break; |
88 | } | 88 | } |
89 | } | 89 | } |
90 | else /* status != CASE_CLOSED */ | 90 | else /* status != CASE_CLOSED */ |
91 | { | 91 | { |
92 | switch ( action ) | 92 | switch ( action ) |
93 | { | 93 | { |
94 | case 1: /* DISPLAY OFF */ ODevice::inst()->setDisplayBrightness( 127 ); break; | 94 | case 1: /* DISPLAY OFF */ ODevice::inst()->setDisplayBrightness( 127 ); break; |
95 | case 2: /* SUSPEND */ /* How to wake up the device from kernel? */; break; | 95 | case 2: /* SUSPEND */ /* How to wake up the device from kernel? */; break; |
96 | default: /* IGNORE */ break; | 96 | default: /* IGNORE */ break; |
97 | } | 97 | } |
98 | } | 98 | } |
99 | qDebug( "RotateApplet::switchAction %d performed.", cfg.readNumEntry( "CloseHingeAction", 0 ) ); | 99 | qDebug( "RotateApplet::switchAction %d performed.", cfg.readNumEntry( "CloseHingeAction", 0 ) ); |
100 | } | 100 | } |
101 | 101 | ||
102 | QDataStream stream( data, IO_ReadOnly ); | 102 | QDataStream stream( data, IO_ReadOnly ); |
103 | if ( msg == "flip()" ) | 103 | if ( msg == "flip()" ) |
104 | { | 104 | { |
105 | activated ( ); | 105 | activated ( ); |
106 | } | 106 | } |
107 | else if ( msg == "rotateDefault()") | 107 | else if ( msg == "rotateDefault()") |
108 | { | 108 | { |
109 | rotateDefault(); | 109 | rotateDefault(); |
110 | } | 110 | } |
111 | } | 111 | } |
112 | 112 | ||
113 | int RotateApplet::position() const | 113 | int RotateApplet::position() const |
114 | { | 114 | { |
115 | return 3; | 115 | return 3; |
116 | } | 116 | } |
117 | 117 | ||
118 | QString RotateApplet::name() const | 118 | QString RotateApplet::name() const |
119 | { | 119 | { |
120 | return tr( "Rotate shortcut" ); | 120 | return tr( "Rotate shortcut" ); |
121 | } | 121 | } |
122 | 122 | ||
123 | QString RotateApplet::text() const | 123 | QString RotateApplet::text() const |
124 | { | 124 | { |
125 | return tr( "Rotate" ); | 125 | return tr( "Rotate" ); |
126 | } | 126 | } |
127 | 127 | ||
128 | /*QString RotateApplet::tr( const char* s ) const | 128 | /*QString RotateApplet::tr( const char* s ) const |
129 | { | 129 | { |
130 | return qApp->translate( "RotateApplet", s, 0 ); | 130 | return qApp->translate( "RotateApplet", s, 0 ); |
131 | } | 131 | } |
132 | 132 | ||
133 | QString RotateApplet::tr( const char* s, const char* p ) const | 133 | QString RotateApplet::tr( const char* s, const char* p ) const |
134 | { | 134 | { |
135 | return qApp->translate( "RotateApplet", s, p ); | 135 | return qApp->translate( "RotateApplet", s, p ); |
136 | } | 136 | } |
137 | */ | 137 | */ |
138 | 138 | ||
139 | QIconSet RotateApplet::icon() const | 139 | QIconSet RotateApplet::icon() const |
140 | { | 140 | { |
141 | QPixmap pix; | 141 | QPixmap pix; |
142 | QImage img = Resource::loadImage( "Rotation" ); | 142 | QImage img = Resource::loadImage( "Rotation" ); |
143 | if ( !img.isNull() ) | 143 | if ( !img.isNull() ) |
144 | pix.convertFromImage( img.smoothScale( 14, 14 ) ); | 144 | pix.convertFromImage( img.smoothScale( 14, 14 ) ); |
145 | return pix; | 145 | return pix; |
146 | } | 146 | } |
147 | 147 | ||
148 | QPopupMenu* RotateApplet::popup(QWidget*) const | 148 | QPopupMenu* RotateApplet::popup(QWidget*) const |