mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-12-15 17:43:41 +00:00
do not derive from qwidget in aggregates
This commit is contained in:
@ -59,13 +59,13 @@ KSysGuard::SensorInfo *SystemInfoSource::initialData(const QString &_source) con
|
||||
qCDebug(LOG_ESS) << "Source" << _source;
|
||||
|
||||
auto data = new KSysGuard::SensorInfo();
|
||||
if (_source == "system/brightness") {
|
||||
if (_source == "brightness") {
|
||||
data->min = 0.0;
|
||||
data->max = 100.0;
|
||||
data->name = "Screen brightness";
|
||||
data->variantType = QVariant::Double;
|
||||
data->unit = KSysGuard::UnitPercent;
|
||||
} else if (_source == "system/volume") {
|
||||
} else if (_source == "volume") {
|
||||
data->min = 0.0;
|
||||
data->max = 100.0;
|
||||
data->name = "Master volume";
|
||||
@ -79,16 +79,16 @@ KSysGuard::SensorInfo *SystemInfoSource::initialData(const QString &_source) con
|
||||
|
||||
void SystemInfoSource::run()
|
||||
{
|
||||
m_values["system/brightness"] = SystemInfoSource::getCurrentBrightness();
|
||||
m_values["system/volume"] = SystemInfoSource::getCurrentVolume();
|
||||
m_values["brightness"] = SystemInfoSource::getCurrentBrightness();
|
||||
m_values["volume"] = SystemInfoSource::getCurrentVolume();
|
||||
}
|
||||
|
||||
|
||||
QStringList SystemInfoSource::sources() const
|
||||
{
|
||||
QStringList sources;
|
||||
sources.append("system/brightness");
|
||||
sources.append("system/volume");
|
||||
sources.append("brightness");
|
||||
sources.append("volume");
|
||||
|
||||
return sources;
|
||||
}
|
||||
@ -100,24 +100,24 @@ QVariant SystemInfoSource::fromDBusVariant(const QVariant &value)
|
||||
}
|
||||
|
||||
|
||||
float SystemInfoSource::getCurrentBrightness()
|
||||
double SystemInfoSource::getCurrentBrightness()
|
||||
{
|
||||
qCDebug(LOG_ESS) << "Get current brightness";
|
||||
|
||||
auto maxBrightness
|
||||
= sendDBusRequest("org.kde.Solid.PowerManagement", "/org/kde/Solid/PowerManagement/Actions/BrightnessControl",
|
||||
"org.kde.Solid.PowerManagement.Actions.BrightnessControl", "brightnessMax")
|
||||
.toFloat();
|
||||
.toDouble();
|
||||
auto brightness
|
||||
= sendDBusRequest("org.kde.Solid.PowerManagement", "/org/kde/Solid/PowerManagement/Actions/BrightnessControl",
|
||||
"org.kde.Solid.PowerManagement.Actions.BrightnessControl", "brightness")
|
||||
.toFloat();
|
||||
.toDouble();
|
||||
|
||||
return std::round(100.0f * brightness / maxBrightness);
|
||||
return std::round(100.0 * brightness / maxBrightness);
|
||||
}
|
||||
|
||||
|
||||
float SystemInfoSource::getCurrentVolume()
|
||||
double SystemInfoSource::getCurrentVolume()
|
||||
{
|
||||
qCDebug(LOG_ESS) << "Get current volume";
|
||||
|
||||
@ -129,7 +129,7 @@ float SystemInfoSource::getCurrentVolume()
|
||||
|
||||
if (currentMixer.isEmpty()) {
|
||||
qCWarning(LOG_ESS) << "Mixer is empty";
|
||||
return std::numeric_limits<float>::quiet_NaN();
|
||||
return std::numeric_limits<double>::quiet_NaN();
|
||||
}
|
||||
currentMixer.replace(":", "_").replace(".", "_").replace("-", "_");
|
||||
|
||||
@ -140,14 +140,14 @@ float SystemInfoSource::getCurrentVolume()
|
||||
.toString();
|
||||
if (currentControl.isEmpty()) {
|
||||
qCWarning(LOG_ESS) << "Control is empty";
|
||||
return std::numeric_limits<float>::quiet_NaN();
|
||||
return std::numeric_limits<double>::quiet_NaN();
|
||||
}
|
||||
currentControl.replace(":", "_").replace(".", "_").replace("-", "_");
|
||||
|
||||
auto path = QString("/Mixers/%1/%2").arg(currentMixer).arg(currentControl);
|
||||
return fromDBusVariant(sendDBusRequest("org.kde.kmix", path, "org.freedesktop.DBus.Properties", "Get",
|
||||
QVariantList({"org.kde.KMix.Control", "volume"})))
|
||||
.toFloat();
|
||||
.toDouble();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user