author | mickeyl <mickeyl> | 2004-10-27 18:32:14 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-10-27 18:32:14 (UTC) |
commit | 7119f16d0439214b97b371ed4df66147a18e0c44 (patch) (side-by-side diff) | |
tree | 2ac19d34b625e61f043fd2e77fff00d5b8bcb950 | |
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 BrightnessAppletControl::~BrightnessAppletControl() { } +void BrightnessAppletControl::hideEvent( QHideEvent* e ) +{ + BrightnessApplet* applet = static_cast<BrightnessApplet*>( parent() ); + applet->writeSystemBrightness( applet->calcBrightnessValue() ); + QFrame::hideEvent( e ); +} + BrightnessApplet::BrightnessApplet( QWidget *parent, const char *name ) :OTaskbarApplet( parent, name ) { setFixedHeight( AppLnk::smallIconSize() ); setFixedWidth( AppLnk::smallIconSize() ); _pixmap.convertFromImage( Resource::loadImage( "brightnessapplet/icon" ).smoothScale( height(), width() ) ); @@ -157,12 +164,14 @@ void BrightnessApplet::writeSystemBrightness(int brightness) if (ps.acStatus() == PowerStatus::Online) { cfg.setGroup("AC"); } else { cfg.setGroup("Battery"); } cfg.writeEntry("Brightness", brightness); + odebug << "writing brightness " << brightness << oendl; + cfg.write(); } int BrightnessApplet::readSystemBrightness(void) { PowerStatus ps = PowerStatusManager::readStatus(); @@ -170,12 +179,14 @@ int BrightnessApplet::readSystemBrightness(void) if (ps.acStatus() == PowerStatus::Online) { cfg.setGroup("AC"); } else { cfg.setGroup("Battery"); } + + odebug << "reading brightness " << cfg.readNumEntry("Brightness", 128) << oendl; return cfg.readNumEntry("Brightness", 128); } BrightnessApplet::~BrightnessApplet() @@ -220,16 +231,11 @@ void BrightnessApplet::mousePressEvent( QMouseEvent* ) { int v = 255 - readSystemBrightness(); popup( _control ); _control->slider->setValue((_control->slider->maxValue() * v + 128) / 255); connect(_control->slider, SIGNAL(valueChanged(int)), this, SLOT(sliderMoved(int))); } - else - { - _control->hide(); - writeSystemBrightness( calcBrightnessValue() ); - } } EXPORT_OPIE_APPLET_v1( BrightnessApplet ) 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; class BrightnessAppletControl : public QFrame { public: BrightnessAppletControl( Opie::Ui::OTaskbarApplet* parent, const char* name = 0 ); ~BrightnessAppletControl(); - + virtual void hideEvent( QHideEvent* ); QSlider* slider; }; class BrightnessApplet : public Opie::Ui::OTaskbarApplet { 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 SOURCES = brightnessapplet.cpp TARGET = brightnessapplet DESTDIR = $(OPIEDIR)/plugins/applets INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopiecore2 -lopieui2 -VERSION = 0.1.0 +VERSION = 0.1.1 include ( $(OPIEDIR)/include.pro ) |