summaryrefslogtreecommitdiff
path: root/noncore/applets/brightnessapplet/brightnessapplet.cpp
Side-by-side diff
Diffstat (limited to 'noncore/applets/brightnessapplet/brightnessapplet.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/brightnessapplet/brightnessapplet.cpp16
1 files changed, 11 insertions, 5 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 )