diff --git a/demos/ff7tkQmlGallery/main.qml b/demos/ff7tkQmlGallery/main.qml index 3095e64ac..771012676 100644 --- a/demos/ff7tkQmlGallery/main.qml +++ b/demos/ff7tkQmlGallery/main.qml @@ -49,14 +49,16 @@ ApplicationWindow { ListElement{text: "ItemPreview"} ListElement{text: "Materia Button"} ListElement{text: "Materia Editor"} + ListElement{text: "Materia Selector"} } onCurrentIndexChanged: { itemLoader.sourceComponent = Qt.binding(function() { switch(comboSelector.currentIndex) { - case 1: return textDemoComponent; - case 2: return itemPreviewComponent; - case 3: return materiaButtonComponent; - case 4: return materiaEditorComponent; + case 1: return textDemoComponent + case 2: return itemPreviewComponent + case 3: return materiaButtonComponent + case 4: return materiaEditorComponent + case 5: return materiaSelectorComponent default: return testComponent; } }) @@ -132,6 +134,16 @@ ApplicationWindow { id: textDemoComponent TextDemo { } } + Component { + id: materiaSelectorComponent + Item{ + anchors.fill: parent + MateriaSelector { + anchors.left: parent.left; + anchors.leftMargin: 6 + } + } + } Component { id: materiaEditorComponent @@ -189,7 +201,7 @@ ApplicationWindow { } MateriaEditor { id: materiaEditor - anchors { fill: parent; topMargin: materiaEditorControls.height + 3 } + anchors { fill: parent; topMargin: materiaEditorControls.height + 6; leftMargin: 6; rightMargin: 6 } } } } diff --git a/src/ff7tkQuick/Controls/CMakeLists.txt b/src/ff7tkQuick/Controls/CMakeLists.txt index bda1ba69f..8bfd27b2b 100644 --- a/src/ff7tkQuick/Controls/CMakeLists.txt +++ b/src/ff7tkQuick/Controls/CMakeLists.txt @@ -12,6 +12,7 @@ set(${libName}_URI "ff7tkQuick.Controls") set(${libName}_QMLFILES ItemPreview.qml + MateriaSelector.qml MateriaEditor.qml MateriaSlotButton.qml Components/ApplicationWindow.qml diff --git a/src/ff7tkQuick/Controls/MateriaEditor.qml b/src/ff7tkQuick/Controls/MateriaEditor.qml index 53c5834d9..6fa0821c8 100644 --- a/src/ff7tkQuick/Controls/MateriaEditor.qml +++ b/src/ff7tkQuick/Controls/MateriaEditor.qml @@ -22,12 +22,12 @@ import "Components" as FFComps Item { id: root - implicitWidth: childrenRect.width + 12 - property bool showPlaceHolderMateria: true + implicitWidth: mSelector.implicitWidth + (24 * 4) + property alias showPlaceHolderMateria: mSelector.showPlaceHolderMateria property bool editable: true property bool fixedHeightSkills: true property int starHeight: 24 - property int currentId: FF7Materia.EmptyId + property alias currentId: mSelector.currentId property int currentAp: FF7Materia.maxMateriaAp readonly property bool isEmpty: ((currentId === FF7Materia.EmptyId)) readonly property int level: FF7Materia.materiaLevel(currentId, currentAp) @@ -35,19 +35,6 @@ Item { signal cutActionTriggered(int currentId, int currentAp) signal pasteActionTriggered() - ListModel { - id: typeModel - ListElement { text: qsTr("All Materia"); icon: "qrc:/materia/all" } - ListElement { text: qsTr("Magic"); icon: "qrc:/materia/magic" } - ListElement { text: qsTr("Summon"); icon: "qrc:/materia/summon" } - ListElement { text: qsTr("Independent"); icon: "qrc:/materia/independent" } - ListElement { text: qsTr("Support"); icon: "qrc:/materia/support" } - ListElement { text: qsTr("Command"); icon: "qrc:/materia/command" } - } - - ListModel { id: materiaModel } - Component.onCompleted: { setupMateriaModel(0); materiaCombo.modelChanged() } - Rectangle { anchors.fill: parent color: palette.base @@ -57,27 +44,19 @@ Item { anchors.right: parent.right anchors.top: parent.top height: 24 - anchors.margins: 6 + anchors.leftMargin: 6 + anchors.rightMargin: 6 spacing: 6 - FFComps.ComboBox { - id: typeCombo - visible: root.editable - Layout.fillHeight: true - Layout.preferredWidth: implicitWidth - model: typeModel - onCurrentIndexChanged: setupMateriaModel(currentIndex) - } - FFComps.ComboBox { - id: materiaCombo + MateriaSelector { + id: mSelector visible: root.editable Layout.fillHeight: true Layout.fillWidth: true - Layout.minimumWidth: implicitWidth - model: materiaModel - onCurrentIndexChanged: currentId = currentIndex !== -1 ? model.get(currentIndex).data : currentId + Layout.preferredWidth: mSelector.implicitWidth + 12 } Image { visible: !root.editable && currentId !== FF7Materia.EmptyId + Layout.margins: 4 Layout.fillHeight: true Layout.preferredWidth: height source: FF7Materia.iconResource(currentId) @@ -361,21 +340,4 @@ Item { } } } - - onShowPlaceHolderMateriaChanged: { - var cI = materiaCombo.currentIndex - typeCombo.currentIndex === 0 ? setupMateriaModel(typeCombo.currentIndex) : null - materiaCombo.currentIndex = cI - } - - function setupMateriaModel(type) { - materiaModel.clear() - for (let i = 0 ; i <= 90; i++) { - if( (type === 0 || FF7Materia.type(i) === type) && FF7Materia.name(i) !== "") { - if(String(FF7Materia.name(i)).includes(":") && !root.showPlaceHolderMateria) - continue; - materiaModel.append({ text: FF7Materia.name(i), icon: FF7Materia.iconResource(i), data: i}) - } - } - } } diff --git a/src/ff7tkQuick/Controls/MateriaSelector.qml b/src/ff7tkQuick/Controls/MateriaSelector.qml new file mode 100644 index 000000000..eacb804af --- /dev/null +++ b/src/ff7tkQuick/Controls/MateriaSelector.qml @@ -0,0 +1,80 @@ +/****************************************************************************/ +// copyright 2022 - 2023 Chris Rizzitello // +// // +// This file is part of FF7tk // +// // +// FF7tk is free software: you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation, either version 3 of the License, or // +// (at your option) any later version. // +// // +// FF7tk is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +/****************************************************************************/ + +import QtQuick +import QtQuick.Layouts +import QtQuick.Controls +import ff7tkQuick.DataTypes +import "Components" as FFComps + +Item { + id: root + implicitWidth: typeCombo.implicitWidth + materiaCombo.implicitWidth + 18 + implicitHeight: 24 + property bool showPlaceHolderMateria: true + property int currentId: FF7Materia.EmptyId + + ListModel { + id: typeModel + ListElement { text: qsTr("All Materia"); icon: "qrc:/materia/all" } + ListElement { text: qsTr("Magic"); icon: "qrc:/materia/magic" } + ListElement { text: qsTr("Summon"); icon: "qrc:/materia/summon" } + ListElement { text: qsTr("Independent"); icon: "qrc:/materia/independent" } + ListElement { text: qsTr("Support"); icon: "qrc:/materia/support" } + ListElement { text: qsTr("Command"); icon: "qrc:/materia/command" } + } + + ListModel { id: materiaModel } + Component.onCompleted: { setupMateriaModel(0); materiaCombo.modelChanged() } + RowLayout { + id: selectorRow + anchors.fill: parent + height: 24 + spacing: 6 + FFComps.ComboBox { + id: typeCombo + Layout.fillHeight: true + Layout.preferredWidth: typeCombo.implicitWidth + model: typeModel + onCurrentIndexChanged: setupMateriaModel(currentIndex) + } + FFComps.ComboBox { + id: materiaCombo + Layout.fillHeight: true + Layout.fillWidth: true + Layout.minimumWidth: materiaCombo.implicitWidth + model: materiaModel + onCurrentIndexChanged: currentId = currentIndex !== -1 ? model.get(currentIndex).data : currentId + } + } + + onShowPlaceHolderMateriaChanged: { + var cI = materiaCombo.currentIndex + typeCombo.currentIndex === 0 ? setupMateriaModel(typeCombo.currentIndex) : null + materiaCombo.currentIndex = cI + } + + function setupMateriaModel(type) { + materiaModel.clear() + for (let i = 0 ; i <= 90; i++) { + if( (type === 0 || FF7Materia.type(i) === type) && FF7Materia.name(i) !== "") { + if(String(FF7Materia.name(i)).includes(":") && !root.showPlaceHolderMateria) + continue; + materiaModel.append({ text: FF7Materia.name(i), icon: FF7Materia.iconResource(i), data: i}) + } + } + } +} diff --git a/translations/ff7tk_de.ts b/translations/ff7tk_de.ts index 54c4f5d96..eb0698575 100644 --- a/translations/ff7tk_de.ts +++ b/translations/ff7tk_de.ts @@ -7282,6 +7282,33 @@ Die km / h beschleunigt berechnet werden während des Spielens Zusatzwirkung + + MateriaSelector + + All Materia + alle Materia + + + Magic + Magie + + + Summon + Beschwörung + + + Independent + Unabhängig + + + Support + Unterstützung + + + Command + Befehl + + MenuListWidget diff --git a/translations/ff7tk_en.ts b/translations/ff7tk_en.ts index 6700f8b1c..4d48d6afd 100644 --- a/translations/ff7tk_en.ts +++ b/translations/ff7tk_en.ts @@ -7282,6 +7282,33 @@ The km/h speeds are calculated while playing Added Effect + + MateriaSelector + + All Materia + All Materia + + + Magic + Magic + + + Summon + Summon + + + Independent + Independent + + + Support + Support + + + Command + Command + + MenuListWidget diff --git a/translations/ff7tk_es.ts b/translations/ff7tk_es.ts index 5fae9345d..fe1ac9796 100644 --- a/translations/ff7tk_es.ts +++ b/translations/ff7tk_es.ts @@ -7282,6 +7282,33 @@ Los km/h son calculados mientras se juega Efecto añaddo + + MateriaSelector + + All Materia + Toda la materia + + + Magic + Magia + + + Summon + Invocación + + + Independent + Independiente + + + Support + Soporte + + + Command + Comando + + MenuListWidget diff --git a/translations/ff7tk_fr.ts b/translations/ff7tk_fr.ts index 03f03e6ec..db1e76ff9 100644 --- a/translations/ff7tk_fr.ts +++ b/translations/ff7tk_fr.ts @@ -7282,6 +7282,33 @@ Les vitesses en km/h sont calculés pendant le jeu Effet suppl + + MateriaSelector + + All Materia + Toutes les matérias + + + Magic + Magie + + + Summon + Invocation + + + Independent + Indépendante + + + Support + Soutien + + + Command + Commande + + MenuListWidget diff --git a/translations/ff7tk_it.ts b/translations/ff7tk_it.ts index b17e07ec3..bf0c7cb41 100644 --- a/translations/ff7tk_it.ts +++ b/translations/ff7tk_it.ts @@ -7293,6 +7293,33 @@ Battaglia %1 Ripristina + + MateriaSelector + + All Materia + Tutte le materie + + + Magic + + + + Summon + Di invocazione + + + Independent + Indipendenti + + + Support + Supporto + + + Command + Comando + + MenuListWidget diff --git a/translations/ff7tk_ja.ts b/translations/ff7tk_ja.ts index 2cc4ad8e0..85209da92 100644 --- a/translations/ff7tk_ja.ts +++ b/translations/ff7tk_ja.ts @@ -7282,6 +7282,33 @@ The km/h speeds are calculated while playing ついかこうか + + MateriaSelector + + All Materia + すべてのマテリア + + + Magic + まほう + + + Summon + しょうかん + + + Independent + どくりつ + + + Support + しえん + + + Command + コマンド + + MenuListWidget diff --git a/translations/ff7tk_pl.ts b/translations/ff7tk_pl.ts index f1e589263..b3dba7915 100644 --- a/translations/ff7tk_pl.ts +++ b/translations/ff7tk_pl.ts @@ -7281,6 +7281,33 @@ The km/h speeds are calculated while playing Wyczyść + + MateriaSelector + + All Materia + Cała Materia + + + Magic + Magia + + + Summon + Wezwanie + + + Independent + Niezależny + + + Support + Wsparcie + + + Command + Komenda + + MenuListWidget diff --git a/translations/ff7tk_re.ts b/translations/ff7tk_re.ts index e29595939..a4b96620c 100644 --- a/translations/ff7tk_re.ts +++ b/translations/ff7tk_re.ts @@ -7282,6 +7282,33 @@ The km/h speeds are calculated while playing Command + + MateriaSelector + + All Materia + All Materia + + + Magic + Magic + + + Summon + Summon + + + Independent + Independent + + + Support + Support + + + Command + Command + + MenuListWidget