167 lines
5.2 KiB
QML
167 lines
5.2 KiB
QML
import QtQuick
|
|
import QtQuick.Layouts
|
|
import QtQuick.Controls as Controls
|
|
import QtQuick.Dialogs as Dialogs
|
|
import org.kde.kirigami as Kirigami
|
|
import Leek
|
|
import Leek.QModInstaller
|
|
|
|
Kirigami.ApplicationWindow {
|
|
id: root
|
|
|
|
title: "Leek"
|
|
|
|
globalDrawer: Kirigami.GlobalDrawer {
|
|
actions: [
|
|
Kirigami.Action {
|
|
// download-symbolic and install-symbolic are the same icon
|
|
// but install looks worse for some reason
|
|
id: addAction
|
|
icon.name: "download-symbolic"
|
|
text: "Add mod"
|
|
shortcut: StandardKey.New
|
|
onTriggered: modFileDialog.open()
|
|
},
|
|
Kirigami.Action {
|
|
text: "Quit"
|
|
icon.name: "application-exit-symbolic"
|
|
shortcut: StandardKey.Quit
|
|
onTriggered: Qt.quit()
|
|
}
|
|
]
|
|
isMenu: true
|
|
}
|
|
|
|
Dialogs.FileDialog {
|
|
id: modFileDialog
|
|
|
|
nameFilters: ["Project DIVA Mods (*.zip *.7z *.rar)"]
|
|
selectedNameFilter.index: 0
|
|
|
|
onAccepted: {
|
|
installInfoDialog.open();
|
|
QModInstaller.statusChanged.connect(() => {
|
|
switch (QModInstaller.status) {
|
|
case "initialized":
|
|
if (QModInstaller.installed) {
|
|
installInfoMessage.text = "This mod is already installed!";
|
|
installInfoDialog.open();
|
|
}
|
|
break;
|
|
case "NoModExceptionError":
|
|
installInfoMessage.text = "This file does not have a mod";
|
|
installInfoDialog.open();
|
|
break;
|
|
case "UnsupportedArchiveTypeError":
|
|
installInfoMessage.text = "I don't know how to unpack this file, sorry :(";
|
|
installInfoDialog.open();
|
|
break;
|
|
}
|
|
});
|
|
QModInstaller.modPath = selectedFile;
|
|
}
|
|
}
|
|
|
|
Kirigami.Dialog {
|
|
id: installInfoDialog
|
|
title: "Add mod"
|
|
standardButtons: Kirigami.Dialog.Ok
|
|
padding: Kirigami.Units.largeSpacing
|
|
Controls.Label {
|
|
id: installInfoMessage
|
|
text: "You should never see this text"
|
|
}
|
|
}
|
|
|
|
pageStack.columnView.columnResizeMode: Kirigami.ColumnView.SingleColumn
|
|
pageStack.initialPage: Kirigami.ScrollablePage {
|
|
title: "Mods"
|
|
|
|
Kirigami.CardsListView {
|
|
id: modsView
|
|
|
|
delegate: ModCardDelegate {}
|
|
model: QModListModel
|
|
|
|
Kirigami.PlaceholderMessage {
|
|
anchors.centerIn: parent
|
|
icon.name: "edit-none"
|
|
visible: modsView.count === 0
|
|
text: "There's no mods installed"
|
|
explanation: "Install a mod, and it will show up here"
|
|
helpfulAction: addAction
|
|
}
|
|
}
|
|
}
|
|
|
|
component ModCardDelegate: Kirigami.AbstractCard {
|
|
required property int index
|
|
required property QMod mod
|
|
|
|
showClickFeedback: true
|
|
onClicked: pageStack.push(Qt.resolvedUrl("ModPage.qml"), {
|
|
mod: mod,
|
|
index: index
|
|
})
|
|
|
|
// headerOrientation: Qt.Horizontal
|
|
contentItem: Item {
|
|
implicitHeight: modCardLayout.implicitHeight
|
|
implicitWidth: modCardLayout.implicitWidth
|
|
|
|
GridLayout {
|
|
id: modCardLayout
|
|
|
|
columnSpacing: Kirigami.Units.largeSpacing
|
|
columns: root.wideScreen ? 4 : 2
|
|
rowSpacing: Kirigami.Units.largeSpacing
|
|
|
|
anchors {
|
|
left: parent.left
|
|
right: parent.right
|
|
top: parent.top
|
|
}
|
|
|
|
// TODO: Replace this with an image once we can get them
|
|
|
|
Kirigami.Padding {
|
|
padding: Kirigami.Units.largeSpacing
|
|
|
|
contentItem: Kirigami.Icon {
|
|
implicitHeight: Kirigami.Units.iconSizes.huge
|
|
implicitWidth: implicitHeight
|
|
source: "package-x-generic"
|
|
}
|
|
}
|
|
ColumnLayout {
|
|
Kirigami.Heading {
|
|
Layout.fillWidth: true
|
|
text: mod.name
|
|
type: Kirigami.Heading.Type.Primary
|
|
}
|
|
Kirigami.Separator {
|
|
Layout.fillWidth: true
|
|
}
|
|
Controls.Label {
|
|
property string desc: mod.description
|
|
|
|
Layout.fillWidth: true
|
|
font.italic: desc ? false : true
|
|
text: desc ? desc : "No description available"
|
|
wrapMode: Text.WordWrap
|
|
}
|
|
}
|
|
ColumnLayout {
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
Controls.Switch {
|
|
checked: mod.enabled
|
|
Layout.alignment: Qt.AlignCenter
|
|
|
|
onClicked: mod.enabled = checked
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|