Skip to content

Commit c322409

Browse files
committed
style: qmlformat, enums and proper settings aliases
also move video settings dialog to separate component
1 parent 8f0fa92 commit c322409

5 files changed

Lines changed: 213 additions & 236 deletions

File tree

package/contents/ui/FadePlayer.qml

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,21 @@ Item {
2222
property int changeWallpaperMode: Enum.ChangeWallpaperMode.Slideshow
2323
property int changeWallpaperTimerMinutes: 10
2424
property int changeWallpaperTimerHours: 0
25-
property int changeWallpaperTimerTime: (changeWallpaperTimerHours*60+changeWallpaperTimerMinutes)*60*1000
25+
property int changeWallpaperTimerTime: (changeWallpaperTimerHours * 60 + changeWallpaperTimerMinutes) * 60 * 1000
2626
property bool resumeLastVideo: true
2727

2828
// Crossfade must not be longer than the shortest video or the fade becomes glitchy
2929
// we don't know the length until a video gets played, so the crossfade duration
3030
// will decrease below the configured duration if needed as videos get played
3131
// Split the crossfade duration between the two videos. If either video is too short,
3232
// reduce only it's part of the crossfade duration accordingly
33-
property int crossfadeMinDurationLast: Math.min(root.targetCrossfadeDuration/2, otherPlayer.actualDuration/3);
34-
property int crossfadeMinDurationCurrent: Math.min(root.targetCrossfadeDuration/2, player.actualDuration/3);
33+
property int crossfadeMinDurationLast: Math.min(root.targetCrossfadeDuration / 2, otherPlayer.actualDuration / 3)
34+
property int crossfadeMinDurationCurrent: Math.min(root.targetCrossfadeDuration / 2, player.actualDuration / 3)
3535
property int crossfadeDuration: {
36-
if(!root.crossfadeEnabled){
36+
if (!root.crossfadeEnabled) {
3737
return 0;
38-
}else if (root.changeWallpaperMode === Enum.ChangeWallpaperMode.OnATimer){
39-
return Math.min(root.targetCrossfadeDuration, changeWallpaperTimerTime/3*2);
38+
} else if (root.changeWallpaperMode === Enum.ChangeWallpaperMode.OnATimer) {
39+
return Math.min(root.targetCrossfadeDuration, changeWallpaperTimerTime / 3 * 2);
4040
} else {
4141
return crossfadeMinDurationLast + crossfadeMinDurationCurrent;
4242
}
@@ -64,34 +64,33 @@ Item {
6464
videoPlayer2.play();
6565
root.primaryPlayer = false;
6666
videoPlayer1.opacity = 0;
67-
6867
} else {
6968
videoPlayer1.playerSource = root.currentSource;
7069
videoPlayer1.play();
7170
root.primaryPlayer = true;
7271
videoPlayer1.opacity = 1;
7372
}
7473

75-
if(root.changeWallpaperMode === Enum.ChangeWallpaperMode.OnATimer){
74+
if (root.changeWallpaperMode === Enum.ChangeWallpaperMode.OnATimer) {
7675
changeTimer.restart();
7776
}
7877
}
7978
signal setNextSource
8079

81-
Timer{
80+
Timer {
8281
id: changeTimer
8382
running: root.changeWallpaperMode === Enum.ChangeWallpaperMode.OnATimer
8483
interval: !running ? 0 : changeWallpaperTimerTime - (root.crossfadeEnabled ? root.crossfadeMinDurationCurrent : 0)
8584
repeat: true
8685
onTriggered: {
87-
if(root.debugEnabled){
86+
if (root.debugEnabled) {
8887
console.log("Timer triggered, changing wallpaper");
8988
}
9089
root.next(true);
9190
}
9291
onIntervalChanged: {
93-
if(running){
94-
if(root.debugEnabled){
92+
if (running) {
93+
if (root.debugEnabled) {
9594
console.log("Timer started. Interval:", interval);
9695
}
9796
changeTimer.restart();
@@ -113,11 +112,11 @@ Item {
113112
opacity: 1
114113
fillMode: root.fillMode
115114
loops: {
116-
if(!root.multipleVideos || (root.currentSource.loop && !root.crossfadeEnabled))
115+
if (!root.multipleVideos || (root.currentSource.loop && !root.crossfadeEnabled))
117116
return MediaPlayer.Infinite;
118-
else if(root.changeWallpaperMode === Enum.ChangeWallpaperMode.Slideshow)
117+
else if (root.changeWallpaperMode === Enum.ChangeWallpaperMode.Slideshow)
119118
return 1;
120-
else // all other (future) modes
119+
else
121120
return MediaPlayer.Infinite;
122121
}
123122
onPositionChanged: {
@@ -132,8 +131,7 @@ Item {
132131
if ((position / playbackRate) > (actualDuration - root.crossfadeMinDurationCurrent)) {
133132
if (root.changeWallpaperMode === Enum.ChangeWallpaperMode.Slideshow) {
134133
root.next(true);
135-
}
136-
else if (root.changeWallpaperMode === Enum.ChangeWallpaperMode.Never) {
134+
} else if (root.changeWallpaperMode === Enum.ChangeWallpaperMode.Never) {
137135
root.next(false);
138136
}
139137
}
@@ -143,8 +141,7 @@ Item {
143141
if (mediaStatus == MediaPlayer.EndOfMedia) {
144142
if (root.crossfadeEnabled) {
145143
return;
146-
}
147-
else if (root.changeWallpaperMode === Enum.ChangeWallpaperMode.Slideshow) {
144+
} else if (root.changeWallpaperMode === Enum.ChangeWallpaperMode.Slideshow) {
148145
root.next(true);
149146
}
150147
}
@@ -159,8 +156,8 @@ Item {
159156
root.restoreLastPosition = false;
160157
}
161158
}
162-
onLoopsChanged:{
163-
if(primaryPlayer){
159+
onLoopsChanged: {
160+
if (primaryPlayer) {
164161
// needed to correctly update player with new loops value
165162
let pos = videoPlayer1.position;
166163
videoPlayer1.stop();
@@ -176,7 +173,7 @@ Item {
176173
}
177174
}
178175
onOpacityChanged: {
179-
if(opacity === 0 || opacity === 1) {
176+
if (opacity === 0 || opacity === 1) {
180177
// Reset other player source to empty to free resources
181178
otherPlayer.playerSource = Utils.createVideo("");
182179
}
@@ -202,11 +199,11 @@ Item {
202199
z: 1
203200
fillMode: root.fillMode
204201
loops: {
205-
if(!root.multipleVideos || (root.currentSource.loop && !root.crossfadeEnabled))
202+
if (!root.multipleVideos || (root.currentSource.loop && !root.crossfadeEnabled))
206203
return MediaPlayer.Infinite;
207-
else if(root.changeWallpaperMode === Enum.ChangeWallpaperMode.Slideshow)
204+
else if (root.changeWallpaperMode === Enum.ChangeWallpaperMode.Slideshow)
208205
return 1;
209-
else // all other (future) modes
206+
else
210207
return MediaPlayer.Infinite;
211208
}
212209
onPositionChanged: {
@@ -215,12 +212,11 @@ Item {
215212
}
216213
root.lastVideoPosition = position;
217214

218-
if (root.crossfadeEnabled) {
215+
if (root.crossfadeEnabled) {
219216
if ((position / playbackRate) > (actualDuration - root.crossfadeMinDurationCurrent)) {
220217
if (root.changeWallpaperMode === Enum.ChangeWallpaperMode.Slideshow) {
221218
root.next(true);
222-
}
223-
else if (root.changeWallpaperMode === Enum.ChangeWallpaperMode.Never) {
219+
} else if (root.changeWallpaperMode === Enum.ChangeWallpaperMode.Never) {
224220
root.next(false);
225221
}
226222
}
@@ -230,14 +226,13 @@ Item {
230226
if (mediaStatus == MediaPlayer.EndOfMedia) {
231227
if (root.crossfadeEnabled) {
232228
return;
233-
}
234-
else if (root.changeWallpaperMode === Enum.ChangeWallpaperMode.Slideshow) {
229+
} else if (root.changeWallpaperMode === Enum.ChangeWallpaperMode.Slideshow) {
235230
root.next(true);
236231
}
237232
}
238233
}
239-
onLoopsChanged:{
240-
if(!primaryPlayer){
234+
onLoopsChanged: {
235+
if (!primaryPlayer) {
241236
// needed to correctly update player with new loops value
242237
let pos = videoPlayer2.position;
243238
videoPlayer2.stop();
@@ -278,7 +273,7 @@ Item {
278273
text: "crossfade " + root.crossfadeEnabled
279274
}
280275
PlasmaComponents.Label {
281-
text: "crossfadeDuration " + root.crossfadeDuration+ " ("+root.crossfadeMinDurationLast+", "+root.crossfadeMinDurationCurrent+")"
276+
text: "crossfadeDuration " + root.crossfadeDuration + " (" + root.crossfadeMinDurationLast + ", " + root.crossfadeMinDurationCurrent + ")"
282277
}
283278
PlasmaComponents.Label {
284279
text: "multipleVideos " + root.multipleVideos

package/contents/ui/code/enum.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,33 @@ const MuteOverride = {
1010
Default: 2,
1111
};
1212

13-
// Keep this list in sync with config.qml
1413
const ChangeWallpaperMode = {
1514
Never: 0,
1615
Slideshow: 1,
1716
OnATimer: 2,
18-
};
17+
};
18+
19+
const PauseMode = {
20+
MaximizedOrFullScreen: 0,
21+
ActiveWindowPresent: 1,
22+
WindowVisible: 2,
23+
Never: 3
24+
};
25+
26+
const BlurMode = {
27+
MaximizedOrFullScreen: 0,
28+
ActiveWindowPresent: 1,
29+
WindowVisible: 2,
30+
VideoPaused: 3,
31+
Always: 4,
32+
Never: 5
33+
};
34+
35+
const MuteMode = {
36+
MaximizedOrFullScreen: 0,
37+
ActiveWindowPresent: 1,
38+
WindowVisible: 2,
39+
AnotherAppPlayingAudio: 3,
40+
Never: 4,
41+
Always: 5,
42+
};
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import QtQuick
2+
import QtQuick.Controls
3+
import QtQuick.Layouts
4+
import org.kde.kirigami as Kirigami
5+
6+
Kirigami.Dialog {
7+
id: root
8+
standardButtons: Kirigami.Dialog.Ok | Kirigami.Dialog.Cancel
9+
title: i18n("Video Settings")
10+
padding: Kirigami.Units.largeSpacing
11+
12+
property int index
13+
property real playbackRate
14+
property bool loop
15+
property string filename: ""
16+
17+
Kirigami.FormLayout {
18+
Label {
19+
text: root.filename
20+
}
21+
RowLayout {
22+
Kirigami.FormData.label: i18n("Playback speed:")
23+
Slider {
24+
id: dialogPlaybackRateSpeed
25+
from: 0
26+
to: 2
27+
stepSize: 0.05
28+
value: root.playbackRate
29+
onValueChanged: {
30+
root.playbackRate = value;
31+
}
32+
Layout.preferredWidth: 200
33+
}
34+
Label {
35+
text: parseFloat(dialogPlaybackRateSpeed.value).toFixed(2) + "x"
36+
font.features: {
37+
"tnum": 1
38+
}
39+
}
40+
Button {
41+
icon.name: "edit-undo-symbolic"
42+
flat: true
43+
onClicked: {
44+
dialogPlaybackRateSpeed.value = 0.0;
45+
}
46+
ToolTip.text: i18n("Reset to default")
47+
ToolTip.visible: hovered
48+
}
49+
Kirigami.ContextualHelpButton {
50+
toolTipText: i18n("Playback speed for this video. Set 0.0 to disable")
51+
}
52+
}
53+
RowLayout {
54+
Kirigami.FormData.label: i18n("Loop:")
55+
CheckBox {
56+
checked: root.loop
57+
onCheckedChanged: root.loop = checked
58+
}
59+
Kirigami.ContextualHelpButton {
60+
toolTipText: i18n("If enabled the video will loop continuously instead of playing the next one.<br>Use the <strong>Next Video</strong> option to play the next video in the list.")
61+
}
62+
}
63+
}
64+
}

0 commit comments

Comments
 (0)