author | mickeyl <mickeyl> | 2004-10-27 18:32:14 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-10-27 18:32:14 (UTC) |
commit | 7119f16d0439214b97b371ed4df66147a18e0c44 (patch) (unidiff) | |
tree | 2ac19d34b625e61f043fd2e77fff00d5b8bcb950 /noncore | |
parent | 14aec3d5de39e1973693940d813d940f248df2d9 (diff) | |
download | opie-7119f16d0439214b97b371ed4df66147a18e0c44.zip opie-7119f16d0439214b97b371ed4df66147a18e0c44.tar.gz opie-7119f16d0439214b97b371ed4df66147a18e0c44.tar.bz2 |
fix writing out the new system brightness
-rw-r--r-- | noncore/applets/brightnessapplet/brightnessapplet.cpp | 16 | ||||
-rw-r--r-- | noncore/applets/brightnessapplet/brightnessapplet.h | 2 | ||||
-rw-r--r-- | noncore/applets/brightnessapplet/brightnessapplet.pro | 2 |
3 files changed, 13 insertions, 7 deletions
diff --git a/noncore/applets/brightnessapplet/brightnessapplet.cpp b/noncore/applets/brightnessapplet/brightnessapplet.cpp index 1ade35e..5aaa27e 100644 --- a/noncore/applets/brightnessapplet/brightnessapplet.cpp +++ b/noncore/applets/brightnessapplet/brightnessapplet.cpp | |||
@@ -136,12 +136,19 @@ BrightnessAppletControl::BrightnessAppletControl( OTaskbarApplet* parent, const | |||
136 | 136 | ||
137 | BrightnessAppletControl::~BrightnessAppletControl() | 137 | BrightnessAppletControl::~BrightnessAppletControl() |
138 | { | 138 | { |
139 | } | 139 | } |
140 | 140 | ||
141 | 141 | ||
142 | void BrightnessAppletControl::hideEvent( QHideEvent* e ) | ||
143 | { | ||
144 | BrightnessApplet* applet = static_cast<BrightnessApplet*>( parent() ); | ||
145 | applet->writeSystemBrightness( applet->calcBrightnessValue() ); | ||
146 | QFrame::hideEvent( e ); | ||
147 | } | ||
148 | |||
142 | BrightnessApplet::BrightnessApplet( QWidget *parent, const char *name ) | 149 | BrightnessApplet::BrightnessApplet( QWidget *parent, const char *name ) |
143 | :OTaskbarApplet( parent, name ) | 150 | :OTaskbarApplet( parent, name ) |
144 | { | 151 | { |
145 | setFixedHeight( AppLnk::smallIconSize() ); | 152 | setFixedHeight( AppLnk::smallIconSize() ); |
146 | setFixedWidth( AppLnk::smallIconSize() ); | 153 | setFixedWidth( AppLnk::smallIconSize() ); |
147 | _pixmap.convertFromImage( Resource::loadImage( "brightnessapplet/icon" ).smoothScale( height(), width() ) ); | 154 | _pixmap.convertFromImage( Resource::loadImage( "brightnessapplet/icon" ).smoothScale( height(), width() ) ); |
@@ -157,12 +164,14 @@ void BrightnessApplet::writeSystemBrightness(int brightness) | |||
157 | if (ps.acStatus() == PowerStatus::Online) { | 164 | if (ps.acStatus() == PowerStatus::Online) { |
158 | cfg.setGroup("AC"); | 165 | cfg.setGroup("AC"); |
159 | } else { | 166 | } else { |
160 | cfg.setGroup("Battery"); | 167 | cfg.setGroup("Battery"); |
161 | } | 168 | } |
162 | cfg.writeEntry("Brightness", brightness); | 169 | cfg.writeEntry("Brightness", brightness); |
170 | odebug << "writing brightness " << brightness << oendl; | ||
171 | cfg.write(); | ||
163 | } | 172 | } |
164 | 173 | ||
165 | 174 | ||
166 | int BrightnessApplet::readSystemBrightness(void) | 175 | int BrightnessApplet::readSystemBrightness(void) |
167 | { | 176 | { |
168 | PowerStatus ps = PowerStatusManager::readStatus(); | 177 | PowerStatus ps = PowerStatusManager::readStatus(); |
@@ -170,12 +179,14 @@ int BrightnessApplet::readSystemBrightness(void) | |||
170 | 179 | ||
171 | if (ps.acStatus() == PowerStatus::Online) { | 180 | if (ps.acStatus() == PowerStatus::Online) { |
172 | cfg.setGroup("AC"); | 181 | cfg.setGroup("AC"); |
173 | } else { | 182 | } else { |
174 | cfg.setGroup("Battery"); | 183 | cfg.setGroup("Battery"); |
175 | } | 184 | } |
185 | |||
186 | odebug << "reading brightness " << cfg.readNumEntry("Brightness", 128) << oendl; | ||
176 | 187 | ||
177 | return cfg.readNumEntry("Brightness", 128); | 188 | return cfg.readNumEntry("Brightness", 128); |
178 | } | 189 | } |
179 | 190 | ||
180 | 191 | ||
181 | BrightnessApplet::~BrightnessApplet() | 192 | BrightnessApplet::~BrightnessApplet() |
@@ -220,16 +231,11 @@ void BrightnessApplet::mousePressEvent( QMouseEvent* ) | |||
220 | { | 231 | { |
221 | int v = 255 - readSystemBrightness(); | 232 | int v = 255 - readSystemBrightness(); |
222 | popup( _control ); | 233 | popup( _control ); |
223 | _control->slider->setValue((_control->slider->maxValue() * v + 128) / 255); | 234 | _control->slider->setValue((_control->slider->maxValue() * v + 128) / 255); |
224 | connect(_control->slider, SIGNAL(valueChanged(int)), this, SLOT(sliderMoved(int))); | 235 | connect(_control->slider, SIGNAL(valueChanged(int)), this, SLOT(sliderMoved(int))); |
225 | } | 236 | } |
226 | else | ||
227 | { | ||
228 | _control->hide(); | ||
229 | writeSystemBrightness( calcBrightnessValue() ); | ||
230 | } | ||
231 | } | 237 | } |
232 | 238 | ||
233 | 239 | ||
234 | EXPORT_OPIE_APPLET_v1( BrightnessApplet ) | 240 | EXPORT_OPIE_APPLET_v1( BrightnessApplet ) |
235 | 241 | ||
diff --git a/noncore/applets/brightnessapplet/brightnessapplet.h b/noncore/applets/brightnessapplet/brightnessapplet.h index 8b88bd1..6d6d369 100644 --- a/noncore/applets/brightnessapplet/brightnessapplet.h +++ b/noncore/applets/brightnessapplet/brightnessapplet.h | |||
@@ -44,13 +44,13 @@ class QSlider; | |||
44 | 44 | ||
45 | class BrightnessAppletControl : public QFrame | 45 | class BrightnessAppletControl : public QFrame |
46 | { | 46 | { |
47 | public: | 47 | public: |
48 | BrightnessAppletControl( Opie::Ui::OTaskbarApplet* parent, const char* name = 0 ); | 48 | BrightnessAppletControl( Opie::Ui::OTaskbarApplet* parent, const char* name = 0 ); |
49 | ~BrightnessAppletControl(); | 49 | ~BrightnessAppletControl(); |
50 | 50 | virtual void hideEvent( QHideEvent* ); | |
51 | QSlider* slider; | 51 | QSlider* slider; |
52 | }; | 52 | }; |
53 | 53 | ||
54 | class BrightnessApplet : public Opie::Ui::OTaskbarApplet | 54 | class BrightnessApplet : public Opie::Ui::OTaskbarApplet |
55 | { | 55 | { |
56 | Q_OBJECT | 56 | Q_OBJECT |
diff --git a/noncore/applets/brightnessapplet/brightnessapplet.pro b/noncore/applets/brightnessapplet/brightnessapplet.pro index 5044f38..8c65120 100644 --- a/noncore/applets/brightnessapplet/brightnessapplet.pro +++ b/noncore/applets/brightnessapplet/brightnessapplet.pro | |||
@@ -4,10 +4,10 @@ HEADERS = brightnessapplet.h | |||
4 | SOURCES = brightnessapplet.cpp | 4 | SOURCES = brightnessapplet.cpp |
5 | TARGET = brightnessapplet | 5 | TARGET = brightnessapplet |
6 | DESTDIR = $(OPIEDIR)/plugins/applets | 6 | DESTDIR = $(OPIEDIR)/plugins/applets |
7 | INCLUDEPATH += $(OPIEDIR)/include | 7 | INCLUDEPATH += $(OPIEDIR)/include |
8 | DEPENDPATH += $(OPIEDIR)/include | 8 | DEPENDPATH += $(OPIEDIR)/include |
9 | LIBS += -lqpe -lopiecore2 -lopieui2 | 9 | LIBS += -lqpe -lopiecore2 -lopieui2 |
10 | VERSION = 0.1.0 | 10 | VERSION = 0.1.1 |
11 | 11 | ||
12 | 12 | ||
13 | include ( $(OPIEDIR)/include.pro ) | 13 | include ( $(OPIEDIR)/include.pro ) |