From 35ed5031a3dfe8c3c1cb26758a071a0f5d312d92 Mon Sep 17 00:00:00 2001 From: danteruiz Date: Fri, 1 Nov 2019 15:11:28 -0700 Subject: [PATCH] prevent uninstall icon from disapearing --- .../qt/src/LauncherInstaller_windows.cpp | 35 +++++++++++++------ 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/launchers/qt/src/LauncherInstaller_windows.cpp b/launchers/qt/src/LauncherInstaller_windows.cpp index 78c7dadd2b..a166074c01 100644 --- a/launchers/qt/src/LauncherInstaller_windows.cpp +++ b/launchers/qt/src/LauncherInstaller_windows.cpp @@ -14,7 +14,16 @@ #include #include #include +#include + +void timeDelay() { + static const int ONE_SECOND = 1; + QTime delayTime = QTime::currentTime().addSecs(ONE_SECOND); + while (QTime::currentTime() < delayTime) { + qDebug() << "Delaying time"; + } +} LauncherInstaller::LauncherInstaller() { _launcherInstallDir = PathUtils::getLauncherDirectory(); _launcherApplicationsDir = PathUtils::getApplicationsDirectory(); @@ -56,8 +65,8 @@ void LauncherInstaller::install() { } deleteShortcuts(); - createShortcuts(); deleteApplicationRegistryKeys(); + createShortcuts(); createApplicationRegistryKeys(); } else { qDebug() << "Failed to install HQ Launcher"; @@ -67,26 +76,26 @@ void LauncherInstaller::install() { void LauncherInstaller::createShortcuts() { QString launcherPath = PathUtils::getLauncherFilePath(); - QString uninstallLinkPath = _launcherInstallDir.absoluteFilePath("Uninstall HQ.lnk"); + QString uninstallLinkPath = _launcherInstallDir.absoluteFilePath("Uninstall HQ Launcher.lnk"); QDir desktopDir = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); QString appStartLinkPath = _launcherApplicationsDir.absoluteFilePath("HQ Launcher.lnk"); - QString uninstallAppStartLinkPath = _launcherApplicationsDir.absoluteFilePath("Uninstall HQ.lnk"); + QString uninstallAppStartLinkPath = _launcherApplicationsDir.absoluteFilePath("Uninstall HQ Launcher.lnk"); QString desktopAppLinkPath = desktopDir.absoluteFilePath("HQ Launcher.lnk"); createSymbolicLink((LPCSTR)launcherPath.toStdString().c_str(), (LPCSTR)uninstallLinkPath.toStdString().c_str(), - (LPCSTR)("Click to Uninstall HQ"), (LPCSTR)("--uninstall")); + (LPCSTR)("Click to Uninstall HQ Launcher"), (LPCSTR)("--uninstall")); createSymbolicLink((LPCSTR)launcherPath.toStdString().c_str(), (LPCSTR)uninstallAppStartLinkPath.toStdString().c_str(), - (LPCSTR)("Click to Uninstall HQ"), (LPCSTR)("--uninstall")); + (LPCSTR)("Click to Uninstall HQ Launcher"), (LPCSTR)("--uninstall")); createSymbolicLink((LPCSTR)launcherPath.toStdString().c_str(), (LPCSTR)desktopAppLinkPath.toStdString().c_str(), - (LPCSTR)("Click to Setup and Launch HQ")); + (LPCSTR)("Click to Setup and Launch HQ Launcher")); createSymbolicLink((LPCSTR)launcherPath.toStdString().c_str(), (LPCSTR)appStartLinkPath.toStdString().c_str(), - (LPCSTR)("Click to Setup and Launch HQ")); + (LPCSTR)("Click to Setup and Launch HQ Launcher")); } QString randomQtString() { @@ -142,6 +151,12 @@ void LauncherInstaller::uninstall() { } return; } + + if (options->contains("--resumeUninstall")) { + // delaying time here to make sure that the previous process exits + // before we try to delete it the file. + timeDelay(); + } QString launcherPath = _launcherInstallDir.absoluteFilePath("HQ Launcher.exe"); if (QFile::exists(launcherPath)) { bool removed = QFile::remove(launcherPath); @@ -154,7 +169,7 @@ void LauncherInstaller::deleteShortcuts() { QDir desktopDir = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); QString applicationPath = _launcherApplicationsDir.absolutePath(); - QString uninstallLinkPath = _launcherInstallDir.absoluteFilePath("Uninstall HQ.lnk"); + QString uninstallLinkPath = _launcherInstallDir.absoluteFilePath("Uninstall HQ Launcher.lnk"); if (QFile::exists(uninstallLinkPath)) { QFile::remove(uninstallLinkPath); } @@ -164,7 +179,7 @@ void LauncherInstaller::deleteShortcuts() { QFile::remove(appStartLinkPath); } - QString uninstallAppStartLinkPath = _launcherApplicationsDir.absoluteFilePath("Uninstall HQ.lnk"); + QString uninstallAppStartLinkPath = _launcherApplicationsDir.absoluteFilePath("Uninstall HQ Launcher.lnk"); if (QFile::exists(uninstallAppStartLinkPath)) { QFile::remove(uninstallAppStartLinkPath); } @@ -212,7 +227,7 @@ void LauncherInstaller::uninstallOldLauncher() { void LauncherInstaller::createApplicationRegistryKeys() { const std::string REGISTRY_PATH = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\HQ"; - bool success = insertRegistryKey(REGISTRY_PATH, "DisplayName", "HQ"); + bool success = insertRegistryKey(REGISTRY_PATH, "DisplayName", "HQ Launcher"); std::string installPath = _launcherInstallDir.absolutePath().replace("/", "\\").toStdString(); success = insertRegistryKey(REGISTRY_PATH, "InstallLocation", installPath); std::string applicationExe = installPath + "\\HQ Launcher.exe";