Skip to content

Commit 32025f2

Browse files
authored
Merge pull request #194 from saeugetier/feature/184-background-image-selector
Feature/184 background image selector
2 parents ca83009 + fc88f34 commit 32025f2

8 files changed

Lines changed: 320 additions & 189 deletions

File tree

File renamed without changes.

images/backgrounds/Stripes.png

844 KB
Loading

qml.qrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
<file>qml/GalleryMenuForm.ui.qml</file>
7979
<file>qml/content/DelegateGalleryItem.qml</file>
8080
<file>qml/styles/RoundProgressBarStyle.qml</file>
81-
<file>images/backgrounds/pexels-pixabay-259915.jpg</file>
81+
<file>images/backgrounds/Brickwall.jpg</file>
8282
<file>shaders/vmirror.frag.qsb</file>
8383
<file>shaders/passthrough.frag.qsb</file>
8484
<file>shaders/bw.frag.qsb</file>
@@ -95,5 +95,6 @@
9595
<file>shaders/previewshader.frag</file>
9696
<file>shaders/previewshader.frag.qsb</file>
9797
<file>models/coco.names</file>
98+
<file>images/backgrounds/Stripes.png</file>
9899
</qresource>
99100
</RCC>

qml/SnapshotMenu.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ SnapshotMenuForm {
126126
cameraRenderer.backgroundFilter.method: snapshotSettings.chromaKeyEnabled ? "Chroma" : "Neural"
127127
cameraRenderer.backgroundFilterEnabled: snapshotSettings.backgroundFilterEnabled
128128
cameraRenderer.backgroundFilter.keyColor: snapshotSettings.chromaKeyColor
129+
cameraRenderer.backgroundImage: snapshotSettings.backgroundImage
129130

130131
SequentialAnimation
131132
{

qml/SnapshotSettings.qml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import QtQuick
22
import QtCore
3+
import Qt.labs.folderlistmodel
34

45
SnapshotSettingsForm {
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

Comments
 (0)