-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | noncore/applets/brightnessapplet/brightnessapplet.cpp | 235 | ||||
-rw-r--r-- | noncore/applets/brightnessapplet/brightnessapplet.h | 81 | ||||
-rw-r--r-- | noncore/applets/brightnessapplet/brightnessapplet.pro | 13 | ||||
-rw-r--r-- | noncore/applets/brightnessapplet/config.in | 6 | ||||
-rw-r--r-- | packages | 1 | ||||
-rw-r--r-- | pics/brightnessapplet/icon.png | bin | 0 -> 3280 bytes |
7 files changed, 337 insertions, 0 deletions
@@ -4,4 +4,5 @@ | |||
4 | ------------ | 4 | ------------ |
5 | * Ported opie-mediaplayer2 to recent libxine (brad,zecke) | 5 | * Ported opie-mediaplayer2 to recent libxine (brad,zecke) |
6 | * Ported brightnessapplet from Qtopia 1.7 (mickeyl) | ||
6 | 7 | ||
7 | Fixed Bugs | 8 | Fixed Bugs |
diff --git a/noncore/applets/brightnessapplet/brightnessapplet.cpp b/noncore/applets/brightnessapplet/brightnessapplet.cpp new file mode 100644 index 0000000..1ade35e --- a/dev/null +++ b/noncore/applets/brightnessapplet/brightnessapplet.cpp | |||
@@ -0,0 +1,235 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | |||
4 | =. (C) 2004 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | ||
5 | .=l. Based on Qtopia 1.7 Brightnessapplet (C) 2003-2004 TrollTech | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = General Public License along with | ||
24 | -- :-=` this application; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | |||
29 | */ | ||
30 | |||
31 | #include "brightnessapplet.h" | ||
32 | |||
33 | /* OPIE */ | ||
34 | #include <opie2/odebug.h> | ||
35 | #include <opie2/odevice.h> | ||
36 | #include <opie2/otaskbarapplet.h> | ||
37 | #include <qpe/applnk.h> | ||
38 | #include <qpe/config.h> | ||
39 | #include <qpe/power.h> | ||
40 | #include <qpe/qcopenvelope_qws.h> | ||
41 | #include <qpe/resource.h> | ||
42 | using namespace Opie::Core; | ||
43 | using namespace Opie::Ui; | ||
44 | |||
45 | /* QT */ | ||
46 | #include <qpainter.h> | ||
47 | #include <qlabel.h> | ||
48 | #include <qslider.h> | ||
49 | #include <qlayout.h> | ||
50 | |||
51 | /* STD */ | ||
52 | #include <assert.h> | ||
53 | |||
54 | /* XPM */ | ||
55 | static const char * const light_on_xpm[] = { | ||
56 | "9 16 5 1", | ||
57 | " c None", | ||
58 | ". c #FFFFFFFF0000", | ||
59 | "X c #000000000000", | ||
60 | "o c #FFFFFFFFFFFF", | ||
61 | "O c #FFFF6C6C0000", | ||
62 | " ", | ||
63 | " XXX ", | ||
64 | " XoooX ", | ||
65 | " Xoooo.X ", | ||
66 | "Xoooooo.X", | ||
67 | "Xoooo...X", | ||
68 | "Xooo.o..X", | ||
69 | " Xooo..X ", | ||
70 | " Xoo...X ", | ||
71 | " Xoo.X ", | ||
72 | " Xoo.XX ", | ||
73 | " XOOOXX ", | ||
74 | " XOOOXX ", | ||
75 | " XOXX ", | ||
76 | " XX ", | ||
77 | " "}; | ||
78 | |||
79 | |||
80 | /* XPM */ | ||
81 | static const char * const light_off_xpm[] = { | ||
82 | "9 16 4 1", | ||
83 | " c None", | ||
84 | ". c #000000000000", | ||
85 | "X c #6B6B6C6C6C6C", | ||
86 | "o c #FFFF6C6C0000", | ||
87 | " ", | ||
88 | " ", | ||
89 | " ... ", | ||
90 | " . . ", | ||
91 | " . X. ", | ||
92 | ". X.", | ||
93 | ". XXX.", | ||
94 | ". X XX.", | ||
95 | " . XX. ", | ||
96 | " . XXX. ", | ||
97 | " . X. ", | ||
98 | " . X.. ", | ||
99 | " .ooo.. ", | ||
100 | " .ooo.. ", | ||
101 | " .o.. ", | ||
102 | " .. "}; | ||
103 | |||
104 | BrightnessAppletControl::BrightnessAppletControl( OTaskbarApplet* parent, const char* name ) | ||
105 | :QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ) | ||
106 | { | ||
107 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); | ||
108 | QGridLayout *gl = new QGridLayout( this, 3, 2, 6, 3 ); | ||
109 | //gl->setRowStretch( 1, 100 ); | ||
110 | |||
111 | int maxbright = ODevice::inst()->displayBrightnessResolution(); | ||
112 | slider = new QSlider(this); | ||
113 | slider->setMaxValue(maxbright); | ||
114 | slider->setOrientation(QSlider::Vertical); | ||
115 | slider->setTickmarks(QSlider::Right); | ||
116 | slider->setTickInterval(QMAX(1, maxbright / 16)); | ||
117 | slider->setLineStep(QMAX(1, maxbright / 16)); | ||
118 | slider->setPageStep(QMAX(1, maxbright / 16)); | ||
119 | gl->addMultiCellWidget( slider, 0, 2, 0, 0 ); | ||
120 | |||
121 | QPixmap onPm( (const char **)light_on_xpm ); | ||
122 | QLabel *l = new QLabel( this ); | ||
123 | l->setPixmap( onPm ); | ||
124 | gl->addWidget( l, 0, 1 ); | ||
125 | |||
126 | QPixmap offPm( (const char **)light_off_xpm ); | ||
127 | l = new QLabel( this ); | ||
128 | l->setPixmap( offPm ); | ||
129 | gl->addWidget( l, 2, 1 ); | ||
130 | |||
131 | setFixedHeight( 100 ); | ||
132 | setFixedWidth( gl->sizeHint().width() ); | ||
133 | setFocusPolicy(QWidget::NoFocus); | ||
134 | } | ||
135 | |||
136 | |||
137 | BrightnessAppletControl::~BrightnessAppletControl() | ||
138 | { | ||
139 | } | ||
140 | |||
141 | |||
142 | BrightnessApplet::BrightnessApplet( QWidget *parent, const char *name ) | ||
143 | :OTaskbarApplet( parent, name ) | ||
144 | { | ||
145 | setFixedHeight( AppLnk::smallIconSize() ); | ||
146 | setFixedWidth( AppLnk::smallIconSize() ); | ||
147 | _pixmap.convertFromImage( Resource::loadImage( "brightnessapplet/icon" ).smoothScale( height(), width() ) ); | ||
148 | _control = new BrightnessAppletControl( this, "control" ); | ||
149 | } | ||
150 | |||
151 | |||
152 | void BrightnessApplet::writeSystemBrightness(int brightness) | ||
153 | { | ||
154 | PowerStatus ps = PowerStatusManager::readStatus(); | ||
155 | |||
156 | Config cfg("qpe"); | ||
157 | if (ps.acStatus() == PowerStatus::Online) { | ||
158 | cfg.setGroup("AC"); | ||
159 | } else { | ||
160 | cfg.setGroup("Battery"); | ||
161 | } | ||
162 | cfg.writeEntry("Brightness", brightness); | ||
163 | } | ||
164 | |||
165 | |||
166 | int BrightnessApplet::readSystemBrightness(void) | ||
167 | { | ||
168 | PowerStatus ps = PowerStatusManager::readStatus(); | ||
169 | Config cfg("qpe"); | ||
170 | |||
171 | if (ps.acStatus() == PowerStatus::Online) { | ||
172 | cfg.setGroup("AC"); | ||
173 | } else { | ||
174 | cfg.setGroup("Battery"); | ||
175 | } | ||
176 | |||
177 | return cfg.readNumEntry("Brightness", 128); | ||
178 | } | ||
179 | |||
180 | |||
181 | BrightnessApplet::~BrightnessApplet() | ||
182 | { | ||
183 | } | ||
184 | |||
185 | |||
186 | int BrightnessApplet::position() | ||
187 | { | ||
188 | return 7; | ||
189 | } | ||
190 | |||
191 | |||
192 | void BrightnessApplet::paintEvent( QPaintEvent* ) | ||
193 | { | ||
194 | QPainter p(this); | ||
195 | p.drawPixmap(0, 0, _pixmap ); | ||
196 | } | ||
197 | |||
198 | |||
199 | int BrightnessApplet::calcBrightnessValue() | ||
200 | { | ||
201 | int v = _control->slider->maxValue() - _control->slider->value(); | ||
202 | return (v * 255 + _control->slider->maxValue() / 2) / _control->slider->maxValue(); | ||
203 | } | ||
204 | |||
205 | |||
206 | void BrightnessApplet::sliderMoved( int value ) | ||
207 | { | ||
208 | #ifndef QT_NO_COP | ||
209 | QCopEnvelope e("QPE/System", "setBacklight(int)"); | ||
210 | e << calcBrightnessValue(); | ||
211 | #else | ||
212 | #error This Applet makes no sense without QCOP | ||
213 | #endif // QT_NO_COP | ||
214 | } | ||
215 | |||
216 | |||
217 | void BrightnessApplet::mousePressEvent( QMouseEvent* ) | ||
218 | { | ||
219 | if ( !_control->isVisible() ) | ||
220 | { | ||
221 | int v = 255 - readSystemBrightness(); | ||
222 | popup( _control ); | ||
223 | _control->slider->setValue((_control->slider->maxValue() * v + 128) / 255); | ||
224 | connect(_control->slider, SIGNAL(valueChanged(int)), this, SLOT(sliderMoved(int))); | ||
225 | } | ||
226 | else | ||
227 | { | ||
228 | _control->hide(); | ||
229 | writeSystemBrightness( calcBrightnessValue() ); | ||
230 | } | ||
231 | } | ||
232 | |||
233 | |||
234 | EXPORT_OPIE_APPLET_v1( BrightnessApplet ) | ||
235 | |||
diff --git a/noncore/applets/brightnessapplet/brightnessapplet.h b/noncore/applets/brightnessapplet/brightnessapplet.h new file mode 100644 index 0000000..8b88bd1 --- a/dev/null +++ b/noncore/applets/brightnessapplet/brightnessapplet.h | |||
@@ -0,0 +1,81 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | |||
4 | =. (C) 2004 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | ||
5 | .=l. Based on Qtopia 1.7 Brightnessapplet (C) 2003-2004 TrollTech | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = General Public License along with | ||
24 | -- :-=` this application; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | |||
29 | */ | ||
30 | |||
31 | #ifndef NETWORKAPPLET_H | ||
32 | #define NETWORKAPPLET_H | ||
33 | |||
34 | #include <opie2/otaskbarapplet.h> | ||
35 | #include <qframe.h> | ||
36 | #include <qstring.h> | ||
37 | #include <qtoolbutton.h> | ||
38 | #include <qlineedit.h> | ||
39 | #include <qpixmap.h> | ||
40 | |||
41 | class QShowEvent; | ||
42 | class QHideEvent; | ||
43 | class QSlider; | ||
44 | |||
45 | class BrightnessAppletControl : public QFrame | ||
46 | { | ||
47 | public: | ||
48 | BrightnessAppletControl( Opie::Ui::OTaskbarApplet* parent, const char* name = 0 ); | ||
49 | ~BrightnessAppletControl(); | ||
50 | |||
51 | QSlider* slider; | ||
52 | }; | ||
53 | |||
54 | class BrightnessApplet : public Opie::Ui::OTaskbarApplet | ||
55 | { | ||
56 | Q_OBJECT | ||
57 | |||
58 | public: | ||
59 | BrightnessApplet( QWidget* parent = 0, const char* name = 0 ); | ||
60 | ~BrightnessApplet(); | ||
61 | |||
62 | void writeSystemBrightness( int brightness ); | ||
63 | int readSystemBrightness(); | ||
64 | int calcBrightnessValue(); | ||
65 | |||
66 | static int position(); | ||
67 | |||
68 | public slots: | ||
69 | void sliderMoved( int value ); | ||
70 | |||
71 | protected: | ||
72 | virtual void paintEvent( QPaintEvent* ); | ||
73 | virtual void mousePressEvent( QMouseEvent* ); | ||
74 | |||
75 | private: | ||
76 | BrightnessAppletControl* _control; | ||
77 | QPixmap _pixmap; | ||
78 | }; | ||
79 | |||
80 | #endif | ||
81 | |||
diff --git a/noncore/applets/brightnessapplet/brightnessapplet.pro b/noncore/applets/brightnessapplet/brightnessapplet.pro new file mode 100644 index 0000000..5044f38 --- a/dev/null +++ b/noncore/applets/brightnessapplet/brightnessapplet.pro | |||
@@ -0,0 +1,13 @@ | |||
1 | TEMPLATE = lib | ||
2 | CONFIG += qt plugin warn_on | ||
3 | HEADERS = brightnessapplet.h | ||
4 | SOURCES = brightnessapplet.cpp | ||
5 | TARGET = brightnessapplet | ||
6 | DESTDIR = $(OPIEDIR)/plugins/applets | ||
7 | INCLUDEPATH += $(OPIEDIR)/include | ||
8 | DEPENDPATH += $(OPIEDIR)/include | ||
9 | LIBS += -lqpe -lopiecore2 -lopieui2 | ||
10 | VERSION = 0.1.0 | ||
11 | |||
12 | |||
13 | include ( $(OPIEDIR)/include.pro ) | ||
diff --git a/noncore/applets/brightnessapplet/config.in b/noncore/applets/brightnessapplet/config.in new file mode 100644 index 0000000..ba88bf0 --- a/dev/null +++ b/noncore/applets/brightnessapplet/config.in | |||
@@ -0,0 +1,6 @@ | |||
1 | config BRIGHTNESSAPPLET | ||
2 | boolean "opie-brightness (control lcd brightness on-the-fly)" | ||
3 | default "n" | ||
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI | ||
5 | comment "Network applet needs a libqpe and libopie2 (core, ui)" | ||
6 | depends !(( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI) | ||
@@ -16,4 +16,5 @@ CONFIG_BINARY noncore/tools/calc2/binary binary.pro | |||
16 | CONFIG_BLUE-PIN noncore/net/opietooth/blue-pinblue-pin.pro | 16 | CONFIG_BLUE-PIN noncore/net/opietooth/blue-pinblue-pin.pro |
17 | CONFIG_BOUNCE noncore/games/bouncebounce.pro | 17 | CONFIG_BOUNCE noncore/games/bouncebounce.pro |
18 | CONFIG_BRIGHTNESSAPPLET noncore/applets/brightnessappletbrightnessapplet.pro | ||
18 | CONFIG_BUTTON-SETTINGS core/settings/buttonbutton.pro | 19 | CONFIG_BUTTON-SETTINGS core/settings/buttonbutton.pro |
19 | CONFIG_BUZZWORD noncore/games/buzzwordbuzzword.pro | 20 | CONFIG_BUZZWORD noncore/games/buzzwordbuzzword.pro |
diff --git a/pics/brightnessapplet/icon.png b/pics/brightnessapplet/icon.png new file mode 100644 index 0000000..c7765c9 --- a/dev/null +++ b/pics/brightnessapplet/icon.png | |||
Binary files differ | |||