11import QtQuick
22import QtCore
3+ import Qt.labs.folderlistmodel
34
45SnapshotSettingsForm {
56 property alias flashEnabled: settings .flashEnabled
@@ -9,6 +10,7 @@ SnapshotSettingsForm {
910 property alias backgroundFilterEnabled: settings .backgroundFilterEnabled
1011 property alias chromaKeyEnabled: settings .chromaKeyEnabled
1112 property alias chromaKeyColor: settings .chromaKeyColor
13+ property alias backgroundImage: settings .backgroundImage
1214
1315 Settings
1416 {
@@ -21,8 +23,38 @@ SnapshotSettingsForm {
2123 property bool backgroundFilterEnabled: false
2224 property bool chromaKeyEnabled: false
2325 property real chromaKeyColor: 0.5
26+ property url backgroundImage: " qrc:/images/backgrounds/Brickwall.jpg"
2427 }
2528
29+ function findBackgroundFiles ()
30+ {
31+ // use default backgrounds if no user backgrounds are found
32+ var path = StandardPaths .locate (StandardPaths .AppLocalDataLocation , " backgrounds" , StandardPaths .LocateDirectory )
33+
34+ if (path .len > 0 )
35+ {
36+ // check if the path is a valid directory and display this custom path in log
37+ console .log (" Background images path: " + path)
38+ return path
39+ }
40+ else
41+ {
42+ // use default backgrounds if no custom backgrounds are provided
43+ return " qrc:/images/backgrounds/"
44+ }
45+ }
46+
47+ FolderListModel
48+ {
49+ id: backgroundImageModel
50+ folder: findBackgroundFiles ()
51+ nameFilters: [" *.jpg" , " *.png" , " *.JPG" , " *.PNG" ]
52+ showDirs: false
53+ sortField: FolderListModel .Name
54+ }
55+
56+ backgroundImageSelectorModel: backgroundImageModel
57+
2658 showButton .onClicked :
2759 {
2860 if (state !== " expanded" )
@@ -85,6 +117,20 @@ SnapshotSettingsForm {
85117 settings .chromaKeyColor = sliderChromaKeyFilterColor .value
86118 }
87119
120+ backgroundImageSelector .currentIndex : backgroundImageSelectorModel .indexOf (settings .backgroundImage )
121+ backgroundImageSelector .onCurrentIndexChanged :
122+ {
123+ if (backgroundImageSelectorModel .count > 0 )
124+ {
125+ console .log (" selected index " + backgroundImageSelector .currentIndex )
126+ if (backgroundImageSelector .currentIndex >= 0 )
127+ {
128+ settings .backgroundImage = backgroundImageSelectorModel .get (backgroundImageSelector .currentIndex , " fileUrl" )
129+ console .log (" selected background " + settings .backgroundImage )
130+ }
131+ }
132+ }
133+
88134 Behavior on width
89135 {
90136 PropertyAnimation
0 commit comments