From 509545601e12329725134d90e704d6d2a29d6040 Mon Sep 17 00:00:00 2001 From: danteruiz Date: Wed, 2 Oct 2019 15:43:32 -0700 Subject: [PATCH] finish touch up of UI --- launchers/qt/CMakeLists.txt | 7 ++- launchers/qt/resources/qml/Download.qml | 34 +++++++--- .../qt/resources/qml/DownloadFinished.qml | 4 ++ .../qml/HFBase/CreateAccountBase.qml | 5 ++ launchers/qt/resources/qml/HFBase/Error.qml | 5 ++ .../qt/resources/qml/HFBase/LoginBase.qml | 5 ++ launchers/qt/resources/qml/SplashScreen.qml | 8 ++- launchers/qt/resources/qml/root.qml | 63 ++++++++++++++++++- .../qt/src/LauncherInstaller_windows.cpp | 19 +++++- launchers/qt/src/LauncherState.cpp | 44 ++++++++----- launchers/qt/src/LauncherState.h | 14 ++++- launchers/qt/src/PathUtils.cpp | 7 ++- 12 files changed, 184 insertions(+), 31 deletions(-) diff --git a/launchers/qt/CMakeLists.txt b/launchers/qt/CMakeLists.txt index e1d3281c4e..e2a8831bc0 100644 --- a/launchers/qt/CMakeLists.txt +++ b/launchers/qt/CMakeLists.txt @@ -16,6 +16,10 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) include("cmake/init.cmake") include("cmake/macros/SetPackagingParameters.cmake") + if(MSVC) + add_definitions(-D_CRT_SECURE_NO_WARNINGS) + endif() + if (WIN32) set(CMAKE_MFC_FLAG 1) endif() @@ -233,13 +237,14 @@ endif() if (LAUNCHER_SOURCE_TREE_RESOURCES) target_compile_definitions(${PROJECT_NAME} PRIVATE RESOURCE_PREFIX_URL="${CMAKE_CURRENT_SOURCE_DIR}/resources/") + target_compile_definitions(${PROJECT_NAME} PRIVATE HIFI_USE_LOCAL_FILE) message("Use source tree resources path: file://${CMAKE_CURRENT_SOURCE_DIR}/resources/") else() target_compile_definitions(${PROJECT_NAME} PRIVATE RESOURCE_PREFIX_URL="qrc:/") message("Use resource.rcc path: qrc:/") endif() -target_compile_definitions(${PROJECT_NAME} PRIVATE LAUNCHER_BUILD_VERSION="${BUILD_VERSION}") + target_compile_definitions(${PROJECT_NAME} PRIVATE LAUNCHER_BUILD_VERSION="${BUILD_VERSION}") if (APPLE) install( diff --git a/launchers/qt/resources/qml/Download.qml b/launchers/qt/resources/qml/Download.qml index a6548ac3b3..8303121479 100644 --- a/launchers/qt/resources/qml/Download.qml +++ b/launchers/qt/resources/qml/Download.qml @@ -99,16 +99,32 @@ Item { color: "#01B2ED" } } + } - //PropertyAnimation { - //target: progressBar; - //loops: Animation.Infinite - //property: "value" - //from: 0; - //to: 1; - //duration: 5000 - //running: true - //} + Text { + width: 100 + height: 17 + + text: "High Fidelity" + font.bold: true + font.family: "Graphik" + font.pixelSize: 24 + font.letterSpacing: -1 + color: "#FFFFFF" + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + + anchors { + bottom: root.bottom + bottomMargin: 15 + left: root.left + leftMargin: 30 + } + } + + Component.onCompleted: { + root.parent.setStateInfoState("right"); + root.parent.setBuildInfoState("left"); } } diff --git a/launchers/qt/resources/qml/DownloadFinished.qml b/launchers/qt/resources/qml/DownloadFinished.qml index a16800fa49..ecd2e6d0c2 100644 --- a/launchers/qt/resources/qml/DownloadFinished.qml +++ b/launchers/qt/resources/qml/DownloadFinished.qml @@ -65,4 +65,8 @@ Item { } } + Component.onCompleted: { + root.parent.setStateInfoState("right"); + root.parent.setBuildInfoState("left"); + } } diff --git a/launchers/qt/resources/qml/HFBase/CreateAccountBase.qml b/launchers/qt/resources/qml/HFBase/CreateAccountBase.qml index 3c98cebd33..04b76d5e36 100644 --- a/launchers/qt/resources/qml/HFBase/CreateAccountBase.qml +++ b/launchers/qt/resources/qml/HFBase/CreateAccountBase.qml @@ -206,4 +206,9 @@ Item { rightMargin: 30 } } + + Component.onCompleted: { + root.parent.setStateInfoState("right"); + root.parent.setBuildInfoState("left"); + } } diff --git a/launchers/qt/resources/qml/HFBase/Error.qml b/launchers/qt/resources/qml/HFBase/Error.qml index f488a3e9bf..09df9e39a7 100644 --- a/launchers/qt/resources/qml/HFBase/Error.qml +++ b/launchers/qt/resources/qml/HFBase/Error.qml @@ -106,4 +106,9 @@ Item { } } + Component.onCompleted: { + root.parent.setStateInfoState("left"); + root.parent.setBuildInfoState("right"); + } + } diff --git a/launchers/qt/resources/qml/HFBase/LoginBase.qml b/launchers/qt/resources/qml/HFBase/LoginBase.qml index deb21ad085..3a295d5fa8 100644 --- a/launchers/qt/resources/qml/HFBase/LoginBase.qml +++ b/launchers/qt/resources/qml/HFBase/LoginBase.qml @@ -179,4 +179,9 @@ Item { rightMargin: 136 } } + + Component.onCompleted: { + root.parent.setStateInfoState("left"); + root.parent.setBuildInfoState("right"); + } } diff --git a/launchers/qt/resources/qml/SplashScreen.qml b/launchers/qt/resources/qml/SplashScreen.qml index a710a7245c..bd4fc5e762 100644 --- a/launchers/qt/resources/qml/SplashScreen.qml +++ b/launchers/qt/resources/qml/SplashScreen.qml @@ -2,6 +2,7 @@ import QtQuick 2.3 import QtQuick.Controls 2.1 Item { + id: root anchors.fill: parent @@ -9,7 +10,7 @@ Item { anchors.centerIn: parent width: parent.width height: parent.height - mirror: true + mirror: false source: PathUtils.resourcePath("images/hifi_window@2x.png"); transformOrigin: Item.Center rotation: 0 @@ -21,4 +22,9 @@ Item { height: 205 source: PathUtils.resourcePath("images/hifi_logo_large@2x.png"); } + + Component.onCompleted: { + root.parent.setStateInfoState("left"); + root.parent.setBuildInfoState("right"); + } } diff --git a/launchers/qt/resources/qml/root.qml b/launchers/qt/resources/qml/root.qml index 3c755c2a6b..8b22763908 100644 --- a/launchers/qt/resources/qml/root.qml +++ b/launchers/qt/resources/qml/root.qml @@ -12,6 +12,15 @@ Item { Loader { anchors.fill: parent id: loader + + + function setBuildInfoState(state) { + buildInfo.state = state; + } + + function setStateInfoState(state) { + stateInfo.state = state; + } } Component.onCompleted: { @@ -31,9 +40,61 @@ Item { font.pixelSize: 12 anchors.right: root.right - anchors.bottom: root.bottom + anchors.top: root.top color: "#FFFFFF" text: LauncherState.uiState.toString() + " - " + LauncherState.applicationState + + states: [ + State { + name: "left" + AnchorChanges { + target: stateInfo + anchors.left: root.left + anchors.right: undefined + } + }, + + State { + name: "right" + AnchorChanges { + target: stateInfo + anchors.right: root.right + anchors.left: undefined + } + } + ] + } + + Text { + id: buildInfo + + font.pixelSize: 12 + + anchors.right: root.right + anchors.bottom: root.bottom + + color: "#FFFFFF" + text: "v." + LauncherState.buildVersion; + + states: [ + State { + name: "left" + AnchorChanges { + target: buildInfo + anchors.left: root.left + anchors.right: undefined + } + }, + + State { + name: "right" + AnchorChanges { + target: buildInfo + anchors.right: root.right + anchors.left: undefined + } + } + ] } } diff --git a/launchers/qt/src/LauncherInstaller_windows.cpp b/launchers/qt/src/LauncherInstaller_windows.cpp index 1bbceb61e7..ffd6218fab 100644 --- a/launchers/qt/src/LauncherInstaller_windows.cpp +++ b/launchers/qt/src/LauncherInstaller_windows.cpp @@ -2,6 +2,10 @@ #include "Helper.h" #include +#include +#include +#include +#include #include #include @@ -101,6 +105,8 @@ void LauncherInstaller::uninstall() { if (QFile::exists(desktopAppLinkPath)) { QFile::remove(desktopAppLinkPath); } + + deleteApplicationRegistryKeys(); } @@ -115,13 +121,22 @@ void LauncherInstaller::createApplicationRegistryKeys() { success = insertRegistryKey(REGISTRY_PATH, "DisplayVersion", "DEV"); success = insertRegistryKey(REGISTRY_PATH, "DisplayIcon", applicationExe); success = insertRegistryKey(REGISTRY_PATH, "Publisher", "High Fidelity"); - //success = LauncherUtils::insertRegistryKey(REGISTRY_PATH, "InstallDate", LauncherUtils::cStringToStd(CTime::GetCurrentTime().Format("%Y%m%d"))); + + auto now = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); + + std::stringstream date; + date << std::put_time(std::localtime(&now), "%Y-%m-%d") ; + success = insertRegistryKey(REGISTRY_PATH, "InstallDate", date.str()); //success = LauncherUtils::insertRegistryKey(REGISTRY_PATH, "EstimatedSize", (DWORD)size); success = insertRegistryKey(REGISTRY_PATH, "NoModify", (DWORD)1); success = insertRegistryKey(REGISTRY_PATH, "NoRepair", (DWORD)1); - qDebug() << "--------: " << success; + qDebug() << "Did succcessfully insertRegistyKeys: " << success; } void LauncherInstaller::deleteApplicationRegistryKeys() { + const std::string regPath= "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\HQ"; + if (!deleteRegistryKey(regPath.c_str())) { + qDebug() << "Failed to delete registryKeys"; + } } diff --git a/launchers/qt/src/LauncherState.cpp b/launchers/qt/src/LauncherState.cpp index 976dbc22fb..12ad27f4db 100644 --- a/launchers/qt/src/LauncherState.cpp +++ b/launchers/qt/src/LauncherState.cpp @@ -46,7 +46,7 @@ QString LauncherState::getClientExecutablePath() const { } bool LauncherState::shouldDownloadContentCache() const { - return !_contentCacheURL.isNull() && !QFile::exists(getContentCachePath()); + return !_contentCacheURL.isEmpty() && !QFile::exists(getContentCachePath()); } bool LatestBuilds::getBuild(QString tag, Build* outBuild) { @@ -233,7 +233,7 @@ void LauncherState::receivedBuildsReply() { } if (shouldDownloadLauncher()) { - //downloadLauncher(); + downloadLauncher(); } getCurrentClientVersion(); } @@ -390,12 +390,15 @@ void LauncherState::requestSettings() { connect(request, &UserSettingsRequest::finished, this, [this, request]() { auto userSettings = request->getUserSettings(); if (userSettings.homeLocation.isEmpty()) { + qDebug() << "UserSettings is empty"; _homeLocation = "hifi://hq"; _contentCacheURL = ""; } else { _homeLocation = userSettings.homeLocation; auto host = QUrl(_homeLocation).host(); _contentCacheURL = "http://orgs.highfidelity.com/host-content-cache/" + host + ".zip"; + + qDebug() << "Content cache url: " << _contentCacheURL; } qDebug() << "Home location is: " << _homeLocation; @@ -423,7 +426,7 @@ void LauncherState::downloadClient() { return; } - _downloadProgress = 0; + _interfaceDownloadProgress = 0; setApplicationState(ApplicationState::DownloadingClient); // Start client download @@ -453,7 +456,7 @@ void LauncherState::downloadClient() { } }); connect(reply, &QNetworkReply::downloadProgress, this, [this](qint64 received, qint64 total) { - _downloadProgress = (float)received / (float)total; + _interfaceDownloadProgress = (float)received / (float)total; emit downloadProgressChanged(); }); } @@ -465,7 +468,7 @@ void LauncherState::launcherDownloadComplete() { #ifdef Q_OS_MAC installLauncher(); #elif defined(Q_OS_WIN) - //launchAutoUpdater(_launcherZipFile.fileName()); + launchAutoUpdater(_launcherZipFile.fileName()); #endif } @@ -475,6 +478,16 @@ void LauncherState::clientDownloadComplete() { installClient(); } + +float LauncherState::calculateDownloadProgress() const{ + if (shouldDownloadContentCache()) { + return (_interfaceDownloadProgress * 0.40f) + (_interfaceInstallProgress * 0.10f) + + (_contentInstallProgress * 0.40f) + (_contentDownloadProgress * 0.10f); + } + + return (_interfaceDownloadProgress * 0.80f) + (_interfaceInstallProgress * 0.20f); +} + void LauncherState::installClient() { ASSERT_STATE(ApplicationState::DownloadingClient); setApplicationState(ApplicationState::InstallingClient); @@ -483,7 +496,7 @@ void LauncherState::installClient() { _launcherDirectory.mkpath("interface_install"); auto installDir = _launcherDirectory.absoluteFilePath("interface_install"); - _downloadProgress = 0; + _interfaceInstallProgress = 0; qDebug() << "Unzipping " << _clientZipFile.fileName() << " to " << installDir; @@ -491,7 +504,7 @@ void LauncherState::installClient() { unzipper->setAutoDelete(true); connect(unzipper, &Unzipper::progress, this, [this](float progress) { //qDebug() << "Unzipper progress: " << progress; - _downloadProgress = progress; + _interfaceInstallProgress = progress; emit downloadProgressChanged(); }); connect(unzipper, &Unzipper::finished, this, [this](bool error, QString errorMessage) { @@ -575,7 +588,7 @@ void LauncherState::downloadContentCache() { if (shouldDownloadContentCache()) { setApplicationState(ApplicationState::DownloadingContentCache); - _downloadProgress = 0; + _contentDownloadProgress = 0; qDebug() << "Downloading content cache from: " << _contentCacheURL; QNetworkRequest request{ QUrl(_contentCacheURL) }; @@ -592,7 +605,7 @@ void LauncherState::downloadContentCache() { connect(reply, &QNetworkReply::finished, this, &LauncherState::contentCacheDownloadComplete); connect(reply, &QNetworkReply::downloadProgress, this, [this](qint64 received, qint64 total) { - _downloadProgress = (float)received / (float)total; + _contentDownloadProgress = (float)received / (float)total; emit downloadProgressChanged(); }); } else { @@ -633,13 +646,13 @@ void LauncherState::installContentCache() { qDebug() << "Unzipping " << _contentZipFile.fileName() << " to " << installDir; - _downloadProgress = 0; + _contentInstallProgress = 0; auto unzipper = new Unzipper(_contentZipFile.fileName(), QDir(installDir)); unzipper->setAutoDelete(true); connect(unzipper, &Unzipper::progress, this, [this](float progress) { qDebug() << "Unzipper progress (content cache): " << progress; - _downloadProgress = progress; + _contentInstallProgress = progress; emit downloadProgressChanged(); }); connect(unzipper, &Unzipper::finished, this, [this](bool error, QString errorMessage) { @@ -700,9 +713,12 @@ void LauncherState::setApplicationState(ApplicationState state) { } _applicationState = state; - - emit uiStateChanged(); - emit updateSourceUrl(PathUtils::resourcePath(getCurrentUISource())); + UIState updatedUIState = getUIState(); + if (_uiState != updatedUIState) { + emit uiStateChanged(); + emit updateSourceUrl(PathUtils::resourcePath(getCurrentUISource())); + _uiState = getUIState(); + } emit applicationStateChanged(); } diff --git a/launchers/qt/src/LauncherState.h b/launchers/qt/src/LauncherState.h index eb87d15343..42bfb45d19 100644 --- a/launchers/qt/src/LauncherState.h +++ b/launchers/qt/src/LauncherState.h @@ -32,7 +32,8 @@ class LauncherState : public QObject { Q_PROPERTY(UIState uiState READ getUIState NOTIFY uiStateChanged) Q_PROPERTY(ApplicationState applicationState READ getApplicationState NOTIFY applicationStateChanged) Q_PROPERTY(float downloadProgress READ getDownloadProgress NOTIFY downloadProgressChanged) - Q_PROPERTY(SignupRequest::Error lastSignupError MEMBER _lastSignupError NOTIFY lastSignupErrorChanged); + Q_PROPERTY(SignupRequest::Error lastSignupError MEMBER _lastSignupError NOTIFY lastSignupErrorChanged) + Q_PROPERTY(QString buildVersion READ getBuildVersion) public: LauncherState(); @@ -95,6 +96,8 @@ public: UIState getUIState() const; + QString getBuildVersion() { return QString(LAUNCHER_BUILD_VERSION); } + void setLastLoginError(LastLoginError lastLoginError); LastLoginError getLastLoginError() const; @@ -135,7 +138,7 @@ public: // Launching void launchClient(); - Q_INVOKABLE float getDownloadProgress() const { return _downloadProgress; } + Q_INVOKABLE float getDownloadProgress() const { return calculateDownloadProgress(); } signals: void updateSourceUrl(QUrl sourceUrl); @@ -157,6 +160,8 @@ private: QString getClientDirectory() const; QString getClientExecutablePath() const; + float calculateDownloadProgress() const; + bool shouldDownloadLauncher(); QNetworkAccessManager _networkAccessManager; @@ -165,6 +170,7 @@ private: // Application State ApplicationState _applicationState { ApplicationState::Init }; + UIState _uiState { UIState::SPLASH_SCREEN }; LoginToken _loginResponse; LastLoginError _lastLoginError { NONE }; SignupRequest::Error _lastSignupError{ SignupRequest::Error::None }; @@ -183,4 +189,8 @@ private: QString _password; float _downloadProgress { 0 }; + float _contentDownloadProgress { 0 }; + float _contentInstallProgress { 0 }; + float _interfaceDownloadProgress { 0 }; + float _interfaceInstallProgress { 0 }; }; diff --git a/launchers/qt/src/PathUtils.cpp b/launchers/qt/src/PathUtils.cpp index 542e268308..3fe970d1f4 100644 --- a/launchers/qt/src/PathUtils.cpp +++ b/launchers/qt/src/PathUtils.cpp @@ -3,5 +3,10 @@ #include QUrl PathUtils::resourcePath(const QString& source) { - return QUrl(RESOURCE_PREFIX_URL + source); + QString filePath = RESOURCE_PREFIX_URL + source; +#ifdef HIFI_USE_LOCAL_FILE + return QUrl::fromLocalFile(filePath); +#else + return QUrl(filePath); +#endif }