Changeset b10bac2


Ignore:
Timestamp:
05/09/14 12:25:10 (13 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, enter/10, releng/10.0.2, releng/10.0.3, releng/10.1, releng/10.1.1, releng/10.1.2
Children:
77631c2
Parents:
5f42f3f (diff), 78fff84 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of github.com:pcbsd/pcbsd

Files:
7 added
7 edited

Legend:

Unmodified
Added
Removed
  • lumina/lumina-desktop/AppMenu.cpp

    rc47b1152 r5f42f3f  
    5353      else if(cats[i] == "System"){ name = tr("System"); icon = "applications-system"; } 
    5454      else if(cats[i] == "Utility"){ name = tr("Utility"); icon = "applications-utilities"; } 
    55       else if(cats[i] == "Unsorted"){ name = tr("Unsorted"); icon = "applications-other"; } 
     55      else{ name = tr("Unsorted"); icon = "applications-other"; } 
     56       
    5657      QMenu *menu = new QMenu(name, this); 
    5758      menu->setIcon(LXDG::findIcon(icon,"")); 
  • lumina/lumina-desktop/Globals.h

    rf12e79a r5f42f3f  
    77#ifndef _LUMINA_DESKTOP_GLOBALS_H 
    88#define _LUMINA_DESKTOP_GLOBALS_H 
     9 
     10#include <LuminaUtils.h> 
    911 
    1012#include <unistd.h> 
     
    4244        //Restart the system 
    4345        static void restart(){ system("(shutdown -r now) &"); } 
     46         
     47        //Determine if there is battery support 
     48        static bool hasBattery(){ 
     49          return (LUtils::getCmdOutput("apm -s").join("").simplified() == "1"); 
     50        } 
     51         
     52        //Get the current battery charge percentage 
     53        static int batteryCharge(){ 
     54          int charge = LUtils::getCmdOutput("apm -l").join("").toInt(); 
     55          if(charge > 100){ charge = -1; } //invalid charge  
     56          return charge; 
     57        } 
     58         
     59        //Get the current battery charge percentage 
     60        static bool batteryIsCharging(){ 
     61          return (LUtils::getCmdOutput("apm -a").join("").simplified() == "1"); 
     62        } 
     63         
     64        //Get the amount of time remaining for the battery 
     65        static int batterySecondsLeft(){ 
     66          return LUtils::getCmdOutput("apm -t").join("").toInt(); 
     67        } 
    4468}; 
    4569 
  • lumina/lumina-desktop/LPanel.cpp

    r59bd6842 r5f42f3f  
    7171  QStringList plugins = settings->value(PPREFIX+"pluginlist", QStringList()).toStringList(); 
    7272  if(defaultpanel && plugins.isEmpty()){ 
    73     plugins << "userbutton" << "desktopbar" << "spacer"  << "clock"; 
     73    plugins << "userbutton" << "desktopbar" << "desktopswitcher" << "spacer"  << "clock"; 
     74    if(SYSTEM::hasBattery()){ plugins << "battery"; } 
    7475  }else if(defaultpanel && !plugins.contains("userbutton") ){ 
    7576    plugins.prepend("userbutton"); //make sure we have this button since that lets the user logout 
  • lumina/lumina-desktop/panel-plugins/battery/LBattery.cpp

    r8ec8faf r5f42f3f  
    1010  iconOld = -1; 
    1111  //Setup the widget 
    12   label = new LTBWidget(this); 
     12  label = new QLabel(this); 
     13    label->setScaledContents(true); 
    1314    //label->setAlignment(Qt::AlignCenter); 
    1415  this->layout()->addWidget(label); 
     
    2829void LBattery::updateBattery(){ 
    2930  // Get current state of charge 
    30   QStringList result = LUtils::getCmdOutput("/usr/sbin/apm", QStringList() << "-al"); 
    31   int charge = result.at(1).toInt(); 
     31  //QStringList result = LUtils::getCmdOutput("/usr/sbin/apm", QStringList() << "-al"); 
     32  int charge = SYSTEM::batteryCharge(); //result.at(1).toInt(); 
    3233//qDebug() << "1: " << result.at(0).toInt() << " 2: " << result.at(1).toInt(); 
    33   int icon = 0; 
    34   if (charge > 100) { icon = 5; } 
    35   else if (charge > 90) { icon = 4; } 
     34  int icon = -1; 
     35  if (charge > 90) { icon = 4; } 
    3636  else if (charge > 70) { icon = 3; } 
    3737  else if (charge > 50) { icon = 2; } 
    3838  else if (charge > 30) { icon = 1; } 
    39   icon = icon + result.at(0).toInt() * 10; 
     39  else if (charge > 0 ) { icon = 0; } 
     40  if(SYSTEM::batteryIsCharging()){ icon = icon+10; } 
     41  //icon = icon + result.at(0).toInt() * 10; 
    4042  if (icon != iconOld) { 
    4143    switch (icon) { 
    4244      case 0: 
    43         label->setIcon( LXDG::findIcon("battery-caution", ":/images/battery-caution.png") ); 
     45        label->setPixmap( LXDG::findIcon("battery-caution", "").pixmap(label->size()) ); 
    4446        break; 
    4547      case 1: 
    46         label->setIcon( LXDG::findIcon("battery-040", ":/images/battery-040.png") ); 
     48        label->setPixmap( LXDG::findIcon("battery-040", "").pixmap(label->size()) ); 
    4749        break; 
    4850      case 2: 
    49         label->setIcon( LXDG::findIcon("battery-060", ":/images/battery-060.png") ); 
     51        label->setPixmap( LXDG::findIcon("battery-060", "").pixmap(label->size()) ); 
    5052        break; 
    5153      case 3: 
    52         label->setIcon( LXDG::findIcon("battery-080", ":/images/battery-080.png") ); 
     54        label->setPixmap( LXDG::findIcon("battery-080", "").pixmap(label->size()) ); 
    5355        break; 
    5456      case 4: 
    55         label->setIcon( LXDG::findIcon("battery-100", ":/images/battery-100.png") ); 
     57        label->setPixmap( LXDG::findIcon("battery-100", "").pixmap(label->size()) ); 
    5658        break; 
    5759      case 10: 
    58         label->setIcon( LXDG::findIcon("battery-charging-caution", ":/images/battery-caution.png") ); 
     60        label->setPixmap( LXDG::findIcon("battery-charging-caution", "").pixmap(label->size()) ); 
    5961        break; 
    6062      case 11: 
    61         label->setIcon( LXDG::findIcon("battery-charging-040", ":/images/battery-040.png") ); 
     63        label->setPixmap( LXDG::findIcon("battery-charging-040", "").pixmap(label->size()) ); 
    6264        break; 
    6365      case 12: 
    64         label->setIcon( LXDG::findIcon("battery-charging-060", ":/images/battery-060.png") ); 
     66        label->setPixmap( LXDG::findIcon("battery-charging-060", "").pixmap(label->size()) ); 
    6567        break; 
    6668      case 13: 
    67         label->setIcon( LXDG::findIcon("battery-charging-080", ":/images/battery-080.png") ); 
     69        label->setPixmap( LXDG::findIcon("battery-charging-080", "").pixmap(label->size()) ); 
    6870        break; 
    6971      case 14: 
    70         label->setIcon( LXDG::findIcon("battery-charging", ":/images/battery-100.png") ); 
     72        label->setPixmap( LXDG::findIcon("battery-charging", "").pixmap(label->size()) ); 
    7173        break; 
    7274      default: 
    73         label->setIcon( LXDG::findIcon("battery-missing", ":/images/battery-missing.png") ); 
     75        label->setPixmap( LXDG::findIcon("battery-missing", "").pixmap(label->size()) ); 
    7476        break; 
    7577    } 
     
    7779  } 
    7880  //Now update the display 
    79   label->setToolTip(QString("%1 %").arg(charge).append(icon > 9 && icon < 15 ? " and charging" : "")); 
     81  QString tt; 
     82  //Make sure the tooltip can be properly translated as necessary (Ken Moore 5/9/14) 
     83  if(icon > 9 && icon < 15){ tt = QString(tr("%1 % (Charging)")).arg(QString::number(charge)); } 
     84  else{ tt = QString( tr("%1 % (%2 Remaining)") ).arg(QString::number(charge), getRemainingTime() ); } 
     85  label->setToolTip(tt); 
    8086} 
     87 
     88QString LBattery::getRemainingTime(){ 
     89  int secs = SYSTEM::batterySecondsLeft(); 
     90  if(secs < 0){ return "??"; } 
     91  QString rem; //remaining 
     92  if(secs > 3600){ 
     93    int hours = secs/3600; 
     94    rem.append( QString::number(hours)+"h "); 
     95    secs = secs - (hours*3600); 
     96  } 
     97  if(secs > 60){ 
     98    int min = secs/60; 
     99    rem.append( QString::number(min)+"m "); 
     100    secs = secs - (min*60); 
     101  } 
     102  if(secs > 0){ 
     103    rem.append(QString::number(secs)+"s"); 
     104  } 
     105  return rem; 
     106} 
  • lumina/lumina-desktop/panel-plugins/battery/LBattery.h

    r418d23a r5f42f3f  
    1111#include <QWidget> 
    1212#include <QString> 
     13#include <QLabel> 
    1314 
    1415#include <LuminaUtils.h> 
    1516#include <LuminaXDG.h> 
    1617 
    17 #include "../LTBWidget.h" 
     18#include "../../Globals.h" 
     19//#include "../LTBWidget.h" 
    1820#include "../LPPlugin.h" 
    1921 
     
    2628private: 
    2729        QTimer *timer; 
    28         QToolButton *label; 
     30        QLabel *label; 
    2931        int iconOld; 
    3032         
    3133private slots: 
    3234        void updateBattery(); 
     35        QString getRemainingTime(); 
    3336         
    3437}; 
  • lumina/lumina-desktop/panel-plugins/desktopswitcher/LDesktopSwitcher.cpp

    rf435093 r5f42f3f  
    1212  //Setup the widget 
    1313  label = new LTBWidget(this); 
    14   label->setIcon( LXDG::findIcon("preferences-desktop-display-color", ":/images/preferences-desktop-display-color.png") ); 
     14  label->setIcon( LXDG::findIcon("preferences-desktop-display-color", "") ); 
    1515  label->setToolTip(QString("Workspace 1")); 
    1616  menu = new QMenu(this); 
     
    2222  // becasue the workspace could be switched via Keyboard-shortcuts ... 
    2323 
    24   createMenu(); 
     24  QTimer::singleShot(500, this, SLOT(createMenu()) ); //needs a delay to make sure it works right the first time 
    2525} 
    2626 
     
    113113  int cur = LX11::GetCurrentDesktop(); //current desktop number 
    114114  int tot = LX11::GetNumberOfDesktops(); //total number of desktops 
    115   qDebug() << "-- vor getCurrentDesktop SWITCH"; 
    116   qDebug() << cur; 
     115  //qDebug() << "-- vor getCurrentDesktop SWITCH"; 
     116  qDebug() << "Virtual Desktops:" << tot << cur; 
    117117  menu->clear(); 
    118118  for (int i = 0; i < tot; i++) { 
    119     menu->addAction(newAction(i, QString("Workspace %1").arg(i +1))); 
     119    QString name = QString(tr("Workspace %1")).arg( QString::number(i+1) ); 
     120    if(i == cur){ name.prepend("**"); } //identify which desktop this is currently 
     121    menu->addAction(newAction(i, name)); 
    120122  } 
    121123} 
     
    123125void LDesktopSwitcher::menuActionTriggered(QAction* act) { 
    124126  LX11::SetCurrentDesktop(act->whatsThis().toInt()); 
    125   label->setToolTip(QString("Workspace %1").arg(act->whatsThis().toInt() +1)); 
     127  label->setToolTip(QString(tr("Workspace %1")).arg(act->whatsThis().toInt() +1)); 
    126128} 
  • lumina/lumina-desktop/panel-plugins/desktopswitcher/LDesktopSwitcher.h

    rf435093 r5f42f3f  
    4242        //int getCurrentDesktop(); 
    4343 
    44         void createMenu(); 
     44 
    4545        QAction* newAction(int, QString); 
    4646         
    4747private slots: 
     48        void createMenu(); 
    4849        void menuActionTriggered(QAction*); 
    4950}; 
Note: See TracChangeset for help on using the changeset viewer.