-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssignSpellActionDialog.qml
More file actions
204 lines (168 loc) · 6.35 KB
/
AssignSpellActionDialog.qml
File metadata and controls
204 lines (168 loc) · 6.35 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
import QtQuick
import QtQuick.Layouts
import qmlcomponents
TibiaDialog {
id: dialogRoot
caption: controller != null
? (controller.showActionBarTarget ? qsTrId("actionbar_assign_spell_dialog_caption").arg(actionBarName) : qsTrId("actionbar_assign_spell_dialog_caption_short"))
: qsTrId("dummy_unknown")
width: 375
property var controller: null
property var currentModelData: null
property bool spellSelected: currentModelData != null
property string actionBarName: controller != null ? controller.buttonName : qsTrId("actionbar_button_identifier").arg(0).arg(0)
property bool spellNeedsParameters: currentModelData ? currentModelData.parameterHints.length > 0 : false
onReturnPressedFunction: okClicked
onCancelPressedFunction: closeClicked
initialFocusItem: searchField
function okClicked() {
if (controller != null) {
controller.onOkClicked(parameterTextField.text);
}
} //function okClicked
function assignSpell() {
if (controller != null) {
controller.onApplyClicked(parameterTextField.text);
}
} //function assignSpell
function closeClicked() {
if (controller != null) {
controller.onCloseClicked();
}
} //function closeClicked
function setParameters() {
parameterTextField.text = controller != null ? controller.spellParameters : "";
} //function setParameters()
ColumnLayout {
anchors { left: parent.left; right: parent.right }
spacing: TibiaStyle.marginUnrelated
RowLayout {
Layout.fillWidth: true
spacing: TibiaStyle.marginRelated
Image {
Layout.preferredHeight: TibiaStyle.spellListIconSize
source: currentModelData ? currentModelData.iconUrl : ""
onSourceChanged: dialogRoot.setParameters(); //neede to react on the change of the current spell
} //Image
ColumnLayout {
spacing: 0
Layout.fillWidth: true
TibiaText {
Layout.fillWidth: true
text: currentModelData ? currentModelData.name : ""
visible: dialogRoot.spellSelected
} // TibiaText
TibiaText {
Layout.fillWidth: true
visible: !dialogRoot.spellSelected
text: qsTrId("actionbar_assign_spell_dialog_no_spell_selected")
} //TibiaText
TibiaText {
Layout.fillWidth: true
text: (currentModelData ? currentModelData.formulaRaw : "") + (parameterTextField.text != "" ? " " + parameterTextField.text : "")
} // TibiaText
} //ColumnLayout
} //RowLayout
TibiaHorizontalSeparator {
Layout.fillWidth: true
} //TibiaHorizontalSeparator
ColumnLayout {
Layout.fillWidth: true
spacing: TibiaStyle.marginRelated
TibiaFrame1PixelDown {
Layout.fillWidth: true
Layout.preferredHeight: 420
ColumnLayout {
anchors.fill: parent
anchors.margins: parent.borderWidth
TibiaTextSearchField {
id: searchField
Layout.fillWidth: true
onSearchTextChanged: {
if (spellList.model != null) {
spellList.model.filterText = searchText;
}
} //onSearchTextChanged
} //TibiaTextSearchField
TibiaScrollView {
Layout.fillWidth: true
Layout.fillHeight: true
contentWidth: spellList.width
SpellList {
id: spellList
KeyNavigation.tab: parameterTextField
model: controller != null ? controller.spellListModel : null
externalSelectedIndex: controller != null ? controller.spellListIndex : -1
showOnlyKnownSpells: controller != null && controller.showOnlyKnownSpells
showSpellgroup: true
onSpellSelected: (spellEnumId) => {
if (controller != null) {
controller.spellSelected(spellEnumId);
var _helperModel = AbstractItemModelHelper.wrapInHelperProxyModel(model);
var newModelData = null;
for (var i = 0; i < _helperModel.rowCount(); i++) {
var tempModelData = _helperModel.sourceItemDataByRowIndex(i);
if (spellEnumId == tempModelData.enumId) {
newModelData = tempModelData;
break;
}
}
currentModelData = newModelData;
}
} //onSpellSelected
} //SpellList
} //TibiaScrollView
} //ColumnLayout
} // TibiaFrame1PixelDown
TibiaMenuOptionCheckBox {
id: showOnlyKnownSpells
text: qsTrId("actionbar_assign_spell_dialog_label_showonlyknownspells")
Layout.fillWidth: true
checked: controller != null && controller.showOnlyKnownSpells
Binding {
target: controller
property: "showOnlyKnownSpells"
value: showOnlyKnownSpells.checked
} //Binding
} //TibiaMenuOptionCheckBox
RowLayout {
Layout.fillWidth: true
spacing: TibiaStyle.marginRelated
enabled: spellNeedsParameters
TibiaText {
text: qsTrId("actionbar_assign_spell_dialog_label_parameters")
} //TibiaText
TibiaTextField {
id: parameterTextField
Layout.fillWidth: true
KeyNavigation.tab: spellList
text: controller != null ? controller.spellParameters : ""
maximumLength: TibiaStyle.chatInputMaxLength - (currentModelData ? currentModelData.formulaRaw.length + 1 : 0)
placeholderText: currentModelData ? currentModelData.parameterHints : ""
} //TibiaTextField
} //RowLayout
} //ColumnLayout
TibiaHorizontalSeparator {
Layout.fillWidth: true
} //TibiaHorizontalSeparator
RowLayout {
Layout.alignment: Qt.AlignRight
spacing: TibiaStyle.marginRelated
Item {Layout.fillWidth: true}
TibiaButton {
text: qsTrId("ok")
onClicked: dialogRoot.okClicked();
enabled: dialogRoot.spellSelected
} // TibiaButton
TibiaButton {
text: qsTrId("apply")
onClicked: dialogRoot.assignSpell();
enabled: dialogRoot.spellSelected
} // TibiaButton
TibiaButton {
text: qsTrId("cancel")
onClicked: dialogRoot.closeClicked();
} // TibiaButton
} // RowLayout
} // ColumnLayout
} // TibiaDialog