From 8be97c1f5ba08810e3fc808d05d37cce8db256ee Mon Sep 17 00:00:00 2001 From: Toast Date: Fri, 6 Jun 2025 17:59:51 +0200 Subject: [PATCH] Qml/Main: clean up mod install logic --- src/leek/qml/Main.qml | 49 ++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/src/leek/qml/Main.qml b/src/leek/qml/Main.qml index 048a0b5..cf6889b 100644 --- a/src/leek/qml/Main.qml +++ b/src/leek/qml/Main.qml @@ -32,6 +32,33 @@ Kirigami.ApplicationWindow { 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 { id: modFileDialog @@ -39,28 +66,6 @@ Kirigami.ApplicationWindow { selectedNameFilter.index: 0 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; } }