Qml/Main: clean up mod install logic
This commit is contained in:
parent
fa8421ff42
commit
8be97c1f5b
1 changed files with 27 additions and 22 deletions
|
|
@ -32,6 +32,33 @@ Kirigami.ApplicationWindow {
|
||||||
isMenu: true
|
isMenu: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
QModInstaller.statusChanged.connect(installerStatusChanged);
|
||||||
|
QModInstaller.finishedInstall.connect(installDialog.close);
|
||||||
|
}
|
||||||
|
|
||||||
|
function installerStatusChanged() {
|
||||||
|
switch (QModInstaller.status) {
|
||||||
|
case "initialized":
|
||||||
|
if (QModInstaller.installed) {
|
||||||
|
installInfoMessage.text = "This mod is already installed!";
|
||||||
|
installInfoDialog.open();
|
||||||
|
} else {
|
||||||
|
installDialog.open();
|
||||||
|
QModInstaller.install();
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Dialogs.FileDialog {
|
Dialogs.FileDialog {
|
||||||
id: modFileDialog
|
id: modFileDialog
|
||||||
|
|
||||||
|
|
@ -39,28 +66,6 @@ Kirigami.ApplicationWindow {
|
||||||
selectedNameFilter.index: 0
|
selectedNameFilter.index: 0
|
||||||
|
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
QModInstaller.statusChanged.connect(() => {
|
|
||||||
switch (QModInstaller.status) {
|
|
||||||
case "initialized":
|
|
||||||
if (QModInstaller.installed) {
|
|
||||||
installInfoMessage.text = "This mod is already installed!";
|
|
||||||
installInfoDialog.open();
|
|
||||||
} else {
|
|
||||||
installDialog.open();
|
|
||||||
QModInstaller.finishedInstall.connect(() => installDialog.close())
|
|
||||||
QModInstaller.install();
|
|
||||||
}
|
|
||||||
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;
|
QModInstaller.modPath = selectedFile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue