Skip to content

Commit 97486c7

Browse files
committed
New Qml Materia Selector
1 parent 5f2186c commit 97486c7

File tree

12 files changed

+323
-52
lines changed

12 files changed

+323
-52
lines changed

demos/ff7tkQmlGallery/main.qml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,16 @@ ApplicationWindow {
4949
ListElement{text: "ItemPreview"}
5050
ListElement{text: "Materia Button"}
5151
ListElement{text: "Materia Editor"}
52+
ListElement{text: "Materia Selector"}
5253
}
5354
onCurrentIndexChanged: {
5455
itemLoader.sourceComponent = Qt.binding(function() {
5556
switch(comboSelector.currentIndex) {
56-
case 1: return textDemoComponent;
57-
case 2: return itemPreviewComponent;
58-
case 3: return materiaButtonComponent;
59-
case 4: return materiaEditorComponent;
57+
case 1: return textDemoComponent
58+
case 2: return itemPreviewComponent
59+
case 3: return materiaButtonComponent
60+
case 4: return materiaEditorComponent
61+
case 5: return materiaSelectorComponent
6062
default: return testComponent;
6163
}
6264
})
@@ -132,6 +134,16 @@ ApplicationWindow {
132134
id: textDemoComponent
133135
TextDemo { }
134136
}
137+
Component {
138+
id: materiaSelectorComponent
139+
Item{
140+
anchors.fill: parent
141+
MateriaSelector {
142+
anchors.left: parent.left;
143+
anchors.leftMargin: 6
144+
}
145+
}
146+
}
135147

136148
Component {
137149
id: materiaEditorComponent
@@ -189,7 +201,7 @@ ApplicationWindow {
189201
}
190202
MateriaEditor {
191203
id: materiaEditor
192-
anchors { fill: parent; topMargin: materiaEditorControls.height + 3 }
204+
anchors { fill: parent; topMargin: materiaEditorControls.height + 6; leftMargin: 6; rightMargin: 6 }
193205
}
194206
}
195207
}

src/ff7tkQuick/Controls/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ set(${libName}_URI "ff7tkQuick.Controls")
1212

