diff options
author | Ken Moore <ken@ixsystems.com> | 2018-01-31 08:55:03 -0500 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2018-01-31 08:55:03 -0500 |
commit | c18d3e92c8ee7fa3c4afc01d1a4952583eef6246 (patch) | |
tree | d7c71ccad9fe069befc921c617ee62c01ee1e6fa /src-qt5/src-cpp/framework-OSInterface_private.cpp | |
parent | Merge branch 'master' of https://github.com/trueos/lumina (diff) | |
download | lumina-c18d3e92c8ee7fa3c4afc01d1a4952583eef6246.tar.gz lumina-c18d3e92c8ee7fa3c4afc01d1a4952583eef6246.tar.bz2 lumina-c18d3e92c8ee7fa3c4afc01d1a4952583eef6246.zip |
Get the volume button/backend functional.
Diffstat (limited to 'src-qt5/src-cpp/framework-OSInterface_private.cpp')
-rw-r--r-- | src-qt5/src-cpp/framework-OSInterface_private.cpp | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/src-qt5/src-cpp/framework-OSInterface_private.cpp b/src-qt5/src-cpp/framework-OSInterface_private.cpp index 27bf910a..7b328849 100644 --- a/src-qt5/src-cpp/framework-OSInterface_private.cpp +++ b/src-qt5/src-cpp/framework-OSInterface_private.cpp @@ -212,7 +212,7 @@ QString OSInterface::networkStatus(){ //NetworkAccessManager slots void OSInterface::netAccessChanged(QNetworkAccessManager::NetworkAccessibility stat){ - qDebug() << "[DEBUG] Got Net Access Changed"; + //qDebug() << "[DEBUG] Got Net Access Changed"; INFO.insert("netaccess/available", stat== QNetworkAccessManager::Accessible); //Update all the other network status info at the same time QNetworkConfiguration active = netman->activeConfiguration(); @@ -271,7 +271,7 @@ void OSInterface::netAccessChanged(QNetworkAccessManager::NetworkAccessibility s icon = "network-workgroup"; //failover to a generic "network" icon } INFO.insert("netaccess/icon",icon); - qDebug() << "[DEBUG] Emit NetworkStatusChanged"; + //qDebug() << "[DEBUG] Emit NetworkStatusChanged"; emit networkStatusChanged(); } @@ -281,30 +281,37 @@ void OSInterface::netAccessChanged(QNetworkAccessManager::NetworkAccessibility s // ======================== //Timer slots void OSInterface::BatteryTimerUpdate(){ + if(batteryTimer->isActive()){ batteryTimer->stop(); } //just in case this was manually triggered QtConcurrent::run(this, &OSInterface::syncBatteryInfo, this, &INFO, batteryTimer); } void OSInterface::UpdateTimerUpdate(){ + if(updateTimer->isActive()){ updateTimer->stop(); } //just in case this was manually triggered QtConcurrent::run(this, &OSInterface::syncUpdateInfo, this, &INFO, updateTimer); } void OSInterface::BrightnessTimerUpdate(){ + if(brightnessTimer->isActive()){ brightnessTimer->stop(); } //just in case this was manually triggered QtConcurrent::run(this, &OSInterface::syncBrightnessInfo, this, &INFO, brightnessTimer); } void OSInterface::VolumeTimerUpdate(){ + if(volumeTimer->isActive()){ volumeTimer->stop(); } //just in case this was manually triggered QtConcurrent::run(this, &OSInterface::syncVolumeInfo, this, &INFO, volumeTimer); } void OSInterface::CpuTimerUpdate(){ + if(cpuTimer->isActive()){ cpuTimer->stop(); } //just in case this was manually triggered QtConcurrent::run(this, &OSInterface::syncCpuInfo, this, &INFO, cpuTimer); } void OSInterface::MemTimerUpdate(){ + if(memTimer->isActive()){ memTimer->stop(); } //just in case this was manually triggered QtConcurrent::run(this, &OSInterface::syncMemoryInfo, this, &INFO, memTimer); } void OSInterface::DiskTimerUpdate(){ + if(diskTimer->isActive()){ diskTimer->stop(); } //just in case this was manually triggered QtConcurrent::run(this, &OSInterface::syncDiskInfo, this, &INFO, diskTimer); } @@ -408,7 +415,18 @@ void OSInterface::syncBrightnessInfo(OSInterface *os, QHash<QString, QVariant> * } void OSInterface::syncVolumeInfo(OSInterface *os, QHash<QString, QVariant> *hash, QTimer *timer){ - + int oldvol = volume(); + int newvol = OS_volume(); + if(oldvol!=newvol){ + hash->insert("volume/current",newvol); + QString icon; + if(newvol>66){ icon = "audio-volume-high"; } + else if(newvol>33){ icon = "audio-volume-medium"; } + else if(newvol>0){ icon = "audio-volume-low"; } + else{ icon = "audio-volume-muted"; } + hash->insert("volume/icon",icon); + os->emit volumeChanged(); + } QTimer::singleShot(0, timer, SLOT(start())); } @@ -448,8 +466,20 @@ QString OSInterface::batteryIcon(){ // = Volume = bool OSInterface::volumeSupported(){ return OS_volumeSupported(); } -int OSInterface::volume(){ return -1; } -void OSInterface::setVolume(int){} +int OSInterface::volume(){ + if(INFO.contains("volume/current")){ return INFO.value("volume/current").toInt(); } + return 0; +} + +void OSInterface::setVolume(int vol){ + OS_setVolume(vol); + VolumeTimerUpdate(); //update the internal cache +} + +QString OSInterface::volumeIcon(){ + if(INFO.contains("volume/icon")){ return INFO.value("volume/icon").toString(); } + return ""; +} // = Media = QStringList OSInterface::mediaDirectories(){ return OS_mediaDirectories(); } |