Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -22,7 +22,7 @@ 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(KF5 REQUIRED COMPONENTS Activities Auth IdleTime Config DBusAddons Solid I18n GlobalAccel KIO NotifyConfig Screen Wayland DocTools Crash Notifications) find_package(LibKWorkspace CONFIG REQUIRED) find_package(KF5BluezQt) Index: daemon/CMakeLists.txt =================================================================== --- daemon/CMakeLists.txt +++ daemon/CMakeLists.txt @@ -39,6 +39,7 @@ powerdevilbrightnesslogic.cpp powerdevilscreenbrightnesslogic.cpp powerdevilkeyboardbrightnesslogic.cpp + powerdevilpowermanagement.cpp brightnessosdwidget.cpp kwinkscreenhelpereffect.cpp ) @@ -106,8 +107,8 @@ powerdevilpolicyagent.h PowerDevil::PolicyAgent powermanagementpolicyagentadaptor PowerManagementPolicyAgentAdaptor) -qt5_add_dbus_adaptor(powerdevil_SRCS ${KDE4_DBUS_INTERFACES_DIR}/kf5_org.freedesktop.PowerManagement.xml powerdevilfdoconnector.h PowerDevil::FdoConnector powermanagementfdoadaptor PowerManagementFdoAdaptor) -qt5_add_dbus_adaptor(powerdevil_SRCS ${KDE4_DBUS_INTERFACES_DIR}/kf5_org.freedesktop.PowerManagement.Inhibit.xml powerdevilfdoconnector.h PowerDevil::FdoConnector powermanagementinhibitadaptor PowerManagementInhibitAdaptor) +qt5_add_dbus_adaptor(powerdevil_SRCS ${SOLID_DBUS_INTERFACES_DIR}/kf5_org.freedesktop.PowerManagement.xml powerdevilfdoconnector.h PowerDevil::FdoConnector powermanagementfdoadaptor PowerManagementFdoAdaptor) +qt5_add_dbus_adaptor(powerdevil_SRCS ${SOLID_DBUS_INTERFACES_DIR}/kf5_org.freedesktop.PowerManagement.Inhibit.xml powerdevilfdoconnector.h PowerDevil::FdoConnector powermanagementinhibitadaptor PowerManagementInhibitAdaptor) # Backends Index: daemon/actions/bundled/CMakeLists.txt =================================================================== --- daemon/actions/bundled/CMakeLists.txt +++ daemon/actions/bundled/CMakeLists.txt @@ -3,6 +3,7 @@ add_library(powerdevil${_name}action_config MODULE ${actionconfig_SRCS}) target_link_libraries(powerdevil${_name}action_config + powerdevilcore powerdevilui Qt5::Widgets KF5::CoreAddons @@ -18,7 +19,7 @@ add_powerdevil_bundled_action(keyboardbrightnesscontrol) add_powerdevil_bundled_action(dimdisplay) add_powerdevil_bundled_action(runscript KF5::KIOCore KF5::KIOWidgets) -add_powerdevil_bundled_action(suspendsession KF5::KIOCore KF5::KIOWidgets KF5::Solid KF5::KDELibs4Support) +add_powerdevil_bundled_action(suspendsession KF5::KIOCore KF5::KIOWidgets) if(HAVE_WIRELESS_SUPPORT) add_powerdevil_bundled_action(wirelesspowersaving KF5::NetworkManagerQt KF5::BluezQt) endif() @@ -30,14 +31,13 @@ add_library(powerdevilhandlebuttoneventsaction_config MODULE ${actionconfig_SRCS}) target_link_libraries(powerdevilhandlebuttoneventsaction_config + powerdevilcore powerdevilui Qt5::Widgets KF5::CoreAddons KF5::I18n KF5::ConfigGui - KF5::Solid KF5::XmlGui - KF5::KDELibs4Support ) install(TARGETS powerdevilhandlebuttoneventsaction_config DESTINATION ${PLUGIN_INSTALL_DIR}) install(FILES powerdevilhandlebuttoneventsaction.desktop DESTINATION ${SERVICES_INSTALL_DIR}) Index: daemon/actions/bundled/handlebuttoneventsconfig.cpp =================================================================== --- daemon/actions/bundled/handlebuttoneventsconfig.cpp +++ daemon/actions/bundled/handlebuttoneventsconfig.cpp @@ -23,8 +23,7 @@ #include "suspendsession.h" #include "upower_interface.h" -#include -#include +#include "powerdevilpowermanagement.h" #include #include @@ -94,19 +93,17 @@ QList boxes; boxes << m_lidCloseCombo << m_powerButtonCombo; - QSet< Solid::PowerManagement::SleepState > methods = Solid::PowerManagement::supportedSleepStates(); - Q_FOREACH (QComboBox *box, boxes) { box->addItem(QIcon::fromTheme("dialog-cancel"), i18n("Do nothing"), (uint)SuspendSession::None); - if (methods.contains(Solid::PowerManagement::SuspendState)) { + if (PowerManagement::instance()->canSuspend()) { box->addItem(QIcon::fromTheme("system-suspend"), i18n("Suspend"), (uint)SuspendSession::ToRamMode); } - if (methods.contains(Solid::PowerManagement::HibernateState)) { + if (PowerManagement::instance()->canHibernate()) { box->addItem(QIcon::fromTheme("system-suspend-hibernate"), i18n("Hibernate"), (uint)SuspendSession::ToDiskMode); } - if (methods.contains(Solid::PowerManagement::HybridSuspendState)) { - box->addItem(QIcon::fromTheme("system-suspend-hybrid"), i18n("Hybrid suspend"), (uint)SuspendSession::SuspendHybridMode); - } +// if (methods.contains(Solid::PowerManagement::HybridSuspendState)) { +// box->addItem(QIcon::fromTheme("system-suspend-hybrid"), i18n("Hybrid suspend"), (uint)SuspendSession::SuspendHybridMode); +// } box->addItem(QIcon::fromTheme("system-shutdown"), i18n("Shut down"), (uint)SuspendSession::ShutdownMode); box->addItem(QIcon::fromTheme("system-lock-screen"), i18n("Lock screen"), (uint)SuspendSession::LockScreenMode); if (box != m_lidCloseCombo) { Index: daemon/actions/bundled/suspendsessionconfig.cpp =================================================================== --- daemon/actions/bundled/suspendsessionconfig.cpp +++ daemon/actions/bundled/suspendsessionconfig.cpp @@ -20,11 +20,11 @@ #include "suspendsessionconfig.h" +#include "powerdevilpowermanagement.h" + #include #include -#include - #include #include #include @@ -78,17 +78,15 @@ m_idleTime->setValue(0); m_idleTime->setSuffix(i18n(" min")); - QSet< Solid::PowerManagement::SleepState > methods = Solid::PowerManagement::supportedSleepStates(); - - if (methods.contains(Solid::PowerManagement::SuspendState)) { + if (PowerManagement::instance()->canSuspend()) { m_comboBox->addItem(QIcon::fromTheme("system-suspend"), i18n("Suspend"), (uint)SuspendSession::ToRamMode); } - if (methods.contains(Solid::PowerManagement::HibernateState)) { + if (PowerManagement::instance()->canHibernate()) { m_comboBox->addItem(QIcon::fromTheme("system-suspend-hibernate"), i18n("Hibernate"), (uint)SuspendSession::ToDiskMode); } - if (methods.contains(Solid::PowerManagement::HybridSuspendState)) { - m_comboBox->addItem(QIcon::fromTheme("system-suspend-hybrid"), i18n("Hybrid suspend"), (uint)SuspendSession::SuspendHybridMode); - } +// if (methods.contains(Solid::PowerManagement::HybridSuspendState)) { +// m_comboBox->addItem(QIcon::fromTheme("system-suspend-hybrid"), i18n("Hybrid suspend"), (uint)SuspendSession::SuspendHybridMode); +// } m_comboBox->addItem(QIcon::fromTheme("system-shutdown"), i18n("Shut down"), (uint)SuspendSession::ShutdownMode); m_comboBox->addItem(QIcon::fromTheme("system-lock-screen"), i18n("Lock screen"), (uint)SuspendSession::LockScreenMode); Index: kcmodule/activities/CMakeLists.txt =================================================================== --- kcmodule/activities/CMakeLists.txt +++ kcmodule/activities/CMakeLists.txt @@ -15,9 +15,7 @@ add_library(kcm_powerdevilactivitiesconfig MODULE ${kcm_powerdevil_activities_SRCS}) target_link_libraries(kcm_powerdevilactivitiesconfig - KF5::Solid KF5::Activities - KF5::KDELibs4Support powerdevilconfigcommonprivate ) Index: kcmodule/activities/activitywidget.cpp =================================================================== --- kcmodule/activities/activitywidget.cpp +++ kcmodule/activities/activitywidget.cpp @@ -24,9 +24,10 @@ #include "../daemon/actions/bundled/suspendsession.h" +#include "powerdevilpowermanagement.h" + #include #include -#include #include #include #include @@ -91,13 +92,11 @@ using namespace PowerDevil::BundledActions; - QSet< Solid::PowerManagement::SleepState > methods = Solid::PowerManagement::supportedSleepStates(); - - if (methods.contains(Solid::PowerManagement::SuspendState)) { + if (PowerDevil::PowerManagement::instance()->canSuspend()) { m_ui->alwaysActionBox->addItem(QIcon::fromTheme("system-suspend"), i18n("Suspend"), (uint)SuspendSession::ToRamMode); } - if (methods.contains(Solid::PowerManagement::HibernateState)) { + if (PowerDevil::PowerManagement::instance()->canHibernate()) { m_ui->alwaysActionBox->addItem(QIcon::fromTheme("system-suspend-hibernate"), i18n("Hibernate"), (uint)SuspendSession::ToDiskMode); } Index: kcmodule/global/CMakeLists.txt =================================================================== --- kcmodule/global/CMakeLists.txt +++ kcmodule/global/CMakeLists.txt @@ -14,9 +14,7 @@ target_link_libraries(kcm_powerdevilglobalconfig KF5::ConfigWidgets KF5::KIOWidgets - KF5::Solid KF5::NotifyConfig - KF5::KDELibs4Support powerdevilconfigcommonprivate ) Index: kcmodule/global/GeneralPage.cpp =================================================================== --- kcmodule/global/GeneralPage.cpp +++ kcmodule/global/GeneralPage.cpp @@ -24,10 +24,11 @@ #include "actions/bundled/suspendsession.h" +#include "powerdevilpowermanagement.h" + #include #include #include -#include #include #include @@ -101,13 +102,11 @@ } } - QSet< Solid::PowerManagement::SleepState > methods = Solid::PowerManagement::supportedSleepStates(); - BatteryCriticalCombo->addItem(QIcon::fromTheme("dialog-cancel"), i18n("Do nothing"), PowerDevil::BundledActions::SuspendSession::None); - if (methods.contains(Solid::PowerManagement::SuspendState)) { + if (PowerDevil::PowerManagement::instance()->canSuspend()) { BatteryCriticalCombo->addItem(QIcon::fromTheme("system-suspend"), i18n("Suspend"), PowerDevil::BundledActions::SuspendSession::ToRamMode); } - if (methods.contains(Solid::PowerManagement::HibernateState)) { + if (PowerDevil::PowerManagement::instance()->canHibernate()) { BatteryCriticalCombo->addItem(QIcon::fromTheme("system-suspend-hibernate"), i18n("Hibernate"), PowerDevil::BundledActions::SuspendSession::ToDiskMode); } BatteryCriticalCombo->addItem(QIcon::fromTheme("system-shutdown"), i18n("Shut down"), PowerDevil::BundledActions::SuspendSession::ShutdownMode); Index: kcmodule/profiles/CMakeLists.txt =================================================================== --- kcmodule/profiles/CMakeLists.txt +++ kcmodule/profiles/CMakeLists.txt @@ -15,10 +15,8 @@ target_link_libraries(kcm_powerdevilprofilesconfig KF5::KIOWidgets - KF5::Solid KF5::ConfigGui KF5::ConfigWidgets - KF5::KDELibs4Support powerdevilui powerdevilconfigcommonprivate ) Index: kcmodule/profiles/EditPage.cpp =================================================================== --- kcmodule/profiles/EditPage.cpp +++ kcmodule/profiles/EditPage.cpp @@ -24,6 +24,7 @@ #include #include +#include #include @@ -50,7 +51,6 @@ #include #include -#include K_PLUGIN_FACTORY(PowerDevilProfilesKCMFactory, registerPlugin(); @@ -79,10 +79,9 @@ if (m_profilesConfig->groupList().isEmpty()) { // Use the generator - QSet methods = Solid::PowerManagement::supportedSleepStates(); PowerDevil::ProfileGenerator::generateProfiles( - methods.contains(Solid::PowerManagement::SuspendState), - methods.contains(Solid::PowerManagement::HibernateState) + PowerDevil::PowerManagement::instance()->canSuspend(), + PowerDevil::PowerManagement::instance()->canHibernate() ); m_profilesConfig->reparseConfiguration(); } @@ -195,10 +194,9 @@ "Are you sure you want to continue?"), i18n("Restore Default Profiles")); if (ret == KMessageBox::Continue) { qCDebug(POWERDEVIL) << "Restoring defaults."; - QSet methods = Solid::PowerManagement::supportedSleepStates(); PowerDevil::ProfileGenerator::generateProfiles( - methods.contains(Solid::PowerManagement::SuspendState), - methods.contains(Solid::PowerManagement::HibernateState) + PowerDevil::PowerManagement::instance()->canSuspend(), + PowerDevil::PowerManagement::instance()->canHibernate() ); load();