diff --git a/daemon/backends/upower/powerdevilupowerbackend.h b/daemon/backends/upower/powerdevilupowerbackend.h index bf900975..299009d8 100644 --- a/daemon/backends/upower/powerdevilupowerbackend.h +++ b/daemon/backends/upower/powerdevilupowerbackend.h @@ -1,129 +1,128 @@ /* This file is part of the KDE project Copyright (C) 2006 Kevin Ottens Copyright (C) 2008-2010 Dario Freddi Copyright (C) 2010 Alejandro Fiestas Copyright (C) 2015 Kai Uwe Broulik This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef POWERDEVILUPOWERBACKEND_H #define POWERDEVILUPOWERBACKEND_H #include #include #include #include "upower_device_interface.h" #include "upower_interface.h" #include "upower_kbdbacklight_interface.h" #include "udevqt.h" #define UPOWER_SERVICE "org.freedesktop.UPower" #define UPOWER_PATH "/org/freedesktop/UPower" #define UPOWER_IFACE "org.freedesktop.UPower" #define UPOWER_IFACE_DEVICE "org.freedesktop.UPower.Device" #define LOGIN1_SERVICE "org.freedesktop.login1" #define CONSOLEKIT2_SERVICE "org.freedesktop.ConsoleKit" -class UdevHelper; class XRandRXCBHelper; class XRandrBrightness; class QPropertyAnimation; class DDCutilBrightness; class Q_DECL_EXPORT PowerDevilUPowerBackend : public PowerDevil::BackendInterface { Q_OBJECT Q_DISABLE_COPY(PowerDevilUPowerBackend) Q_PLUGIN_METADATA(IID "org.kde.powerdevil.upowerbackend"); public: explicit PowerDevilUPowerBackend(QObject* parent = nullptr); ~PowerDevilUPowerBackend() override; void init() override; static bool isAvailable(); int brightness(BrightnessControlType type = Screen) const override; int brightnessMax(BrightnessControlType type = Screen) const override; int brightnessKeyPressed(PowerDevil::BrightnessLogic::BrightnessKeyType type, BrightnessControlType controlType) override; void setBrightness(int value, PowerDevil::BackendInterface::BrightnessControlType type = Screen) override; KJob* suspend(PowerDevil::BackendInterface::SuspendMethod method) override; Q_SIGNALS: void brightnessSupportQueried(bool available); private: void enumerateDevices(); void addDevice(const QString &); private Q_SLOTS: void updateDeviceProps(); void slotDeviceAdded(const QString &); void slotDeviceRemoved(const QString &); void slotDeviceAdded(const QDBusObjectPath & path); void slotDeviceRemoved(const QDBusObjectPath & path); void slotDeviceChanged(const QString &); void slotPropertyChanged(); void slotLogin1PrepareForSleep(bool active); void slotScreenBrightnessChanged(); void onDeviceChanged(const UdevQt::Device &device); void onKeyboardBrightnessChanged(int); void onPropertiesChanged(const QString &ifaceName, const QVariantMap &changedProps, const QStringList &invalidatedProps); void onDevicePropertiesChanged(const QString &ifaceName, const QVariantMap &changedProps, const QStringList &invalidatedProps); private: void animationValueChanged(const QVariant &value); void initWithBrightness(bool brightnessSupport); // upower devices QMap m_devices; OrgFreedesktopUPowerDeviceInterface *m_displayDevice; // brightness QMap m_cachedBrightnessMap; XRandrBrightness *m_brightnessControl; XRandRXCBHelper *m_randrHelper; DDCutilBrightness *m_ddcBrightnessControl; OrgFreedesktopUPowerInterface *m_upowerInterface; OrgFreedesktopUPowerKbdBacklightInterface *m_kbdBacklight; int m_kbdMaxBrightness; int m_brightnessMax = 0; QPropertyAnimation *m_brightnessAnimation = nullptr; // login1 interface QPointer m_login1Interface; bool m_useUPowerSuspend = false; // buttons bool m_lidIsPresent; bool m_lidIsClosed; bool m_onBattery; // property if brightness control is leds subsystem bool m_isLedBrightnessControl; //helper path QString m_syspath; }; #endif // POWERDEVILUPOWERBACKEND_H diff --git a/daemon/powerdevilapp.h b/daemon/powerdevilapp.h index 1cdf0e50..c6175b4f 100644 --- a/daemon/powerdevilapp.h +++ b/daemon/powerdevilapp.h @@ -1,52 +1,51 @@ /*************************************************************************** * 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 . * ***************************************************************************/ #ifndef POWERDEVILAPP_H #define POWERDEVILAPP_H #include #include namespace PowerDevil { class Core; - class BackendInterface; } using InhibitionInfo = QPair; class PowerDevilApp : public QGuiApplication { Q_OBJECT Q_DISABLE_COPY(PowerDevilApp) public: explicit PowerDevilApp(int &argc, char **argv); ~PowerDevilApp() override; void init(); private Q_SLOTS: void onCoreReady(); private: PowerDevil::Core *m_core; void migratePre512KeyboardShortcuts(); }; #endif // POWERDEVILAPP_H diff --git a/daemon/powerdevilcore.h b/daemon/powerdevilcore.h index 5e29d496..8c25fb71 100644 --- a/daemon/powerdevilcore.h +++ b/daemon/powerdevilcore.h @@ -1,161 +1,160 @@ /*************************************************************************** * 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 . * ***************************************************************************/ #ifndef POWERDEVILCORE_H #define POWERDEVILCORE_H #include "powerdevilbackendinterface.h" #include #include #include #include namespace KActivities { class Consumer; } // namespace KActivities -class KDirWatch; class QDBusServiceWatcher; class QTimer; class KNotification; namespace Solid { class Battery; } namespace PowerDevil { class BackendInterface; class Action; class Q_DECL_EXPORT Core : public QObject { Q_OBJECT Q_DISABLE_COPY(Core) Q_CLASSINFO("D-Bus Interface", "org.kde.Solid.PowerManagement") public: explicit Core(QObject* parent); ~Core() override; void reloadProfile(int state); void emitNotification(const QString &evid, const QString &message = QString(), const QString &iconname = QString()); void emitRichNotification(const QString &evid, const QString &title, const QString &message = QString()); void emitNotification(const QString &eventId, const QString &title, const QString &message, const QString &iconName); bool emitBatteryChargePercentNotification(int currentPercent, int previousPercent, const QString &udi = QString()); BackendInterface *backend(); // More... public Q_SLOTS: void loadCore(PowerDevil::BackendInterface *backend); // Set of common action - useful for the DBus interface uint backendCapabilities(); void refreshStatus(); void reparseConfiguration(); QString currentProfile() const; void loadProfile(bool force = false); qulonglong batteryRemainingTime() const; bool isLidClosed() const; bool isLidPresent() const; bool isActionSupported(const QString &actionName); bool hasDualGpu() const; Q_SIGNALS: void coreReady(); void profileChanged(const QString &newProfile); void configurationReloaded(); void batteryRemainingTimeChanged(qulonglong time); void lidClosedChanged(bool closed); private: void registerActionTimeout(Action *action, int timeout); void unregisterActionTimeouts(Action *action); void handleCriticalBattery(int percent); /** * Computes the current global charge percentage. * Sum of all battery charges. */ int currentChargePercent() const; friend class Action; bool m_hasDualGpu; BackendInterface *m_backend; QDBusServiceWatcher *m_notificationsWatcher; bool m_notificationsReady = false; KSharedConfigPtr m_profilesConfig; QString m_currentProfile; QHash m_batteriesPercent; QHash m_peripheralBatteriesPercent; QHash m_batteriesCharged; QTimer *m_criticalBatteryTimer; QPointer m_criticalBatteryNotification; KActivities::Consumer *m_activityConsumer; // Idle time management QHash< Action*, QList< int > > m_registeredActionTimeouts; QSet m_pendingResumeFromIdleActions; bool m_pendingWakeupEvent; // Activity inhibition management QHash< QString, int > m_sessionActivityInhibit; QHash< QString, int > m_screenActivityInhibit; private Q_SLOTS: void onBackendReady(); void onAcAdapterStateChanged(PowerDevil::BackendInterface::AcAdapterState); void onBatteryChargePercentChanged(int,const QString&); void onBatteryChargeStateChanged(int,const QString&); void onBatteryRemainingTimeChanged(qulonglong); void onKIdleTimeoutReached(int,int); void onResumingFromIdle(); void onDeviceAdded(const QString &udi); void onDeviceRemoved(const QString &udi); void onCriticalBatteryTimerExpired(); void onNotificationTimeout(); void onServiceRegistered(const QString &service); void onLidClosedChanged(bool closed); void onAboutToSuspend(); }; } #endif // POWERDEVILCORE_H diff --git a/kcmodule/profiles/EditPage.h b/kcmodule/profiles/EditPage.h index 3116b6c9..c5631c29 100644 --- a/kcmodule/profiles/EditPage.h +++ b/kcmodule/profiles/EditPage.h @@ -1,70 +1,67 @@ /*************************************************************************** * Copyright (C) 2008 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 . * ***************************************************************************/ #ifndef EDITPAGE_H #define EDITPAGE_H #include #include #include "ui_profileEditPage.h" class ActionEditWidget; namespace PowerDevil { -class ActionConfig; } class ErrorOverlay; -class QCheckBox; -class KToolBar; class EditPage : public KCModule, private Ui_profileEditPage { Q_OBJECT public: explicit EditPage(QWidget *parent, const QVariantList &args); ~EditPage() override = default; void load() override; void save() override; void defaults() override; private Q_SLOTS: void onChanged(bool changed); void restoreDefaultProfiles(); void notifyDaemon(); void openUrl(const QString &url); void onServiceRegistered(const QString &service); void onServiceUnregistered(const QString &service); void checkAndEmitChanged(); private: KSharedConfig::Ptr m_profilesConfig; QHash< QString, bool > m_profileEdited; ErrorOverlay *m_errorOverlay = nullptr; QHash< QString, ActionEditWidget* > m_editWidgets; }; #endif /* EDITPAGE_H */