-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.qml
More file actions
2026 lines (1789 loc) · 101 KB
/
Copy pathMain.qml
File metadata and controls
2026 lines (1789 loc) · 101 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ============================================================
// Theme : aurora-greeter
// Author : Biryukov Nikita (@execorn)
// License : CC-BY-SA-4.0 / MIT
// ============================================================
import QtQuick
import QtQuick.Controls
import QtMultimedia
import SddmComponents
import Qt.labs.settings 1.0
import "components"
Item {
id: root
// Unique ID for this screen instance
readonly property string screenId: "screen_" + (typeof primaryScreen !== "undefined" && primaryScreen ? "PRIMARY" : "AUX") + "_" + Math.random().toString(36).substr(2, 5) + "_" + Screen.width + "x" + Screen.height
readonly property bool isPrimary: typeof primaryScreen !== "undefined" && primaryScreen
// ── Per-monitor geometry ─────────────────────────────────────────────
width: Screen.width
height: Screen.height
// focus: true ensures this root Item always receives keyboard events.
// SDDM greeter has no window manager, so Qt.ApplicationShortcut never
// fires — we rely on Keys.onPressed on the permanently-focused root.
focus: true
LayoutMirroring.enabled: Qt.locale().textDirection === Qt.RightToLeft
LayoutMirroring.childrenInherit: true
// ─────────────────────────────────────────────────────────────────────
// PERSISTENT SETTINGS — pure QML/JS, no QtCore.Settings required
//
// Reads from / writes to an INI file at:
// /var/lib/sddm/.config/AuroraGreeter/settings.conf
//
// The sddm system user must own that directory with write access.
// install.sh creates it with chown sddm:sddm + chmod 750.
//
// Call persist.sync() after writing any property to flush to disk.
// ─────────────────────────────────────────────────────────────────────
QtObject {
id: persist
// Heuristic to detect system mode vs local dev
readonly property bool _isSystemMode: Qt.resolvedUrl(".").toString().startsWith("file:///usr/share/sddm/themes/")
// ── Config file location ──────────────────────────────────────
property string _configPath: _isSystemMode
? "file:///var/lib/sddm/.config/AuroraGreeter/settings.conf"
: Qt.resolvedUrl("settings.conf").toString()
// Linux-only: strips file:// prefix leaving the leading / for absolute paths.
// On Linux, file:///path → /path (correct). Not portable to Windows.
property string _configPathRaw: _configPath.replace(/^file:\/\//, "")
// ── Live properties ───────────────────────────────────────────
property string activePlaylist: "playlists/Background.mp4"
property string activeMultiMonitorMode: "primary-only"
property string clockFormat: "24h"
property real loginCardOpacity: 0.85
property string accentColor: "#89b4fa"
// Backdrop type: "video" | "image" | "slideshow" | "color"
property string activeBackgroundType: "video"
// Slideshow interval in seconds (5–60)
property int slideshowInterval: 15
// Solid background colour used when activeBackgroundType === "color"
property string backgroundColor: "#1e1e2e"
// [v4] Separate source for image / slideshow modes.
// NEVER set this to a video M3U — Image {} cannot render .mov.
// Defaults to the bundled fallback image which is always present.
property string activeMediaSource: "backgrounds/background.jpg"
// [v4] Performance profile: "auto" | "high" | "low"
// auto — screen-adaptive resolution cap (≤1920 px wide → 2K URLs)
// high — always use source URLs unchanged; full animation durations
// low — force 2K, reduced animation durations (less GPU compositing)
property string performanceMode: "auto"
// [v5] Day/night scheduling toggle: true = time-based, false = manual/hardcoded
property bool useDayNightSchedule: true
// Indicator if the configuration file was loaded and parsed successfully from disk
property bool _loaded: false
// Simple INI file parser
function _parseIni(text) {
var numericKeys = ["loginCardOpacity", "slideshowInterval"]
var booleanKeys = ["useDayNightSchedule"]
var lines = text.split("\n");
var data = {};
for (var i = 0; i < lines.length; i++) {
var line = lines[i].trim();
if (line.startsWith("[") || line === "" || line.startsWith("#") || line.startsWith(";")) {
continue;
}
var parts = line.split("=");
if (parts.length >= 2) {
var key = parts[0].trim();
var val = parts.slice(1).join("=").trim();
// Type coercion based on known key types
if (booleanKeys.indexOf(key) !== -1) {
val = (val.toLowerCase() === "true")
} else if (numericKeys.indexOf(key) !== -1 && val !== "" && !isNaN(val)) {
if (val.indexOf(".") !== -1) val = parseFloat(val);
else val = parseInt(val, 10);
}
// All other keys remain as strings (including colours, paths, etc.)
data[key] = val;
}
}
return data;
}
// ── load(): read INI from disk, overwrite properties ──────────
// Called once from Component.onCompleted.
function load() {
var xhr = new XMLHttpRequest()
xhr.open("GET", _configPath, false)
try {
xhr.send()
} catch(e) {
console.info("[AuroraGreeter] No settings file yet (first boot?) —",
_configPath, "| Using defaults.")
return
}
if (xhr.status !== 0 && xhr.status !== 200) {
console.info("[AuroraGreeter] Settings file not readable (status",
xhr.status, ") — using defaults.")
return
}
if (!xhr.responseText || xhr.responseText.trim() === "") {
console.info("[AuroraGreeter] Settings file empty — using defaults.")
return
}
try {
var data = _parseIni(xhr.responseText)
if (typeof data.activePlaylist === "string") activePlaylist = data.activePlaylist
if (typeof data.activeMultiMonitorMode === "string") activeMultiMonitorMode = data.activeMultiMonitorMode
if (typeof data.clockFormat === "string") clockFormat = data.clockFormat
if (typeof data.loginCardOpacity === "number") loginCardOpacity = data.loginCardOpacity
if (typeof data.accentColor === "string") accentColor = data.accentColor
if (typeof data.activeBackgroundType === "string") activeBackgroundType = data.activeBackgroundType
if (typeof data.slideshowInterval === "number") slideshowInterval = data.slideshowInterval
if (typeof data.backgroundColor === "string") backgroundColor = data.backgroundColor
if (typeof data.activeMediaSource === "string") activeMediaSource = data.activeMediaSource
if (typeof data.performanceMode === "string") performanceMode = data.performanceMode
var hasCustomPlaylist = (typeof data.activePlaylist === "string" && data.activePlaylist !== "playlists/Background.mp4")
if (typeof data.useDayNightSchedule === "boolean") {
useDayNightSchedule = data.useDayNightSchedule
} else {
useDayNightSchedule = !hasCustomPlaylist
}
_loaded = true
console.log("[AuroraGreeter] Settings loaded from:", _configPath)
} catch(e) {
console.warn("[AuroraGreeter] Settings INI parse error:", e)
}
}
// ── sync(): write current property values back to disk ────────
// Called by ConfigDrawer whenever the user changes a setting.
function sync() {
settingsStore.activePlaylist = activePlaylist
settingsStore.activeMultiMonitorMode = activeMultiMonitorMode
settingsStore.clockFormat = clockFormat
settingsStore.loginCardOpacity = loginCardOpacity
settingsStore.accentColor = accentColor
settingsStore.activeBackgroundType = activeBackgroundType
settingsStore.slideshowInterval = slideshowInterval
settingsStore.backgroundColor = backgroundColor
settingsStore.activeMediaSource = activeMediaSource
settingsStore.performanceMode = performanceMode
settingsStore.useDayNightSchedule = useDayNightSchedule
settingsStore.sync()
}
}
Settings {
id: settingsStore
fileName: persist._configPathRaw
property string activePlaylist
property string activeMultiMonitorMode
property string clockFormat
property real loginCardOpacity
property string accentColor
property string activeBackgroundType
property int slideshowInterval
property string backgroundColor
property string activeMediaSource
property string performanceMode
property bool useDayNightSchedule
}
// ─────────────────────────────────────────────────────────────────────
// ROOT-LEVEL BRIDGING PROPERTIES
//
// Single source of truth for every child component and the
// ConfigDrawer. Writing to persist.* propagates here via
// the property binding engine; children that read root.* update
// automatically.
// ─────────────────────────────────────────────────────────────────────
property string activePlaylist: persist.activePlaylist
property string activeMultiMonitorMode: persist.activeMultiMonitorMode
property string clockFormat: persist.clockFormat
property real loginCardOpacity: persist.loginCardOpacity
property string accentColor: persist.accentColor
// Backdrop engine bridging
property string activeBackgroundType: persist.activeBackgroundType
property int slideshowInterval: persist.slideshowInterval
property string backgroundColor: persist.backgroundColor
// [v4] Separate image/slideshow source (never a video M3U)
property string activeMediaSource: persist.activeMediaSource
// [v4] Performance profile bridging
property string performanceMode: persist.performanceMode
// [v5] Day/night scheduling toggle bridging
property bool useDayNightSchedule: persist.useDayNightSchedule
// ─────────────────────────────────────────────────────────────────────
// PERFORMANCE PROFILE — COMPUTED ANIMATION DURATIONS [v4]
//
// All Behavior blocks read from these computed properties so that
// switching the performance profile in ConfigDrawer hot-updates
// every animation in the theme simultaneously.
//
// "low" → shorter durations (less GPU compositing per frame)
// "high" → cinematic durations (best visual quality)
// "auto" → same as "high" (auto only affects resolution, not animation)
//
// Duration map:
// _animDuration — primary opacity crossfade (image/slideshow/video)
// _fastAnimDuration — UI elements, colour swaps, dim overlay
// _colorAnimDuration— ColorAnimation blocks (accent, background color)
// _swapDelay — _swapSlideshowLayers timer: must be > _animDuration
// ─────────────────────────────────────────────────────────────────────
// Whether the effective (resolved) mode is "low".
// "auto" resolves to "low" when this screen is ≤ 1920 px wide.
// "low" is always low. "high" is always high.
readonly property bool _isLowPerf: {
if (root.performanceMode === "low") return true
if (root.performanceMode === "auto") return Screen.width <= 1920
return false // "high"
}
// Primary crossfade duration: video reveal, image fade, slideshow dissolve
readonly property int _animDuration: _isLowPerf ? 300 : 800
// Secondary animation duration: dim overlay, UI opacity
readonly property int _fastAnimDuration: _isLowPerf ? 150 : 500
// Colour transition duration: accent changes, background color swaps
readonly property int _colorAnimDuration: _isLowPerf ? 150 : 400
// Video surface reveal (intentionally slower for cinematic feel in high)
readonly property int _videoFadeDuration: _isLowPerf ? 400 : 1200
// Background color swap (solidBlack.color in color mode)
readonly property int _bgColorDuration: _isLowPerf ? 200 : 600
// _swapSlideshowLayers fires after the crossfade finishes.
// Must be slightly longer than _animDuration so the swap is invisible.
readonly property int _swapDelay: _animDuration + 20
// ─────────────────────────────────────────────────────────────────────
// MULTI-MONITOR MODE
//
// Priority: persist.activeMultiMonitorMode → config.multiMonitorMode
// → "mirror" (hard default)
//
// Accepted values:
// "mirror" – video + UI on every connected screen
// "primary-only" – video on all screens; UI on primary only
// "blank-auxiliary" – primary gets video + UI;
// auxiliary screens render solid black
// ─────────────────────────────────────────────────────────────────────
readonly property string monitorMode: {
var saved = root.activeMultiMonitorMode
if (saved !== "" && saved !== undefined) return saved
var cfgVal = (typeof config.multiMonitorMode !== "undefined")
? config.multiMonitorMode : ""
if (cfgVal !== "") return cfgVal
return "mirror"
}
// Whether THIS screen instance should render the video background
readonly property bool showBackground: (monitorMode !== "blank-auxiliary") || primaryScreen
// Whether THIS screen instance should render the login UI
readonly property bool showUI: (monitorMode === "mirror") || primaryScreen
// ─────────────────────────────────────────────────────────────────────
// BACKDROP MODE SHORTCUTS (read by the layer stack below)
// ─────────────────────────────────────────────────────────────────────
readonly property bool _modeVideo: root.activeBackgroundType === "video"
readonly property bool _modeImage: root.activeBackgroundType === "image"
readonly property bool _modeSlideshow: root.activeBackgroundType === "slideshow"
readonly property bool _modeColor: root.activeBackgroundType === "color"
// ─────────────────────────────────────────────────────────────────────
// CROSS-BOUNDARY STATE
// ─────────────────────────────────────────────────────────────────────
property string loginErrorText: ""
property color loginErrorColor: "white"
property bool uiVisible: false
// Playlist runtime state (video mode + slideshow mode share the parsed list)
property var playlistEntries: []
property int playlistIndex: 0
// ─────────────────────────────────────────────────────────────────────
// SLIDESHOW INTERNAL STATE
//
// _ssEntries — parsed image paths for the slideshow playlist.
// _ssIndex — index of the currently visible image.
// _ssFront — which image element is currently "front" (visible).
// true → fallbackImage is front, slideshowBufferImage is back.
// false → slideshowBufferImage is front, fallbackImage is back.
//
// The crossfade works by:
// 1. Loading next image into the hidden (back) element.
// 2. Waiting for Image.Ready on the back element.
// 3. Animating front opacity to 0 (reveals the back).
// 4. _swapSlideshowLayers fires after _swapDelay ms and swaps
// source/roles so the elements cycle without a visible flash.
// ─────────────────────────────────────────────────────────────────────
property var _ssEntries: []
property int _ssIndex: 0
property bool _ssFront: true // true = fallbackImage is the visible front
// Guard flag: true while _reloadPlaylist() is in progress.
// Suppresses the NoMedia status signal's _activateImageFallback() call
// that fires between backgroundVideo.stop() and the new source being set.
// Cleared in onMediaStatusChanged when BufferedMedia fires (or on error).
property bool _videoReloading: false
// ─────────────────────────────────────────────────────────────────────
// SDDM BINDINGS
// ─────────────────────────────────────────────────────────────────────
TextConstants { id: textConstants }
// In Qt6, FontLoader.name is a READ-ONLY output property (the detected
// family after loading a font file). config.displayFont is already a
// font-family name string, so no loading is needed — expose it directly
// via a plain QtObject so that all existing displayFont.name references
// in child items continue to work without modification.
QtObject {
id: displayFont
readonly property string name: (typeof config !== "undefined" &&
typeof config.displayFont !== "undefined" &&
config.displayFont !== "")
? config.displayFont
: "sans-serif"
}
Connections {
target: sddm
function onLoginSucceeded() {
// The compositor will destroy the greeter — no action needed.
}
function onLoginFailed() {
root.loginErrorColor = "#dc322f"
root.loginErrorText = textConstants.loginFailed
}
}
// ─────────────────────────────────────────────────────────────────────
// BACKGROUND LAYER STACK (z-order 0 → 3, back to front)
//
// Layer assignments:
// z 0 solidBlack — always present; colour canvas / "color" mode
// z 1 slideshowBufferImg — slideshow back buffer (hidden when not in use)
// z 2 fallbackImage — static image / slideshow front; video fallback
// z 3 videoSurface — video output (invisible outside "video" mode)
//
// Only the active mode's layer(s) are visible. All other layers have
// opacity 0 and visible: false so the GPU skips rasterising them.
// ─────────────────────────────────────────────────────────────────────
// ── Layer 0: Solid canvas — also the "color" mode backdrop ───────────
//
// In "color" mode this is the only visible layer. Its color property
// is bound to persist.backgroundColor so it hot-updates from the drawer.
// In all other modes it remains black and is covered by higher layers.
Rectangle {
id: solidBlack
anchors.fill: parent
z: 0
// Bind to the persisted backgroundColor in color-mode;
// fall back to black in all other modes.
color: root._modeColor ? root.backgroundColor : "black"
// Smooth transition when the user changes color-mode background.
// Duration is profile-aware: shorter in "low" mode.
Behavior on color {
ColorAnimation { duration: root._bgColorDuration; easing.type: Easing.InOutQuad }
}
}
// ── Layer 1: Slideshow back-buffer image ──────────────────────────────
//
// This layer is only active during "slideshow" mode. It sits behind
// fallbackImage (the front) and receives the next image while the
// current one is still visible. The crossfade is achieved by fading
// fallbackImage's opacity to 0, revealing this element, then swapping
// sources so the two layers swap roles without a visible stutter.
Image {
id: slideshowBufferImage
anchors.fill: parent
fillMode: Image.PreserveAspectCrop
asynchronous: true
cache: false
z: 1
// Only rendered during slideshow mode and only on screens that
// should show a background at all.
visible: root.showBackground && root._modeSlideshow
opacity: 0 // always starts hidden; crossfade logic drives opacity
// No Behavior here: this layer must snap to full opacity instantly
// after the crossfade swap so the front layer can re-hide behind it.
// Note: crossfade-out when this is the front (L648-652) is instant (no Behavior),
// while crossfade-out of fallbackImage is animated. This asymmetry is intentional.
}
// ── Layer 2: Static image / slideshow front / video fallback ─────────
//
// Multi-purpose image layer:
// "image" → rendered at full opacity, fills screen.
// "slideshow" → the currently visible slide (front buffer).
// "video" → emergency fallback if MediaPlayer fails.
// "color" → opacity 0 (not shown).
Image {
id: fallbackImage
anchors.fill: parent
fillMode: Image.PreserveAspectCrop
asynchronous: true
cache: false
z: 2
// Visible in image/slideshow mode and as the video fallback.
// Invisible in color mode (solidBlack handles the backdrop).
visible: root.showBackground && !root._modeColor
opacity: 0
// Duration bound to performance profile.
Behavior on opacity {
NumberAnimation { duration: root._animDuration; easing.type: Easing.InOutQuad }
}
onStatusChanged: {
if (status === Image.Error) {
console.warn("[AuroraGreeter] Image load failed:", source,
"\u2014 solid black background will be used.")
}
// Reveal in image mode
if (status === Image.Ready && root._modeImage) {
opacity = 1.0
}
// Reveal as slideshow front buffer (when _ssFront === true)
// This fires when _initSlideshow() loads the first image.
if (status === Image.Ready && root._modeSlideshow && root._ssFront) {
opacity = 1.0
}
}
}
// ─────────────────────────────────────────────────────────────────────
// SINGLE-PIPELINE VIDEO ENGINE
//
// Only active when activeBackgroundType === "video".
// In all other modes the player is stopped and stays at source: ""
// so no decode threads, no VRAM upload, no GPU load.
// ─────────────────────────────────────────────────────────────────────
MediaPlayer {
id: backgroundVideo
loops: MediaPlayer.Infinite
// NOTE: No audioOutput attached — intentionally omitted.
// SDDM's greeter runs under a restricted user with no audio
// device access. Even a muted AudioOutput { volume: 0 } forces
// Qt6 Multimedia / GStreamer to negotiate a PipeWire/ALSA
// pipeline, which triggers a fatal SIGSEGV (spaVisitChoice
// null-pointer dereference) inside the sandboxed session.
// Omitting the property entirely prevents Qt from allocating
// any audio pipeline.
videoOutput: videoSurface
onMediaStatusChanged: {
console.log("[Aurora] MediaPlayer status:", mediaStatus,
"| src:", source.toString().split("/").pop(),
"| playbackState:", playbackState,
"| reloading:", root._videoReloading)
// Guard: ignore status changes when not in video mode
if (!root._modeVideo) return
switch (mediaStatus) {
case MediaPlayer.LoadingMedia:
// Normal; pipeline is buffering the new source.
break
case MediaPlayer.LoadedMedia:
// Fires for local files when the first frame is decoded —
// on many GStreamer backends BufferedMedia never follows for
// local sources, so we must reveal here as well.
console.log("[Aurora] Video loaded (LoadedMedia) — revealing surface")
root._videoReloading = false
videoSurface.opacity = 1.0
break
case MediaPlayer.BufferedMedia:
// New track fully buffered — animate the surface back in.
// Also fires for network streams after initial buffering.
console.log("[Aurora] Video buffered (BufferedMedia) — revealing surface")
root._videoReloading = false
videoSurface.opacity = 1.0
break
case MediaPlayer.NoMedia:
// Fires during hot-reload between stop() and new source being set.
// _videoReloading suppresses false _activateImageFallback() calls.
if (root._videoReloading) {
console.log("[Aurora] NoMedia during reload — suppressing fallback")
break
}
console.warn("[Aurora] Video: NoMedia — no source set.")
_activateImageFallback()
break
case MediaPlayer.InvalidMedia:
// ALWAYS clear the reload guard so the next attempt can proceed.
// Also reset source to "" to put the Qt6 pipeline back into
// a clean NoMedia state — without this the player ignores
// subsequent play() calls after a failed source.
console.warn("[Aurora] Video source invalid or missing:", source)
root._videoReloading = false
backgroundVideo.source = ""
_activateImageFallback()
break
default:
break
}
}
onErrorOccurred: function(error, errorString) {
if (!root._modeVideo) return
console.warn("[Aurora] MediaPlayer error (code", error, "):", errorString)
// Clear the reload guard and reset player state (same reason as InvalidMedia).
root._videoReloading = false
Qt.callLater(function() { backgroundVideo.source = "" })
_activateImageFallback()
}
onPlaybackStateChanged: {
console.log("[Aurora] MediaPlayer playbackState →", playbackState,
"| src:", source.toString().split("/").pop())
}
}
// ── Layer 3: Video surface ────────────────────────────────────────────
//
// Only visible in video mode. Opacity is animated:
// • fades to 0 when a track swap begins (_reloadPlaylist)
// • fades back to 1.0 once MediaPlayer.BufferedMedia fires
VideoOutput {
id: videoSurface
anchors.fill: parent
fillMode: VideoOutput.PreserveAspectCrop
z: 3
// Visible only in video mode and only on screens that show backgrounds.
visible: root.showBackground && root._modeVideo
opacity: 0
// Duration bound to performance profile.
// Intentionally slower than _animDuration for a cinematic reveal in
// "high" mode; still visible (400 ms) in "low" mode.
Behavior on opacity {
NumberAnimation { duration: root._videoFadeDuration; easing.type: Easing.InOutQuad }
}
}
// ─────────────────────────────────────────────────────────────────────
// SLIDESHOW TIMER
//
// Fires every slideshowInterval seconds. On each tick it:
// 1. Picks the next image path from _ssEntries.
// 2. Loads it into the back-buffer image element.
// 3. The back-buffer's onStatusChanged starts the crossfade
// once the image is decoded and ready.
//
// The timer is only running when activeBackgroundType === "slideshow"
// and _ssEntries has at least two entries.
// ─────────────────────────────────────────────────────────────────────
Timer {
id: slideshowTimer
// Interval is bound live to the persisted setting so changing the
// slider in ConfigDrawer takes effect at the next tick.
interval: root.slideshowInterval * 1000
repeat: true
running: false // started/stopped by _initSlideshow / mode guards
onTriggered: {
if (!root._modeSlideshow || root._ssEntries.length === 0) {
stop()
return
}
_advanceSlideshow()
}
}
// ─────────────────────────────────────────────────────────────────────
// SLIDESHOW BACK-BUFFER READY HANDLER
//
// When slideshowBufferImage finishes loading its next source we start
// the opacity crossfade. Using a Connections block rather than an
// inline onStatusChanged on the element itself keeps the crossfade
// logic in one place alongside the Timer code.
// ─────────────────────────────────────────────────────────────────────
Connections {
target: slideshowBufferImage
function onStatusChanged() {
if (!root._modeSlideshow) return
if (slideshowBufferImage.status !== Image.Ready) return
// The next image is decoded. Perform the crossfade.
if (root._ssFront) {
// fallbackImage is the front → fade it out to reveal the buffer
fallbackImage.opacity = 0
// After the opacity animation completes, swap roles.
// _swapSlideshowLayers.interval is bound to root._swapDelay.
_swapSlideshowLayers.start()
} else {
// slideshowBufferImage is the front → fade it out.
// Reveal fallbackImage by fading out slideshowBufferImage.
slideshowBufferImage.opacity = 0
_swapSlideshowLayers.start()
}
}
}
// Short timer that fires after the crossfade opacity animation ends.
// Its interval is bound to root._swapDelay (= _animDuration + 20) so it
// always trails the fallbackImage Behavior regardless of performance profile.
Timer {
id: _swapSlideshowLayers
// Bound to the computed swap delay so profile changes update it live.
interval: root._swapDelay
repeat: false
running: false
onTriggered: {
if (!root._modeSlideshow) return
if (root._ssFront) {
// Swap: make the buffer the new front.
// 1. Bring buffer to full opacity instantly (no Behavior on it).
slideshowBufferImage.opacity = 1.0
// 2. fallbackImage is now fully hidden — sync its source to
// the same image so it becomes the idle back-buffer.
fallbackImage.source = slideshowBufferImage.source
fallbackImage.opacity = 0 // keep hidden; next cycle it's the buffer
root._ssFront = false
} else {
// Swap: make fallbackImage the new front again.
// 1. fallbackImage already has the new image loaded (back-buffer role)
// and is at opacity 0 — reveal it.
fallbackImage.opacity = 1.0
// 2. Buffer is now hidden — sync its source so next cycle is ready.
slideshowBufferImage.source = fallbackImage.source
slideshowBufferImage.opacity = 0
root._ssFront = true
}
}
}
// ─────────────────────────────────────────────────────────────────────
// INTERACTION CAPTURE LAYER (z 4)
// ─────────────────────────────────────────────────────────────────────
MouseArea {
id: globalMouseArea
anchors.fill: parent
z: 4
propagateComposedEvents: true
onPressed: function(mouse) {
_revealUI()
if (config.autofocusInput === "true") {
_focusAppropriateInput()
}
mouse.accepted = false
}
}
// ─────────────────────────────────────────────────────────────────────
// GLOBAL KEYBOARD SHORTCUT (Alt+S / Super+S — toggle Config Drawer)
//
// WHY Keys.onPressed instead of Shortcut {}:
// Qt's Shortcut { context: Qt.ApplicationShortcut } requires the platform
// window manager to deliver a "window activated" event. SDDM runs its
// greeter WITHOUT a traditional window manager (it is the only client on
// the X11 display / Wayland compositor). As a result Qt never marks the
// greeter window as "active" in the WM sense, so ApplicationShortcut
// silently absorbs the key event (preventing the 's' from typing) but
// never fires onActivated.
//
// The correct pattern for SDDM themes is to hold permanent focus on the
// root Item with focus:true (not just on primaryScreen) and intercept
// Alt+S in Keys.onPressed. We set event.accepted = true for the
// shortcut so it doesn't fall through to any focused child, and leave it
// false for all other keys so normal typing is unaffected.
// ─────────────────────────────────────────────────────────────────────
Keys.onPressed: function(event) {
var isAlt = (event.modifiers & Qt.AltModifier) !== 0
var isMeta = (event.modifiers & Qt.MetaModifier) !== 0
var isS = (event.key === Qt.Key_S)
if ((isAlt || isMeta) && isS) {
if (root.isPrimary)
configDrawer.toggle()
event.accepted = true // consume — do NOT forward to text inputs
return
}
// All other keys: reveal the login UI (e.g. user starts typing).
// Do NOT accept — let the key propagate to the focused child input.
_revealUI()
}
// ─────────────────────────────────────────────────────────────────────
// DIM OVERLAY (z 5)
// ─────────────────────────────────────────────────────────────────────
Rectangle {
id: dimOverlay
anchors.fill: parent
color: Qt.rgba(0, 0, 0, 0.50)
opacity: root.uiVisible ? 1.0 : 0.0
// Hide entirely in "blank-auxiliary" mode on non-primary screens
visible: root.showBackground || root._modeColor
z: 5
// Duration bound to performance profile.
Behavior on opacity {
NumberAnimation { duration: root._fastAnimDuration; easing.type: Easing.InOutQuad }
}
}
// ─────────────────────────────────────────────────────────────────────
// UI LOADER (z 6)
// ─────────────────────────────────────────────────────────────────────
Loader {
id: uiLoader
anchors.fill: parent
z: 6
active: root.showUI
sourceComponent: loginUIComponent
}
// ─────────────────────────────────────────────────────────────────────
// LOGIN UI COMPONENT
// ─────────────────────────────────────────────────────────────────────
Component {
id: loginUIComponent
Item {
id: loginUI
anchors.fill: parent
// Duration bound to performance profile.
opacity: root.uiVisible ? 1.0 : 0.0
Behavior on opacity {
NumberAnimation { duration: root._fastAnimDuration; easing.type: Easing.InOutQuad }
}
readonly property bool showLoginBtn: config.showLoginButton !== "false"
function focusAppropriateInput() {
if (usernameInput.text === "")
usernameInput.forceActiveFocus()
else
passwordInput.forceActiveFocus()
}
// ── Clock ─────────────────────────────────────────────────────
Clock {
id: clock
x: parent.width * config.relativePositionX - clock.width / 2
y: parent.height * config.relativePositionY - clock.height / 2
color: "white"
timeFont.family: displayFont.name
dateFont.family: displayFont.name
clockFormat: root.clockFormat
}
// ── Login Container ───────────────────────────────────────────
Item {
id: loginContainer
// Centre the login block on the same horizontal axis as the
// clock regardless of how wide the clock is. Previously
// anchors.left: clock.left caused right-shift on wide clocks.
anchors.horizontalCenter: clock.horizontalCenter
y: clock.y + clock.height + 30
width: Math.max(clock.implicitWidth, 360)
height: loginColumn.implicitHeight
Column {
id: loginColumn
anchors.left: parent.left
anchors.right: parent.right
spacing: 10
// ── Username Row ──────────────────────────────────────
Item {
id: usernameRow
width: parent.width
height: 40
Text {
id: usernameLabel
anchors {
left: parent.left
verticalCenter: parent.verticalCenter
}
width: 90
text: "Username"
horizontalAlignment: Text.AlignLeft
font.family: displayFont.name
font.bold: true
font.pixelSize: 14
color: "white"
elide: Text.ElideRight
}
TextBox {
id: usernameInput
anchors {
left: usernameLabel.right
leftMargin: config.usernameLeftMargin
right: parent.right
verticalCenter: parent.verticalCenter
}
height: parent.height
text: userModel.lastUser
focus: primaryScreen
font: displayFont.name
color: "#25000000"
borderColor: "transparent"
textColor: "white"
accentColor: root.accentColor
Keys.onPressed: function(event) {
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
sddm.login(usernameInput.text,
passwordInput.text,
sessionCombo.index)
event.accepted = true
}
}
KeyNavigation.backtab: passwordInput
KeyNavigation.tab: passwordInput
}
}
// ── Password Row ──────────────────────────────────────
Item {
id: passwordRow
width: parent.width
height: 40
Text {
id: passwordLabel
anchors {
left: parent.left
verticalCenter: parent.verticalCenter
}
width: 90
text: textConstants.password
horizontalAlignment: Text.AlignLeft
font.family: displayFont.name
font.bold: true
font.pixelSize: 14
color: "white"
elide: Text.ElideRight
}
PasswordBox {
id: passwordInput
anchors {
left: passwordLabel.right
leftMargin: config.passwordLeftMargin
right: parent.right
rightMargin: loginUI.showLoginBtn ? parent.height + 4 : 0
verticalCenter: parent.verticalCenter
}
height: parent.height
font: displayFont.name
color: "#25000000"
borderColor: "transparent"
textColor: "white"
tooltipBG: "#25000000"
tooltipFG: "#dc322f"
image: Qt.resolvedUrl("components/resources/warning_red.png")
accentColor: root.accentColor
errorText: root.loginErrorText
onTextChanged: {
clearPasswdButton.visible =
(passwordInput.text !== "" &&
config.showClearPasswordButton !== "false")
}
Keys.onPressed: function(event) {
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
sddm.login(usernameInput.text,
passwordInput.text,
sessionCombo.index)
event.accepted = true
}
}
KeyNavigation.backtab: usernameInput
KeyNavigation.tab: loginButton
}
// Clear password button (×)
Button {
id: clearPasswdButton
visible: false
anchors {
right: loginUI.showLoginBtn ? loginButton.left : parent.right
rightMargin: 4
verticalCenter: parent.verticalCenter
}
height: parent.height
width: parent.height
text: "x"
font: displayFont.name
color: "transparent"
border.color: "transparent"
border.width: 0
disabledColor: "#dc322f"
activeColor: "#393939"
pressedColor: "#2aa198"
onClicked: {
passwordInput.text = ""
passwordInput.forceActiveFocus()
}
}
// Login button — modern accent pill with arrow icon
Rectangle {
id: loginButton
visible: loginUI.showLoginBtn
anchors {
right: parent.right
verticalCenter: parent.verticalCenter
}
height: parent.height
width: parent.height // square → circle via radius
radius: height / 2
// ── Accent gradient fill ─────────────────────
readonly property color _accent: root.accentColor
readonly property bool _hovered: loginMa.containsMouse && enabled
readonly property bool _pressed: loginMa.pressed && enabled
color: {
if (!enabled) return Qt.rgba(0.86, 0.19, 0.18, 0.75) // #dc322f disabled
if (_pressed) return Qt.darker(_accent, 1.22)
if (_hovered) return Qt.lighter(_accent, 1.15)