Qml/Main: add error handling to installation
This commit is contained in:
parent
e94d11f138
commit
0cd631c92c
2 changed files with 34 additions and 1 deletions
|
|
@ -38,10 +38,40 @@ Kirigami.ApplicationWindow {
|
||||||
selectedNameFilter.index: 0
|
selectedNameFilter.index: 0
|
||||||
|
|
||||||
onAccepted: {
|
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;
|
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.columnView.columnResizeMode: Kirigami.ColumnView.SingleColumn
|
||||||
pageStack.initialPage: Kirigami.ScrollablePage {
|
pageStack.initialPage: Kirigami.ScrollablePage {
|
||||||
title: "Mods"
|
title: "Mods"
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ from urllib.parse import urlparse
|
||||||
from PySide6.QtCore import Property, QObject, Signal
|
from PySide6.QtCore import Property, QObject, Signal
|
||||||
from PySide6.QtQml import QmlElement, QmlSingleton
|
from PySide6.QtQml import QmlElement, QmlSingleton
|
||||||
|
|
||||||
from leek.mod_installer import ModInstaller, UnsupportedArchiveTypeError
|
from leek.mod_installer import ModInstaller, UnsupportedArchiveTypeError, NoModExceptionError
|
||||||
|
|
||||||
QML_IMPORT_NAME = "Leek.QModInstaller"
|
QML_IMPORT_NAME = "Leek.QModInstaller"
|
||||||
QML_IMPORT_MAJOR_VERSION = 1
|
QML_IMPORT_MAJOR_VERSION = 1
|
||||||
|
|
@ -43,6 +43,9 @@ class QModInstaller(QObject):
|
||||||
except UnsupportedArchiveTypeError:
|
except UnsupportedArchiveTypeError:
|
||||||
self.__status = "UnsupportedArchiveTypeError"
|
self.__status = "UnsupportedArchiveTypeError"
|
||||||
self.status_changed.emit()
|
self.status_changed.emit()
|
||||||
|
except NoModExceptionError:
|
||||||
|
self.__status = "NoModExceptionError"
|
||||||
|
self.status_changed.emit()
|
||||||
|
|
||||||
install_status_changed = Signal(name="installStatusChanged")
|
install_status_changed = Signal(name="installStatusChanged")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue