rev 12467 - in kde-extras/kpowersave/trunk/debian: . patches
Michael Biebl
biebl at alioth.debian.org
Sat Oct 25 19:22:54 UTC 2008
Author: biebl
Date: 2008-10-25 19:22:53 +0000 (Sat, 25 Oct 2008)
New Revision: 12467
Added:
kde-extras/kpowersave/trunk/debian/patches/05-battery_rescan.patch
Modified:
kde-extras/kpowersave/trunk/debian/changelog
kde-extras/kpowersave/trunk/debian/patches/series
Log:
* debian/patches/05-battery_rescan.patch
- Detect battery plug/unplug events. Closes: #470618, #481146
Patch cherry picked from upstream svn.
Modified: kde-extras/kpowersave/trunk/debian/changelog
===================================================================
--- kde-extras/kpowersave/trunk/debian/changelog 2008-10-25 18:40:32 UTC (rev 12466)
+++ kde-extras/kpowersave/trunk/debian/changelog 2008-10-25 19:22:53 UTC (rev 12467)
@@ -18,6 +18,9 @@
* debian/patches/04-default_config.patch
- Change ActionOnPowerButton to LOGOUT_DIALOG. Closes: #486512
- Change ActionOnLidClose to SUSPEND2RAM.
+ * debian/patches/05-battery_rescan.patch
+ - Detect battery plug/unplug events. Closes: #470618, #481146
+ Patch cherry picked from upstream svn.
-- Michael Biebl <biebl at debian.org> Sat, 11 Oct 2008 12:12:27 +0200
Added: kde-extras/kpowersave/trunk/debian/patches/05-battery_rescan.patch
===================================================================
--- kde-extras/kpowersave/trunk/debian/patches/05-battery_rescan.patch (rev 0)
+++ kde-extras/kpowersave/trunk/debian/patches/05-battery_rescan.patch 2008-10-25 19:22:53 UTC (rev 12467)
@@ -0,0 +1,322 @@
+Index: kpowersave-0.7.3/src/detaileddialog.cpp
+===================================================================
+--- kpowersave-0.7.3.orig/src/detaileddialog.cpp 2007-09-17 19:39:45.000000000 +0200
++++ kpowersave-0.7.3/src/detaileddialog.cpp 2008-10-25 17:57:38.000000000 +0200
+@@ -52,61 +52,22 @@
+ hwinfo = _hwinfo;
+ config = _set;
+ pixmap = _pixmap;
+- primaryBatteries = hwinfo->getPrimaryBatteries();
++
+ cpuInfo = new CPUInfo();
+
+- int batteries = primaryBatteries->getNumBatteries();
+ numOfCPUs = cpuInfo->getCPUNum();
+
+ this->setCaption(i18n("KPowersave Information Dialog"));
+
++ initBatteryFrame();
++
+ // use this as compromise with current translation process
+ // TODO: remove them in the next translation round
+ GeneralGroup->setTitle(i18n("Miscellaneous"));
+ ProcessorGroup->setTitle(i18n("CPUs"));
+-
+ ProcessorGridLayout = new QGridLayout(ProcessorFrame, numOfCPUs, 2, 0, 5, "ProcessorGridLayout");
+
+- if (batteries > 0) {
+- if (batteries > 1) batteries++;
+-
+- BatteryGroup->setTitle(i18n("Battery state:").remove(":"));
+- BatteryGridLayout = new QGridLayout(BatteryFrame, batteries, 2, 0, 5, "BatteryGridLayout");
+-
+- for (int i = 0; i < batteries; i++) {
+- QLabel *Label = new QLabel(BatteryFrame, "BatteryLabel");
+- if ((primaryBatteries->getNumBatteries() > 1) && (i == 0))
+- Label->setText( i18n( "Total:" ));
+- else if ((primaryBatteries->getNumBatteries() > 1) && (i > 0))
+- Label->setText( i18n( "Battery %1" ).arg(i));
+- else
+- Label->setText( i18n( "Battery %1" ).arg(i + 1));
+-
+- BatteryGridLayout->addWidget( Label, i , 0);
+-
+- KProgress *PBar = new KProgress(BatteryFrame, "BatteryPBar");
+- PBar->setTextEnabled(true);
+-
+- BatteryPBar.append( PBar );
+- BatteryGridLayout->addWidget( PBar, i , 1);
+- }
+- BatteryFrame->adjustSize();
+- tl_powerConsDesc->hide();
+- tl_powerConsValue->hide();
+- connect(hwinfo, SIGNAL(generalDataChanged()), this, SLOT(setBattery()));
+- connect(primaryBatteries, SIGNAL(batteryChanged()), this, SLOT(setBattery()));
+- connect(primaryBatteries, SIGNAL(batteryChargingStateChanged(int)), this,
+- SLOT(setPowerConsumption()));
+- connect(primaryBatteries, SIGNAL(batteryRateChanged()), this,
+- SLOT(setPowerConsumption()));
+- setBattery();
+- setPowerConsumption();
+- } else {
+- BatteryGroup->hide();
+- }
+-
+ cpuInfo->checkCPUSpeed();
+-
+ ProcessorPictogram->setPixmap(SmallIcon("processor", 22));
+
+ for (int i = 0; i < numOfCPUs; i++) {
+@@ -123,9 +84,11 @@
+ ProcessorFrame->adjustSize();
+
+ connect(OkButton, SIGNAL(clicked()), this, SLOT(closeDetailedDlg()));
+- connect(hwinfo, SIGNAL(ACStatus(bool)), this, SLOT(setAC()));
+ // TODO: replace event
+ //connect(pd, SIGNAL(schemeDataChanged()), this, SLOT(setInfos()));
++ connect(hwinfo, SIGNAL(generalDataChanged()), this, SLOT(setBattery()));
++ connect(hwinfo, SIGNAL(primaryBatteryAddedRemoved()), this, SLOT(initBatteryFrame()));
++ connect(hwinfo, SIGNAL(ACStatus(bool)), this, SLOT(setAC()));
+ connect(hwinfo, SIGNAL(generalDataChanged()), this, SLOT(setInfos()));
+
+ if (hwinfo->supportCPUFreq() || cpuInfo->cpuFreqHW) {
+@@ -153,6 +116,89 @@
+ // no need to delete child widgets, Qt does it all for us
+ }
+
++void detaileddialog::initBatteryFrame () {
++ kdDebugFuncIn(trace);
++
++ int batteries = 0;
++
++ primaryBatteries = hwinfo->getPrimaryBatteries();
++ batteries = primaryBatteries->getNumBatteries();
++
++ if (batteries > 0) {
++ if (batteries > 1) batteries++;
++
++ BatteryGroup->setTitle(i18n("Battery state:").remove(":"));
++
++ // we have to remove the battery labels and progressbar
++ if (BatteryGridLayout && !BatteryPBar.isEmpty()) {
++ // not sure atm if this is the correct way ...
++ if (!BatteryPBar.isEmpty()) {
++ int bars = BatteryPBar.count();
++
++ for (int i = 0; i < bars; i++) {
++ BatteryGridLayout->remove(BatteryPBar[i]);
++ delete BatteryPBar[i];
++ }
++
++ BatteryPBar.clear();
++ }
++ if (!BatteryLabel.isEmpty()) {
++ int labels = BatteryLabel.count();
++
++ for (int i = 0; i < labels; i++) {
++ BatteryGridLayout->remove(BatteryLabel[i]);
++ delete BatteryLabel[i];
++ }
++
++ BatteryLabel.clear();
++ }
++
++ delete BatteryGridLayout;
++ }
++
++ BatteryGridLayout = new QGridLayout(BatteryFrame, batteries, 2, 0, 5, "BatteryGridLayout");
++
++ for (int i = 0; i < batteries; i++) {
++ QLabel *Label = new QLabel(BatteryFrame, "BatteryLabel");
++ if ((primaryBatteries->getNumBatteries() > 1) && (i == 0))
++ Label->setText( i18n( "Total:" ));
++ else if ((primaryBatteries->getNumBatteries() > 1) && (i > 0))
++ Label->setText( i18n( "Battery %1" ).arg(i));
++ else
++ Label->setText( i18n( "Battery %1" ).arg(i + 1));
++
++ BatteryLabel.append(Label);
++ BatteryGridLayout->addWidget( Label, i , 0);
++
++ KProgress *PBar = new KProgress(BatteryFrame, "BatteryPBar");
++ PBar->setTextEnabled(true);
++
++ BatteryPBar.append( PBar );
++ BatteryGridLayout->addWidget( PBar, i , 1);
++ }
++
++ if (BatteryGroup->isHidden()) {
++ BatteryGroup->show();
++ }
++
++ BatteryFrame->adjustSize();
++ tl_powerConsDesc->show();
++ tl_powerConsValue->show();
++ setBattery();
++ setPowerConsumption();
++
++ connect(primaryBatteries, SIGNAL(batteryChanged()), this, SLOT(setBattery()));
++ connect(primaryBatteries, SIGNAL(batteryChargingStateChanged(int)), this,
++ SLOT(setPowerConsumption()));
++ connect(primaryBatteries, SIGNAL(batteryRateChanged()), this,
++ SLOT(setPowerConsumption()));
++ } else {
++ BatteryGroup->hide();
++ }
++
++ kdDebugFuncIn(trace);
++}
++
+ /*!
+ * \b SLOT called if the dialog is closed by the user.
+ * We do some cleanups here.
+@@ -173,7 +219,6 @@
+ QString minutes;
+ int batteries = 0;
+
+-
+ // refresh battery collection
+ primaryBatteries = hwinfo->getPrimaryBatteries();
+ QPtrList<Battery> allBatteries = hwinfo->getAllBatteries();
+Index: kpowersave-0.7.3/src/detaileddialog.h
+===================================================================
+--- kpowersave-0.7.3.orig/src/detaileddialog.h 2007-09-17 19:39:45.000000000 +0200
++++ kpowersave-0.7.3/src/detaileddialog.h 2008-10-25 17:57:38.000000000 +0200
+@@ -61,6 +61,8 @@
+ private slots:
+ //! to close the dialog
+ void closeDetailedDlg();
++ //! to init the battery frame object
++ void initBatteryFrame ();
+ //! to setup the battery progress widgets
+ void setBattery();
+ //! to setup the current power consumtion widgets
+@@ -97,6 +99,13 @@
+ * one battery or batteryslot
+ */
+ QValueList<KProgress *> BatteryPBar;
++ //! list of qlabels for battery information
++ /*!
++ * This QValueList with type QLabel contains the list
++ * of battery progress widgets. Each element represent
++ * one battery or batteryslot
++ */
++ QValueList<QLabel *> BatteryLabel;
+ //! list of progressbars for CPU information
+ /*!
+ * This QValueList with type KProgress contains the list
+Index: kpowersave-0.7.3/src/hardware.cpp
+===================================================================
+--- kpowersave-0.7.3.orig/src/hardware.cpp 2007-09-17 19:39:45.000000000 +0200
++++ kpowersave-0.7.3/src/hardware.cpp 2008-10-25 17:57:38.000000000 +0200
+@@ -234,6 +234,9 @@
+ if (checkIfHandleDevice(value, &_type)) {
+ switch (_type) {
+ case BATTERY:
++ batteryRemovedAdded = true;
++ QTimer::singleShot(50, this, SLOT(handleDeviceRemoveAdd()));
++ break;
+ case AC_ADAPTER:
+ case BUTTON_SLEEP:
+ case BUTTON_POWER:
+@@ -250,24 +253,14 @@
+ }
+ }
+ } else if (message.startsWith("DeviceRemoved")) {
++ // check if we monitor this device
+ if (allUDIs.contains(value)) {
+- if (checkIfHandleDevice(value, &_type)) {
+- switch (_type) {
+- case BATTERY:
+- case AC_ADAPTER:
+- case BUTTON_SLEEP:
+- case BUTTON_POWER:
+- case LID:
+- // TODO: handle code if needed
+- break;
+- case LAPTOP_PANEL:
+- checkBrightness();
+- break;
+- default:
+- kdDebug() << "Couldn't handle unknown device" << endl;
+- break;
+- }
+- }
++ batteryRemovedAdded = false;
++
++ if (primaryBatteries->isBatteryHandled(value))
++ batteryRemovedAdded = true;
++
++ QTimer::singleShot(50, this, SLOT(handleDeviceRemoveAdd()));
+ } else {
+ kdDebug() << "Not monitored device removed: " << value << endl;
+ }
+@@ -371,6 +364,28 @@
+ kdDebugFuncOut(trace);
+ }
+
++/*!
++ * This SLOT is used to handle device remove and add events
++ * (incl. decouple the event from the event loop)
++ */
++void HardwareInfo::handleDeviceRemoveAdd () {
++ kdDebugFuncIn(trace);
++
++ // do it the hard way for now
++ // TODO: write a own function to handle batteries
++ reinitHardwareInfos();
++
++ if(batteryRemovedAdded) {
++ emit primaryBatteryAddedRemoved();
++ batteryRemovedAdded = false;
++ emit primaryBatteryChanged();
++ }
++
++ emit generalDataChanged();
++
++ kdDebugFuncOut(trace);
++}
++
+ /*!
+ * This function checks the session for the running KPowersave instance
+ * \return Boolean with result of operation
+Index: kpowersave-0.7.3/src/hardware.h
+===================================================================
+--- kpowersave-0.7.3.orig/src/hardware.h 2007-09-17 19:39:45.000000000 +0200
++++ kpowersave-0.7.3/src/hardware.h 2008-10-25 17:57:38.000000000 +0200
+@@ -252,6 +252,16 @@
+ */
+ bool sessionIsActive;
+
++ //! if a battery was removed/added on the last device event
++ /*!
++ * This boolean represent information if a battery was added or removed
++ * on the last device event
++ * \li true: if removed/added
++ * \li false: else
++ */
++ bool batteryRemovedAdded;
++
++
+ //! if the current user can use the CPU Freq interface
+ /*!
+ * This integer tell if the current user is allowed to change the
+@@ -340,6 +350,9 @@
+ //! SLOT to handle resume and forward a signal for resume
+ void handleResumeSignal (int result);
+
++ //! SLOT to handle device remove and add events
++ void handleDeviceRemoveAdd ();
++
+ //! to emit signal for power button
+ void emitPowerButtonPressed();
+ //! to emit signal for sleep button
+@@ -374,6 +387,8 @@
+ // battery related signals
+ //! signal if the primary battery collection changed
+ void primaryBatteryChanged();
++ //! signal that a battery was removed/added (only needed for power_supply case)
++ void primaryBatteryAddedRemoved();
+ //! signal to inform about reaching a warning state
+ void batteryWARNState(int type, int state);
+
Modified: kde-extras/kpowersave/trunk/debian/patches/series
===================================================================
--- kde-extras/kpowersave/trunk/debian/patches/series 2008-10-25 18:40:32 UTC (rev 12466)
+++ kde-extras/kpowersave/trunk/debian/patches/series 2008-10-25 19:22:53 UTC (rev 12467)
@@ -1,2 +1,3 @@
03-reset_blankonly_to_default.patch
04-default_config.patch
+05-battery_rescan.patch
More information about the pkg-kde-commits
mailing list