-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDailyRewardPickItemsDialog.qml
More file actions
308 lines (245 loc) · 10.2 KB
/
DailyRewardPickItemsDialog.qml
File metadata and controls
308 lines (245 loc) · 10.2 KB
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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
import QtQuick
import QtQuick.Layouts
import qmlcomponents
TibiaDialog {
id: dialogRoot
caption: qsTrId("pickitems_caption")
width: 450
property var controller: null
property int totalPickCount: controller != null ? controller.totalPickCount : 0
property int pickCountLeft: controller != null ? controller.pickCountLeft : 0
property int currentPickCount: controller != null ? controller.currentPickCount : 0
onReturnPressedFunction: okButtonClicked
onCancelPressedFunction: closeDialog
function closeDialog() {
if (controller != null) {
controller.closeButtonClicked();
}
} //function closeDialog
function okButtonClicked() {
if (controller != null && confirmButton.enabled) {
controller.okButtonClicked();
}
} //function okButtonClicked
initialFocusItem: dialogRoot
KeyNavigation.tab: dialogRoot
ColumnLayout {
anchors { left: parent.left; top: parent.top; right: parent.right }
spacing: TibiaStyle.marginRelated
TibiaText {
text: qsTrId("pickitems_pick_count_tracker").arg(dialogRoot.currentPickCount)
.arg(dialogRoot.totalPickCount)
.arg(dialogRoot.pickCountLeft == 0 ? TibiaStyle.green1 : TibiaStyle.red2)
} // TibiaText
TibiaFrame1PixelDown {
id: listFrame
Layout.fillWidth: true
Layout.preferredHeight: 265
Rectangle {
anchors.fill: parent
anchors.margins: parent.borderWidth
color: TibiaStyle.tableViewBackgroundColor
} //Rectangle
TibiaScrollView {
anchors.fill: parent
anchors.margins: parent.borderWidth
ListView {
id: listView
boundsBehavior: Flickable.StopAtBounds
interactive: false //prevent flick behavior on touch screens
model: controller != null ? controller.objectToPickModel : null
delegate: Rectangle {
width: listView.width
property int margin: 1
height: TibiaStyle.containerSlotSize + 2 * margin
color: index % 2 == 0 ? TibiaStyle.tableViewItemBackgroundColor : TibiaStyle.tableViewAlternateBackgroundColor
RowLayout {
anchors.fill: parent
anchors.margins: parent.margin
spacing: TibiaStyle.marginRelated
ContainerSlot {
objectAppearanceInstanceTypeId: modelData.objectID
objectAppearanceInstanceCumulativeCount: 1
mouseAreaEnabled: false
} //ContainerSlot
TibiaText {
Layout.fillWidth: true
Layout.maximumHeight: TibiaStyle.containerSlotSize
wrapMode: Text.Wrap
text: modelData.name
} //TibiaText
RowLayout {
spacing: TibiaStyle.marginNarrow
TibiaButton {
Layout.preferredHeight: amountField.height
Layout.preferredWidth: Layout.preferredHeight
imageSource: "/images/icon-arrowskip.png"
imageSourceDisabled: "/images/icon-arrowskip-disabled.png"
onClicked: amountField.changeAmountTo(0)
enabled: amountField.amount > 0
} //TibiaButton
TibiaButton {
Layout.preferredHeight: amountField.height
Layout.preferredWidth: Layout.preferredHeight
imageSource: "/images/icon-arrow.png"
imageSourceDisabled: "/images/icon-arrow-disabled.png"
autoRepeat: true
onClicked: amountField.changeAmountBy(-1)
enabled: amountField.amount > 0
} //TibiaButton
TibiaTextField {
id: amountField
Layout.preferredWidth: 24
maximumLength:2
horizontalAlignment: TextInput.AlignHCenter
validator: RegularExpressionValidator { regularExpression: /[0-9]{0,2}/; }
KeyNavigation.tab: amountField
text: "0"
property int amount: modelData.amount
onTextChanged: {
stringToIntTimer.restart();
} //onTextChanged
onEditingFinished: amountField.convertTextToAmountAndForceBounds()
onActiveFocusChanged: amountField.convertTextToAmountAndForceBounds()
Timer {
id: stringToIntTimer
interval: 500
onTriggered: amountField.convertTextToAmountAndForceBounds()
} //Timer
onAmountChanged: {
text = amount;
modelData.setAmount(amount);
} //onAmountChanged
function convertTextToAmountAndForceBounds() {
var newAmount = text == "" ? 0 : parseInt(text) //parseInt returns NaN for empty strings
amount = Math.max(0, Math.min(newAmount, dialogRoot.totalPickCount));
text = amount;
} //function convertTextToAmountAndForceBounds()
function changeAmountBy(changeBy) {
convertTextToAmountAndForceBounds();
amount = Math.max(0, Math.min(dialogRoot.totalPickCount, amount + changeBy));
} //function changeAmountBy(changeBy)
function changeAmountTo(changeTo) {
convertTextToAmountAndForceBounds();
amount = Math.max(0, Math.min(dialogRoot.totalPickCount, changeTo));
} //function changeAmountTo(changeTo)
} //TibiaTextField
TibiaButton {
Layout.preferredHeight: amountField.height
Layout.preferredWidth: Layout.preferredHeight
imageSource: "/images/icon-arrow.png"
imageSourceDisabled: "/images/icon-arrow-disabled.png"
autoRepeat: true
imageMirrored: true
onClicked: amountField.changeAmountBy(+1)
enabled: dialogRoot.pickCountLeft > 0
} //TibiaButton
TibiaButton {
Layout.preferredHeight: amountField.height
Layout.preferredWidth: Layout.preferredHeight
imageSource: "/images/icon-arrowskip.png"
imageSourceDisabled: "/images/icon-arrowskip-disabled.png"
imageMirrored: true
onClicked: amountField.changeAmountTo(amountField.amount + dialogRoot.pickCountLeft)
enabled: dialogRoot.pickCountLeft > 0
} //TibiaButton
} //RowLayout
Item {
Layout.preferredWidth: weightText.width
Layout.preferredHeight: weightText.height
RowLayout {
id: weightText
spacing: TibiaStyle.marginNarrow
TibiaText {
Layout.preferredWidth: TibiaStyle.pickItemWeightWith
Layout.maximumWidth: Layout.preferredWidth
horizontalAlignment: Text.AlignRight
text: modelData.totalWeight
} //TibiaText
TibiaText {
text: qsTrId("ounce_short")
} //TibiaText
} //RowLayout
Tooltip {
anchors.fill: parent
text: qsTrId("pickitems_single_weight").arg(modelData.singleWeight)
} //Tooltip
} //Item
} //RowLayout
} //delegate: Rectangle
} //ListView
} //TibiaScrollView
} //TibiaFrame1PixelDown
RowLayout {
Layout.rightMargin: TibiaStyle.scrollBarWidth + 1 + listFrame.borderWidth //+1 delegates right margin
spacing: TibiaStyle.marginNarrow
TibiaText {
text: qsTrId("pickitems_free_capacity")
} //TibiaText
TibiaText {
text: controller != null ? controller.capacity : "0.00"
} //TibiaText
TibiaText {
text: qsTrId("ounce_short")
} //TibiaText
Item {
Layout.fillWidth: true
} //Item
TibiaText {
text: qsTrId("pickitems_total_weight")
} //TibiaText
TibiaText {
id: totalWeightText
Layout.preferredWidth: TibiaStyle.pickItemWeightWith
Layout.maximumWidth: Layout.preferredWidth
horizontalAlignment: Text.AlignRight
styleType: controller != null && controller.isTooHeavy ? "Negative" : "Dialog"
text: controller != null ? controller.currentTotalWeight : "0.00"
} //TibiaText
TibiaText {
styleType: totalWeightText.styleType
text: qsTrId("ounce_short")
} //TibiaText
} //RowLayout
TibiaHorizontalSeparator {
Layout.fillWidth: true
} //TibiaHorizontalSeparator
RowLayout {
Layout.alignment: Qt.AlignRight
spacing: TibiaStyle.marginRelated
Item {Layout.fillWidth: true}
Item {
Layout.preferredWidth: confirmButton.width
Layout.preferredHeight: confirmButton.height
TibiaButton {
id: confirmButton
text: qsTrId("ok")
enabled: dialogRoot.pickCountLeft == 0 && (controller != null && !controller.isTooHeavy)
onClicked: dialogRoot.okButtonClicked()
} //TibiaButton
Tooltip {
anchors.fill: parent
text: {
var tooltip = "";
if (dialogRoot.pickCountLeft != 0) {
tooltip += qsTrId("pickitems_exact_amount_tooltip").arg(dialogRoot.totalPickCount)
}
if (controller != null && controller.isTooHeavy) {
if(tooltip.length > 0) {
tooltip += "\n"
}
tooltip += qsTrId("pickitems_too_heavy_tooltip")
}
return tooltip
} //text
enabled: text != ""
} //Tooltip
} //Item
TibiaButton {
id: closeButton
text: qsTrId("close")
onClicked: dialogRoot.closeDialog()
} //TibiaButton
} //RowLayout
} //ColumnLayout
} //TibiaDialog