mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 07:27:04 +02:00
prevent uninstall icon from disapearing
This commit is contained in:
parent
44e196c588
commit
35ed5031a3
1 changed files with 25 additions and 10 deletions
|
@ -14,7 +14,16 @@
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QTime>
|
||||||
|
|
||||||
|
|
||||||
|
void timeDelay() {
|
||||||
|
static const int ONE_SECOND = 1;
|
||||||
|
QTime delayTime = QTime::currentTime().addSecs(ONE_SECOND);
|
||||||
|
while (QTime::currentTime() < delayTime) {
|
||||||
|
qDebug() << "Delaying time";
|
||||||
|
}
|
||||||
|
}
|
||||||
LauncherInstaller::LauncherInstaller() {
|
LauncherInstaller::LauncherInstaller() {
|
||||||
_launcherInstallDir = PathUtils::getLauncherDirectory();
|
_launcherInstallDir = PathUtils::getLauncherDirectory();
|
||||||
_launcherApplicationsDir = PathUtils::getApplicationsDirectory();
|
_launcherApplicationsDir = PathUtils::getApplicationsDirectory();
|
||||||
|
@ -56,8 +65,8 @@ void LauncherInstaller::install() {
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteShortcuts();
|
deleteShortcuts();
|
||||||
createShortcuts();
|
|
||||||
deleteApplicationRegistryKeys();
|
deleteApplicationRegistryKeys();
|
||||||
|
createShortcuts();
|
||||||
createApplicationRegistryKeys();
|
createApplicationRegistryKeys();
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Failed to install HQ Launcher";
|
qDebug() << "Failed to install HQ Launcher";
|
||||||
|
@ -67,26 +76,26 @@ void LauncherInstaller::install() {
|
||||||
void LauncherInstaller::createShortcuts() {
|
void LauncherInstaller::createShortcuts() {
|
||||||
QString launcherPath = PathUtils::getLauncherFilePath();
|
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);
|
QDir desktopDir = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
|
||||||
|
|
||||||
QString appStartLinkPath = _launcherApplicationsDir.absoluteFilePath("HQ Launcher.lnk");
|
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");
|
QString desktopAppLinkPath = desktopDir.absoluteFilePath("HQ Launcher.lnk");
|
||||||
|
|
||||||
|
|
||||||
createSymbolicLink((LPCSTR)launcherPath.toStdString().c_str(), (LPCSTR)uninstallLinkPath.toStdString().c_str(),
|
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(),
|
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(),
|
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(),
|
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() {
|
QString randomQtString() {
|
||||||
|
@ -142,6 +151,12 @@ void LauncherInstaller::uninstall() {
|
||||||
}
|
}
|
||||||
return;
|
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");
|
QString launcherPath = _launcherInstallDir.absoluteFilePath("HQ Launcher.exe");
|
||||||
if (QFile::exists(launcherPath)) {
|
if (QFile::exists(launcherPath)) {
|
||||||
bool removed = QFile::remove(launcherPath);
|
bool removed = QFile::remove(launcherPath);
|
||||||
|
@ -154,7 +169,7 @@ void LauncherInstaller::deleteShortcuts() {
|
||||||
QDir desktopDir = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
|
QDir desktopDir = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
|
||||||
QString applicationPath = _launcherApplicationsDir.absolutePath();
|
QString applicationPath = _launcherApplicationsDir.absolutePath();
|
||||||
|
|
||||||
QString uninstallLinkPath = _launcherInstallDir.absoluteFilePath("Uninstall HQ.lnk");
|
QString uninstallLinkPath = _launcherInstallDir.absoluteFilePath("Uninstall HQ Launcher.lnk");
|
||||||
if (QFile::exists(uninstallLinkPath)) {
|
if (QFile::exists(uninstallLinkPath)) {
|
||||||
QFile::remove(uninstallLinkPath);
|
QFile::remove(uninstallLinkPath);
|
||||||
}
|
}
|
||||||
|
@ -164,7 +179,7 @@ void LauncherInstaller::deleteShortcuts() {
|
||||||
QFile::remove(appStartLinkPath);
|
QFile::remove(appStartLinkPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString uninstallAppStartLinkPath = _launcherApplicationsDir.absoluteFilePath("Uninstall HQ.lnk");
|
QString uninstallAppStartLinkPath = _launcherApplicationsDir.absoluteFilePath("Uninstall HQ Launcher.lnk");
|
||||||
if (QFile::exists(uninstallAppStartLinkPath)) {
|
if (QFile::exists(uninstallAppStartLinkPath)) {
|
||||||
QFile::remove(uninstallAppStartLinkPath);
|
QFile::remove(uninstallAppStartLinkPath);
|
||||||
}
|
}
|
||||||
|
@ -212,7 +227,7 @@ void LauncherInstaller::uninstallOldLauncher() {
|
||||||
|
|
||||||
void LauncherInstaller::createApplicationRegistryKeys() {
|
void LauncherInstaller::createApplicationRegistryKeys() {
|
||||||
const std::string REGISTRY_PATH = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\HQ";
|
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();
|
std::string installPath = _launcherInstallDir.absolutePath().replace("/", "\\").toStdString();
|
||||||
success = insertRegistryKey(REGISTRY_PATH, "InstallLocation", installPath);
|
success = insertRegistryKey(REGISTRY_PATH, "InstallLocation", installPath);
|
||||||
std::string applicationExe = installPath + "\\HQ Launcher.exe";
|
std::string applicationExe = installPath + "\\HQ Launcher.exe";
|
||||||
|
|
Loading…
Reference in a new issue