diff --git a/package/contents/config/main.xml b/package/contents/config/main.xml
index 2f71654..5979635 100644
--- a/package/contents/config/main.xml
+++ b/package/contents/config/main.xml
@@ -30,5 +30,8 @@
true
+
+ 10
+
diff --git a/package/contents/ui/config.qml b/package/contents/ui/config.qml
index a72c68b..da22e48 100644
--- a/package/contents/ui/config.qml
+++ b/package/contents/ui/config.qml
@@ -36,12 +36,11 @@ Kirigami.FormLayout {
property alias formLayout: root
property alias cfg_VideoWallpaperBackgroundVideo: videoPathLine.text
- property int cfg_FillMode: 2
- property bool cfg_MuteAudio: true
- property bool cfg_DoublePlayer: true
-
+ property int cfg_FillMode: videoFillMode.currentIndex
+ property bool cfg_MuteAudio: muteRadio.checked
property int cfg_PauseMode: wallpaper.configuration.PauseMode
property alias cfg_BackgroundColor: colorButton.color
+ property int cfg_PauseBatteryLevel: pauseBatteryLevel.value
RowLayout {
Layout.fillWidth:true
@@ -107,18 +106,35 @@ Kirigami.FormLayout {
dialogTitle: i18nd("@dialog:background_color_title", "Select Background Color")
}
+ CheckBox {
+ id: muteRadio
+ Kirigami.FormData.label: i18nd("@checkbox:mute_audio", "Mute audio:")
+ checked: cfg_MuteAudio
+ onCheckedChanged: {
+ if (checked) {
+ cfg_MuteAudio = true
+ } else {
+ cfg_MuteAudio = false
+ }
+ }
+ }
+
+ Label {
+ Kirigami.FormData.label: i18nd("@buttonGroup:pause_mode", "Pause video:")
+ text: "Window State"
+ font.weight: Font.DemiBold
+ }
RadioButton {
id: maximizedPauseRadioButtton
- Kirigami.FormData.label: i18nd("@buttonGroup:pause_mode", "Pause video:")
- text: i18n("When there are maximized or full-screen windows.")
+ text: i18n("When there are maximized or full-screen windows")
ButtonGroup.group: pauseModeGroup
property int index: 0
checked: wallpaper.configuration.PauseMode === index
}
RadioButton {
id: busyPauseRadioButton
- text: i18n("When the desktop is busy.")
+ text: i18n("When at least one window is shown")
ButtonGroup.group: pauseModeGroup
property int index: 1
checked: wallpaper.configuration.PauseMode === index
@@ -130,6 +146,26 @@ Kirigami.FormLayout {
property int index: 2
checked: wallpaper.configuration.PauseMode === index
}
+ Label {
+ text: "On Battery"
+ font.weight: Font.DemiBold
+ }
+ RowLayout {
+ Label {
+ id: batteryPauseCheckBox
+ text: i18n("When is below:")
+ }
+ SpinBox {
+ id: pauseBatteryLevel
+ from: 0
+ to: 100
+ value: cfg_PauseBatteryLevel
+ onValueChanged: {
+ cfg_PauseBatteryLevel = value
+ }
+ }
+ }
+
ButtonGroup {
id: pauseModeGroup
onCheckedButtonChanged: {
@@ -139,19 +175,6 @@ Kirigami.FormLayout {
}
}
- CheckBox {
- id: muteRadio
- Kirigami.FormData.label: i18nd("@checkbox:mute_audio", "Mute audio:")
- checked: cfg_MuteAudio
- onCheckedChanged: {
- if (checked) {
- cfg_MuteAudio = true
- } else {
- cfg_MuteAudio = false
- }
- }
- }
-
FileDialog {
id: fileDialog
fileMode : FileDialog.OpenFile
diff --git a/package/contents/ui/main.qml b/package/contents/ui/main.qml
index e2d2173..a014f35 100644
--- a/package/contents/ui/main.qml
+++ b/package/contents/ui/main.qml
@@ -19,24 +19,50 @@
*/
import QtQuick
-
import org.kde.plasma.core as Plasmacore
-import org.kde.plasma.wallpapers.image as Wallpaper
-import org.kde.plasma.plasmoid
import QtMultimedia
+import org.kde.plasma.plasma5support as P5Support
+import org.kde.plasma.plasmoid
WallpaperItem {
anchors.fill: parent
id: main
property string videoWallpaperBackgroundVideo: wallpaper.configuration.VideoWallpaperBackgroundVideo
- property bool playing: windowModel.playVideoWallpaper
+ property bool playing: windowModel.playVideoWallpaper && !pauseBattery
property bool isLoading: true
- onPlayingChanged: playing && !isLoading ? main.play() : main.pause()
+ property int pauseBatteryLevel: wallpaper.configuration.PauseBatteryLevel
+
+ onPlayingChanged: {
+ playing && !isLoading ? main.play() : main.pause()
+ }
onVideoWallpaperBackgroundVideoChanged: {
if (isLoading) return
updateState()
}
+ property QtObject pmSource: P5Support.DataSource {
+ id: pmSource
+ engine: "powermanagement"
+ connectedSources: sources
+ onSourceAdded: source => {
+ disconnectSource(source);
+ connectSource(source);
+ dumpProps(pmSource.connectedSources)
+ }
+ onSourceRemoved: source => {
+ disconnectSource(source);
+ dumpProps(pmSource.connectedSources)
+ }
+ }
+
+ property bool pauseBattery: {
+ let result = false
+ if (pmSource.data.Battery["Has Cumulative"] && pmSource.data["Battery"]["State"] === "Discharging") {
+ result = pauseBatteryLevel > pmSource.data.Battery.Percent
+ }
+ return result
+ }
+
WindowModel {
id: windowModel
screenGeometry: main.parent.screenGeometry