summaryrefslogtreecommitdiff
authordrw <drw>2005-06-05 22:11:17 (UTC)
committer drw <drw>2005-06-05 22:11:17 (UTC)
commite2b65062bd7554062fcc87bbf406c2e3a54d79a2 (patch) (unidiff)
tree52267420665f677fd9c442a4207874af9ccac2a0
parentd5ab3d3170acd2f4ff03f42db8ad93251a698add (diff)
downloadopie-e2b65062bd7554062fcc87bbf406c2e3a54d79a2.zip
opie-e2b65062bd7554062fcc87bbf406c2e3a54d79a2.tar.gz
opie-e2b65062bd7554062fcc87bbf406c2e3a54d79a2.tar.bz2
Resource -> OResource and fix compile warning
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/brightnessapplet/brightnessapplet.cpp46
1 files changed, 23 insertions, 23 deletions
diff --git a/noncore/applets/brightnessapplet/brightnessapplet.cpp b/noncore/applets/brightnessapplet/brightnessapplet.cpp
index 90fde05..f373dd8 100644
--- a/noncore/applets/brightnessapplet/brightnessapplet.cpp
+++ b/noncore/applets/brightnessapplet/brightnessapplet.cpp
@@ -1,241 +1,241 @@
1/* 1/*
2                 This file is part of the Opie Project 2 This file is part of the Opie Project
3 3
4 =. (C) 2004 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 4 =. (C) 2004 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 .=l. Based on Qtopia 1.7 Brightnessapplet (C) 2003-2004 TrollTech 5 .=l. Based on Qtopia 1.7 Brightnessapplet (C) 2003-2004 TrollTech
6           .>+-= 6 .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7_;:, .> :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public 9:`=1 )Y*s>-.-- : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11- . .-<_> .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13    .%`+i>       _;_. 13 .%`+i> _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; General Public License for more 19..}^=.= = ; General Public License for more
20++=   -.     .`     .: details. 20++= -. .` .: details.
21 :     =  ...= . :.=- 21: = ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22-. .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = General Public License along with 23 -_. . . )=. = General Public License along with
24    --        :-=` this application; see the file COPYING.LIB. 24 -- :-=` this application; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31#include "brightnessapplet.h" 31#include "brightnessapplet.h"
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie2/odebug.h> 34#include <opie2/odebug.h>
35#include <opie2/odevice.h> 35#include <opie2/odevice.h>
36#include <opie2/oresource.h>
36#include <opie2/otaskbarapplet.h> 37#include <opie2/otaskbarapplet.h>
37#include <qpe/applnk.h> 38#include <qpe/applnk.h>
38#include <qpe/config.h> 39#include <qpe/config.h>
39#include <qpe/power.h> 40#include <qpe/power.h>
40#include <qpe/qcopenvelope_qws.h> 41#include <qpe/qcopenvelope_qws.h>
41#include <qpe/resource.h>
42using namespace Opie::Core; 42using namespace Opie::Core;
43using namespace Opie::Ui; 43using namespace Opie::Ui;
44 44
45/* QT */ 45/* QT */
46#include <qpainter.h> 46#include <qpainter.h>
47#include <qlabel.h> 47#include <qlabel.h>
48#include <qslider.h> 48#include <qslider.h>
49#include <qlayout.h> 49#include <qlayout.h>
50 50
51/* STD */ 51/* STD */
52#include <assert.h> 52#include <assert.h>
53 53
54/* XPM */ 54/* XPM */
55static const char * const light_on_xpm[] = { 55static const char * const light_on_xpm[] = {
56"9 16 5 1", 56"9 16 5 1",
57" c None", 57" c None",
58". c #FFFFFFFF0000", 58". c #FFFFFFFF0000",
59"X c #000000000000", 59"X c #000000000000",
60"o c #FFFFFFFFFFFF", 60"o c #FFFFFFFFFFFF",
61"O c #FFFF6C6C0000", 61"O c #FFFF6C6C0000",
62" ", 62" ",
63" XXX ", 63" XXX ",
64" XoooX ", 64" XoooX ",
65" Xoooo.X ", 65" Xoooo.X ",
66"Xoooooo.X", 66"Xoooooo.X",
67"Xoooo...X", 67"Xoooo...X",
68"Xooo.o..X", 68"Xooo.o..X",
69" Xooo..X ", 69" Xooo..X ",
70" Xoo...X ", 70" Xoo...X ",
71" Xoo.X ", 71" Xoo.X ",
72" Xoo.XX ", 72" Xoo.XX ",
73" XOOOXX ", 73" XOOOXX ",
74" XOOOXX ", 74" XOOOXX ",
75" XOXX ", 75" XOXX ",
76" XX ", 76" XX ",
77" "}; 77" "};
78 78
79 79
80/* XPM */ 80/* XPM */
81static const char * const light_off_xpm[] = { 81static const char * const light_off_xpm[] = {
82"9 16 4 1", 82"9 16 4 1",
83" c None", 83" c None",
84". c #000000000000", 84". c #000000000000",
85"X c #6B6B6C6C6C6C", 85"X c #6B6B6C6C6C6C",
86"o c #FFFF6C6C0000", 86"o c #FFFF6C6C0000",
87" ", 87" ",
88" ", 88" ",
89" ... ", 89" ... ",
90" . . ", 90" . . ",
91" . X. ", 91" . X. ",
92". X.", 92". X.",
93". XXX.", 93". XXX.",
94". X XX.", 94". X XX.",
95" . XX. ", 95" . XX. ",
96" . XXX. ", 96" . XXX. ",
97" . X. ", 97" . X. ",
98" . X.. ", 98" . X.. ",
99" .ooo.. ", 99" .ooo.. ",
100" .ooo.. ", 100" .ooo.. ",
101" .o.. ", 101" .o.. ",
102" .. "}; 102" .. "};
103 103
104BrightnessAppletControl::BrightnessAppletControl( OTaskbarApplet* parent, const char* name ) 104BrightnessAppletControl::BrightnessAppletControl( OTaskbarApplet* parent, const char* name )
105 :QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ) 105 :QFrame( parent, name, WStyle_StaysOnTop | WType_Popup )
106{ 106{
107 setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); 107 setFrameStyle( QFrame::PopupPanel | QFrame::Raised );
108 QGridLayout *gl = new QGridLayout( this, 3, 2, 6, 3 ); 108 QGridLayout *gl = new QGridLayout( this, 3, 2, 6, 3 );
109 //gl->setRowStretch( 1, 100 ); 109 //gl->setRowStretch( 1, 100 );
110 110
111 int maxbright = ODevice::inst()->displayBrightnessResolution(); 111 int maxbright = ODevice::inst()->displayBrightnessResolution();
112 slider = new QSlider(this); 112 slider = new QSlider(this);
113 slider->setMaxValue(maxbright); 113 slider->setMaxValue(maxbright);
114 slider->setOrientation(QSlider::Vertical); 114 slider->setOrientation(QSlider::Vertical);
115 slider->setTickmarks(QSlider::Right); 115 slider->setTickmarks(QSlider::Right);
116 slider->setTickInterval(QMAX(1, maxbright / 16)); 116 slider->setTickInterval(QMAX(1, maxbright / 16));
117 slider->setLineStep(QMAX(1, maxbright / 16)); 117 slider->setLineStep(QMAX(1, maxbright / 16));
118 slider->setPageStep(QMAX(1, maxbright / 16)); 118 slider->setPageStep(QMAX(1, maxbright / 16));
119 gl->addMultiCellWidget( slider, 0, 2, 0, 0 ); 119 gl->addMultiCellWidget( slider, 0, 2, 0, 0 );
120 120
121 QPixmap onPm( (const char **)light_on_xpm ); 121 QPixmap onPm( (const char **)light_on_xpm );
122 QLabel *l = new QLabel( this ); 122 QLabel *l = new QLabel( this );
123 l->setPixmap( onPm ); 123 l->setPixmap( onPm );
124 gl->addWidget( l, 0, 1 ); 124 gl->addWidget( l, 0, 1 );
125 125
126 QPixmap offPm( (const char **)light_off_xpm ); 126 QPixmap offPm( (const char **)light_off_xpm );
127 l = new QLabel( this ); 127 l = new QLabel( this );
128 l->setPixmap( offPm ); 128 l->setPixmap( offPm );
129 gl->addWidget( l, 2, 1 ); 129 gl->addWidget( l, 2, 1 );
130 130
131 setFixedHeight( 100 ); 131 setFixedHeight( 100 );
132 setFixedWidth( gl->sizeHint().width() ); 132 setFixedWidth( gl->sizeHint().width() );
133 setFocusPolicy(QWidget::NoFocus); 133 setFocusPolicy(QWidget::NoFocus);
134} 134}
135 135
136 136
137BrightnessAppletControl::~BrightnessAppletControl() 137BrightnessAppletControl::~BrightnessAppletControl()
138{ 138{
139} 139}
140 140
141 141
142void BrightnessAppletControl::hideEvent( QHideEvent* e ) 142void BrightnessAppletControl::hideEvent( QHideEvent* e )
143{ 143{
144 BrightnessApplet* applet = static_cast<BrightnessApplet*>( parent() ); 144 BrightnessApplet* applet = static_cast<BrightnessApplet*>( parent() );
145 applet->writeSystemBrightness( applet->calcBrightnessValue() ); 145 applet->writeSystemBrightness( applet->calcBrightnessValue() );
146 QFrame::hideEvent( e ); 146 QFrame::hideEvent( e );
147} 147}
148 148
149BrightnessApplet::BrightnessApplet( QWidget *parent, const char *name ) 149BrightnessApplet::BrightnessApplet( QWidget *parent, const char *name )
150 :OTaskbarApplet( parent, name ) 150 :OTaskbarApplet( parent, name )
151{ 151{
152 setFixedHeight( AppLnk::smallIconSize() ); 152 setFixedHeight( AppLnk::smallIconSize() );
153 setFixedWidth( AppLnk::smallIconSize() ); 153 setFixedWidth( AppLnk::smallIconSize() );
154 _pixmap.convertFromImage( Resource::loadImage( "brightnessapplet/icon" ).smoothScale( height(), width() ) ); 154 _pixmap = Opie::Core::OResource::loadPixmap( "brightnessapplet/icon", Opie::Core::OResource::SmallIcon );
155 _control = new BrightnessAppletControl( this, "control" ); 155 _control = new BrightnessAppletControl( this, "control" );
156} 156}
157 157
158 158
159void BrightnessApplet::writeSystemBrightness(int brightness) 159void BrightnessApplet::writeSystemBrightness(int brightness)
160{ 160{
161 PowerStatus ps = PowerStatusManager::readStatus(); 161 PowerStatus ps = PowerStatusManager::readStatus();
162 162
163 Config cfg( "apm" ); 163 Config cfg( "apm" );
164 if (ps.acStatus() == PowerStatus::Online) { 164 if (ps.acStatus() == PowerStatus::Online) {
165 cfg.setGroup("AC"); 165 cfg.setGroup("AC");
166 } else { 166 } else {
167 cfg.setGroup("Battery"); 167 cfg.setGroup("Battery");
168 } 168 }
169 cfg.writeEntry("Brightness", brightness); 169 cfg.writeEntry("Brightness", brightness);
170 odebug << "writing brightness " << brightness << oendl; 170 odebug << "writing brightness " << brightness << oendl;
171 cfg.write(); 171 cfg.write();
172} 172}
173 173
174 174
175int BrightnessApplet::readSystemBrightness(void) 175int BrightnessApplet::readSystemBrightness(void)
176{ 176{
177 PowerStatus ps = PowerStatusManager::readStatus(); 177 PowerStatus ps = PowerStatusManager::readStatus();
178 Config cfg( "apm" ); 178 Config cfg( "apm" );
179 179
180 if (ps.acStatus() == PowerStatus::Online) { 180 if (ps.acStatus() == PowerStatus::Online) {
181 cfg.setGroup("AC"); 181 cfg.setGroup("AC");
182 } else { 182 } else {
183 cfg.setGroup("Battery"); 183 cfg.setGroup("Battery");
184 } 184 }
185 185
186 odebug << "reading brightness " << cfg.readNumEntry("Brightness", 128) << oendl; 186 odebug << "reading brightness " << cfg.readNumEntry("Brightness", 128) << oendl;
187 187
188 return cfg.readNumEntry("Brightness", 128); 188 return cfg.readNumEntry("Brightness", 128);
189} 189}
190 190
191 191
192BrightnessApplet::~BrightnessApplet() 192BrightnessApplet::~BrightnessApplet()
193{ 193{
194} 194}
195 195
196 196
197int BrightnessApplet::position() 197int BrightnessApplet::position()
198{ 198{
199 return 7; 199 return 7;
200} 200}
201 201
202 202
203void BrightnessApplet::paintEvent( QPaintEvent* ) 203void BrightnessApplet::paintEvent( QPaintEvent* )
204{ 204{
205 QPainter p(this); 205 QPainter p(this);
206 p.drawPixmap(0, 0, _pixmap ); 206 p.drawPixmap(0, 0, _pixmap );
207} 207}
208 208
209 209
210int BrightnessApplet::calcBrightnessValue() 210int BrightnessApplet::calcBrightnessValue()
211{ 211{
212 int v = _control->slider->maxValue() - _control->slider->value(); 212 int v = _control->slider->maxValue() - _control->slider->value();
213 return (v * 255 + _control->slider->maxValue() / 2) / _control->slider->maxValue(); 213 return (v * 255 + _control->slider->maxValue() / 2) / _control->slider->maxValue();
214} 214}
215 215
216 216
217void BrightnessApplet::sliderMoved( int value ) 217void BrightnessApplet::sliderMoved( int /*value*/ )
218{ 218{
219#ifndef QT_NO_COP 219#ifndef QT_NO_COP
220 QCopEnvelope e("QPE/System", "setBacklight(int)"); 220 QCopEnvelope e("QPE/System", "setBacklight(int)");
221 e << calcBrightnessValue(); 221 e << calcBrightnessValue();
222#else 222#else
223#error This Applet makes no sense without QCOP 223#error This Applet makes no sense without QCOP
224#endif // QT_NO_COP 224#endif // QT_NO_COP
225} 225}
226 226
227 227
228void BrightnessApplet::mousePressEvent( QMouseEvent* ) 228void BrightnessApplet::mousePressEvent( QMouseEvent* )
229{ 229{
230 if ( !_control->isVisible() ) 230 if ( !_control->isVisible() )
231 { 231 {
232 int v = 255 - readSystemBrightness(); 232 int v = 255 - readSystemBrightness();
233 popup( _control ); 233 popup( _control );
234 _control->slider->setValue((_control->slider->maxValue() * v + 128) / 255); 234 _control->slider->setValue((_control->slider->maxValue() * v + 128) / 255);
235 connect(_control->slider, SIGNAL(valueChanged(int)), this, SLOT(sliderMoved(int))); 235 connect(_control->slider, SIGNAL(valueChanged(int)), this, SLOT(sliderMoved(int)));
236 } 236 }
237} 237}
238 238
239 239
240EXPORT_OPIE_APPLET_v1( BrightnessApplet ) 240EXPORT_OPIE_APPLET_v1( BrightnessApplet )
241 241