diff --git a/launchers/qt/CMakeLists.txt b/launchers/qt/CMakeLists.txt index 3b3374f152..8155400f45 100644 --- a/launchers/qt/CMakeLists.txt +++ b/launchers/qt/CMakeLists.txt @@ -66,7 +66,12 @@ if (WIN32) list(APPEND CMAKE_PREFIX_PATH ${SOURCE_DIR}/lib/cmake) set(SSL_DIR ${SOURCE_DIR}/ssl) + set(OPENSSL_ROOT_DIR ${SSL_DIR}) message("SSL dir is ${SSL_DIR}") + set(OPENSSL_USE_STATIC_LIBS TRUE) + find_package(OpenSSL REQUIRED) + + message("-- Found OpenSSL Libs ${OPENSSL_LIBRARIES}") endif () @@ -220,8 +225,9 @@ if (WIN32) target_link_libraries(${PROJECT_NAME} wsock32 ws2_32 Winmm version imm32 dwmapi Crypt32 Iphlpapi - "${SSL_DIR}/lib/libeay32.lib" - "${SSL_DIR}/lib/ssleay32.lib" + #"${SSL_DIR}/lib/libeay32.lib" + #"${SSL_DIR}/lib/ssleay32.lib" + ${OPENSSL_LIBRARIES} "${_qt5Core_install_prefix}/qml/QtQuick.2/qtquick2plugin.lib" "${_qt5Core_install_prefix}/qml/QtQuick/Controls.2/qtquickcontrols2plugin.lib" "${_qt5Core_install_prefix}/qml/QtQuick/Templates.2/qtquicktemplates2plugin.lib") diff --git a/launchers/qt/resources/qml/Download.qml b/launchers/qt/resources/qml/Download.qml index 00542d02d0..5c3bb3fd1c 100644 --- a/launchers/qt/resources/qml/Download.qml +++ b/launchers/qt/resources/qml/Download.qml @@ -54,7 +54,7 @@ Item { HFTextRegular { id: secondText - text: "We're getting everything setup for you." + text: "We're getting everything set up for you." anchors { top: firstText.bottom diff --git a/launchers/qt/resources/qml/HFBase/CreateAccountBase.qml b/launchers/qt/resources/qml/HFBase/CreateAccountBase.qml index a3e7ee5557..c419878413 100644 --- a/launchers/qt/resources/qml/HFBase/CreateAccountBase.qml +++ b/launchers/qt/resources/qml/HFBase/CreateAccountBase.qml @@ -8,7 +8,7 @@ import HQLauncher 1.0 Item { id: root anchors.centerIn: parent - property string titleText: "Sign-in and pick a password" + property string titleText: "Sign in and pick a password" property string usernamePlaceholder: "Username" property string passwordPlaceholder: "Set a password (must be at least 6 characters)" property int marginLeft: root.width * 0.15 @@ -30,7 +30,7 @@ Item { width: 481 lineHeight: 35 lineHeightMode: Text.FixedHeight - text: LauncherState.lastSignupErrorMessage.length == 0 ? root.titleText : "Uh oh." + text: LauncherState.lastSignupErrorMessage.length == 0 ? root.titleText : "Uh oh" anchors { top: root.top topMargin: 29 @@ -43,7 +43,7 @@ Item { id: instruction width: 425 - text: "Use the email address you applied for access with." + text: "Use the email address you applied for access with" visible: LauncherState.lastSignupErrorMessage.length == 0 anchors { @@ -136,7 +136,7 @@ Item { HFTextRegular { id: displayNameText - text: "This is the display name other people see in world, it can be changed at anytime, from your profile." + text: "This is the display name other people see in High Fidelity. It can be changed at any time from your profile." wrapMode: Text.Wrap width: 430 @@ -164,7 +164,11 @@ Item { topMargin: 4 } - onAccepted: LauncherState.signup(email.text, username.text, password.text, displayName.text) + onAccepted: { + if (root.enabled && email.text.length > 0 && username.text.length > 0 && password.text.length > 0 && displayName.text.length > 0) { + LauncherState.signup(email.text, username.text, password.text, displayName.text); + } + } } HFButton { @@ -214,7 +218,6 @@ Item { bottom: root.bottom bottomMargin: 46 right: displayName.right - rightMargin: 30 } } diff --git a/launchers/qt/resources/qml/HFBase/Error.qml b/launchers/qt/resources/qml/HFBase/Error.qml index ad57f242f4..98eb1d17ac 100644 --- a/launchers/qt/resources/qml/HFBase/Error.qml +++ b/launchers/qt/resources/qml/HFBase/Error.qml @@ -33,10 +33,6 @@ Item { HFTextHeader { id: header - - width: 87 - height: 31 - text: "Uh oh." anchors { @@ -49,10 +45,7 @@ Item { HFTextRegular { id: description - text: "We seem to have a problem.\nPlease restart Launcher" - - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter + text: "We seem to have a problem.\n Please restart Launcher." anchors { top: header.bottom diff --git a/launchers/qt/resources/qml/HFBase/LoginBase.qml b/launchers/qt/resources/qml/HFBase/LoginBase.qml index cb468f9bc1..1df9950dd4 100644 --- a/launchers/qt/resources/qml/HFBase/LoginBase.qml +++ b/launchers/qt/resources/qml/HFBase/LoginBase.qml @@ -21,7 +21,7 @@ Item { } Item { - width: 353 + width: 430 height: root.height @@ -32,9 +32,8 @@ Item { HFTextHeader { id: title - - font.bold: true - + lineHeight: 35 + lineHeightMode: Text.FixedHeight text: "Please Log in" anchors { @@ -75,6 +74,7 @@ Item { id: username enabled: root.enabled + width: 430 text: LauncherState.lastUsedUsername placeholderText: "Username" @@ -91,7 +91,7 @@ Item { HFTextField { id: password - + width: 430 enabled: root.enabled placeholderText: "Password" @@ -111,7 +111,8 @@ Item { HFTextRegular { id: displayText - text: "You can change this at anytime from your profile." + text: "This is the display name other people see in High Fidelity. It can be changed at any time from your profile." + wrapMode: Text.Wrap anchors { top: password.bottom @@ -124,7 +125,7 @@ Item { HFTextField { id: displayName - + width: 430 enabled: root.enabled placeholderText: "Display name" @@ -136,12 +137,16 @@ Item { left: parent.left right: parent.right; } - onAccepted: LauncherState.login(username.text, password.text, displayName.text) + onAccepted: { + if (root.enabled && username.text.length > 0 && password.text.length > 0 && displayName.text.length > 0) { + LauncherState.login(username.text, password.text, displayName.text); + } + } } HFButton { id: button - width: 110 + width: 134 enabled: root.enabled && username.text.length > 0 && password.text.length > 0 && displayName.text.length > 0 @@ -160,7 +165,7 @@ Item { Text { id: createAccountLink - text: "Create New Account" + text: "Sign up" font.family: "Graphik" font.pixelSize: 14 color: "#009EE0" @@ -190,8 +195,8 @@ Item { right: parent.right } } - } + } Component.onCompleted: { root.parent.setBuildInfoState("right"); } diff --git a/launchers/qt/resources/qml/HFControls/HFButton.qml b/launchers/qt/resources/qml/HFControls/HFButton.qml index a4d077a1e7..727e139360 100644 --- a/launchers/qt/resources/qml/HFControls/HFButton.qml +++ b/launchers/qt/resources/qml/HFControls/HFButton.qml @@ -14,7 +14,7 @@ Button { property int backgroundWidth: 2 font.family: "Graphik Semibold" - font.pointSize: 12 + font.pixelSize: 15 background: Rectangle { implicitWidth: 100 diff --git a/launchers/qt/resources/qml/HFControls/HFTextField.qml b/launchers/qt/resources/qml/HFControls/HFTextField.qml index 133107ddd6..7b5dde0b23 100644 --- a/launchers/qt/resources/qml/HFControls/HFTextField.qml +++ b/launchers/qt/resources/qml/HFControls/HFTextField.qml @@ -7,7 +7,7 @@ TextField { height: 50 font.family: "Graphik Regular" - font.pointSize: 10.5 + font.pixelSize: 14 color: (text.length == 0 || !enabled) ? "#7e8c81" : "#000000" property bool togglePasswordField: false diff --git a/launchers/qt/resources/qml/HFControls/HFTextHeader.qml b/launchers/qt/resources/qml/HFControls/HFTextHeader.qml index f0349d7f5c..914ead46a1 100644 --- a/launchers/qt/resources/qml/HFControls/HFTextHeader.qml +++ b/launchers/qt/resources/qml/HFControls/HFTextHeader.qml @@ -3,6 +3,6 @@ import QtQuick 2.1 Text { font.family: "Graphik Semibold" - font.pointSize: 24 + font.pixelSize: 32 color: "#ffffff" } diff --git a/launchers/qt/resources/qml/HFControls/HFTextLogo.qml b/launchers/qt/resources/qml/HFControls/HFTextLogo.qml index 08025ef715..b8d06f16f1 100644 --- a/launchers/qt/resources/qml/HFControls/HFTextLogo.qml +++ b/launchers/qt/resources/qml/HFControls/HFTextLogo.qml @@ -5,7 +5,7 @@ Text { text: "High Fidelity" font.bold: true font.family: "Graphik Semibold" - font.pointSize: 14 + font.pixelSize: 17 font.letterSpacing: -1 color: "#FFFFFF" } diff --git a/launchers/qt/resources/qml/HFControls/HFTextRegular.qml b/launchers/qt/resources/qml/HFControls/HFTextRegular.qml index 58103d6118..fd43aafe55 100644 --- a/launchers/qt/resources/qml/HFControls/HFTextRegular.qml +++ b/launchers/qt/resources/qml/HFControls/HFTextRegular.qml @@ -5,7 +5,7 @@ Text { id: root font.family: "Graphik Regular" - font.pointSize: 10.5 + font.pixelSize: 14 color: "#C4C4C4" linkColor: color diff --git a/launchers/qt/resources/qml/root.qml b/launchers/qt/resources/qml/root.qml index e3f82450f2..b87f8e7450 100644 --- a/launchers/qt/resources/qml/root.qml +++ b/launchers/qt/resources/qml/root.qml @@ -7,8 +7,6 @@ import "HFControls" Item { id: root - width: 627 - height: 540 Loader { anchors.fill: parent id: loader @@ -34,8 +32,6 @@ Item { HFTextRegular { id: buildInfo - font.pixelSize: 12 - anchors { leftMargin: 10 rightMargin: 10 diff --git a/launchers/qt/src/CommandlineOptions.cpp b/launchers/qt/src/CommandlineOptions.cpp index fa60e0d236..e8b1ad0a12 100644 --- a/launchers/qt/src/CommandlineOptions.cpp +++ b/launchers/qt/src/CommandlineOptions.cpp @@ -20,14 +20,12 @@ void CommandlineOptions::parse(const int argc, char** argv) { for (int index = 1; index < argc; index++) { std::string option = argv[index]; if (isCommandlineOption(option)) { - qDebug() << "adding commandline option: " << QString::fromStdString(option); _commandlineOptions.push_back(option); } } } void CommandlineOptions::append(const std::string& command) { - qDebug() << "appending option: " << QString::fromStdString(command); _commandlineOptions.push_back(command); } diff --git a/launchers/qt/src/Helper.cpp b/launchers/qt/src/Helper.cpp index 2fe3ecc46a..d09088a0e6 100644 --- a/launchers/qt/src/Helper.cpp +++ b/launchers/qt/src/Helper.cpp @@ -1,5 +1,7 @@ #include "Helper.h" +#include "PathUtils.h" + #include #include #include @@ -47,9 +49,9 @@ void messageHandler(QtMsgType type, const QMessageLogContext& context, const QSt break; } - QDir launcherDirectory = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); - launcherDirectory.mkpath(launcherDirectory.absolutePath()); - QString filename = launcherDirectory.absoluteFilePath("Log.txt"); + QDir logsDir = PathUtils::getLogsDirectory(); + logsDir.mkpath(logsDir.absolutePath()); + QString filename = logsDir.absoluteFilePath("Log.txt"); QFile outFile(filename); outFile.open(QIODevice::WriteOnly | QIODevice::Append); diff --git a/launchers/qt/src/Launcher.cpp b/launchers/qt/src/Launcher.cpp index edc52f6427..cf80604c39 100644 --- a/launchers/qt/src/Launcher.cpp +++ b/launchers/qt/src/Launcher.cpp @@ -33,6 +33,8 @@ Launcher::Launcher(int& argc, char**argv) : QGuiApplication(argc, argv) { QFontDatabase::addApplicationFont(PathUtils::fontPath("Graphik-Semibold.ttf")); _launcherWindow->setSource(QUrl(PathUtils::resourcePath("qml/root.qml"))); + _launcherWindow->setHeight(540); + _launcherWindow->setWidth(627); _launcherWindow->setResizeMode(QQuickView::SizeRootObjectToView); _launcherWindow->show(); } diff --git a/launchers/qt/src/LauncherInstaller_windows.cpp b/launchers/qt/src/LauncherInstaller_windows.cpp index f157a3b927..7ba8b8e2d2 100644 --- a/launchers/qt/src/LauncherInstaller_windows.cpp +++ b/launchers/qt/src/LauncherInstaller_windows.cpp @@ -2,6 +2,7 @@ #include "CommandlineOptions.h" #include "Helper.h" +#include "PathUtils.h" #include #include @@ -15,10 +16,11 @@ #include LauncherInstaller::LauncherInstaller(const QString& applicationFilePath) { - _launcherInstallDir = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation); - _launcherApplicationsDir = QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation) + "/Launcher"; + _launcherInstallDir = PathUtils::getLauncherDirectory(); + _launcherApplicationsDir = PathUtils::getApplicationsDirectory(); qDebug() << "Launcher install dir: " << _launcherInstallDir.absolutePath(); qDebug() << "Launcher Application dir: " << _launcherApplicationsDir.absolutePath(); + _launcherInstallDir.mkpath(_launcherInstallDir.absolutePath()); _launcherApplicationsDir.mkpath(_launcherApplicationsDir.absolutePath()); QFileInfo fileInfo(applicationFilePath); @@ -36,7 +38,7 @@ void LauncherInstaller::install() { if (runningOutsideOfInstallDir()) { qDebug() << "Installing HQ Launcher...."; uninstallOldLauncher(); - QString oldLauncherPath = _launcherInstallDir.absolutePath() + "/HQ Launcher.exe"; + QString oldLauncherPath = PathUtils::getLauncherFilePath(); if (QFile::exists(oldLauncherPath)) { bool didRemove = QFile::remove(oldLauncherPath); @@ -59,15 +61,15 @@ void LauncherInstaller::install() { } void LauncherInstaller::createShortcuts() { - QString launcherPath = _launcherInstallDir.absolutePath() + "/HQ Launcher.exe"; + QString launcherPath = PathUtils::getLauncherFilePath(); - QString uninstallLinkPath = _launcherInstallDir.absolutePath() + "/Uninstall HQ.lnk"; - QString desktopPath = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); - QString applicationPath = _launcherApplicationsDir.absolutePath(); + QString uninstallLinkPath = _launcherInstallDir.absoluteFilePath("Uninstall HQ.lnk"); - QString appStartLinkPath = applicationPath + "/HQ Launcher.lnk"; - QString uninstallAppStartLinkPath = applicationPath + "/Uninstall HQ.lnk"; - QString desktopAppLinkPath = desktopPath + "/HQ Launcher.lnk"; + QDir desktopDir = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); + + QString appStartLinkPath = _launcherApplicationsDir.absoluteFilePath("HQ Launcher.lnk"); + QString uninstallAppStartLinkPath = _launcherApplicationsDir.absoluteFilePath("Uninstall HQ.lnk"); + QString desktopAppLinkPath = desktopDir.absoluteFilePath("HQ Launcher.lnk"); createSymbolicLink((LPCSTR)launcherPath.toStdString().c_str(), (LPCSTR)uninstallLinkPath.toStdString().c_str(), @@ -136,7 +138,7 @@ void LauncherInstaller::uninstall() { } return; } - QString launcherPath = _launcherInstallDir.absolutePath() + "/HQ Launcher.exe"; + QString launcherPath = _launcherInstallDir.absoluteFilePath("HQ Launcher.exe"); if (QFile::exists(launcherPath)) { bool removed = QFile::remove(launcherPath); qDebug() << "Successfully removed " << launcherPath << ": " << removed; @@ -145,58 +147,58 @@ void LauncherInstaller::uninstall() { } void LauncherInstaller::deleteShortcuts() { - QString desktopPath = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); + QDir desktopDir = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); QString applicationPath = _launcherApplicationsDir.absolutePath(); - QString uninstallLinkPath = _launcherInstallDir.absolutePath() + "/Uninstall HQ.lnk"; + QString uninstallLinkPath = _launcherInstallDir.absoluteFilePath("Uninstall HQ.lnk"); if (QFile::exists(uninstallLinkPath)) { QFile::remove(uninstallLinkPath); } - QString appStartLinkPath = applicationPath + "/HQ Launcher.lnk"; + QString appStartLinkPath = _launcherApplicationsDir.absoluteFilePath("HQ Launcher.lnk"); if (QFile::exists(appStartLinkPath)) { QFile::remove(appStartLinkPath); } - QString uninstallAppStartLinkPath = applicationPath + "/Uninstall HQ.lnk"; + QString uninstallAppStartLinkPath = _launcherApplicationsDir.absoluteFilePath("Uninstall HQ.lnk"); if (QFile::exists(uninstallAppStartLinkPath)) { QFile::remove(uninstallAppStartLinkPath); } - QString desktopAppLinkPath = desktopPath + "/HQ Launcher.lnk"; + QString desktopAppLinkPath = desktopDir.absoluteFilePath("HQ Launcher.lnk"); if (QFile::exists(desktopAppLinkPath)) { QFile::remove(desktopAppLinkPath); } } void LauncherInstaller::uninstallOldLauncher() { - QDir localAppPath = QStandardPaths::standardLocations(QStandardPaths::AppLocalDataLocation).value(0) + "/../../HQ"; - QDir startAppPath = QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation).value(0) + "/HQ"; - QString desktopPath = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); + QDir localAppDir = QStandardPaths::standardLocations(QStandardPaths::AppLocalDataLocation).value(0) + "/../../HQ"; + QDir startAppDir = QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation).value(0) + "/HQ"; + QDir desktopDir = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); - qDebug() << localAppPath.absolutePath(); - qDebug() << startAppPath.absolutePath(); - QString desktopAppLinkPath = desktopPath + "/HQ Launcher.lnk"; + qDebug() << localAppDir.absolutePath(); + qDebug() << startAppDir.absolutePath(); + QString desktopAppLinkPath = desktopDir.absoluteFilePath("HQ Launcher.lnk"); if (QFile::exists(desktopAppLinkPath)) { QFile::remove(desktopAppLinkPath); } - QString uninstallLinkPath = localAppPath.absolutePath() + "/Uninstall HQ.lnk"; + QString uninstallLinkPath = localAppDir.absoluteFilePath("Uninstall HQ.lnk"); if (QFile::exists(uninstallLinkPath)) { QFile::remove(uninstallLinkPath); } - QString applicationPath = localAppPath.absolutePath() + "/HQ Launcher.exe"; + QString applicationPath = localAppDir.absoluteFilePath("HQ Launcher.exe"); if (QFile::exists(applicationPath)) { QFile::remove(applicationPath); } - QString appStartLinkPath = startAppPath.absolutePath() + "/HQ Launcher.lnk"; + QString appStartLinkPath = startAppDir.absoluteFilePath("HQ Launcher.lnk"); if (QFile::exists(appStartLinkPath)) { QFile::remove(appStartLinkPath); } - QString uninstallAppStartLinkPath = startAppPath.absolutePath() + "/Uninstall HQ.lnk"; + QString uninstallAppStartLinkPath = startAppDir.absoluteFilePath("Uninstall HQ.lnk"); if (QFile::exists(uninstallAppStartLinkPath)) { QFile::remove(uninstallAppStartLinkPath); } diff --git a/launchers/qt/src/LauncherState.cpp b/launchers/qt/src/LauncherState.cpp index 763718a08e..98e476bc99 100644 --- a/launchers/qt/src/LauncherState.cpp +++ b/launchers/qt/src/LauncherState.cpp @@ -23,7 +23,6 @@ #include -#include #include #include @@ -33,6 +32,7 @@ #endif //#define BREAK_ON_ERROR +//#define DEBUG_UI const QString configHomeLocationKey { "homeLocation" }; const QString configLastLoginKey { "lastLogin" }; @@ -48,6 +48,7 @@ Q_INVOKABLE void LauncherState::openURLInBrowser(QString url) { } void LauncherState::toggleDebugState() { +#ifdef DEBUG_UI _isDebuggingScreens = !_isDebuggingScreens; UIState updatedUIState = getUIState(); @@ -56,8 +57,10 @@ void LauncherState::toggleDebugState() { emit updateSourceUrl(PathUtils::resourcePath(getCurrentUISource())); _uiState = getUIState(); } +#endif } void LauncherState::gotoNextDebugScreen() { +#ifdef DEBUG_UI if (_currentDebugScreen < (UIState::UI_STATE_NUM - 1)) { _currentDebugScreen = (UIState)(_currentDebugScreen + 1); //UIState updatedUIState = getUIState(); @@ -65,48 +68,21 @@ void LauncherState::gotoNextDebugScreen() { emit updateSourceUrl(PathUtils::resourcePath(getCurrentUISource())); _uiState = getUIState(); } +#endif } void LauncherState::gotoPreviousDebugScreen() { +#ifdef DEBUG_UI if (_currentDebugScreen > 0) { _currentDebugScreen = (UIState)(_currentDebugScreen - 1); emit uiStateChanged(); emit updateSourceUrl(PathUtils::resourcePath(getCurrentUISource())); _uiState = getUIState(); } -} - -QString LauncherState::getContentCachePath() const { - return _launcherDirectory.filePath("cache"); -} - -QString LauncherState::getClientDirectory() const { - return _launcherDirectory.filePath("interface_install"); -} - -QString LauncherState::getClientExecutablePath() const { - QDir clientDirectory = getClientDirectory(); -#if defined(Q_OS_WIN) - return clientDirectory.absoluteFilePath("interface.exe"); -#elif defined(Q_OS_MACOS) - return clientDirectory.absoluteFilePath("interface.app/Contents/MacOS/interface"); -#endif -} - -QString LauncherState::getConfigFilePath() const { - QDir clientDirectory = getClientDirectory(); - return clientDirectory.absoluteFilePath("config.json"); -} - -QString LauncherState::getLauncherFilePath() const { -#if defined(Q_OS_WIN) - return _launcherDirectory.absoluteFilePath("launcher.exe"); -#elif defined(Q_OS_MACOS) - return getBundlePath() + "/Contents/MacOS/HQ Launcher"; #endif } bool LauncherState::shouldDownloadContentCache() const { - return !_contentCacheURL.isEmpty() && !QFile::exists(getContentCachePath()); + return !_contentCacheURL.isEmpty() && !QFile::exists(PathUtils::getContentCachePath()); } void LauncherState::setLastSignupErrorMessage(const QString& msg) { @@ -146,10 +122,10 @@ void LauncherState::ASSERT_STATE(const std::vector& states) { } LauncherState::LauncherState() { - _launcherDirectory = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); - // TODO Fix launcher directory + _launcherDirectory = PathUtils::getLauncherDirectory(); qDebug() << "Launcher directory: " << _launcherDirectory.absolutePath(); _launcherDirectory.mkpath(_launcherDirectory.absolutePath()); + _launcherDirectory.mkpath(PathUtils::getDownloadDirectory().absolutePath()); requestBuilds(); } @@ -255,7 +231,7 @@ void LauncherState::getCurrentClientVersion() { connect(&client, QOverload::of(&QProcess::finished), &loop, &QEventLoop::exit, Qt::QueuedConnection); connect(&client, &QProcess::errorOccurred, &loop, &QEventLoop::exit, Qt::QueuedConnection); - client.start(getClientExecutablePath(), { "--version" }); + client.start(PathUtils::getClientExecutablePath(), { "--version" }); loop.exec(); // TODO Handle errors @@ -273,14 +249,14 @@ void LauncherState::getCurrentClientVersion() { qDebug() << "Current client version is: " << _currentClientVersion; { - auto path = getConfigFilePath(); + auto path = PathUtils::getConfigFilePath(); QFile configFile{ path }; if (configFile.open(QIODevice::ReadOnly)) { QJsonDocument doc = QJsonDocument::fromJson(configFile.readAll()); auto root = doc.object(); - _config.launcherPath = getLauncherFilePath(); + _config.launcherPath = PathUtils::getLauncherFilePath(); _config.loggedIn = false; if (root.contains(configLoggedInKey)) { _config.loggedIn = root[configLoggedInKey].toBool(); @@ -358,27 +334,27 @@ void LauncherState::signup(QString email, QString username, QString password, QS auto err = signupRequest->getError(); if (err == SignupRequest::Error::ExistingUsername) { - setLastSignupErrorMessage(_username + " is already taken - please try a different username."); + setLastSignupErrorMessage(_username + " is already taken. Please try a different username."); setApplicationState(ApplicationState::WaitingForSignup); return; } else if (err == SignupRequest::Error::BadPassword) { - setLastSignupErrorMessage("That's an invalid password - must be at least 6 characters."); + setLastSignupErrorMessage("That's an invalid password. Must be at least 6 characters."); setApplicationState(ApplicationState::WaitingForSignup); return; } else if (err == SignupRequest::Error::BadUsername) { - setLastSignupErrorMessage("That's an invalid username - please try another username."); + setLastSignupErrorMessage("That's an invalid username. Please try another username."); setApplicationState(ApplicationState::WaitingForSignup); return; } else if (err == SignupRequest::Error::UserProfileAlreadyCompleted) { - setLastSignupErrorMessage("This email exists, if it's yours please login."); + setLastSignupErrorMessage("An account with this email already exists. Please log in."); setApplicationState(ApplicationState::WaitingForSignup); return; } else if (err == SignupRequest::Error::NoSuchEmail) { - setLastSignupErrorMessage("That email isn't setup yet. Request Access."); + setLastSignupErrorMessage("That email isn't setup yet. Request access."); setApplicationState(ApplicationState::WaitingForSignup); return; } else if (err != SignupRequest::Error::None) { - setApplicationStateError("Failed to sign up"); + setApplicationStateError("Failed to sign up. Please try again."); return; } @@ -397,11 +373,11 @@ void LauncherState::signup(QString email, QString username, QString password, QS auto err = loginRequest->getError(); if (err == LoginRequest::Error::BadUsernameOrPassword) { - setLastLoginErrorMessage("Bad username or password"); + setLastLoginErrorMessage("Invalid username or password."); setApplicationState(ApplicationState::WaitingForLogin); return; } else if (err != LoginRequest::Error::None) { - setApplicationStateError("Failed to login"); + setApplicationStateError("Failed to login. Please try again."); return; } @@ -436,11 +412,11 @@ void LauncherState::login(QString username, QString password, QString displayNam auto err = request->getError(); if (err == LoginRequest::Error::BadUsernameOrPassword) { - setLastLoginErrorMessage("Bad username or password"); + setLastLoginErrorMessage("Invalid username or password"); setApplicationState(ApplicationState::WaitingForLogin); return; } else if (err != LoginRequest::Error::None) { - setApplicationStateError("Failed to login"); + setApplicationStateError("Failed to login. Please try again."); return; } @@ -509,7 +485,8 @@ void LauncherState::downloadClient() { auto request = new QNetworkRequest(QUrl(build.installerZipURL)); auto reply = _networkAccessManager.get(*request); - _clientZipFile.setFileName(_launcherDirectory.absoluteFilePath("client.zip")); + QDir downloadDir{ PathUtils::getDownloadDirectory() }; + _clientZipFile.setFileName(downloadDir.absoluteFilePath("client.zip")); qDebug() << "Opening " << _clientZipFile.fileName(); if (!_clientZipFile.open(QIODevice::WriteOnly)) { @@ -566,15 +543,18 @@ void LauncherState::installClient() { ASSERT_STATE(ApplicationState::DownloadingClient); setApplicationState(ApplicationState::InstallingClient); - _launcherDirectory.rmpath("interface_install"); - _launcherDirectory.mkpath("interface_install"); - auto installDir = _launcherDirectory.absoluteFilePath("interface_install"); + + auto clientDir = PathUtils::getClientDirectory(); + + auto clientPath = clientDir.absolutePath(); + _launcherDirectory.rmpath(clientPath); + _launcherDirectory.mkpath(clientPath); _interfaceInstallProgress = 0; - qDebug() << "Unzipping " << _clientZipFile.fileName() << " to " << installDir; + qDebug() << "Unzipping " << _clientZipFile.fileName() << " to " << clientDir.absolutePath(); - auto unzipper = new Unzipper(_clientZipFile.fileName(), QDir(installDir)); + auto unzipper = new Unzipper(_clientZipFile.fileName(), clientDir); unzipper->setAutoDelete(true); connect(unzipper, &Unzipper::progress, this, [this](float progress) { _interfaceInstallProgress = progress; @@ -666,7 +646,8 @@ void LauncherState::downloadContentCache() { request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); auto reply = _networkAccessManager.get(request); - _contentZipFile.setFileName(_launcherDirectory.absoluteFilePath("content_cache.zip")); + QDir downloadDir{ PathUtils::getDownloadDirectory() }; + _contentZipFile.setFileName(downloadDir.absoluteFilePath("content_cache.zip")); qDebug() << "Opening " << _contentZipFile.fileName(); if (!_contentZipFile.open(QIODevice::WriteOnly)) { @@ -692,6 +673,8 @@ void LauncherState::contentCacheDownloadComplete() { if (reply->error()) { qDebug() << "Error downloading content cache: " << reply->error() << reply->readAll(); qDebug() << "Continuing to launch client"; + _contentDownloadProgress = 100.0f; + _contentInstallProgress = 100.0f; launchClient(); return; } @@ -713,7 +696,7 @@ void LauncherState::installContentCache() { ASSERT_STATE(ApplicationState::DownloadingContentCache); setApplicationState(ApplicationState::InstallingContentCache); - auto installDir = getContentCachePath(); + auto installDir = PathUtils::getContentCachePath(); qDebug() << "Unzipping " << _contentZipFile.fileName() << " to " << installDir; @@ -750,15 +733,10 @@ void LauncherState::launchClient() { setApplicationState(ApplicationState::LaunchingHighFidelity); - QDir installDirectory = _launcherDirectory.filePath("interface_install"); - QString clientPath; -#if defined(Q_OS_WIN) - clientPath = installDirectory.absoluteFilePath("interface.exe"); -#elif defined(Q_OS_MACOS) - clientPath = installDirectory.absoluteFilePath("interface.app/Contents/MacOS/interface"); -#endif + QDir installDirectory = PathUtils::getClientDirectory(); + QString clientPath = PathUtils::getClientExecutablePath(); - auto path = getConfigFilePath(); + auto path = PathUtils::getConfigFilePath(); QFile configFile{ path }; if (configFile.open(QIODevice::ReadWrite | QIODevice::Truncate)) { QJsonDocument doc = QJsonDocument::fromJson(configFile.readAll()); @@ -766,7 +744,7 @@ void LauncherState::launchClient() { { configHomeLocationKey, _config.homeLocation }, { configLastLoginKey, _config.lastLogin }, { configLoggedInKey, _config.loggedIn }, - { configLauncherPathKey, getLauncherFilePath() }, + { configLauncherPathKey, PathUtils::getLauncherFilePath() }, }); qint64 result = configFile.write(doc.toJson()); configFile.close(); diff --git a/launchers/qt/src/LauncherState.h b/launchers/qt/src/LauncherState.h index 11a8fbaaaf..39c4141b81 100644 --- a/launchers/qt/src/LauncherState.h +++ b/launchers/qt/src/LauncherState.h @@ -155,12 +155,6 @@ private: bool shouldDownloadContentCache() const; void getCurrentClientVersion(); - QString getContentCachePath() const; - QString getClientDirectory() const; - QString getClientExecutablePath() const; - QString getConfigFilePath() const; - QString getLauncherFilePath() const; - float calculateDownloadProgress() const; bool shouldDownloadLauncher(); diff --git a/launchers/qt/src/PathUtils.cpp b/launchers/qt/src/PathUtils.cpp index eba74721cb..538303b564 100644 --- a/launchers/qt/src/PathUtils.cpp +++ b/launchers/qt/src/PathUtils.cpp @@ -1,6 +1,10 @@ #include "PathUtils.h" +#include "Helper.h" + +#include #include +#include QUrl PathUtils::resourcePath(const QString& source) { QString filePath = RESOURCE_PREFIX_URL + source; @@ -18,3 +22,56 @@ QString PathUtils::fontPath(const QString& fontName) { return ":/fonts/" + fontName; #endif } + +QDir PathUtils::getLauncherDirectory() { + return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation); +} + +QDir PathUtils::getApplicationsDirectory() { + return QDir(QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation)).absoluteFilePath("Launcher"); +} + +// The client directory is where interface is installed to. +QDir PathUtils::getClientDirectory() { + return getLauncherDirectory().filePath("client"); +} + +QDir PathUtils::getLogsDirectory() { + return getLauncherDirectory().filePath("logs"); +} + +// The download directory is used to store files downloaded during installation. +QDir PathUtils::getDownloadDirectory() { + return getLauncherDirectory().filePath("downloads"); +} + +// The content cache path is the directory interface uses for caching data. +// It is pre-populated on startup with domain content. +QString PathUtils::getContentCachePath() { + return getLauncherDirectory().filePath("contentcache"); +} + +// The path to the interface binary. +QString PathUtils::getClientExecutablePath() { + QDir clientDirectory = getClientDirectory(); +#if defined(Q_OS_WIN) + return clientDirectory.absoluteFilePath("interface.exe"); +#elif defined(Q_OS_MACOS) + return clientDirectory.absoluteFilePath("interface.app/Contents/MacOS/interface"); +#endif +} + +// The path to the config.json file that the launcher uses to store information like +// the last user that logged in. +QString PathUtils::getConfigFilePath() { + return getClientDirectory().absoluteFilePath("config.json"); +} + +// The path to the launcher binary. +QString PathUtils::getLauncherFilePath() { +#if defined(Q_OS_WIN) + return getLauncherDirectory().absoluteFilePath("HQ Launcher.exe"); +#elif defined(Q_OS_MACOS) + return getBundlePath() + "/Contents/MacOS/HQ Launcher"; +#endif +} diff --git a/launchers/qt/src/PathUtils.h b/launchers/qt/src/PathUtils.h index c33041736b..d9f5279408 100644 --- a/launchers/qt/src/PathUtils.h +++ b/launchers/qt/src/PathUtils.h @@ -1,14 +1,28 @@ #pragma once +#include #include #include #include #include + class PathUtils : public QObject { Q_OBJECT public: PathUtils() = default; ~PathUtils() = default; Q_INVOKABLE static QUrl resourcePath(const QString& source); - QString static fontPath(const QString& fontName); + + static QString fontPath(const QString& fontName); + + static QDir getLauncherDirectory(); + static QDir getApplicationsDirectory(); + static QDir getDownloadDirectory(); + static QDir getClientDirectory(); + static QDir getLogsDirectory(); + + static QString getContentCachePath(); + static QString getClientExecutablePath(); + static QString getConfigFilePath(); + static QString getLauncherFilePath(); }; diff --git a/launchers/qt/src/main.cpp b/launchers/qt/src/main.cpp index c3971d03d9..3918ec944e 100644 --- a/launchers/qt/src/main.cpp +++ b/launchers/qt/src/main.cpp @@ -30,16 +30,17 @@ bool hasSuffix(const std::string& path, const std::string& suffix) { } int main(int argc, char *argv[]) { - QString name { "High Fidelity" }; QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - QCoreApplication::setOrganizationName(name); + QCoreApplication::setOrganizationName("High Fidelity"); QCoreApplication::setApplicationName("Launcher"); + Q_INIT_RESOURCE(resources); cleanLogFile(); qInstallMessageHandler(messageHandler); CommandlineOptions* options = CommandlineOptions::getInstance(); options->parse(argc, argv); bool didUpdate = false; + #ifdef Q_OS_MAC if (isLauncherAlreadyRunning()) { return 0; @@ -48,7 +49,7 @@ int main(int argc, char *argv[]) { if (argc == 3) { if (hasSuffix(argv[1], "app") && hasSuffix(argv[2], "app")) { bool success = swapLaunchers(argv[1], argv[2]); - qDebug() << "Launcher install success: " << success; + qDebug() << "Successfully installed Launcher: " << success; if (!success) { options->append("--noUpdate"); } @@ -56,6 +57,12 @@ int main(int argc, char *argv[]) { } } #endif + + if (options->contains("--version")) { + std::cout << LAUNCHER_BUILD_VERSION << std::endl; + return 0; + } + #ifdef Q_OS_WIN LauncherInstaller launcherInstaller(argv[0]); if (options->contains("--uninstall") || options->contains("--resumeUninstall")) { @@ -69,7 +76,6 @@ int main(int argc, char *argv[]) { if (isProcessRunning("interface.exe", interfacePID)) { shutdownProcess(interfacePID, 0); } - #endif QProcessEnvironment processEnvironment = QProcessEnvironment::systemEnvironment(); @@ -78,6 +84,7 @@ int main(int argc, char *argv[]) { options->append("--noUpdate"); } } + Launcher launcher(argc, argv); return launcher.exec(); }