aboutsummaryrefslogtreecommitdiff
path: root/installer/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'installer/main.cpp')
-rw-r--r--installer/main.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/installer/main.cpp b/installer/main.cpp
index b29c90d..ec07db9 100644
--- a/installer/main.cpp
+++ b/installer/main.cpp
@@ -6,6 +6,8 @@
#include <QTranslator>
#include <QLibraryInfo>
#include <QFile>
+#include <QTemporaryFile>
+#include <QMessageBox>
int main(int argc, char *argv[])
{
@@ -36,12 +38,25 @@ int main(int argc, char *argv[])
a.setQuitOnLastWindowClosed(false);
return a.exec();
- } else if (QFile(a.applicationDirPath() + "/uninstall.json").exists()) {
+ } else if (a.arguments().contains("--uninstallmetadata")) {
//Modify UI mode
MaintainWindow w;
w.show();
return a.exec();
+ } else if (QFile(a.applicationDirPath() + "/uninstall.json").exists()) {
+ //Prepare uninstall mode
+ QString tempInstallerPath = QDir::tempPath() + "/theinstaller.exe";
+ if (QFile::exists(tempInstallerPath)) {
+ QFile::remove(tempInstallerPath);
+ }
+ if (QFile::copy(QApplication::applicationFilePath(), tempInstallerPath)) {
+ QProcess::startDetached(tempInstallerPath, QStringList() << "--uninstallmetadata" << a.applicationDirPath() + "/uninstall.json");
+ return 0;
+ } else {
+ QMessageBox::warning(nullptr, "Error", "Failed to prepare uninstallation", QMessageBox::Ok, QMessageBox::Ok);
+ return 1;
+ }
}
//Install UI mode