diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ include(KDECompilerSettings NO_POLICY_SCOPE) find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Widgets DBus X11Extras) -find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Activities Auth IdleTime Config DBusAddons Solid I18n GlobalAccel KIO NotifyConfig Wayland DocTools Crash Notifications) +find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Activities Auth IdleTime Config DBusAddons Solid I18n GlobalAccel KIO NotifyConfig Wayland DocTools Crash Notifications CoreAddons) find_package(KF5Screen CONFIG REQUIRED) find_package(LibKWorkspace CONFIG REQUIRED) diff --git a/daemon/powerdevilcore.cpp b/daemon/powerdevilcore.cpp --- a/daemon/powerdevilcore.cpp +++ b/daemon/powerdevilcore.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -629,10 +630,28 @@ i18n("AC Adapter Plugged In"), i18n("The computer will no longer go to sleep.")); } else { - emitRichNotification(QStringLiteral("pluggedin"), i18n("Running on AC power"), i18n("The power adapter has been plugged in.")); + QString detail; + if (batteryRemainingTime() > 0) { + detail = i18n("Remaining charging time: %1", KFormat().formatDuration(batteryRemainingTime(), KFormat::HideSeconds)); + } else { + int currentPercent = currentChargePercent(); + detail = i18n("Charge level: %1 %", currentPercent); + } + + emitRichNotification(QStringLiteral("pluggedin"), i18n("Running on AC power"), detail); } } else if (state == BackendInterface::Unplugged) { - emitRichNotification(QStringLiteral("unplugged"), i18n("Running on Battery Power"), i18n("The power adapter has been unplugged.")); + QString detail; + if (batteryRemainingTime() > 0) { + detail = i18n("Remaining battery life: %1", KFormat().formatDuration(batteryRemainingTime(), KFormat::HideSeconds)); + } else { + int currentPercent = currentChargePercent(); + detail = i18n("Charge level: %1 %", currentPercent); + } + + emitRichNotification(QStringLiteral("unplugged"), + i18n("Running on Battery Power"), + detail); } }