aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/src-cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src-qt5/src-cpp')
-rw-r--r--src-qt5/src-cpp/framework-OSInterface_private.cpp94
1 files changed, 52 insertions, 42 deletions
diff --git a/src-qt5/src-cpp/framework-OSInterface_private.cpp b/src-qt5/src-cpp/framework-OSInterface_private.cpp
index 15ee6f8e..b0a22b1d 100644
--- a/src-qt5/src-cpp/framework-OSInterface_private.cpp
+++ b/src-qt5/src-cpp/framework-OSInterface_private.cpp
@@ -8,7 +8,7 @@
//===========================================
#include <framework-OSInterface.h>
#include <QtConcurrent>
-
+#include <QIcon>
#include <QQmlEngine>
OSInterface::OSInterface(QObject *parent) : QObject(parent){
@@ -341,31 +341,34 @@ void OSInterface::syncNetworkInfo(OSInterface *os, QHash<QString, QVariant> *has
hash->insert("netaccess/address", address.join(", "));
//Figure out the icon used for this type/strnegth
- QString icon;
+ QStringList icons;
if(type.startsWith("cell")){
- if(address.isEmpty()){ icon = "network-cell-off"; }
- else if(strength>80){ icon = "network-cell-connected-100"; }
- else if(strength>60){ icon = "network-cell-connected-75"; }
- else if(strength>40){ icon = "network-cell-connected-50"; }
- else if(strength>10){ icon = "network-cell-connected-25"; }
- else if(strength >=0){ icon = "network-cell-connected-00"; }
- else{ icon = "network-cell"; } //unknown strength - just use generic icon so we at least get off/on visibility
+ if(address.isEmpty()){ icons <<"network-cell-off"; }
+ else if(strength>80){ icons <<"network-cell-connected-100"; }
+ else if(strength>60){ icons <<"network-cell-connected-75"; }
+ else if(strength>40){ icons << "network-cell-connected-50"; }
+ else if(strength>10){ icons << "network-cell-connected-25"; }
+ else if(strength >=0){ icons << "network-cell-connected-00"; }
+ icons << "network-cell"; //fallback - just use generic icon so we at least get off/on visibility
+
}else if(type=="wifi"){
- if(address.isEmpty()){ icon = "network-wireless-off"; }
- else if(strength>80){ icon = "network-wireless-100"; }
- else if(strength>60){ icon = "network-wireless-75"; }
- else if(strength>40){ icon = "network-wireless-50"; }
- else if(strength>10){ icon = "network-wireless-25"; }
- else if(strength >=0){ icon = "network-wireless-00"; }
- else{ icon = "network-wireless"; } //unknown strength - just use generic icon so we at least get off/on visibility
+ if(address.isEmpty()){ icons << "network-wireless-disconnected" << "network-wireless-00" << "network-wireless-off"; }
+ else if(strength>80){ icons << "network-wireless-100"; }
+ else if(strength>60){ icons << "network-wireless-75"; }
+ else if(strength>40){ icons << "network-wireless-50"; }
+ else if(strength>10){ icons << "network-wireless-25"; }
+ else if(strength >=0){ icons << "network-wireless-00"; }
+ icons << "network-wireless"; //fallback - just use generic icon so we at least get off/on visibility
+
}else if(type=="wired"){
- if(strength==100 && !address.isEmpty()){ icon = "network-wired-connected"; }
- else if(strength==100){ icon = "network-wired-pending"; }
- else{ icon = "network-wired-disconnected"; }
- }else{
- icon = "network-workgroup"; //failover to a generic "network" icon
+ if(strength==100 && !address.isEmpty()){ icons << "network-wired-connected" << "network-wired"; }
+ else if(strength==100){ icons << "network-wired-pending" << "network-wired-aquiring"; }
+ else{ icons << "network-wired-unavailable" << "network-wired-disconnected" ; }
+ }
+ icons << "network-workgroup" << "network-unknown";
+ for(int i=0; i<icons.length(); i++){
+ if(QIcon::hasThemeIcon(icons[i])){ hash->insert("netaccess/icon",icons[i]); break; }
}
- hash->insert("netaccess/icon",icon);
//qDebug() << "[DEBUG] Emit NetworkStatusChanged";
os->emit networkStatusChanged();
QTimer::singleShot(0, timer, SLOT(start()));
@@ -490,24 +493,26 @@ void OSInterface::syncBatteryInfo(OSInterface *os, QHash<QString, QVariant> *has
}
hash->insert("battery/time", time);
//Determine the icon which should be used for this status
- QString icon;
+ QStringList icons;
if(charging){
- if(charge>=99){ icon="battery-charging"; }
- else if(charge>80){ icon="battery-charging-80"; }
- else if(charge >60){ icon="battery-charging-60"; }
- else if(charge >30){ icon="battery-charging-40"; }
- else if(charge >0){ icon="battery-charging-20"; }
- else{ icon="battery-unknown"; }
+ if(charge>=99){ icons << "battery-100-charging" << "battery-charging-100" << "battery-full-charging" << "battery-charging-full" << "battery-charging"; }
+ else if(charge >80){ icons << "battery-charging-80"<< "battery-80-charging"<< "battery-charging-080" << "battery-080-charging" << "battery-good-charging" << "battery-charging-good"; }
+ else if(charge >60){ icons << "battery-charging-60"<< "battery-60-charging"<< "battery-charging-060" << "battery-060-charging" << "battery-good-charging" << "battery-charging-good"; }
+ else if(charge >40){ icons << "battery-charging-40"<< "battery-40-charging"<< "battery-charging-040" << "battery-040-charging" << "battery-good-charging" << "battery-charging-good"; }
+ else if(charge >20){ icons << "battery-charging-20"<< "battery-20-charging"<< "battery-charging-020" << "battery-020-charging" << "battery-low-charging" << "battery-charging-low"; }
+ else if(charge > 0){ icons << "battery-charging-00"<< "battery-00-charging"<< "battery-charging-000" << "battery-000-charging" << "battery-caution-charging" << "battery-charging-caution"; }
}else{
- if(charge>90){ icon="battery"; }
- else if(charge>80){ icon="battery-80"; }
- else if(charge >60){ icon="battery-60"; }
- else if(charge >30){ icon="battery-40"; }
- else if(charge >10){ icon="battery-20"; }
- else if(charge >0){ icon="battery-alert"; }
- else{ icon="battery-unknown"; }
+ if(charge>=99){ icons << "battery-100" << "battery-full-charged" << "battery-full" << "battery"; }
+ else if(charge >80){ icons << "battery-80"<< "battery-080" << "battery-good"; }
+ else if(charge >60){ icons << "battery-60"<< "battery-060" << "battery-good"; }
+ else if(charge >40){ icons << "battery-40"<< "battery-040" << "battery-good"; }
+ else if(charge >20){ icons << "battery-20"<< "battery-020" << "battery-low"; }
+ else if(charge > 0){ icons << "battery-00" << "battery-000" << "battery-caution"; }
+ }
+ icons << "battery-unknown" << "battery";
+ for(int i=0; i<icons.length(); i++){
+ if(QIcon::hasThemeIcon(icons[i])){ hash->insert("battery/icon",icons[i]); break; }
}
- hash->insert("battery/icon",icon);
//Now emit the change signal and restart the timer
os->emit batteryChanged();
QTimer::singleShot(0, timer, SLOT(start()));
@@ -515,18 +520,23 @@ void OSInterface::syncBatteryInfo(OSInterface *os, QHash<QString, QVariant> *has
void OSInterface::syncUpdateInfo(OSInterface *os, QHash<QString, QVariant> *hash, QTimer *timer){
//Get the current status
- QString status, icon;
+ QString status;
+ QStringList icons;
if(OS_updatesRunning()){
- status="running"; icon="sync";
+ status="running"; icons << "state-download" << "update-medium" << "sync";
}else if(OS_updatesFinished()){
- status="finished"; icon="security-high";
+ status="finished"; icons << "state-ok" << "update-high" << "security-high";
}else if(OS_updatesAvailable()){
- status="available"; icon="security-medium";
+ status="available"; icons << "state-warning" << "update-medium" << "security-medium";
}
+ icons << "state-offline" << "update-none";
+ //qDebug() << "Update Sync:" << status << icons;
//Save the current info into the hash (if different)
if(status != updateStatus()){
hash->insert("updates/status", status);
- hash->insert("updates/icon", icon);
+ for(int i=0; i<icons.length(); i++){
+ if(QIcon::hasThemeIcon(icons[i])){ hash->insert("updates/icon", icons[i]); break;}
+ }
os->emit updateStatusChanged();
}
QTimer::singleShot(0, timer, SLOT(start()));
bgstack15