Skip to content

Commit 528fe0a

Browse files
committed
feat: add seconds picker to timed wallpaper change
1 parent 91b28d3 commit 528fe0a

4 files changed

Lines changed: 37 additions & 14 deletions

File tree

package/contents/config/main.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@
119119
<entry name="ChangeWallpaperMode" type="Int">
120120
<default>1</default>
121121
</entry>
122+
<entry name="ChangeWallpaperTimerSeconds" type="Int">
123+
<default>0</default>
124+
</entry>
122125
<entry name="ChangeWallpaperTimerMinutes" type="Int">
123126
<default>10</default>
124127
</entry>

package/contents/ui/FadePlayer.qml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ Item {
1919
property bool restoreLastPosition: true
2020
property bool debugEnabled: false
2121
property int changeWallpaperMode: Enum.ChangeWallpaperMode.Slideshow
22+
property int changeWallpaperTimerSeconds: 0
2223
property int changeWallpaperTimerMinutes: 10
2324
property int changeWallpaperTimerHours: 0
24-
property int changeWallpaperTimerTime: (changeWallpaperTimerHours * 60 + changeWallpaperTimerMinutes) * 60 * 1000
25+
property int changeWallpaperTimerMs: ((changeWallpaperTimerHours * 60 * 60) + (changeWallpaperTimerMinutes * 60) + changeWallpaperTimerSeconds) * 1000
2526
property bool resumeLastVideo: true
2627

2728
// Crossfade must not be longer than the shortest video or the fade becomes glitchy
@@ -35,7 +36,7 @@ Item {
3536
if (!root.crossfadeEnabled) {
3637
return 0;
3738
} else if (root.changeWallpaperMode === Enum.ChangeWallpaperMode.OnATimer) {
38-
return Math.min(root.targetCrossfadeDuration, changeWallpaperTimerTime / 3 * 2);
39+
return Math.min(root.targetCrossfadeDuration, changeWallpaperTimerMs / 3 * 2);
3940
} else {
4041
return crossfadeMinDurationLast + crossfadeMinDurationCurrent;
4142
}
@@ -71,17 +72,13 @@ Item {
7172
root.primaryPlayer = true;
7273
videoPlayer1.opacity = 1;
7374
}
74-
75-
if (root.changeWallpaperMode === Enum.ChangeWallpaperMode.OnATimer) {
76-
changeTimer.restart();
77-
}
7875
}
7976
signal setNextSource
8077

8178
Timer {
8279
id: changeTimer
8380
running: root.changeWallpaperMode === Enum.ChangeWallpaperMode.OnATimer && root.player.playing
84-
interval: !running ? 0 : changeWallpaperTimerTime - (root.crossfadeEnabled ? root.crossfadeMinDurationCurrent : 0)
81+
interval: !running ? 0 : root.changeWallpaperTimerMs - (root.crossfadeEnabled ? root.crossfadeMinDurationCurrent : 0)
8582
repeat: true
8683
onTriggered: {
8784
if (root.debugEnabled) {

package/contents/ui/config.qml

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ ColumnLayout {
6363
property alias cfg_RandomMode: randomModeCheckbox.checked
6464
property alias cfg_ResumeLastVideo: resumeLastVideoCheckbox.checked
6565
property alias cfg_ChangeWallpaperMode: changeWallpaperModeComboBox.currentValue
66+
property alias cfg_ChangeWallpaperTimerSeconds: changeWallpaperTimerSecondsSpinBox.value
6667
property alias cfg_ChangeWallpaperTimerMinutes: changeWallpaperTimerMinutesSpinBox.value
6768
property alias cfg_ChangeWallpaperTimerHours: changeWallpaperTimerHoursSpinBox.value
6869
property int currentTab
@@ -72,6 +73,8 @@ ColumnLayout {
7273
property int editingIndex: -1
7374
property var validDropExtensions: [".mp4", ".mpg", ".ogg", ".mov", ".webm", ".flv", ".mkv", ".avi", ".wmv", ".gif"]
7475

76+
readonly property int seconds: (changeWallpaperTimerHoursSpinBox.value * 60 * 60) + (changeWallpaperTimerMinutesSpinBox.value * 60) + changeWallpaperTimerSecondsSpinBox.value
77+
7578
property var muteModeModel: {
7679
// options for desktop and lock screen
7780
let model = [
@@ -333,23 +336,41 @@ ColumnLayout {
333336

334337
RowLayout {
335338
visible: currentTab === 1 && changeWallpaperModeComboBox.currentIndex === Enum.ChangeWallpaperMode.OnATimer
336-
Label {
337-
text: i18n("Hours:")
338-
}
339339
SpinBox {
340340
id: changeWallpaperTimerHoursSpinBox
341341
from: 0
342342
to: 12
343343
stepSize: 1
344-
}
345-
Label {
346-
text: i18n("Minutes:")
344+
textFromValue: function (value, locale) {
345+
return i18np("%1 hour", "%1 hours", value);
346+
}
347+
valueFromText: function (text, locale) {
348+
return parseInt(text);
349+
}
347350
}
348351
SpinBox {
349352
id: changeWallpaperTimerMinutesSpinBox
350-
from: changeWallpaperTimerHoursSpinBox.value > 0 ? 0 : 1
353+
from: 0
351354
to: 59
352355
stepSize: 1
356+
textFromValue: function (value, locale) {
357+
return i18np("%1 minute", "%1 minutes", value);
358+
}
359+
valueFromText: function (text, locale) {
360+
return parseInt(text);
361+
}
362+
}
363+
SpinBox {
364+
id: changeWallpaperTimerSecondsSpinBox
365+
from: root.seconds > 0 ? 0 : 1
366+
to: 59
367+
stepSize: 1
368+
textFromValue: function (value, locale) {
369+
return i18np("%1 second", "%1 seconds", value);
370+
}
371+
valueFromText: function (text, locale) {
372+
return parseInt(text);
373+
}
353374
}
354375
}
355376

package/contents/ui/main.qml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ WallpaperItem {
134134
property bool randomMode: main.configuration.RandomMode
135135
property int lastVideoPosition: main.configuration.LastVideoPosition
136136
property int changeWallpaperMode: main.configuration.ChangeWallpaperMode
137+
property int changeWallpaperTimerSeconds: main.configuration.ChangeWallpaperTimerSeconds
137138
property int changeWallpaperTimerMinutes: main.configuration.ChangeWallpaperTimerMinutes
138139
property int changeWallpaperTimerHours: main.configuration.ChangeWallpaperTimerHours
139140
property bool muteAudio: {
@@ -260,6 +261,7 @@ WallpaperItem {
260261
targetCrossfadeDuration: main.configuration.CrossfadeDuration
261262
debugEnabled: main.debugEnabled
262263
changeWallpaperMode: main.changeWallpaperMode
264+
changeWallpaperTimerSeconds: main.changeWallpaperTimerSeconds
263265
changeWallpaperTimerMinutes: main.changeWallpaperTimerMinutes
264266
changeWallpaperTimerHours: main.changeWallpaperTimerHours
265267
fillMode: main.configuration.FillMode

0 commit comments

Comments
 (0)