diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c8a0fb9..8a8b04f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,83 +1,85 @@ project(PowerDevil) set(PROJECT_VERSION "5.11.90") set(PROJECT_VERSION_MAJOR 5) cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) set(QT_MIN_VERSION "5.7.0") find_package(ECM 1.2.0 REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) include(FeatureSummary) include(WriteBasicConfigVersionFile) include(KDEInstallDirs) include(KDECMakeSettings) include(KDECompilerSettings NO_POLICY_SCOPE) # require at least gcc 4.8 if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") if ("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "4.8") message(SEND_ERROR "Version ${CMAKE_CXX_COMPILER_VERSION} of the ${CMAKE_CXX_COMPILER_ID} C++ compiler is not supported. Please use version 4.8 or later.") endif() endif() find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Widgets DBus X11Extras) find_package(KF5 REQUIRED COMPONENTS Activities Auth IdleTime Config DBusAddons Solid I18n GlobalAccel KIO NotifyConfig Screen KDELibs4Support Wayland) find_package(LibKWorkspace CONFIG REQUIRED) find_package(KF5BluezQt) set_package_properties(KF5BluezQt PROPERTIES DESCRIPTION "Qt wrapper for BlueZ 5 DBus API" TYPE OPTIONAL PURPOSE "Support for wireless energy saving actions" ) find_package(KF5NetworkManagerQt) set_package_properties(KF5NetworkManagerQt PROPERTIES DESCRIPTION "Qt wrapper for NetworkManager API" TYPE OPTIONAL PURPOSE "Support for wireless energy saving actions" ) set(HAVE_WIRELESS_SUPPORT FALSE) if(KF5NetworkManagerQt_FOUND AND KF5BluezQt_FOUND) set(HAVE_WIRELESS_SUPPORT TRUE) endif() add_feature_info( "Wireless power saving" HAVE_WIRELESS_SUPPORT "Support turning off signal-transmitting devices to save energy" ) find_package(UDev REQUIRED) find_package(XCB REQUIRED COMPONENTS XCB RANDR DPMS) if(WITH_DDCUTIL) find_package(DDCUtil) set_package_properties(DDCUtil PROPERTIES DESCRIPTION "DDCUtil library support" TYPE OPTIONAL PURPOSE "Set monitor settings over DDC/CI channel" ) else() add_feature_info("DDCUtil" "Off" "DDCUtil library support is disabled by default as recomemded by authors, add -DWITH_DDCUTIL=On to enable") endif() include_directories ( ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/daemon ) add_definitions(-DQT_NO_KEYWORDS) add_definitions(-DQT_NO_KEYWORDS) add_subdirectory(daemon) add_subdirectory(kcmodule) add_subdirectory(doc) +add_subdirectory(kconf_update) + install( FILES powerdevil.notifyrc DESTINATION ${KNOTIFYRC_INSTALL_DIR} ) if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) endif() diff --git a/daemon/actions/bundled/brightnesscontrol.cpp b/daemon/actions/bundled/brightnesscontrol.cpp index abcea522..d849a758 100644 --- a/daemon/actions/bundled/brightnesscontrol.cpp +++ b/daemon/actions/bundled/brightnesscontrol.cpp @@ -1,214 +1,210 @@ /*************************************************************************** * Copyright (C) 2010 by Dario Freddi * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * ***************************************************************************/ #include "brightnesscontrol.h" #include "brightnessosdwidget.h" #include "brightnesscontroladaptor.h" #include #include #include #include #include #include #include #include #include #include namespace PowerDevil { namespace BundledActions { -static const QString s_globalAccelComponent = QStringLiteral("kded5"); - BrightnessControl::BrightnessControl(QObject* parent) : Action(parent) { // DBus new BrightnessControlAdaptor(this); setRequiredPolicies(PowerDevil::PolicyAgent::ChangeScreenSettings); connect(core()->backend(), &PowerDevil::BackendInterface::brightnessChanged, this, &PowerDevil::BundledActions::BrightnessControl::onBrightnessChangedFromBackend); KActionCollection* actionCollection = new KActionCollection( this ); actionCollection->setComponentDisplayName(i18nc("Name for powerdevil shortcuts category", "Power Management")); QAction* globalAction = actionCollection->addAction(QLatin1String("Increase Screen Brightness")); globalAction->setText(i18nc("@action:inmenu Global shortcut", "Increase Screen Brightness")); - globalAction->setProperty("componentName", s_globalAccelComponent); KGlobalAccel::setGlobalShortcut(globalAction, Qt::Key_MonBrightnessUp); connect(globalAction, SIGNAL(triggered(bool)), SLOT(increaseBrightness())); globalAction = actionCollection->addAction(QLatin1String("Decrease Screen Brightness")); globalAction->setText(i18nc("@action:inmenu Global shortcut", "Decrease Screen Brightness")); - globalAction->setProperty("componentName", s_globalAccelComponent); KGlobalAccel::setGlobalShortcut(globalAction, Qt::Key_MonBrightnessDown); connect(globalAction, SIGNAL(triggered(bool)), SLOT(decreaseBrightness())); } void BrightnessControl::onProfileUnload() { // } void BrightnessControl::onWakeupFromIdle() { // } void BrightnessControl::onIdleTimeout(int msec) { Q_UNUSED(msec); } void BrightnessControl::onProfileLoad() { const int absoluteBrightnessValue = qRound(m_defaultValue / 100.0 * brightnessMax()); // if the current profile is more conservative than the previous one and the // current brightness is lower than the new profile if (((m_currentProfile == QLatin1String("Battery") && m_lastProfile == QLatin1String("AC")) || (m_currentProfile == QLatin1String("LowBattery") && (m_lastProfile == QLatin1String("AC") || m_lastProfile == QLatin1String("Battery")))) && absoluteBrightnessValue > brightness()) { // We don't want to change anything here qCDebug(POWERDEVIL) << "Not changing brightness, the current one is lower and the profile is more conservative"; } else if (absoluteBrightnessValue >= 0) { QVariantMap args{ {QStringLiteral("Value"), QVariant::fromValue(absoluteBrightnessValue)} }; // plugging in/out the AC is always explicit if ((m_currentProfile == QLatin1String("AC") && m_lastProfile != QLatin1String("AC")) || (m_currentProfile != QLatin1String("AC") && m_lastProfile == QLatin1String("AC"))) { args["Explicit"] = true; args["Silent"] = true; // but we still don't want to show the OSD then } trigger(args); } } void BrightnessControl::triggerImpl(const QVariantMap &args) { const int value = args.value(QStringLiteral("Value")).toInt(); backend()->setBrightness(value); if (args.value(QStringLiteral("Explicit")).toBool() && !args.value(QStringLiteral("Silent")).toBool()) { BrightnessOSDWidget::show(brightnessPercent(value)); } } bool BrightnessControl::isSupported() { BackendInterface::BrightnessControlsList controls = backend()->brightnessControlsAvailable(); if (controls.key(BackendInterface::Screen).isEmpty()) { return false; } return true; } bool BrightnessControl::loadAction(const KConfigGroup& config) { // Handle profile changes m_lastProfile = m_currentProfile; m_currentProfile = config.parent().name(); qCDebug(POWERDEVIL) << "Profiles: " << m_currentProfile << m_lastProfile; if (config.hasKey("value")) { m_defaultValue = config.readEntry("value", 50); } return true; } void BrightnessControl::onBrightnessChangedFromBackend(const BrightnessLogic::BrightnessInfo &info, BackendInterface::BrightnessControlType type) { if (type == BackendInterface::Screen) { Q_EMIT brightnessChanged(info.value); Q_EMIT brightnessMaxChanged(info.valueMax); } } int BrightnessControl::brightness() const { return backend()->brightness(); } int BrightnessControl::brightnessMax() const { return backend()->brightnessMax(); } void BrightnessControl::setBrightness(int value) { trigger({ {QStringLiteral("Value"), QVariant::fromValue(value)}, {QStringLiteral("Explicit"), true} }); } void BrightnessControl::setBrightnessSilent(int value) { trigger({ {QStringLiteral("Value"), QVariant::fromValue(value)}, {QStringLiteral("Explicit"), true}, {QStringLiteral("Silent"), true} }); } void BrightnessControl::increaseBrightness() { const int newBrightness = backend()->brightnessKeyPressed(BrightnessLogic::Increase); if (newBrightness > -1) { BrightnessOSDWidget::show(brightnessPercent(newBrightness)); } } void BrightnessControl::decreaseBrightness() { const int newBrightness = backend()->brightnessKeyPressed(BrightnessLogic::Decrease); if (newBrightness > -1) { BrightnessOSDWidget::show(brightnessPercent(newBrightness)); } } int BrightnessControl::brightnessSteps() const { return backend()->brightnessSteps(); } int BrightnessControl::brightnessPercent(float value) const { const float maxBrightness = brightnessMax(); if (maxBrightness <= 0) { return 0; } return qRound(value / maxBrightness * 100); } } } diff --git a/daemon/actions/bundled/handlebuttonevents.cpp b/daemon/actions/bundled/handlebuttonevents.cpp index 5b118768..7ec9adcf 100644 --- a/daemon/actions/bundled/handlebuttonevents.cpp +++ b/daemon/actions/bundled/handlebuttonevents.cpp @@ -1,261 +1,256 @@ /*************************************************************************** * Copyright (C) 2010 by Dario Freddi * * Copyright (C) 2015 by Kai Uwe Broulik * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * ***************************************************************************/ #include "handlebuttonevents.h" #include "handlebuttoneventsadaptor.h" #include "suspendsession.h" #include #include #include #include #include #include #include #include #include #include #include #include namespace PowerDevil { namespace BundledActions { -static const QString s_globalAccelComponent = QStringLiteral("kded5"); - HandleButtonEvents::HandleButtonEvents(QObject *parent) : Action(parent) , m_screenConfiguration(nullptr) { new HandleButtonEventsAdaptor(this); // We enforce no policies here - after all, we just call other actions - which have their policies. setRequiredPolicies(PowerDevil::PolicyAgent::None); connect(backend(), SIGNAL(buttonPressed(PowerDevil::BackendInterface::ButtonType)), this, SLOT(onButtonPressed(PowerDevil::BackendInterface::ButtonType))); KActionCollection* actionCollection = new KActionCollection( this ); actionCollection->setComponentDisplayName(i18nc("Name for powerdevil shortcuts category", "Power Management")); KGlobalAccel *accel = KGlobalAccel::self(); QAction *globalAction = actionCollection->addAction("Sleep"); globalAction->setText(i18nc("@action:inmenu Global shortcut", "Suspend")); - globalAction->setProperty("componentName", s_globalAccelComponent); accel->setGlobalShortcut(globalAction, Qt::Key_Sleep); connect(globalAction, SIGNAL(triggered(bool)), SLOT(suspendToRam())); globalAction = actionCollection->addAction("Hibernate"); globalAction->setText(i18nc("@action:inmenu Global shortcut", "Hibernate")); - globalAction->setProperty("componentName", s_globalAccelComponent); accel->setGlobalShortcut(globalAction, Qt::Key_Hibernate); connect(globalAction, SIGNAL(triggered(bool)), SLOT(suspendToDisk())); globalAction = actionCollection->addAction("PowerOff"); globalAction->setText(i18nc("@action:inmenu Global shortcut", "Power Off")); - globalAction->setProperty("componentName", s_globalAccelComponent); accel->setGlobalShortcut(globalAction, Qt::Key_PowerOff); connect(globalAction, SIGNAL(triggered(bool)), SLOT(powerOffButtonTriggered())); connect(new KScreen::GetConfigOperation(KScreen::GetConfigOperation::NoEDID), &KScreen::ConfigOperation::finished, this, [this](KScreen::ConfigOperation *op) { m_screenConfiguration = qobject_cast(op)->config(); checkOutputs(); KScreen::ConfigMonitor::instance()->addConfig(m_screenConfiguration); connect(KScreen::ConfigMonitor::instance(), &KScreen::ConfigMonitor::configurationChanged, this, &HandleButtonEvents::checkOutputs); }); } HandleButtonEvents::~HandleButtonEvents() { } bool HandleButtonEvents::isSupported() { //we handles keyboard shortcuts in our button handling, users always have a keyboard return true; } void HandleButtonEvents::onProfileUnload() { m_lidAction = 0; m_powerButtonAction = 0; } void HandleButtonEvents::onWakeupFromIdle() { // } void HandleButtonEvents::onIdleTimeout(int msec) { Q_UNUSED(msec) } void HandleButtonEvents::onProfileLoad() { // } void HandleButtonEvents::onButtonPressed(BackendInterface::ButtonType type) { switch (type) { case BackendInterface::LidClose: if (!triggersLidAction()) { qCWarning(POWERDEVIL) << "Lid action was suppressed because an external monitor is present"; return; } processAction(m_lidAction); break; case BackendInterface::LidOpen: // In this case, let's send a wakeup event KIdleTime::instance()->simulateUserActivity(); break; case BackendInterface::PowerButton: processAction(m_powerButtonAction); break; case BackendInterface::SleepButton: processAction(m_sleepButtonAction); break; case BackendInterface::HibernateButton: processAction(m_hibernateButtonAction); break; default: break; } } void HandleButtonEvents::processAction(uint action) { // Basically, we simply trigger other actions :) switch (static_cast(action)) { case SuspendSession::TurnOffScreenMode: // Turn off screen triggerAction("DPMSControl", QStringLiteral("TurnOff")); break; case SuspendSession::ToggleScreenOnOffMode: // Toggle screen on/off triggerAction("DPMSControl", QStringLiteral("ToggleOnOff")); break; default: triggerAction("SuspendSession", action); break; } } void HandleButtonEvents::triggerAction(const QString &action, const QVariant &type) { PowerDevil::Action *helperAction = ActionPool::instance()->loadAction(action, KConfigGroup(), core()); if (helperAction) { helperAction->trigger({ {QStringLiteral("Type"), type}, {QStringLiteral("Explicit"), true} }); } } void HandleButtonEvents::triggerImpl(const QVariantMap& args) { // For now, let's just accept the phantomatic "32" button. It is also always explicit if (args["Button"].toInt() == 32) { if (args.contains("Type")) { triggerAction("SuspendSession", args["Type"]); } } } bool HandleButtonEvents::loadAction(const KConfigGroup& config) { // Read configs m_lidAction = config.readEntry("lidAction", 0); m_triggerLidActionWhenExternalMonitorPresent = config.readEntry("triggerLidActionWhenExternalMonitorPresent", false); m_powerButtonAction = config.readEntry("powerButtonAction", 0); checkOutputs(); return true; } int HandleButtonEvents::lidAction() const { return m_lidAction; } bool HandleButtonEvents::triggersLidAction() const { return m_triggerLidActionWhenExternalMonitorPresent || !m_externalMonitorPresent; } void HandleButtonEvents::powerOffButtonTriggered() { onButtonPressed(BackendInterface::PowerButton); } void HandleButtonEvents::suspendToDisk() { onButtonPressed(BackendInterface::HibernateButton); } void HandleButtonEvents::suspendToRam() { onButtonPressed(BackendInterface::SleepButton); } void HandleButtonEvents::checkOutputs() { if (!m_screenConfiguration) { qCWarning(POWERDEVIL) << "Handle button events action could not check for screen configuration"; return; } const bool old_triggersLidAction = triggersLidAction(); bool hasExternalMonitor = false; for(const KScreen::OutputPtr &output : m_screenConfiguration->outputs()) { if (output->isConnected() && output->isEnabled() && output->type() != KScreen::Output::Panel && output->type() != KScreen::Output::Unknown) { hasExternalMonitor = true; break; } } m_externalMonitorPresent = hasExternalMonitor; if (old_triggersLidAction != triggersLidAction()) { Q_EMIT triggersLidActionChanged(triggersLidAction()); // when the lid is closed but we don't suspend because of an external monitor but we then // unplug said monitor, re-trigger the lid action (Bug 379265) if (triggersLidAction() && backend()->isLidClosed()) { qCDebug(POWERDEVIL) << "External monitor that kept us from suspending is gone and lid is closed, re-triggering lid action"; onButtonPressed(BackendInterface::LidClose); } } } } } diff --git a/daemon/actions/bundled/keyboardbrightnesscontrol.cpp b/daemon/actions/bundled/keyboardbrightnesscontrol.cpp index 2a195b66..4e6b1747 100644 --- a/daemon/actions/bundled/keyboardbrightnesscontrol.cpp +++ b/daemon/actions/bundled/keyboardbrightnesscontrol.cpp @@ -1,232 +1,227 @@ /*************************************************************************** * Copyright (C) 2012 by Michael Zanetti * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * ***************************************************************************/ #include "keyboardbrightnesscontrol.h" #include "keyboardbrightnesscontroladaptor.h" #include "brightnessosdwidget.h" #include #include #include #include #include #include #include #include #include #include #include #include namespace PowerDevil { namespace BundledActions { -static const QString s_globalAccelComponent = QStringLiteral("kded5"); - KeyboardBrightnessControl::KeyboardBrightnessControl(QObject* parent) : Action(parent) { // DBus new KeyboardBrightnessControlAdaptor(this); setRequiredPolicies(PowerDevil::PolicyAgent::ChangeScreenSettings); connect(core()->backend(), &PowerDevil::BackendInterface::brightnessChanged, this, &PowerDevil::BundledActions::KeyboardBrightnessControl::onBrightnessChangedFromBackend); KActionCollection* actionCollection = new KActionCollection( this ); actionCollection->setComponentDisplayName(i18nc("Name for powerdevil shortcuts category", "Power Management")); KGlobalAccel *accel = KGlobalAccel::self(); QAction *globalAction = actionCollection->addAction(QLatin1String("Increase Keyboard Brightness")); globalAction->setText(i18nc("@action:inmenu Global shortcut", "Increase Keyboard Brightness")); - globalAction->setProperty("componentName", s_globalAccelComponent); accel->setGlobalShortcut(globalAction, Qt::Key_KeyboardBrightnessUp); connect(globalAction, SIGNAL(triggered(bool)), SLOT(increaseKeyboardBrightness())); globalAction = actionCollection->addAction(QLatin1String("Decrease Keyboard Brightness")); globalAction->setText(i18nc("@action:inmenu Global shortcut", "Decrease Keyboard Brightness")); - globalAction->setProperty("componentName", s_globalAccelComponent); accel->setGlobalShortcut(globalAction, Qt::Key_KeyboardBrightnessDown); connect(globalAction, SIGNAL(triggered(bool)), SLOT(decreaseKeyboardBrightness())); globalAction = actionCollection->addAction("Toggle Keyboard Backlight"); globalAction->setText(i18nc("@action:inmenu Global shortcut", "Toggle Keyboard Backlight")); - globalAction->setProperty("componentName", s_globalAccelComponent); accel->setGlobalShortcut(globalAction, Qt::Key_KeyboardLightOnOff); connect(globalAction, SIGNAL(triggered(bool)), SLOT(toggleKeyboardBacklight())); // My laptop sets the keyboard brightness to zero when I close the lid and it suspends // this makes sure the keyboard brightness is restored when we wake up :) connect(backend(), &PowerDevil::BackendInterface::resumeFromSuspend, this, [this] { setKeyboardBrightnessSilent(keyboardBrightness()); }); } void KeyboardBrightnessControl::onProfileUnload() { // } void KeyboardBrightnessControl::onWakeupFromIdle() { // } void KeyboardBrightnessControl::onIdleTimeout(int msec) { Q_UNUSED(msec); } void KeyboardBrightnessControl::onProfileLoad() { const int absoluteKeyboardBrightnessValue = qRound(m_defaultValue / 100.0 * keyboardBrightnessMax()); // if the current profile is more conservative than the previous one and the // current brightness is lower than the new profile if (((m_currentProfile == QLatin1String("Battery") && m_lastProfile == QLatin1String("AC")) || (m_currentProfile == QLatin1String("LowBattery") && (m_lastProfile == QLatin1String("AC") || m_lastProfile == QLatin1String("Battery")))) && absoluteKeyboardBrightnessValue > keyboardBrightness()) { // We don't want to change anything here qCDebug(POWERDEVIL) << "Not changing keyboard brightness, the current one is lower and the profile is more conservative"; } else if (absoluteKeyboardBrightnessValue > 0) { QVariantMap args{ {QStringLiteral("Value"), QVariant::fromValue(absoluteKeyboardBrightnessValue)} }; // plugging in/out the AC is always explicit if ((m_currentProfile == QLatin1String("AC") && m_lastProfile != QLatin1String("AC")) || (m_currentProfile != QLatin1String("AC") && m_lastProfile == QLatin1String("AC"))) { args["Explicit"] = true; args["Silent"] = true; // but we still don't want to show the OSD then } trigger(args); } } void KeyboardBrightnessControl::triggerImpl(const QVariantMap &args) { backend()->setBrightness(args.value(QStringLiteral("Value")).toInt(), BackendInterface::Keyboard); if (args.value(QStringLiteral("Explicit")).toBool() && !args.value(QStringLiteral("Silent")).toBool()) { BrightnessOSDWidget::show(keyboardBrightnessPercent(), BackendInterface::Keyboard); } } bool KeyboardBrightnessControl::isSupported() { BackendInterface::BrightnessControlsList controls = backend()->brightnessControlsAvailable(); if (controls.key(BackendInterface::Keyboard).isEmpty()) { return false; } return true; } bool KeyboardBrightnessControl::loadAction(const KConfigGroup& config) { // Handle profile changes m_lastProfile = m_currentProfile; m_currentProfile = config.parent().name(); qCDebug(POWERDEVIL) << "Profiles: " << m_currentProfile << m_lastProfile; if (config.hasKey("value")) { m_defaultValue = config.readEntry("value", 50); } return true; } void KeyboardBrightnessControl::onBrightnessChangedFromBackend(const BrightnessLogic::BrightnessInfo &info, BackendInterface::BrightnessControlType type) { if (type == BackendInterface::Keyboard) { Q_EMIT keyboardBrightnessChanged(info.value); Q_EMIT keyboardBrightnessMaxChanged(info.valueMax); } } void KeyboardBrightnessControl::increaseKeyboardBrightness() { backend()->brightnessKeyPressed(BrightnessLogic::Increase, BackendInterface::Keyboard); BrightnessOSDWidget::show(keyboardBrightnessPercent(), BackendInterface::Keyboard); } void KeyboardBrightnessControl::decreaseKeyboardBrightness() { backend()->brightnessKeyPressed(BrightnessLogic::Decrease, BackendInterface::Keyboard); BrightnessOSDWidget::show(keyboardBrightnessPercent(), BackendInterface::Keyboard); } void KeyboardBrightnessControl::toggleKeyboardBacklight() { backend()->brightnessKeyPressed(BrightnessLogic::Toggle, BackendInterface::Keyboard); BrightnessOSDWidget::show(keyboardBrightnessPercent(), BackendInterface::Keyboard); } int KeyboardBrightnessControl::keyboardBrightness() const { return backend()->brightness(BackendInterface::Keyboard); } int KeyboardBrightnessControl::keyboardBrightnessMax() const { return backend()->brightnessMax(BackendInterface::Keyboard); } void KeyboardBrightnessControl::setKeyboardBrightness(int percent) { trigger({ {QStringLiteral("Value"), QVariant::fromValue(percent)}, {QStringLiteral("Explicit"), true} }); } void KeyboardBrightnessControl::setKeyboardBrightnessSilent(int percent) { trigger({ {QStringLiteral("Value"), QVariant::fromValue(percent)}, {QStringLiteral("Explicit"), true}, {QStringLiteral("Silent"), true} }); } int KeyboardBrightnessControl::keyboardBrightnessSteps() const { return backend()->brightnessSteps(BackendInterface::Keyboard); } int KeyboardBrightnessControl::keyboardBrightnessPercent() const { const float maxBrightness = keyboardBrightnessMax(); if (maxBrightness <= 0) { return 0; } return qRound(keyboardBrightness() / maxBrightness * 100); } } } diff --git a/kconf_update/CMakeLists.txt b/kconf_update/CMakeLists.txt new file mode 100644 index 00000000..b3204a8d --- /dev/null +++ b/kconf_update/CMakeLists.txt @@ -0,0 +1 @@ +install(FILES powerdevil_move_shortcuts.upd DESTINATION ${KCONF_UPDATE_INSTALL_DIR}) diff --git a/kconf_update/powerdevil_move_shortcuts.upd b/kconf_update/powerdevil_move_shortcuts.upd new file mode 100644 index 00000000..5a10708a --- /dev/null +++ b/kconf_update/powerdevil_move_shortcuts.upd @@ -0,0 +1,12 @@ +Version=5 +Id=powerdevil_move_shortcuts +File=kglobalshortcutsrc +Group=kded5, org_kde_powerdevil +Key=Hibernate +Key=PowerOff +Key=Sleep +Key=Decrease Keyboard Brightness +Key=Decrease Screen Brightness +Key=Increase Keyboard Brightness +Key=Increase Screen Brightness +Key=Toggle Keyboard Backlight