blob: 5aa1b020bc905ab29a62323396c5b424e11edb58 (
plain)
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
|
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.Controls
Item {
id: rootItem
property string currentImage: imagesModel ? imagesModel.currentImageFile : ""
property string description
property int currentIndex: 0
property var imagesModel: null
property bool open: false
property bool showAddButton: false
signal addPressed
height: parent.height - 20
width: height
onCurrentIndexChanged: {
imagesModel.setImageIndex(currentIndex);
}
Item {
anchors.fill: parent
Rectangle {
anchors.fill: parent
color: mainView.backgroundColor2
border.color: mainView.foregroundColor1
opacity: 0.8
radius: 4
}
Image {
id: currentImageItem
anchors.fill: parent
anchors.margins: 6
source: rootItem.currentImage
fillMode: Image.PreserveAspectFit
mipmap: true
sourceSize: Qt.size(128, 128)
}
}
MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: true
onClicked: {
rootItem.open = !rootItem.open;
}
}
Column {
id: imageSelector
anchors.top: parent.bottom
visible: rootItem.open
Repeater {
model: imagesModel
Item {
width: rootItem.width
height: rootItem.height
Rectangle {
anchors.fill: parent
color: mainView.backgroundColor2
border.color: mainView.foregroundColor1
border.width: 1
opacity: 0.8
}
Image {
anchors.fill: parent
anchors.margins: 6
source: model.file
fillMode: Image.PreserveAspectFit
mipmap: true
sourceSize: Qt.size(128, 128)
}
MouseArea {
anchors.fill: parent
onClicked: {
rootItem.currentIndex = index;
rootItem.open = false;
}
}
}
}
// Optionally show add button as the last item
Rectangle {
width: rootItem.width
height: rootItem.height
visible: rootItem.showAddButton
color: mainView.backgroundColor1
border.color: mainView.foregroundColor2
border.width: 1
radius: 4
Image {
anchors.fill: parent
anchors.margins: 6
source: "images/icon_add.png"
fillMode: Image.PreserveAspectFit
mipmap: true
}
MouseArea {
anchors.fill: parent
onClicked: {
rootItem.addPressed();
rootItem.open = false;
}
}
}
}
ToolTip {
parent: rootItem
visible: mouseArea.containsMouse
delay: 1000
text: description
}
}
|