diff options
| author | Victor Tran <vicr12345@gmail.com> | 2018-07-13 14:55:07 +1000 |
|---|---|---|
| committer | Victor Tran <vicr12345@gmail.com> | 2018-07-13 14:55:07 +1000 |
| commit | e8ca150c38478cfd4a762dccd3da1752ee19ab29 (patch) | |
| tree | 57038a26154d95206940fadc3e823f8038b70c11 /installer/main.cpp | |
| parent | abc4021919f406ee25e101122144879f8770d51d (diff) | |
| download | theInstaller-e8ca150c38478cfd4a762dccd3da1752ee19ab29.tar.gz theInstaller-e8ca150c38478cfd4a762dccd3da1752ee19ab29.tar.bz2 theInstaller-e8ca150c38478cfd4a762dccd3da1752ee19ab29.zip | |
Add/Remove Programs support
Diffstat (limited to 'installer/main.cpp')
| -rw-r--r-- | installer/main.cpp | 17 |
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 |
