mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 19:30:41 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi
This commit is contained in:
commit
382b9fabaf
4 changed files with 48 additions and 16 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() {
|
||||||
|
@ -141,20 +150,42 @@ void LauncherInstaller::uninstall() {
|
||||||
qDebug() << "Failed to complete uninstall launcher";
|
qDebug() << "Failed to complete uninstall launcher";
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
|
||||||
|
bool deletedHQLauncherExe = deleteHQLauncherExecutable();
|
||||||
|
if (deletedHQLauncherExe) {
|
||||||
|
qDebug() << "Deleteing registry keys";
|
||||||
|
deleteApplicationRegistryKeys();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LauncherInstaller::deleteHQLauncherExecutable() {
|
||||||
|
static const int MAX_DELETE_ATTEMPTS = 3;
|
||||||
|
|
||||||
|
int deleteAttempts = 0;
|
||||||
|
bool fileRemoved = false;
|
||||||
QString launcherPath = _launcherInstallDir.absoluteFilePath("HQ Launcher.exe");
|
QString launcherPath = _launcherInstallDir.absoluteFilePath("HQ Launcher.exe");
|
||||||
if (QFile::exists(launcherPath)) {
|
while (deleteAttempts < MAX_DELETE_ATTEMPTS) {
|
||||||
bool removed = QFile::remove(launcherPath);
|
fileRemoved = QFile::remove(launcherPath);
|
||||||
qDebug() << "Successfully removed " << launcherPath << ": " << removed;
|
if (fileRemoved) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
timeDelay();
|
||||||
|
deleteAttempts++;
|
||||||
}
|
}
|
||||||
deleteApplicationRegistryKeys();
|
|
||||||
|
qDebug() << "Successfully removed " << launcherPath << ": " << fileRemoved;
|
||||||
|
|
||||||
|
return fileRemoved;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherInstaller::deleteShortcuts() {
|
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 +195,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 +243,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";
|
||||||
|
|
|
@ -15,6 +15,7 @@ private:
|
||||||
void createApplicationRegistryKeys();
|
void createApplicationRegistryKeys();
|
||||||
void deleteShortcuts();
|
void deleteShortcuts();
|
||||||
void deleteApplicationRegistryKeys();
|
void deleteApplicationRegistryKeys();
|
||||||
|
bool deleteHQLauncherExecutable();
|
||||||
|
|
||||||
QDir _launcherInstallDir;
|
QDir _launcherInstallDir;
|
||||||
QDir _launcherApplicationsDir;
|
QDir _launcherApplicationsDir;
|
||||||
|
|
|
@ -28,7 +28,7 @@ QDir PathUtils::getLauncherDirectory() {
|
||||||
}
|
}
|
||||||
|
|
||||||
QDir PathUtils::getApplicationsDirectory() {
|
QDir PathUtils::getApplicationsDirectory() {
|
||||||
return QDir(QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation)).absoluteFilePath("Launcher");
|
return QDir(QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation)).absoluteFilePath("HQ");
|
||||||
}
|
}
|
||||||
|
|
||||||
// The client directory is where interface is installed to.
|
// The client directory is where interface is installed to.
|
||||||
|
|
|
@ -32,7 +32,7 @@ bool hasSuffix(const std::string& path, const std::string& suffix) {
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
QCoreApplication::setOrganizationName("High Fidelity");
|
QCoreApplication::setOrganizationName("High Fidelity");
|
||||||
QCoreApplication::setApplicationName("Launcher");
|
QCoreApplication::setApplicationName("HQ Launcher");
|
||||||
|
|
||||||
Q_INIT_RESOURCE(resources);
|
Q_INIT_RESOURCE(resources);
|
||||||
cleanLogFile();
|
cleanLogFile();
|
||||||
|
|
Loading…
Reference in a new issue