blob: cb99479ca49919f33d9c1b42a5de38769cbeb8c5 (
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
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
|
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
import QtQuick 2.9
import QtQuick.Controls 2.0
import TimelineTheme 1.0
Item {
id: rangeDetails
property real titleBarHeight: 20
property real borderWidth: 1
property real outerMargin: 10
property real innerMargin: 5
property real minimumInnerWidth: 150
property real initialWidth: 300
property real minimumX: 0
property real maximumX: parent.width
property real minimumY: 0
property real maximumY: parent.height
property string dialogTitle: ""
property string file: ""
property int line: -1
property int column: -1
property bool locked: false
property var model: []
property alias noteText: noteEdit.text
property alias noteFocus: noteEdit.focus
property alias noteReadonly: noteEdit.readOnly
signal recenterOnItem
signal clearSelection
signal updateNote(string text)
visible: dialogTitle.length > 0 || model.length > 0
width: dragHandle.x + dragHandle.width
height: contentArea.height + titleBar.height
onMinimumXChanged: x = Math.max(x, minimumX)
onMaximumXChanged: x = Math.min(x, Math.max(minimumX, maximumX - width))
onMinimumYChanged: y = Math.max(y, minimumY)
onMaximumYChanged: y = Math.min(y, Math.max(minimumY, maximumY - height))
MouseArea {
anchors.fill: parent
drag.target: parent
drag.minimumX: parent.minimumX
drag.maximumX: parent.maximumX - rangeDetails.width
drag.minimumY: parent.minimumY
drag.maximumY: parent.maximumY - rangeDetails.height
onClicked: rangeDetails.recenterOnItem()
}
Rectangle {
id: titleBar
width: parent.width
height: titleBarHeight
color: Theme.color(Theme.Timeline_PanelHeaderColor)
border.width: borderWidth
border.color: Theme.color(Theme.PanelTextColorMid)
TimelineText {
id: typeTitle
text: rangeDetails.dialogTitle
font.bold: true
verticalAlignment: Text.AlignVCenter
anchors.left: parent.left
anchors.right: closeIcon.left
anchors.leftMargin: outerMargin
anchors.rightMargin: innerMargin
anchors.top: parent.top
anchors.bottom: parent.bottom
color: Theme.color(Theme.PanelTextColorLight)
elide: Text.ElideRight
}
ImageToolButton {
id: editIcon
imageSource: "image://icons/edit"
anchors.top: parent.top
anchors.right: lockIcon.left
implicitHeight: typeTitle.height
visible: !rangeDetails.noteReadonly
onClicked: noteEdit.focus = true
ToolTip.text: qsTr("Edit note")
}
ImageToolButton {
id: lockIcon
imageSource: "image://icons/lock_" + (locked ? "closed" : "open")
anchors.top: closeIcon.top
anchors.right: closeIcon.left
implicitHeight: typeTitle.height
onClicked: locked = !locked
ToolTip.text: qsTr("View event information on mouseover.")
}
ImageToolButton {
id: closeIcon
anchors.right: parent.right
anchors.top: parent.top
implicitHeight: typeTitle.height
imageSource: "image://icons/close_window"
onClicked: rangeDetails.clearSelection()
ToolTip.text: qsTr("Close")
}
}
Rectangle {
id: contentArea
color: Theme.color(Theme.Timeline_PanelBackgroundColor)
anchors.top: titleBar.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: dragHandle.bottom
border.width: borderWidth
border.color: Theme.color(Theme.PanelTextColorMid)
}
Grid {
id: col
anchors.left: parent.left
anchors.top: titleBar.bottom
anchors.topMargin: innerMargin
anchors.leftMargin: outerMargin
anchors.rightMargin: outerMargin
spacing: innerMargin
columns: 2
property int minimumWidth: minimumInnerWidth
onPositioningComplete: {
// max(width of longest label * 2, minimumInnerWidth)
var result = minimumInnerWidth;
for (var i = 0; i < children.length; ++i) {
if (children[i].isLabel)
result = Math.max(children[i].implicitWidth * 2 + innerMargin, result);
}
minimumWidth = result + 2 * outerMargin;
}
property int labelWidth: Math.ceil((minimumWidth - innerMargin) / 2) - outerMargin
property int valueWidth: dragHandle.x - labelWidth - innerMargin - outerMargin
onMinimumWidthChanged: {
if (dragHandle.x < minimumWidth - outerMargin)
dragHandle.x = minimumWidth - outerMargin;
}
Repeater {
model: rangeDetails.model
Detail {
labelWidth: col.labelWidth
valueWidth: col.valueWidth
isLabel: index % 2 === 0
text: isLabel ? (modelData + ":") : modelData
}
}
}
TextEdit {
id: noteEdit
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: outerMargin
anchors.rightMargin: outerMargin
anchors.topMargin: visible ? innerMargin : 0
anchors.top: col.bottom
height: visible ? implicitHeight : 0
readOnly: rangeDetails.noteReadonly
visible: (text.length > 0 || focus)
wrapMode: Text.Wrap
color: Theme.color(Theme.Timeline_HighlightColor)
font.italic: true
font.pixelSize: typeTitle.font.pixelSize
font.family: typeTitle.font.family
renderType: typeTitle.renderType
selectByMouse: true
onTextChanged: saveTimer.restart()
onFocusChanged: {
if (!focus) {
saveTimer.stop();
if (!readOnly)
rangeDetails.updateNote(text);
}
}
Timer {
id: saveTimer
onTriggered: {
if (!rangeDetails.readOnly)
rangeDetails.updateNote(noteEdit.text);
}
interval: 1000
}
}
Item {
id: dragHandle
width: outerMargin
height: outerMargin
x: initialWidth
anchors.top: noteEdit.bottom
clip: true
MouseArea {
anchors.fill: parent
drag.target: parent
drag.minimumX: col.minimumWidth - outerMargin
drag.axis: Drag.XAxis
cursorShape: Qt.SizeHorCursor
}
Rectangle {
color: Theme.color(Theme.Timeline_PanelHeaderColor)
rotation: 45
width: parent.width * Math.SQRT2
height: parent.height * Math.SQRT2
x: parent.width - width / 2
y: parent.height - height / 2
}
}
}
|