PowerDevilRunner: Set screen brightness values

powerdevil expects the brightness to be in absolute values not
percentages.
I know this is a blocking call, but we use QDBusInterfaces and
other blocking calls in here so it's not great but is a reasonable
fix for now.
BUG: 437408
wilder-5.24
David Redondo 5 years ago
parent 512135a650
commit 9dc1307997
  1. 6
      runners/powerdevil/PowerDevilRunner.cpp

@ -32,6 +32,8 @@
#include <KLocalizedString>
#include <KSharedConfig>
#include <cmath>
K_EXPORT_PLASMA_RUNNER_WITH_JSON(PowerDevilRunner, "plasma-runner-powerdevil.json")
PowerDevilRunner::PowerDevilRunner(QObject *parent, const KPluginMetaData &metaData, const QVariantList &args)
@ -179,7 +181,9 @@ void PowerDevilRunner::run(const Plasma::RunnerContext &context, const Plasma::Q
if (match.id().startsWith(QLatin1String("PowerDevil_ProfileChange"))) {
iface.asyncCall(QStringLiteral("loadProfile"), match.data().toString());
} else if (match.id() == QLatin1String("PowerDevil_BrightnessChange")) {
brightnessIface.asyncCall(QStringLiteral("setBrightness"), match.data().toInt());
QDBusReply<int> max = brightnessIface.call("brightnessMax");
const int value = max.isValid() ? std::round(match.data().toInt() * max / 100.0) : match.data().toInt();
brightnessIface.asyncCall("setBrightness", value);
} else if (match.id() == QLatin1String("PowerDevil_DimTotal")) {
brightnessIface.asyncCall(QStringLiteral("setBrightness"), 0);
} else if (match.id() == QLatin1String("PowerDevil_DimHalf")) {

Loading…
Cancel
Save