Skip to content

Commit 5f2186c

Browse files
committed
Use Components in existing demo items
1 parent 75c9e34 commit 5f2186c

File tree

2 files changed

+106
-94
lines changed

2 files changed

+106
-94
lines changed

demos/ff7tkQmlGallery/TextDemo.qml

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,47 +15,49 @@
1515
/****************************************************************************/
1616

1717
import QtQuick
18-
import QtQuick.Controls
18+
import QtQuick.Controls as QQC
1919
import ff7tkQuick.DataTypes
20+
import ff7tkQuick.Controls
2021

2122
Item {
2223
id:root
2324

24-
Column {
25-
anchors.fill: parent
26-
TextField{
27-
id:txtInput
28-
anchors.left: parent.left
29-
anchors.right: parent.right
30-
placeholderText: "Text to Convert"
31-
}
32-
Row {
33-
id: btnRow
34-
anchors.horizontalCenter: parent.horizontalCenter
35-
spacing: 6
36-
CheckBox {
37-
anchors.top: parent.top
38-
text: "Use Japanese Pc output"
39-
onCheckedChanged: FF7Text.japanese = checkState
25+
Column {
26+
anchors.fill: parent
27+
spacing: 3
28+
QQC.TextField{
29+
id:txtInput
30+
anchors.left: parent.left
31+
anchors.right: parent.right
32+
placeholderText: "Text to Convert"
4033
}
41-
Button {
42-
anchors.top:parent.top
43-
text:"Convert to PC"
44-
enabled: txtInput.text !== ""
45-
onClicked: txtOutput.text = FF7Text.toPC(txtInput.text)
34+
Row {
35+
id: btnRow
36+
anchors.horizontalCenter: parent.horizontalCenter
37+
spacing: 6
38+
CheckBox {
39+
anchors.top: parent.top
40+
text: "Use Japanese Pc output"
41+
onCheckedChanged: FF7Text.japanese = checkState
42+
}
43+
Button {
44+
anchors.top:parent.top
45+
text:"Convert to PC"
46+
enabled: txtInput.text !== ""
47+
onClicked: txtOutput.text = FF7Text.toPC(txtInput.text)
48+
}
49+
Button {
50+
anchors.top: parent.top
51+
text: "Convert to FF7Text"
52+
enabled: txtInput.text !== ""
53+
onClicked: txtOutput.text = FF7Text.toFF7(txtInput.text)
54+
}
4655
}
47-
Button {
48-
anchors.top: parent.top
49-
text: "Convert to FF7Text"
50-
enabled: txtInput.text !== ""
51-
onClicked: txtOutput.text = FF7Text.toFF7(txtInput.text)
56+
QQC.TextField{
57+
id:txtOutput
58+
anchors.left: parent.left
59+
anchors.right: parent.right
60+
placeholderText: "Converted Text Here"
5261
}
5362
}
54-
TextField{
55-
id:txtOutput
56-
anchors.left: parent.left
57-
anchors.right: parent.right
58-
placeholderText: "Converted Text Here"
59-
}
60-
}
6163
}

demos/ff7tkQmlGallery/main.qml

Lines changed: 70 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,41 @@
1515
/****************************************************************************/
1616

1717
import QtQuick
18-
import QtQuick.Controls
18+
import QtQuick.Controls as QQC
1919
import ff7tkQuick.DataTypes
20-
import ff7tkQuick.Controls as FF7tkControls
20+
import ff7tkQuick.Controls
2121

2222

2323
ApplicationWindow {
2424
id: root
2525
width: 800
2626
height: 600
27-
title: "ff7tkQmlGallery-" + FF7tkInfo.ff7tkVersion
28-
visible: true
29-
header: Item {
27+
title: "ff7tkQmlGallery - " + FF7tkInfo.ff7tkVersion
28+
header: Rectangle {
3029
id: headerItem
31-
Text{
30+
color: palette.alternateBase
31+
border.color: palette.dark
32+
border.width: 2
33+
height: comboSelector.height + 12
34+
Label {
3235
id: previewLabel
3336
text: "Current Preview:"
34-
color: palette.text
3537
anchors.verticalCenter: comboSelector.verticalCenter
3638
}
3739
ComboBox {
3840
id: comboSelector
39-
model: ["", "Text Demo", "ItemPreview", "MateriaButton", "MateriaEditor"]
40-
anchors.right: parent.right
41-
anchors.left: previewLabel.right
42-
anchors.leftMargin: 6
41+
anchors {
42+
margins: 6
43+
top: parent.top
44+
left: previewLabel.right; right: parent.right
45+
}
46+
model: ListModel {
47+
ListElement{text: ""}
48+
ListElement{text: "Text Demo"}
49+
ListElement{text: "ItemPreview"}
50+
ListElement{text: "Materia Button"}
51+
ListElement{text: "Materia Editor"}
52+
}
4353
onCurrentIndexChanged: {
4454
itemLoader.sourceComponent = Qt.binding(function() {
4555
switch(comboSelector.currentIndex) {
@@ -56,14 +66,15 @@ ApplicationWindow {
5666
Loader {
5767
id: itemLoader
5868
anchors.fill: parent
59-
anchors.topMargin: comboSelector.height + 6
69+
anchors.topMargin: 6
6070
}
6171

6272
Component {
6373
id: testComponent
6474
Rectangle {
65-
color: "lightblue"
66-
Text {
75+
color: palette.base
76+
Label {
77+
anchors.centerIn:parent
6778
text: "Please Select an Item to Preview"
6879
}
6980
}
@@ -73,44 +84,43 @@ ApplicationWindow {
7384
id: materiaButtonComponent
7485
Item {
7586
anchors.fill: parent
76-
Label {
77-
id: lbl_materiaId
78-
anchors.top: parent.top
79-
anchors.left: parent.left
80-
palette: palette
81-
text: "Materia Type"
82-
}
83-
ComboBox {
84-
id: combo_materiaID
85-
anchors.top: parent.top
86-
anchors.left: lbl_materiaId.right
87-
anchors.leftMargin: 6
88-
model: [ "None", "Magic", "Support", "Summon","Independent", "Command"]
89-
onCurrentIndexChanged: {
90-
switch (currentIndex) {
91-
case 0: materiaSlotButton.currentID = FF7Materia.EmptyId; break;
92-
case 1: materiaSlotButton.currentID = FF7Materia.Fire; break;
93-
case 2: materiaSlotButton.currentID = FF7Materia.All; break;
94-
case 3: materiaSlotButton.currentID = FF7Materia.ChocoMog; break;
95-
case 4: materiaSlotButton.currentID = FF7Materia.MpPlus; break;
96-
case 5: materiaSlotButton.currentID = FF7Materia.Steal; break;
87+
Item {
88+
anchors.fill: parent
89+
height: 50
90+
Label {
91+
id: lbl_materiaId
92+
anchors.verticalCenter: combo_materiaID.verticalCenter
93+
anchors.left: parent.left
94+
text: "Materia Type"
95+
}
96+
ComboBox {
97+
id: combo_materiaID
98+
anchors.top: parent.top
99+
anchors.left: lbl_materiaId.right
100+
anchors.leftMargin: 6
101+
model: ListModel {
102+
ListElement{text: "None"; value: 0xFF}
103+
ListElement{text: "Magic"; value: FF7Materia.Fire}
104+
ListElement{text: "Support"; value: FF7Materia.All}
105+
ListElement{text: "Summon";value: FF7Materia.ChocoMog}
106+
ListElement{text: "Independent"; value: FF7Materia.MpPlus}
107+
ListElement{text: "Command"; value: FF7Materia.Steal}
97108
}
109+
onCurrentIndexChanged: materiaSlotButton.currentID = combo_materiaID.model.get(currentIndex).value
110+
}
111+
CheckBox {
112+
id: cb_materiaSlotGrowth
113+
anchors.top: combo_materiaID.bottom
114+
anchors.left: parent.left
115+
anchors.margins: 4
116+
text: "Slot Growth"
98117
}
99118
}
100-
CheckBox {
101-
id: cb_materiaSlotGrowth
102-
anchors.top: lbl_materiaId.bottom
103-
height: 30
104-
anchors.left: parent.left
105-
anchors.right: parent.right
106-
text: "Slot Growth"
107-
}
108-
FF7tkControls.MateriaSlotButton {
119+
120+
MateriaSlotButton {
109121
id: materiaSlotButton
110-
anchors.top: parent.top
111-
anchors.bottom: parent.bottom
112-
anchors.left: combo_materiaID.right
113-
anchors.right: parent.right
122+
anchors.fill: parent
123+
anchors.topMargin: 60
114124
anchors.margins: 10
115125
currentID: FF7Materia.EmptyId
116126
growthSlot: cb_materiaSlotGrowth.checked
@@ -134,20 +144,20 @@ ApplicationWindow {
134144
color: palette.alternateBase
135145
height: 50
136146
id: materiaEditorControls
137-
SpinBox {
147+
QQC.SpinBox {
138148
id: spStarHeight
139149
anchors.top: parent.top
140150
anchors.left: parent.left
141151
from: 0; to: 256
142152
value: materiaEditor.starHeight
143153
onValueChanged: materiaEditor.starHeight = value
144154
}
145-
Text {
155+
Label {
146156
anchors.top:parent.top
147157
anchors.left: spStarHeight.right
148158
text: "Id: " + materiaEditor.currentId
149159
}
150-
Text {
160+
Label {
151161
anchors.top:parent.top
152162
anchors.right: parent.right
153163
text: "Ap: " + materiaEditor.currentAp
@@ -177,7 +187,7 @@ ApplicationWindow {
177187
onCheckedChanged: materiaEditor.fixedHeightSkills = checked
178188
}
179189
}
180-
FF7tkControls.MateriaEditor {
190+
MateriaEditor {
181191
id: materiaEditor
182192
anchors { fill: parent; topMargin: materiaEditorControls.height + 3 }
183193
}
@@ -187,24 +197,24 @@ ApplicationWindow {
187197
Component {
188198
id: itemPreviewComponent
189199
Item{
190-
Text {
200+
Label {
191201
id: itemPreviewOptions
192202
anchors.left: parent.left
193-
anchors.top:parent.top
203+
anchors.verticalCenter: sb_itemNumber.verticalCenter
194204
anchors.margins: 6
195-
text: "FF7ItemPreview - Options"
205+
text: "Item Id to Preview"
196206
}
197-
SpinBox {
207+
QQC.SpinBox {
198208
id:sb_itemNumber
199-
anchors.top: itemPreviewOptions.bottom
200-
anchors.left: parent.left
201-
anchors.margins: 6
209+
anchors.top: parent.top
210+
anchors.left: itemPreviewOptions.right
211+
anchors.rightMargin: 6
202212
editable: true
203213
value: -1
204214
from: -1
205215
to: 319
206216
}
207-
FF7tkControls.ItemPreview {
217+
ItemPreview {
208218
anchors.top: sb_itemNumber.bottom
209219
anchors.bottom: parent.bottom
210220
anchors.left: parent.left

0 commit comments

Comments
 (0)