Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qml: Base Components for Controls #140

Merged
merged 8 commits into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 36 additions & 34 deletions demos/ff7tkQmlGallery/TextDemo.qml
Original file line number Diff line number Diff line change
Expand Up @@ -15,47 +15,49 @@
/****************************************************************************/

import QtQuick
import QtQuick.Controls
import QtQuick.Controls as QQC
import ff7tkQuick.DataTypes
import ff7tkQuick.Controls

Item {
id:root

Column {
anchors.fill: parent
TextField{
id:txtInput
anchors.left: parent.left
anchors.right: parent.right
placeholderText: "Text to Convert"
}
Row {
id: btnRow
anchors.horizontalCenter: parent.horizontalCenter
spacing: 6
CheckBox {
anchors.top: parent.top
text: "Use Japanese Pc output"
onCheckedChanged: FF7Text.japanese = checkState
Column {
anchors.fill: parent
spacing: 3
QQC.TextField{
id:txtInput
anchors.left: parent.left
anchors.right: parent.right
placeholderText: "Text to Convert"
}
Button {
anchors.top:parent.top
text:"Convert to PC"
enabled: txtInput.text !== ""
onClicked: txtOutput.text = FF7Text.toPC(txtInput.text)
Row {
id: btnRow
anchors.horizontalCenter: parent.horizontalCenter
spacing: 6
CheckBox {
anchors.top: parent.top
text: "Use Japanese Pc output"
onCheckedChanged: FF7Text.japanese = checkState
}
Button {
anchors.top:parent.top
text:"Convert to PC"
enabled: txtInput.text !== ""
onClicked: txtOutput.text = FF7Text.toPC(txtInput.text)
}
Button {
anchors.top: parent.top
text: "Convert to FF7Text"
enabled: txtInput.text !== ""
onClicked: txtOutput.text = FF7Text.toFF7(txtInput.text)
}
}
Button {
anchors.top: parent.top
text: "Convert to FF7Text"
enabled: txtInput.text !== ""
onClicked: txtOutput.text = FF7Text.toFF7(txtInput.text)
QQC.TextField{
id:txtOutput
anchors.left: parent.left
anchors.right: parent.right
placeholderText: "Converted Text Here"
}
}
TextField{
id:txtOutput
anchors.left: parent.left
anchors.right: parent.right
placeholderText: "Converted Text Here"
}
}
}
200 changes: 139 additions & 61 deletions demos/ff7tkQmlGallery/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,50 @@
/****************************************************************************/

import QtQuick
import QtQuick.Controls
import QtQuick.Controls as QQC
import ff7tkQuick.DataTypes
import ff7tkQuick.Controls as FF7tkControls
import ff7tkQuick.Controls


ApplicationWindow {
id: root
width: 800
height: 600
title: "ff7tkQmlGallery-" + FF7tkInfo.ff7tkVersion
visible: true
header: Item {
title: "ff7tkQmlGallery - " + FF7tkInfo.ff7tkVersion
header: Rectangle {
id: headerItem
Text{
color: palette.alternateBase
border.color: palette.dark
border.width: 2
height: comboSelector.height + 12
Label {
id: previewLabel
text: "Current Preview:"
color: palette.text
anchors.verticalCenter: comboSelector.verticalCenter
}
ComboBox {
id: comboSelector
model: ["", "Text Demo", "ItemPreview", "MateriaButton", "MateriaEditor"]
anchors.right: parent.right
anchors.left: previewLabel.right
anchors.leftMargin: 6
anchors {
margins: 6
top: parent.top
left: previewLabel.right; right: parent.right
}
model: ListModel {
ListElement{text: ""}
ListElement{text: "Text Demo"}
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;
}
})
Expand All @@ -56,14 +68,15 @@ ApplicationWindow {
Loader {
id: itemLoader
anchors.fill: parent
anchors.topMargin: comboSelector.height + 6
anchors.topMargin: 6
}

Component {
id: testComponent
Rectangle {
color: "lightblue"
Text {
color: palette.base
Label {
anchors.centerIn:parent
text: "Please Select an Item to Preview"
}
}
Expand All @@ -73,44 +86,43 @@ ApplicationWindow {
id: materiaButtonComponent
Item {
anchors.fill: parent
Label {
id: lbl_materiaId
anchors.top: parent.top
anchors.left: parent.left
palette: palette
text: "Materia Type"
}
ComboBox {
id: combo_materiaID
anchors.top: parent.top
anchors.left: lbl_materiaId.right
anchors.leftMargin: 6
model: [ "None", "Magic", "Support", "Summon","Independent", "Command"]
onCurrentIndexChanged: {
switch (currentIndex) {
case 0: materiaSlotButton.currentID = FF7Materia.EmptyId; break;
case 1: materiaSlotButton.currentID = FF7Materia.Fire; break;
case 2: materiaSlotButton.currentID = FF7Materia.All; break;
case 3: materiaSlotButton.currentID = FF7Materia.ChocoMog; break;
case 4: materiaSlotButton.currentID = FF7Materia.MpPlus; break;
case 5: materiaSlotButton.currentID = FF7Materia.Steal; break;
Item {
anchors.fill: parent
height: 50
Label {
id: lbl_materiaId
anchors.verticalCenter: combo_materiaID.verticalCenter
anchors.left: parent.left
text: "Materia Type"
}
ComboBox {
id: combo_materiaID
anchors.top: parent.top
anchors.left: lbl_materiaId.right
anchors.leftMargin: 6
model: ListModel {
ListElement{text: "None"; value: 0xFF}
ListElement{text: "Magic"; value: FF7Materia.Fire}
ListElement{text: "Support"; value: FF7Materia.All}
ListElement{text: "Summon";value: FF7Materia.ChocoMog}
ListElement{text: "Independent"; value: FF7Materia.MpPlus}
ListElement{text: "Command"; value: FF7Materia.Steal}
}
onCurrentIndexChanged: materiaSlotButton.currentID = combo_materiaID.model.get(currentIndex).value
}
CheckBox {
id: cb_materiaSlotGrowth
anchors.top: combo_materiaID.bottom
anchors.left: parent.left
anchors.margins: 4
text: "Slot Growth"
}
}
CheckBox {
id: cb_materiaSlotGrowth
anchors.top: lbl_materiaId.bottom
height: 30
anchors.left: parent.left
anchors.right: parent.right
text: "Slot Growth"
}
FF7tkControls.MateriaSlotButton {

MateriaSlotButton {
id: materiaSlotButton
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.left: combo_materiaID.right
anchors.right: parent.right
anchors.fill: parent
anchors.topMargin: 60
anchors.margins: 10
currentID: FF7Materia.EmptyId
growthSlot: cb_materiaSlotGrowth.checked
Expand All @@ -122,33 +134,99 @@ ApplicationWindow {
id: textDemoComponent
TextDemo { }
}
Component {
id: materiaSelectorComponent
Item{
anchors.fill: parent
MateriaSelector {
anchors.left: parent.left;
anchors.leftMargin: 6
}
}
}

Component {
id: materiaEditorComponent
FF7tkControls.MateriaEditor { }
Item {
anchors.fill: parent
Rectangle {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
color: palette.alternateBase
height: 50
id: materiaEditorControls
QQC.SpinBox {
id: spStarHeight
anchors.top: parent.top
anchors.left: parent.left
from: 0; to: 256
value: materiaEditor.starHeight
onValueChanged: materiaEditor.starHeight = value
}
Label {
anchors.top:parent.top
anchors.left: spStarHeight.right
text: "Id: " + materiaEditor.currentId
}
Label {
anchors.top:parent.top
anchors.right: parent.right
text: "Ap: " + materiaEditor.currentAp
}
CheckBox {
anchors.left: parent.left
anchors.top: spStarHeight.bottom
anchors.bottom: parent.bottom
text: "Editable"
checked: materiaEditor.editable
onCheckedChanged: materiaEditor.editable = checked
}
CheckBox {
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: spStarHeight.bottom
anchors.bottom: parent.bottom
text: "Show PlaceHolder Materia"
checked: materiaEditor.showPlaceHolderMateria
onCheckedChanged: materiaEditor.showPlaceHolderMateria = checked
}
CheckBox {
anchors.right: parent.right
anchors.top: spStarHeight.bottom
anchors.bottom: parent.bottom
text: "ShortLayout"
checked: materiaEditor.fixedHeightSkills
onCheckedChanged: materiaEditor.fixedHeightSkills = checked
}
}
MateriaEditor {
id: materiaEditor
anchors { fill: parent; topMargin: materiaEditorControls.height + 6; leftMargin: 6; rightMargin: 6 }
}
}
}

Component {
id: itemPreviewComponent
Item{
Text {
Label {
id: itemPreviewOptions
anchors.left: parent.left
anchors.top:parent.top
anchors.verticalCenter: sb_itemNumber.verticalCenter
anchors.margins: 6
text: "FF7ItemPreview - Options"
text: "Item Id to Preview"
}
SpinBox {
QQC.SpinBox {
id:sb_itemNumber
anchors.top: itemPreviewOptions.bottom
anchors.left: parent.left
anchors.margins: 6
anchors.top: parent.top
anchors.left: itemPreviewOptions.right
anchors.rightMargin: 6
editable: true
value: -1
from: -1
to: 319
}
FF7tkControls.ItemPreview {
ItemPreview {
anchors.top: sb_itemNumber.bottom
anchors.bottom: parent.bottom
anchors.left: parent.left
Expand Down
6 changes: 6 additions & 0 deletions src/ff7tkQuick/Controls/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ set(${libName}_URI "ff7tkQuick.Controls")

set(${libName}_QMLFILES
ItemPreview.qml
MateriaSelector.qml
MateriaEditor.qml
MateriaSlotButton.qml
Components/ApplicationWindow.qml
Components/Button.qml
Components/ComboBox.qml
Components/Label.qml
Components/CheckBox.qml
Components/ToolTip.qml
)

set(${libName}_DEPENDS
Expand Down
12 changes: 12 additions & 0 deletions src/ff7tkQuick/Controls/Components/ApplicationWindow.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import QtQuick
import QtQuick.Templates as T

T.ApplicationWindow {
id: root
visible: true
property alias backgroundColor: bk.color
background: Rectangle {
id: bk
color: palette.alternateBase
}
}
Loading