diff options
author | Ken Moore <ken@ixsystems.com> | 2018-02-02 11:55:57 -0500 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2018-02-02 11:55:57 -0500 |
commit | 2f262ae79eb5fcab5257895534d605f47da047fa (patch) | |
tree | 99871e316a16dfd7ce1649504e7ad493f3018d10 | |
parent | Get the FreeBSD OSInterface class all setup. (diff) | |
download | lumina-2f262ae79eb5fcab5257895534d605f47da047fa.tar.gz lumina-2f262ae79eb5fcab5257895534d605f47da047fa.tar.bz2 lumina-2f262ae79eb5fcab5257895534d605f47da047fa.zip |
Fix up the battery status text.
3 files changed, 21 insertions, 1 deletions
diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/plugins/status_tray/BatteryButton.qml b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/plugins/status_tray/BatteryButton.qml index 8603e072..bc8ba68a 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/plugins/status_tray/BatteryButton.qml +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/plugins/status_tray/BatteryButton.qml @@ -14,7 +14,7 @@ ToolButton{ property OSInterface os: RootObject.os_interface() id: "batButton" iconName: os.batteryIcon - tooltip: os.batteryCharge+"%: "+os.batteryRemaining + tooltip: os.batteryStatus visible: os.batteryAvailable() //enabled: false } diff --git a/src-qt5/src-cpp/framework-OSInterface.h b/src-qt5/src-cpp/framework-OSInterface.h index 2c4a4e0c..debc6c05 100644 --- a/src-qt5/src-cpp/framework-OSInterface.h +++ b/src-qt5/src-cpp/framework-OSInterface.h @@ -43,6 +43,7 @@ class OSInterface : public QObject{ Q_PROPERTY( bool batteryCharging READ batteryCharging NOTIFY batteryChanged) Q_PROPERTY( QString batteryRemaining READ batteryRemaining NOTIFY batteryChanged) Q_PROPERTY( QString batteryIcon READ batteryIcon NOTIFY batteryChanged) + Q_PROPERTY( QString batteryStatus READ batteryStatus NOTIFY batteryChanged) //Volume Q_PROPERTY( int volume READ volume WRITE setVolume NOTIFY volumeChanged) Q_PROPERTY( QString volumeIcon READ volumeIcon NOTIFY volumeChanged) @@ -82,6 +83,7 @@ public: Q_INVOKABLE bool batteryCharging(); Q_INVOKABLE QString batteryRemaining(); Q_INVOKABLE QString batteryIcon(); + Q_INVOKABLE QString batteryStatus(); // = Volume = Q_INVOKABLE bool volumeSupported(); diff --git a/src-qt5/src-cpp/framework-OSInterface_private.cpp b/src-qt5/src-cpp/framework-OSInterface_private.cpp index 36da1bd4..e6d082cc 100644 --- a/src-qt5/src-cpp/framework-OSInterface_private.cpp +++ b/src-qt5/src-cpp/framework-OSInterface_private.cpp @@ -467,6 +467,13 @@ void OSInterface::syncBatteryInfo(OSInterface *os, QHash<QString, QVariant> *has hash->insert("battery/charging",charging); //Convert the seconds to human-readable QString time; + if(secs>3600){ + time = QString::number( qRound(secs/360.0)/10.0 )+" h"; + }else if(secs>60){ + time = QString::number( qRound(secs/6.0)/10.0 )+" m"; + }else if(secs>0){ + time = QString::number(secs)+" s"; + } hash->insert("battery/time", time); //Determine the icon which should be used for this status QString icon; @@ -566,6 +573,17 @@ QString OSInterface::batteryIcon(){ return ""; } +QString OSInterface::batteryStatus(){ + QString text = QString::number(batteryCharge())+"%"; + if(!batteryCharging()){ + QString time = batteryRemaining(); + if(!time.isEmpty()){ + text.append(" ("+time+")"); + } + } + return text; +} + // = Volume = bool OSInterface::volumeSupported(){ return OS_volumeSupported(); } int OSInterface::volume(){ |