From 15318cad33835e4e2dc620d033e43cd930676cdd Mon Sep 17 00:00:00 2001 From: kergoth Date: Fri, 25 Jan 2002 22:14:26 +0000 Subject: Initial revision --- (limited to 'core/settings/light-and-power') diff --git a/core/settings/light-and-power/.cvsignore b/core/settings/light-and-power/.cvsignore new file mode 100644 index 0000000..e6ba7a1 --- a/dev/null +++ b/core/settings/light-and-power/.cvsignore @@ -0,0 +1,4 @@ +moc_* +Makefile +lightsettingsbase.h +lightsettingsbase.cpp diff --git a/core/settings/light-and-power/Makefile.in b/core/settings/light-and-power/Makefile.in new file mode 100644 index 0000000..8236ed0 --- a/dev/null +++ b/core/settings/light-and-power/Makefile.in @@ -0,0 +1,135 @@ +############################################################################# + +####### Compiler, tools and options + +CXX = $(SYSCONF_CXX) $(QT_CXX_MT) +CXXFLAGS= $(SYSCONF_CXXFLAGS_QT) $(SYSCONF_CXXFLAGS) +CC = $(SYSCONF_CC) $(QT_C_MT) +CFLAGS = $(SYSCONF_CFLAGS) +INCPATH = -I$(QPEDIR)/include +LFLAGS = $(SYSCONF_LFLAGS_QT) $(SYSCONF_RPATH_QT) $(SYSCONF_LFLAGS) $(QT_LFLAGS_MT) +LIBS = $(SUBLIBS) -lqpe $(SYSCONF_LIBS_QT) $(SYSCONF_LIBS) $(SYSCONF_LIBS_QTAPP) +MOC = $(SYSCONF_MOC) +UIC = $(SYSCONF_UIC) + +####### Target + +DESTDIR = ../../bin/ +VER_MAJ = 1 +VER_MIN = 0 +VER_PATCH = 0 +TARGET = light-and-power +TARGET1 = lib$(TARGET).so.$(VER_MAJ) + +####### Files + +HEADERS = settings.h +SOURCES = light.cpp \ + main.cpp +OBJECTS = light.o \ + main.o \ + lightsettingsbase.o +INTERFACES = lightsettingsbase.ui +UICDECLS = lightsettingsbase.h +UICIMPLS = lightsettingsbase.cpp +SRCMOC = moc_settings.cpp \ + moc_lightsettingsbase.cpp +OBJMOC = moc_settings.o \ + moc_lightsettingsbase.o + + +####### Implicit rules + +.SUFFIXES: .cpp .cxx .cc .C .c + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< + +####### Build rules + + +all: $(DESTDIR)$(TARGET) + +$(DESTDIR)$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) + $(SYSCONF_LINK) $(LFLAGS) -o $(DESTDIR)$(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS) + +moc: $(SRCMOC) + +tmake: + tmake light-and-power.pro + +clean: + -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) + -rm -f *~ core + -rm -f allmoc.cpp + +####### Extension Modules + +listpromodules: + @echo + +listallmodules: + @echo + +listaddonpromodules: + @echo + +listaddonentmodules: + @echo + + +REQUIRES= + +####### Sub-libraries + + +###### Combined headers + + + +####### Compile + +light.o: light.cpp \ + settings.h \ + lightsettingsbase.h + +main.o: main.cpp \ + settings.h \ + lightsettingsbase.h + +lightsettingsbase.h: lightsettingsbase.ui + $(UIC) lightsettingsbase.ui -o $(INTERFACE_DECL_PATH)/lightsettingsbase.h + +lightsettingsbase.cpp: lightsettingsbase.ui + $(UIC) lightsettingsbase.ui -i lightsettingsbase.h -o lightsettingsbase.cpp + +lightsettingsbase.o: lightsettingsbase.cpp \ + lightsettingsbase.h \ + lightsettingsbase.ui + +moc_settings.o: moc_settings.cpp \ + settings.h \ + lightsettingsbase.h + +moc_lightsettingsbase.o: moc_lightsettingsbase.cpp \ + lightsettingsbase.h + +moc_settings.cpp: settings.h + $(MOC) settings.h -o moc_settings.cpp + +moc_lightsettingsbase.cpp: lightsettingsbase.h + $(MOC) lightsettingsbase.h -o moc_lightsettingsbase.cpp + + diff --git a/core/settings/light-and-power/light-and-power.pro b/core/settings/light-and-power/light-and-power.pro new file mode 100644 index 0000000..87bb111 --- a/dev/null +++ b/core/settings/light-and-power/light-and-power.pro @@ -0,0 +1,12 @@ +TEMPLATE = app +CONFIG += qt warn_on release +DESTDIR = ../../bin +HEADERS = settings.h +SOURCES = light.cpp main.cpp +INTERFACES = lightsettingsbase.ui +INCLUDEPATH += $(QPEDIR)/include +DEPENDPATH += ../$(QPEDIR)/include +LIBS += -lqpe +TARGET = light-and-power + +TRANSLATIONS = ../../i18n/de/light-and-power.ts diff --git a/core/settings/light-and-power/light-off.xpm b/core/settings/light-and-power/light-off.xpm new file mode 100644 index 0000000..26624c7 --- a/dev/null +++ b/core/settings/light-and-power/light-off.xpm @@ -0,0 +1,23 @@ +/* XPM */ +static char * light_off_xpm[] = { +"16 16 4 1", +" c None", +". c #000000000000", +"X c #6B6B6C6C6C6C", +"o c #FFFF6C6C0000", +" ", +" ", +" ... ", +" . . ", +" . X. ", +" . X. ", +" . XXX. ", +" . X XX. ", +" . XX. ", +" . XXX. ", +" . X. ", +" . X.. ", +" .ooo.. ", +" .ooo.. ", +" .o.. ", +" .. "}; diff --git a/core/settings/light-and-power/light-on.xpm b/core/settings/light-and-power/light-on.xpm new file mode 100644 index 0000000..3f8e174 --- a/dev/null +++ b/core/settings/light-and-power/light-on.xpm @@ -0,0 +1,24 @@ +/* XPM */ +static char * light_on_xpm[] = { +"16 16 5 1", +" c None", +". c #FFFFFFFF0000", +"X c #000000000000", +"o c #FFFFFFFFFFFF", +"O c #FFFF6C6C0000", +" . . ", +" . . . ", +" . XXX . ", +" XoooX . ", +" Xoooo.X ", +" .. Xoooooo.X ", +" Xoooo...X ..", +" Xooo.o..X ", +" .. Xooo..X ", +" Xoo...X ", +" . Xoo.X . ", +" . Xoo.XX . ", +" XOOOXX ", +" XOOOXX ", +" XOXX ", +" XX "}; diff --git a/core/settings/light-and-power/light.cpp b/core/settings/light-and-power/light.cpp new file mode 100644 index 0000000..24e1fab --- a/dev/null +++ b/core/settings/light-and-power/light.cpp @@ -0,0 +1,133 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of Qtopia Environment. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact info@trolltech.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ +#include "settings.h" + +#include +#include +#include +#include +#include +#if defined(Q_WS_QWS) && !defined(QT_NO_COP) +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if QT_VERSION >= 300 +#include +#endif + +extern int qpe_sysBrightnessSteps(); + +LightSettings::LightSettings( QWidget* parent, const char* name, WFlags fl ) + : LightSettingsBase( parent, name, TRUE, fl ) +{ + // Not supported + auto_brightness->hide(); + + Config config( "qpe" ); + + config.setGroup( "Screensaver" ); + + int interval; + interval = config.readNumEntry( "Interval_Dim", 30 ); + interval_dim->setValue( interval ); + interval = config.readNumEntry( "Interval_LightOff", 20 ); + interval_lightoff->setValue( interval ); + interval = config.readNumEntry( "Interval", 60 ); + if ( interval > 3600 ) interval /= 1000; // compatibility (was millisecs) + interval_suspend->setValue( interval ); + + screensaver_dim->setChecked( config.readNumEntry("Dim",1) != 0 ); + screensaver_lightoff->setChecked( config.readNumEntry("LightOff",1) != 0 ); + int maxbright = qpe_sysBrightnessSteps(); + initbright = config.readNumEntry("Brightness",255); + brightness->setMaxValue( maxbright ); + brightness->setTickInterval( QMAX(1,maxbright/16) ); + brightness->setLineStep( QMAX(1,maxbright/16) ); + brightness->setPageStep( QMAX(1,maxbright/16) ); + brightness->setValue( (maxbright*255 - initbright*maxbright)/255 ); + + connect(brightness, SIGNAL(valueChanged(int)), this, SLOT(applyBrightness())); +} + +LightSettings::~LightSettings() +{ +} + +static void set_fl(int bright) +{ + QCopEnvelope e("QPE/System", "setBacklight(int)" ); + e << bright; +} + +void LightSettings::reject() +{ + set_fl(initbright); + + QDialog::reject(); +} + +void LightSettings::accept() +{ + if ( qApp->focusWidget() ) + qApp->focusWidget()->clearFocus(); + + applyBrightness(); + + int i_dim = (screensaver_dim->isChecked() ? interval_dim->value() : 0); + int i_lightoff = (screensaver_lightoff->isChecked() ? interval_lightoff->value() : 0); + int i_suspend = interval_suspend->value(); + QCopEnvelope e("QPE/System", "setScreenSaverIntervals(int,int,int)" ); + e << i_dim << i_lightoff << i_suspend; + + Config config( "qpe" ); + config.setGroup( "Screensaver" ); + config.writeEntry( "Dim", (int)screensaver_dim->isChecked() ); + config.writeEntry( "LightOff", (int)screensaver_lightoff->isChecked() ); + config.writeEntry( "Interval_Dim", interval_dim->value() ); + config.writeEntry( "Interval_LightOff", interval_lightoff->value() ); + config.writeEntry( "Interval", interval_suspend->value() ); + config.writeEntry( "Brightness", + (brightness->maxValue()-brightness->value())*255/brightness->maxValue() ); + config.write(); + + QDialog::accept(); +} + +void LightSettings::applyBrightness() +{ + int bright = (brightness->maxValue()-brightness->value())*255 + / brightness->maxValue(); + set_fl(bright); +} + + diff --git a/core/settings/light-and-power/lightsettingsbase.ui b/core/settings/light-and-power/lightsettingsbase.ui new file mode 100644 index 0000000..47775f7 --- a/dev/null +++ b/core/settings/light-and-power/lightsettingsbase.ui @@ -0,0 +1,471 @@ + +LightSettingsBase + + QDialog + + name + LightSettingsBase + + + geometry + + 0 + 0 + 256 + 316 + + + + caption + Light Settings + + + layoutMargin + + + + margin + 7 + + + spacing + 6 + + + QCheckBox + + name + auto_brightness + + + text + Adjust to environment + + + whatsThis + By sensing the ambient light where you are using your device, the screen light can be adjusted automatically. The brightness setting still affects the average brightness. + + + + QGroupBox + + name + GroupBox3 + + + title + Power saving + + + layoutMargin + + + layoutSpacing + + + + margin + 6 + + + spacing + 3 + + + QSpinBox + + name + interval_lightoff + + + suffix + seconds + + + buttonSymbols + PlusMinus + + + maxValue + 3600 + + + minValue + 10 + + + lineStep + 15 + + + + QSpinBox + + name + interval_suspend + + + suffix + seconds + + + buttonSymbols + PlusMinus + + + maxValue + 3600 + + + minValue + 10 + + + lineStep + 15 + + + + QCheckBox + + name + screensaver_lightoff + + + sizePolicy + + 1 + 0 + + + + text + Light off after + + + checked + true + + + + QCheckBox + + name + screensaver_dim + + + sizePolicy + + 1 + 0 + + + + text + Dim light after + + + checked + true + + + + QSpinBox + + name + interval_dim + + + suffix + seconds + + + buttonSymbols + PlusMinus + + + maxValue + 3600 + + + minValue + 10 + + + lineStep + 15 + + + + QLabel + + name + TextLabel1_2 + + + text + Suspend after + + + + + + QLayoutWidget + + name + Layout18 + + + layoutMargin + + + + margin + 0 + + + spacing + 6 + + + QSlider + + name + brightness + + + maxValue + 255 + + + lineStep + 16 + + + pageStep + 16 + + + orientation + Vertical + + + tickmarks + Right + + + tickInterval + 32 + + + + QLayoutWidget + + name + Layout16 + + + layoutSpacing + + + + margin + 0 + + + spacing + 0 + + + QLayoutWidget + + name + Layout10 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + PixmapLabel1 + + + pixmap + image0 + + + scaledContents + false + + + + QLabel + + name + TextLabel1 + + + text + Bright + + + + + name + Spacer3 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + + + QLabel + + name + TextLabel3 + + + sizePolicy + + 5 + 7 + + + + text + <blockquote>The brighter the screen light, the more battery power is used.</blockquote> + + + + QLayoutWidget + + name + Layout9 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + PixmapLabel2 + + + pixmap + image1 + + + scaledContents + false + + + + QLabel + + name + TextLabel2 + + + text + Off + + + alignment + AlignVCenter|AlignLeft + + + vAlign + + + + + name + Spacer2 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + + + + + + + + + + image0 + 789c6d8ec10ac2300c86ef7b8ad0ff36a4730777111f41f1288887b4b3e8610a3a0f22bebb6dd3d54d0ca5cdffe54f9aaaa4dd764d6555dc7beecf96ec896f54b68fae7bee0fab57a1ea86fc5950ad6685d2646973bd1c43ce3ec73c46903648e79a5624443a27d20cd2b9382704747e124382f11a7c5e30b364b957b331866331b3800c38f70282121c7c628367c098c1e0eb03121ccd4b46fcb0f80b26bb4833987f76b6d6f274de5fe6a1a031d30969f55e161fe4715f7b + + + image1 + 789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523234530022130543251d2e253d856405bffcbc54105b19c856360003103711c4354b344b314b04719340dcb434b31488ac1e1a2020a6acac8c2ea60cc54862606ea232b218541b5810452c3111432c510f550c22886a1e482c115d0c2c88e6168818babaa4a42462c48082cae8e68102011a06b5d65c0041d3518e + + + + + screensaver_dim + toggled(bool) + interval_dim + setEnabled(bool) + + + screensaver_lightoff + toggled(bool) + interval_lightoff + setEnabled(bool) + + + + auto_brightness + screensaver_dim + interval_dim + screensaver_lightoff + interval_lightoff + interval_suspend + brightness + + diff --git a/core/settings/light-and-power/main.cpp b/core/settings/light-and-power/main.cpp new file mode 100644 index 0000000..051fdec --- a/dev/null +++ b/core/settings/light-and-power/main.cpp @@ -0,0 +1,38 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of Qtopia Environment. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact info@trolltech.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +#include "settings.h" + +#include +#include +#include + + +int main(int argc, char** argv) +{ + QPEApplication a(argc,argv); + + LightSettings dlg; + + a.showMainWidget(&dlg); + + return a.exec(); +} + diff --git a/core/settings/light-and-power/qpe-light-and-power.control b/core/settings/light-and-power/qpe-light-and-power.control new file mode 100644 index 0000000..0ed9d84 --- a/dev/null +++ b/core/settings/light-and-power/qpe-light-and-power.control @@ -0,0 +1,9 @@ +Files: bin/light-and-power apps/Settings/Light.desktop +Priority: optional +Section: qpe/settings +Maintainer: Warwick Allison +Architecture: arm +Version: $QPE_VERSION-3 +Depends: qpe-base ($QPE_VERSION) +Description: Light and Power settings dialog + For the Qtopia environment. diff --git a/core/settings/light-and-power/settings.h b/core/settings/light-and-power/settings.h new file mode 100644 index 0000000..cec08e3 --- a/dev/null +++ b/core/settings/light-and-power/settings.h @@ -0,0 +1,50 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of Qtopia Environment. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact info@trolltech.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ +#ifndef SETTINGS_H +#define SETTINGS_H + + +#include +#include +#include "lightsettingsbase.h" + + +class LightSettings : public LightSettingsBase +{ + Q_OBJECT + +public: + LightSettings( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~LightSettings(); + +protected: + void accept(); + void reject(); + +private slots: + void applyBrightness(); + +private: + int initbright; +}; + + +#endif // SETTINGS_H + -- cgit v0.9.0.2