1313
set(${libName}_QMLFILES
1414
ItemPreview.qml
15+
MateriaSelector.qml
1516
MateriaEditor.qml
1617
MateriaSlotButton.qml
1718
Components/ApplicationWindow.qml

src/ff7tkQuick/Controls/MateriaEditor.qml

Lines changed: 9 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,19 @@ import "Components" as FFComps
2222

2323
Item {
2424
id: root
25-
implicitWidth: childrenRect.width + 12
26-
property bool showPlaceHolderMateria: true
25+
implicitWidth: mSelector.implicitWidth + (24 * 4)
26+
property alias showPlaceHolderMateria: mSelector.showPlaceHolderMateria
2727
property bool editable: true
2828
property bool fixedHeightSkills: true
2929
property int starHeight: 24
30-
property int currentId: FF7Materia.EmptyId
30+
property alias currentId: mSelector.currentId
3131
property int currentAp: FF7Materia.maxMateriaAp
3232
readonly property bool isEmpty: ((currentId === FF7Materia.EmptyId))
3333
readonly property int level: FF7Materia.materiaLevel(currentId, currentAp)
3434
signal copyActionTriggered(int currentId, int currentAp)
3535
signal cutActionTriggered(int currentId, int currentAp)
3636
signal pasteActionTriggered()
3737

38-
ListModel {
39-
id: typeModel
40-
ListElement { text: qsTr("All Materia"); icon: "qrc:/materia/all" }
41-
ListElement { text: qsTr("Magic"); icon: "qrc:/materia/magic" }
42-
ListElement { text: qsTr("Summon"); icon: "qrc:/materia/summon" }
43-
ListElement { text: qsTr("Independent"); icon: "qrc:/materia/independent" }
44-
ListElement { text: qsTr("Support"); icon: "qrc:/materia/support" }
45-
ListElement { text: qsTr("Command"); icon: "qrc:/materia/command" }
46-
}
47-
48-
ListModel { id: materiaModel }
49-
Component.onCompleted: { setupMateriaModel(0); materiaCombo.modelChanged() }
50-
5138
Rectangle {
5239
anchors.fill: parent
5340
color: palette.base
@@ -57,27 +44,19 @@ Item {
5744
anchors.right: parent.right
5845
anchors.top: parent.top
5946
height: 24
60-
anchors.margins: 6
47+
anchors.leftMargin: 6
48+
anchors.rightMargin: 6
6149
spacing: 6
62-
FFComps.ComboBox {
63-
id: typeCombo
64-
visible: root.editable
65-
Layout.fillHeight: true
66-
Layout.preferredWidth: implicitWidth
67-
model: typeModel
68-
onCurrentIndexChanged: setupMateriaModel(currentIndex)
69-
}
70-
FFComps.ComboBox {
71-
id: materiaCombo
50+
MateriaSelector {
51+
id: mSelector
7252
visible: root.editable
7353
Layout.fillHeight: true
7454
Layout.fillWidth: true
75-
Layout.minimumWidth: implicitWidth
76-
model: materiaModel
77-
onCurrentIndexChanged: currentId = currentIndex !== -1 ? model.get(currentIndex).data : currentId
55+
Layout.preferredWidth: mSelector.implicitWidth + 12
7856
}
7957
Image {
8058
visible: !root.editable && currentId !== FF7Materia.EmptyId
59+
Layout.margins: 4
8160
Layout.fillHeight: true
8261
Layout.preferredWidth: height
8362
source: FF7Materia.iconResource(currentId)
@@ -361,21 +340,4 @@ Item {
361340
}
362341
}
363342
}
364-
365-
onShowPlaceHolderMateriaChanged: {
366-
var cI = materiaCombo.currentIndex
367-
typeCombo.currentIndex === 0 ? setupMateriaModel(typeCombo.currentIndex) : null
368-
materiaCombo.currentIndex = cI
369-
}
370-
371-
function setupMateriaModel(type) {
372-
materiaModel.clear()
373-
for (let i = 0 ; i <= 90; i++) {
374-
if( (type === 0 || FF7Materia.type(i) === type) && FF7Materia.name(i) !== "") {
375-
if(String(FF7Materia.name(i)).includes(":") && !root.showPlaceHolderMateria)
376-
continue;
377-
materiaModel.append({ text: FF7Materia.name(i), icon: FF7Materia.iconResource(i), data: i})
378-
}
379-
}
380-
}
381343
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/****************************************************************************/
2+
// copyright 2022 - 2023 Chris Rizzitello <sithlord48@gmail.com> //
3+
// //
4+
// This file is part of FF7tk //
5+
// //
6+
// FF7tk is free software: you can redistribute it and/or modify //
7+
// it under the terms of the GNU General Public License as published by //
8+
// the Free Software Foundation, either version 3 of the License, or //
9+
// (at your option) any later version. //
10+
// //
11+
// FF7tk is distributed in the hope that it will be useful, //
12+
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
13+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
14+
// GNU General Public License for more details. //
15+
/****************************************************************************/
16+
17+
import QtQuick
18+
import QtQuick.Layouts
19+
import QtQuick.Controls
20+
import ff7tkQuick.DataTypes
21+
import "Components" as FFComps
22+
23+
Item {
24+
id: root
25+
implicitWidth: typeCombo.implicitWidth + materiaCombo.implicitWidth + 18
26+
implicitHeight: 24
27+
property bool showPlaceHolderMateria: true
28+
property int currentId: FF7Materia.EmptyId
29+
30+
ListModel {
31+
id: typeModel
32+
ListElement { text: qsTr("All Materia"); icon: "qrc:/materia/all" }
33+
ListElement { text: qsTr("Magic"); icon: "qrc:/materia/magic" }
34+
ListElement { text: qsTr("Summon"); icon: "qrc:/materia/summon" }
35+
ListElement { text: qsTr("Independent"); icon: "qrc:/materia/independent" }
36+
ListElement { text: qsTr("Support"); icon: "qrc:/materia/support" }
37+
ListElement { text: qsTr("Command"); icon: "qrc:/materia/command" }
38+
}
39+
40+
ListModel { id: materiaModel }
41+
Component.onCompleted: { setupMateriaModel(0); materiaCombo.modelChanged() }
42+
RowLayout {
43+
id: selectorRow
44+
anchors.fill: parent
45+
height: 24
46+
spacing: 6
47+
FFComps.ComboBox {
48+
id: typeCombo
49+
Layout.fillHeight: true
50+
Layout.preferredWidth: typeCombo.implicitWidth
51+
model: typeModel
52+
onCurrentIndexChanged: setupMateriaModel(currentIndex)
53+
}
54+
FFComps.ComboBox {
55+
id: materiaCombo
56+
Layout.fillHeight: true
57+
Layout.fillWidth: true
58+
Layout.minimumWidth: materiaCombo.implicitWidth
59+
model: materiaModel
60+
onCurrentIndexChanged: currentId = currentIndex !== -1 ? model.get(currentIndex).data : currentId
61+
}
62+
}
63+
64+
onShowPlaceHolderMateriaChanged: {
65+
var cI = materiaCombo.currentIndex
66+
typeCombo.currentIndex === 0 ? setupMateriaModel(typeCombo.currentIndex) : null
67+
materiaCombo.currentIndex = cI
68+
}
69+
70+
function setupMateriaModel(type) {
71+
materiaModel.clear()
72+
for (let i = 0 ; i <= 90; i++) {
73+
if( (type === 0 || FF7Materia.type(i) === type) && FF7Materia.name(i) !== "") {
74+
if(String(FF7Materia.name(i)).includes(":") && !root.showPlaceHolderMateria)
75+
continue;
76+
materiaModel.append({ text: FF7Materia.name(i), icon: FF7Materia.iconResource(i), data: i})
77+
}
78+
}
79+
}
80+
}

translations/ff7tk_de.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7282,6 +7282,33 @@ Die km / h beschleunigt berechnet werden während des Spielens </translation>
72827282
<translation>Zusatzwirkung</translation>
72837283
</message>
72847284
</context>
7285+
<context>
7286+
<name>MateriaSelector</name>
7287+
<message>
7288+
<source>All Materia</source>
7289+
<translation type="unfinished">alle Materia</translation>
7290+
</message>
7291+
<message>
7292+
<source>Magic</source>
7293+
<translation type="unfinished">Magie</translation>
7294+
</message>
7295+
<message>
7296+
<source>Summon</source>
7297+
<translation type="unfinished">Beschwörung</translation>
7298+
</message>
7299+
<message>
7300+
<source>Independent</source>
7301+
<translation type="unfinished">Unabhängig</translation>
7302+
</message>
7303+
<message>
7304+
<source>Support</source>
7305+
<translation type="unfinished">Unterstützung</translation>
7306+
</message>
7307+
<message>
7308+
<source>Command</source>
7309+
<translation type="unfinished">Befehl</translation>
7310+
</message>
7311+
</context>
72857312
<context>
72867313
<name>MenuListWidget</name>
72877314
<message>

translations/ff7tk_en.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7282,6 +7282,33 @@ The km/h speeds are calculated while playing </translation>
72827282
<translation>Added Effect</translation>
72837283
</message>
72847284
</context>
7285+
<context>
7286+
<name>MateriaSelector</name>
7287+
<message>
7288+
<source>All Materia</source>
7289+
<translation type="unfinished">All Materia</translation>
7290+
</message>
7291+
<message>
7292+
<source>Magic</source>
7293+
<translation type="unfinished">Magic</translation>
7294+
</message>
7295+
<message>
7296+
<source>Summon</source>
7297+
<translation type="unfinished">Summon</translation>
7298+
</message>
7299+
<message>
7300+
<source>Independent</source>
7301+
<translation type="unfinished">Independent</translation>
7302+
</message>
7303+
<message>
7304+
<source>Support</source>
7305+
<translation type="unfinished">Support</translation>
7306+
</message>
7307+
<message>
7308+
<source>Command</source>
7309+
<translation type="unfinished">Command</translation>
7310+
</message>
7311+
</context>
72857312
<context>
72867313
<name>MenuListWidget</name>
72877314
<message>

translations/ff7tk_es.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7282,6 +7282,33 @@ Los km/h son calculados mientras se juega </translation>
72827282
<translation>Efecto añaddo</translation>
72837283
</message>
72847284
</context>
7285+
<context>
7286+
<name>MateriaSelector</name>
7287+
<message>
7288+
<source>All Materia</source>
7289+
<translation type="unfinished">Toda la materia</translation>
7290+
</message>
7291+
<message>
7292+
<source>Magic</source>
7293+
<translation type="unfinished">Magia</translation>
7294+
</message>
7295+
<message>
7296+
<source>Summon</source>
7297+
<translation type="unfinished">Invocación</translation>
7298+
</message>
7299+
<message>
7300+
<source>Independent</source>
7301+
<translation type="unfinished">Independiente</translation>
7302+
</message>
7303+
<message>
7304+
<source>Support</source>
7305+
<translation type="unfinished">Soporte</translation>
7306+
</message>
7307+
<message>
7308+
<source>Command</source>
7309+
<translation type="unfinished">Comando</translation>
7310+
</message>
7311+
</context>
72857312
<context>
72867313
<name>MenuListWidget</name>
72877314
<message>

translations/ff7tk_fr.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7282,6 +7282,33 @@ Les vitesses en km/h sont calculés pendant le jeu </translation>
72827282
<translation>Effet suppl</translation>
72837283
</message>
72847284
</context>
7285+
<context>
7286+
<name>MateriaSelector</name>
7287+
<message>
7288+
<source>All Materia</source>
7289+
<translation type="unfinished">Toutes les matérias</translation>
7290+
</message>
7291+
<message>
7292+
<source>Magic</source>
7293+
<translation type="unfinished">Magie</translation>
7294+
</message>
7295+
<message>
7296+
<source>Summon</source>
7297+
<translation type="unfinished">Invocation</translation>
7298+
</message>
7299+
<message>
7300+
<source>Independent</source>
7301+
<translation type="unfinished">Indépendante</translation>
7302+
</message>
7303+
<message>
7304+
<source>Support</source>
7305+
<translation type="unfinished">Soutien</translation>
7306+
</message>
7307+
<message>
7308+
<source>Command</source>
7309+
<translation type="unfinished">Commande</translation>
7310+
</message>
7311+
</context>
72857312
<context>
72867313
<name>MenuListWidget</name>
72877314
<message>

translations/ff7tk_it.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7293,6 +7293,33 @@ Battaglia %1</translation>
72937293
<translation type="unfinished">Ripristina</translation>
72947294
</message>
72957295
</context>
7296+
<context>
7297+
<name>MateriaSelector</name>
7298+
<message>
7299+
<source>All Materia</source>
7300+
<translation type="unfinished">Tutte le materie</translation>
7301+
</message>
7302+
<message>
7303+
<source>Magic</source>
7304+
<translation type="unfinished"></translation>
7305+
</message>
7306+
<message>
7307+
<source>Summon</source>
7308+
<translation type="unfinished">Di invocazione</translation>
7309+
</message>
7310+
<message>
7311+
<source>Independent</source>
7312+
<translation type="unfinished">Indipendenti</translation>
7313+
</message>
7314+
<message>
7315+
<source>Support</source>
7316+
<translation type="unfinished">Supporto</translation>
7317+
</message>
7318+
<message>
7319+
<source>Command</source>
7320+
<translation type="unfinished">Comando</translation>
7321+
</message>
7322+
</context>
72967323
<context>
72977324
<name>MenuListWidget</name>
72987325
<message>

0 commit comments

Comments
 (0)