Skip to content

Commit bf10bd1

Browse files
committed
svg materia slots and link
1 parent 656e816 commit bf10bd1

File tree

12 files changed

+556
-110
lines changed

12 files changed

+556
-110
lines changed

demos/ff7tkQmlGallery/ItemPreview.qml

Lines changed: 150 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import QtQuick
2+
import QtQuick.Layouts
23
import org.ff7tk 1.0 as FF7tk
34

45
Item {
56
id: root
67
property int itemId: -1
78
visible: itemId != -1
9+
810
Rectangle {
911
anchors.fill: parent
1012
color: palette.base
@@ -43,6 +45,7 @@ Item {
4345
}
4446
Rectangle {
4547
id: materiaSlots
48+
property int leftMargin: materiaLink1.width
4649
property string imagePath: FF7tk.FF7Item.materiaGrowthRate(itemId) > 0 ? FF7tk.FF7Item.materiaSlotResource() : FF7tk.FF7Item.materiaSlotNoGrowthResource()
4750
anchors.left: parent.left
4851
anchors.right: parent.right
@@ -51,7 +54,7 @@ Item {
5154
border.width: 2
5255
border.color: palette.dark
5356
color: palette.alternateBase
54-
height: 100
57+
height: 64
5558
visible: (FF7tk.FF7Item.type(itemId) !== FF7tk.FF7Item.Item) && (FF7tk.FF7Item.type(itemId) !== FF7tk.FF7Item.Accessory) && (FF7tk.FF7Item.type(itemId) !== FF7tk.FF7Item.Unknown)
5659
Text{
5760
id: materiaBoxTitle
@@ -64,105 +67,148 @@ Item {
6467
horizontalAlignment: Text.AlignHCenter
6568
color: palette.text
6669
}
67-
Image{
68-
id: materiaSlot1
69-
anchors.left: parent.left
70-
anchors.leftMargin: 32
71-
anchors.top: materiaBoxTitle.bottom
72-
width: 64; height: width
73-
source: parent.imagePath
74-
visible: FF7tk.FF7Item.materiaSlots(itemId) > 0
75-
}
76-
Image{
77-
id: materiaLink1
78-
anchors.left: materiaSlot1.right
79-
anchors.verticalCenter: materiaSlot1.verticalCenter
80-
width: 32; height: 48
81-
source: FF7tk.FF7Item.materiaLinkResource()
82-
visible: FF7tk.FF7Item.linkedSlots(itemId) > 0
83-
}
84-
Image{
85-
id: materiaSlot2
86-
anchors.top: materiaBoxTitle.bottom
87-
anchors.left: materiaLink1.right
88-
width: 64; height: width
89-
source: parent.imagePath
90-
visible: FF7tk.FF7Item.materiaSlots(itemId) > 1
91-
}
92-
Image{
93-
id: materiaSlot3
94-
anchors.left: materiaSlot2.right
95-
anchors.leftMargin: 32
96-
anchors.top: materiaBoxTitle.bottom
97-
width: 64; height: width
98-
source: parent.imagePath
99-
visible: FF7tk.FF7Item.materiaSlots(itemId) > 2
100-
}
101-
Image{
102-
id: materiaLink2
103-
anchors.left: materiaSlot3.right
104-
anchors.verticalCenter: materiaSlot3.verticalCenter
105-
width: 32; height: 48
106-
source: FF7tk.FF7Item.materiaLinkResource()
107-
visible: FF7tk.FF7Item.linkedSlots(itemId) > 1
108-
}
109-
Image{
110-
id: materiaSlot4
111-
anchors.top: materiaBoxTitle.bottom
112-
anchors.left: materiaLink2.right
113-
width: 64; height: width
114-
source: parent.imagePath
115-
visible: FF7tk.FF7Item.materiaSlots(itemId) > 3
116-
}
117-
Image{
118-
id: materiaSlot5
119-
anchors.left: materiaSlot4.right
120-
anchors.leftMargin: 32
121-
anchors.top: materiaBoxTitle.bottom
122-
width: 64; height: width
123-
source: parent.imagePath
124-
visible: FF7tk.FF7Item.materiaSlots(itemId) > 4
125-
}
126-
Image{
127-
id: materiaLink3
128-
anchors.left: materiaSlot5.right
129-
anchors.verticalCenter: materiaSlot5.verticalCenter
130-
width: 32; height: 48
131-
source: FF7tk.FF7Item.materiaLinkResource()
132-
visible: FF7tk.FF7Item.linkedSlots(itemId) > 3
133-
}
134-
Image{
135-
id: materiaSlot6
136-
anchors.top: materiaBoxTitle.bottom
137-
anchors.left: materiaLink3.right
138-
width: 64; height: width
139-
source: parent.imagePath
140-
visible: FF7tk.FF7Item.materiaSlots(itemId) > 5
141-
}
142-
Image{
143-
id: materiaSlot7
144-
anchors.left: materiaSlot6.right
145-
anchors.leftMargin: 32
146-
anchors.top: materiaBoxTitle.bottom
147-
width: 64; height: width
148-
source: parent.imagePath
149-
visible: FF7tk.FF7Item.materiaSlots(itemId) > 6
150-
}
151-
Image{
152-
id: materiaLink4
153-
anchors.left: materiaSlot7.right
154-
anchors.verticalCenter: materiaSlot7.verticalCenter
155-
width: 32; height: 48
156-
source: FF7tk.FF7Item.materiaLinkResource()
157-
visible: FF7tk.FF7Item.linkedSlots(itemId) > 3
158-
}
159-
Image{
160-
id: materiaSlot8
161-
anchors.top: materiaBoxTitle.bottom
162-
anchors.left: materiaLink4.right
163-
width: 64; height: width
164-
source: parent.imagePath
165-
visible: FF7tk.FF7Item.materiaSlots(itemId) > 7
70+
RowLayout {
71+
spacing: 0
72+
anchors {
73+
top: materiaBoxTitle.bottom
74+
topMargin: parent.height / 16
75+
bottom: parent.bottom
76+
bottomMargin: parent.height / 16
77+
left: parent.left
78+
leftMargin:materiaSlots.border.width
79+
right: parent.right
80+
rightMargin:materiaSlots.border.width
81+
}
82+
83+
Image{
84+
id: materiaSlot1
85+
Layout.fillHeight: true
86+
Layout.leftMargin: width / 4
87+
Layout.preferredHeight: 32
88+
Layout.preferredWidth: 32
89+
fillMode: Qt.KeepAspectRatio
90+
sourceSize: Qt.size(width,height)
91+
source: materiaSlots.imagePath
92+
visible: FF7tk.FF7Item.materiaSlots(itemId) > 0
93+
}
94+
Image{
95+
id: materiaLink1
96+
Layout.fillHeight: true
97+
Layout.maximumWidth: height / 4
98+
fillMode: Qt.KeepAspectRatio
99+
source: FF7tk.FF7Item.materiaLinkResource()
100+
sourceSize: Qt.size(width,height)
101+
visible: FF7tk.FF7Item.linkedSlots(itemId) > 0
102+
}
103+
Image{
104+
id: materiaSlot2
105+
Layout.fillHeight: true
106+
Layout.leftMargin: materiaLink1.visible ? -1 : materiaSlots.leftMargin
107+
Layout.preferredHeight: 32
108+
Layout.preferredWidth: 32
109+
fillMode: Qt.KeepAspectRatio
110+
source: materiaSlots.imagePath
111+
sourceSize: Qt.size(width,height)
112+
visible: FF7tk.FF7Item.materiaSlots(itemId) > 1
113+
}
114+
Image{
115+
id: materiaSlot3
116+
Layout.fillHeight: true
117+
Layout.leftMargin: width / 4
118+
Layout.preferredHeight: 32
119+
Layout.preferredWidth: 32
120+
fillMode: Qt.KeepAspectRatio
121+
sourceSize: Qt.size(width,height)
122+
source: materiaSlots.imagePath
123+
visible: FF7tk.FF7Item.materiaSlots(itemId) > 2
124+
}
125+
Image{
126+
id: materiaLink2
127+
Layout.fillHeight: true
128+
Layout.maximumWidth: height / 4
129+
fillMode: Qt.KeepAspectRatio
130+
source: FF7tk.FF7Item.materiaLinkResource()
131+
sourceSize: Qt.size(width,height)
132+
visible: FF7tk.FF7Item.linkedSlots(itemId) > 1
133+
}
134+
Image{
135+
id: materiaSlot4
136+
Layout.fillHeight: true
137+
Layout.leftMargin: materiaLink2.visible ? -1 : materiaSlots.leftMargin
138+
Layout.preferredHeight: 32
139+
Layout.preferredWidth: 32
140+
fillMode: Qt.KeepAspectRatio
141+
source: materiaSlots.imagePath
142+
sourceSize: Qt.size(width,height)
143+
visible: FF7tk.FF7Item.materiaSlots(itemId) > 3
144+
}
145+
Image{
146+
id: materiaSlot5
147+
Layout.fillHeight: true
148+
Layout.leftMargin: width / 4
149+
Layout.preferredHeight: 32
150+
Layout.preferredWidth: 32
151+
fillMode: Qt.KeepAspectRatio
152+
source: materiaSlots.imagePath
153+
sourceSize: Qt.size(width,height)
154+
visible: FF7tk.FF7Item.materiaSlots(itemId) > 4
155+
}
156+
Image{
157+
id: materiaLink3
158+
Layout.fillHeight: true
159+
Layout.maximumWidth: height / 4
160+
fillMode: Qt.KeepAspectRatio
161+
source: FF7tk.FF7Item.materiaLinkResource()
162+
sourceSize: Qt.size(width,height)
163+
visible: FF7tk.FF7Item.linkedSlots(itemId) > 3
164+
}
165+
Image{
166+
id: materiaSlot6
167+
Layout.fillHeight: true
168+
Layout.leftMargin: materiaLink3.visible ? -1 : materiaSlots.leftMargin
169+
Layout.preferredHeight: 32
170+
Layout.preferredWidth: 32
171+
fillMode: Qt.KeepAspectRatio
172+
source: materiaSlots.imagePath
173+
sourceSize: Qt.size(width,height)
174+
visible: FF7tk.FF7Item.materiaSlots(itemId) > 5
175+
}
176+
Image{
177+
id: materiaSlot7
178+
Layout.fillHeight: true
179+
Layout.leftMargin: width / 4
180+
Layout.preferredHeight: 32
181+
Layout.preferredWidth: 32
182+
fillMode: Qt.KeepAspectRatio
183+
source: materiaSlots.imagePath
184+
sourceSize: Qt.size(width,height)
185+
visible: FF7tk.FF7Item.materiaSlots(itemId) > 6
186+
}
187+
Image{
188+
id: materiaLink4
189+
Layout.fillHeight: true
190+
Layout.maximumWidth: height / 4
191+
fillMode: Qt.KeepAspectRatio
192+
source: FF7tk.FF7Item.materiaLinkResource()
193+
sourceSize: Qt.size(width,height)
194+
visible: FF7tk.FF7Item.linkedSlots(itemId) > 3
195+
}
196+
Image{
197+
id: materiaSlot8
198+
Layout.fillHeight: true
199+
Layout.leftMargin: materiaLink4.visible ? -1 : materiaSlots.leftMargin
200+
Layout.preferredHeight: 32
201+
Layout.preferredWidth: 32
202+
fillMode: Qt.KeepAspectRatio
203+
source: materiaSlots.imagePath
204+
sourceSize: Qt.size(width,height)
205+
visible: FF7tk.FF7Item.materiaSlots(itemId) > 7
206+
}
207+
Rectangle {
208+
Layout.fillHeight: true
209+
Layout.fillWidth: true
210+
color: materiaSlots.color
211+
}
166212
}
167213
}
168214
Item {
@@ -171,8 +217,8 @@ Item {
171217
anchors.top: materiaSlots.visible ? materiaSlots.bottom : desc.bottom
172218
anchors.topMargin: 6
173219
anchors.left: parent.left
174-
anchors.leftMargin: 12
175-
width: 250
220+
anchors.leftMargin: 6
221+
width: (parent.width / 2) - 12
176222
height: elementTitle.paintedHeight + 10 + (elementalList.count * (fm.height + 3))
177223
visible: elementalList.count > 0
178224
Rectangle {
@@ -216,10 +262,10 @@ Item {
216262
Item {
217263
id: groupStatus
218264
anchors.left: elementalList.count > 0 ? groupElemental.right : parent.left
219-
anchors.leftMargin: 12
265+
anchors.leftMargin: 6
220266
anchors.top: materiaSlots.visible ? materiaSlots.bottom : desc.bottom
221267
anchors.topMargin: 6
222-
width: 250
268+
width: groupElemental.visible ? (parent.width / 2) - 6 : (parent.width / 2) - 12
223269
height: statusTitle.paintedHeight + 10 + (statusList.count * (fm.height + 3))
224270
visible: statusList.count > 0
225271
Rectangle {
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import QtQuick
2+
import QtQuick.Controls
3+
import org.ff7tk 1.0 as FF7tk
4+
5+
Item {
6+
property bool growthSlot: true
7+
property bool clickable: true
8+
property int currentID: FF7tk.FF7Materia.EmptyId
9+
signal clicked()
10+
implicitHeight: 32
11+
implicitWidth: 32
12+
Image{
13+
id: slot
14+
anchors.fill: parent
15+
fillMode: Image.PreserveAspectFit
16+
sourceSize: Qt.size(width,height)
17+
source: growthSlot ? FF7tk.FF7Item.materiaSlotNoGrowthResource() : FF7tk.FF7Item.materiaSlotResource()
18+
Image {
19+
anchors {
20+
fill: parent
21+
verticalCenter: parent.verticalCenter
22+
horizontalCenter: parent.horizontalCenter
23+
topMargin:slot.paintedHeight /11; bottomMargin: slot.paintedHeight /11
24+
leftMargin: slot.paintedWidth /11; rightMargin: slot.paintedWidth /11
25+
}
26+
fillMode: Image.PreserveAspectFit
27+
source: FF7tk.FF7Materia.iconResource(currentID)
28+
MouseArea {
29+
anchors.fill: parent
30+
visible: root.clickable
31+
onClicked: root.clicked
32+
}
33+
}
34+
}
35+
}

demos/ff7tkQmlGallery/main.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include <FF7Text>
2222
#include <FF7Item>
23+
#include <FF7Materia>
2324
#include <ff7tkInfo>
2425

2526
int main(int argc, char *argv[])
@@ -38,6 +39,10 @@ int main(int argc, char *argv[])
3839
return ff7tkInfo::qmlSingletonRegister(engine, jsEngine);
3940
});
4041

42+
qmlRegisterSingletonType<FF7Materia>("org.ff7tk", 1, 0, "FF7Materia", [](QQmlEngine *engine, QJSEngine *jsEngine) -> QObject * {
43+
return FF7Materia::qmlSingletonRegister(engine, jsEngine);
44+
});
45+
4146
QQmlApplicationEngine engine;
4247
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
4348

0 commit comments

Comments
 (0)