Skip to content

Commit 4c27099

Browse files
committed
make background image selectable in grid view
1 parent 18c36a1 commit 4c27099

2 files changed

Lines changed: 40 additions & 15 deletions

File tree

qml/SnapshotSettings.qml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ SnapshotSettingsForm {
1010
property alias backgroundFilterEnabled: settings.backgroundFilterEnabled
1111
property alias chromaKeyEnabled: settings.chromaKeyEnabled
1212
property alias chromaKeyColor: settings.chromaKeyColor
13+
property alias backgroundImage: settings.backgroundImage
1314

1415
Settings
1516
{
@@ -116,6 +117,20 @@ SnapshotSettingsForm {
116117
settings.chromaKeyColor = sliderChromaKeyFilterColor.value
117118
}
118119

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+
119134
Behavior on width
120135
{
121136
PropertyAnimation

qml/SnapshotSettingsForm.ui.qml

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -356,35 +356,45 @@ Pane {
356356
{
357357
visible: switchBackgroundFilterEnable.checked
358358

359-
360359
GridView
361360
{
362361
id: backgroundSelector
363-
362+
cellWidth: 100
363+
cellHeight: 120
364364
Layout.fillWidth: true
365365

366-
delegate: Item {
367-
width: 250
368-
height: 80
366+
focus: true
367+
368+
delegate: Column {
369+
spacing: 5
369370

370371
Rectangle {
371-
anchors.fill: parent
372-
border.color: "gray"
373-
color: "gray"
372+
width: backgroundSelector.cellWidth - 10
373+
height: backgroundSelector.cellHeight - 30
374+
border.color: GridView.isCurrentItem ? "blue" : "gray"
375+
border.width: 5
376+
radius: 8
374377

375378
Image {
376-
width: 80
377-
height: 80
378-
379+
anchors.fill: parent
379380
source: model.fileUrl
380-
fillMode: Image.PreserveAspectFit
381+
fillMode: Image.PreserveAspectCrop
381382
}
382383

383-
Text {
384-
id: name
385-
text: model.fileBaseName
384+
MouseArea {
385+
anchors.fill: parent
386+
cursorShape: Qt.PointingHandCursor
387+
onClicked: backgroundSelector.currentIndex = index
386388
}
387389
}
390+
391+
Label {
392+
width: backgroundSelector.cellWidth - 10
393+
text: model.fileBaseName
394+
font.pixelSize: 12
395+
horizontalAlignment: Text.AlignHCenter
396+
elide: Text.ElideRight
397+
}
388398
}
389399
}
390400
}

0 commit comments

Comments
 (0)