Changeset 418d23a


Ignore:
Timestamp:
05/06/14 12:19:44 (11 months ago)
Author:
susannej <susanne_j@…>
Branches:
master, releng/10.0.2, releng/10.0.3, releng/10.1, releng/10.1.1
Children:
8ec8faf
Parents:
cf7372a
Message:

added charging state

Location:
lumina/lumina-desktop/panel-plugins/battery
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lumina/lumina-desktop/panel-plugins/battery/LBattery.cpp

    r495c69b r418d23a  
    1010  iconOld = -1; 
    1111  //Setup the widget 
    12   label = new QLabel(this); 
    13     label->setAlignment(Qt::AlignCenter); 
     12  label = new LTBWidget(this); 
     13    //label->setAlignment(Qt::AlignCenter); 
    1414  this->layout()->addWidget(label); 
    1515  //Setup the timer 
    1616  timer = new QTimer(); 
    17   timer->setInterval(3000); //update every 3 seconds 
     17  timer->setInterval(5000); //update every 3 seconds 
    1818  connect(timer,SIGNAL(timeout()), this, SLOT(updateBattery()) ); 
    1919  updateBattery(); 
     
    2828void LBattery::updateBattery(){ 
    2929  // Get current state of charge 
    30   QStringList result = LUtils::getCmdOutput("/usr/sbin/apm", QStringList() << "-l"); 
    31   int charge = result.at(0).toInt(); 
     30  QStringList result = LUtils::getCmdOutput("/usr/sbin/apm", QStringList() << "-al"); 
     31  int charge = result.at(1).toInt(); 
     32//qDebug() << "1: " << result.at(0).toInt() << " 2: " << result.at(1).toInt(); 
    3233  int icon = 0; 
    3334  if (charge > 100) { icon = 5; } 
     
    3637  else if (charge > 50) { icon = 2; } 
    3738  else if (charge > 30) { icon = 1; } 
     39  icon = icon + result.at(0).toInt() * 10; 
    3840  if (icon != iconOld) { 
    3941    switch (icon) { 
     
    5355        label->setIcon( LXDG::findIcon("battery-100", ":/images/battery-100.png") ); 
    5456        break; 
    55       case 5: 
     57      case 10: 
     58        label->setIcon( LXDG::findIcon("battery-charging-caution", ":/images/battery-caution.png") ); 
     59        break; 
     60      case 11: 
     61        label->setIcon( LXDG::findIcon("battery-charging-040", ":/images/battery-040.png") ); 
     62        break; 
     63      case 12: 
     64        label->setIcon( LXDG::findIcon("battery-charging-060", ":/images/battery-060.png") ); 
     65        break; 
     66      case 13: 
     67        label->setIcon( LXDG::findIcon("battery-charging-080", ":/images/battery-080.png") ); 
     68        break; 
     69      case 14: 
     70        label->setIcon( LXDG::findIcon("battery-charging-100", ":/images/battery-100.png") ); 
     71        break; 
     72      default: 
    5673        label->setIcon( LXDG::findIcon("battery-missing", ":/images/battery-missing.png") ); 
    5774        break; 
     
    6077  } 
    6178  //Now update the display 
    62   label->setToolTip(QString("%1 %%").arg(charge)); 
     79  label->setToolTip(QString("%1 %").arg(charge).append(icon > 9 && icon < 15 ? " and charging" : "")); 
    6380} 
  • lumina/lumina-desktop/panel-plugins/battery/LBattery.h

    r11d5b93 r418d23a  
    99 
    1010#include <QTimer> 
    11 #include <QLabel> 
    1211#include <QWidget> 
    1312#include <QString> 
    1413 
     14#include <LuminaUtils.h> 
     15#include <LuminaXDG.h> 
     16 
     17#include "../LTBWidget.h" 
    1518#include "../LPPlugin.h" 
    1619 
     
    2326private: 
    2427        QTimer *timer; 
    25         QLabel *label; 
     28        QToolButton *label; 
    2629        int iconOld; 
    2730         
Note: See TracChangeset for help on using the changeset viewer.