From f912268129a1479c2f8b975c02d643578c599ebe Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 4 Oct 2019 16:43:58 -0700 Subject: [PATCH] Update qt launcher to disable inputs when making requests --- .../resources/qml/HFBase/CreateAccountBase.qml | 17 ++++++++++++++++- launchers/qt/resources/qml/HFBase/LoginBase.qml | 12 ++++++++++++ .../qt/resources/qml/HFControls/HFButton.qml | 4 ++-- .../qt/resources/qml/HFControls/HFTextField.qml | 2 +- launchers/qt/resources/qml/SplashScreen.qml | 1 - launchers/qt/src/BuildsRequest.cpp | 2 -- launchers/qt/src/Launcher.cpp | 1 + launchers/qt/src/LauncherState.cpp | 10 ++++------ launchers/qt/src/LauncherState.h | 9 ++++----- launchers/qt/src/main.cpp | 3 ++- 10 files changed, 42 insertions(+), 19 deletions(-) diff --git a/launchers/qt/resources/qml/HFBase/CreateAccountBase.qml b/launchers/qt/resources/qml/HFBase/CreateAccountBase.qml index b39479fbaf..cf03b282bf 100644 --- a/launchers/qt/resources/qml/HFBase/CreateAccountBase.qml +++ b/launchers/qt/resources/qml/HFBase/CreateAccountBase.qml @@ -1,6 +1,8 @@ import QtQuick 2.3 import QtQuick 2.1 + import "../HFControls" +import HQLauncher 1.0 Item { @@ -11,6 +13,8 @@ Item { property string passwordPlaceholder: "Set a password" property int marginLeft: root.width * 0.15 + property bool enabled: LauncherState.applicationState == ApplicationState.WaitingForSignup + Image { anchors.centerIn: parent width: parent.width @@ -26,7 +30,7 @@ Item { width: 481 lineHeight: 35 lineHeightMode: Text.FixedHeight - text: root.titleText + text: root.titleText + " " + LauncherState.applicationState visible: LauncherState.lastSignupErrorMessage.length == 0 ? root.titleText : "Uh oh." anchors { top: root.top @@ -73,6 +77,8 @@ Item { id: email width: 430 + enabled: root.enabled + placeholderText: "Email Address" seperatorColor: Qt.rgba(1, 1, 1, 0.3) anchors { @@ -87,6 +93,8 @@ Item { id: username width: 430 + enabled: root.enabled + placeholderText: root.usernamePlaceholder seperatorColor: Qt.rgba(1, 1, 1, 0.3) anchors { @@ -101,6 +109,8 @@ Item { id: passwordField width: 430 + enabled: root.enabled + placeholderText: root.passwordPlaceholder seperatorColor: Qt.rgba(1, 1, 1, 0.3) togglePasswordField: true @@ -133,6 +143,9 @@ Item { HFTextField { id: displayName width: 430 + + enabled: root.enabled + placeholderText: "Display Name" seperatorColor: Qt.rgba(1, 1, 1, 0.3) anchors { @@ -149,6 +162,8 @@ Item { id: button width: 134 + enabled: root.enabled + text: "NEXT" anchors { diff --git a/launchers/qt/resources/qml/HFBase/LoginBase.qml b/launchers/qt/resources/qml/HFBase/LoginBase.qml index 41d011635e..f30ce7bcd5 100644 --- a/launchers/qt/resources/qml/HFBase/LoginBase.qml +++ b/launchers/qt/resources/qml/HFBase/LoginBase.qml @@ -1,11 +1,15 @@ import QtQuick 2.3 import QtQuick 2.1 + import "../HFControls" +import HQLauncher 1.0 Item { id: root anchors.fill: parent + property bool enabled: LauncherState.applicationState == ApplicationState.WaitingForLogin + Image { anchors.centerIn: parent width: parent.width @@ -72,6 +76,8 @@ Item { HFTextField { id: username + enabled: root.enabled + placeholderText: "Username" seperatorColor: Qt.rgba(1, 1, 1, 0.3) @@ -87,6 +93,8 @@ Item { HFTextField { id: password + enabled: root.enabled + placeholderText: "Password" togglePasswordField: true echoMode: TextInput.Password @@ -118,6 +126,8 @@ Item { HFTextField { id: displayName + enabled: root.enabled + placeholderText: "Display name" seperatorColor: Qt.rgba(1, 1, 1, 0.3) anchors { @@ -134,6 +144,8 @@ Item { id: button width: 110 + enabled: root.enabled + text: "NEXT" anchors { diff --git a/launchers/qt/resources/qml/HFControls/HFButton.qml b/launchers/qt/resources/qml/HFControls/HFButton.qml index ad04286114..a4d077a1e7 100644 --- a/launchers/qt/resources/qml/HFControls/HFButton.qml +++ b/launchers/qt/resources/qml/HFControls/HFButton.qml @@ -7,8 +7,8 @@ Button { height: 50 property string backgroundColor: "#00000000" - property string borderColor: "#FFFFFF" - property string textColor: "#FFFFFF" + property string borderColor: enabled ? "#FFFFFF" : "#7e8c81" + property string textColor: borderColor property int backgroundOpacity: 1 property int backgroundRadius: 1 property int backgroundWidth: 2 diff --git a/launchers/qt/resources/qml/HFControls/HFTextField.qml b/launchers/qt/resources/qml/HFControls/HFTextField.qml index cce0a0fc1e..a98e73c659 100644 --- a/launchers/qt/resources/qml/HFControls/HFTextField.qml +++ b/launchers/qt/resources/qml/HFControls/HFTextField.qml @@ -8,7 +8,7 @@ TextField { font.family: "Graphik Regular" font.pointSize: 10.5 - color: text.length == 0 ? "#7e8c81" : "#000000" + color: (text.length == 0 || !enabled) ? "#7e8c81" : "#000000" property bool togglePasswordField: false verticalAlignment: TextInput.AlignVCenter diff --git a/launchers/qt/resources/qml/SplashScreen.qml b/launchers/qt/resources/qml/SplashScreen.qml index 0e2e522232..acbb7b900f 100644 --- a/launchers/qt/resources/qml/SplashScreen.qml +++ b/launchers/qt/resources/qml/SplashScreen.qml @@ -5,7 +5,6 @@ Item { id: root anchors.fill: parent - Image { anchors.centerIn: parent width: parent.width diff --git a/launchers/qt/src/BuildsRequest.cpp b/launchers/qt/src/BuildsRequest.cpp index 5986bf085f..e7ec02c380 100644 --- a/launchers/qt/src/BuildsRequest.cpp +++ b/launchers/qt/src/BuildsRequest.cpp @@ -64,7 +64,6 @@ void BuildsRequest::receivedResponse() { } else { auto root = doc.object(); if (!root.contains("default_tag")) { - //setApplicationState(ApplicationState::UnexpectedError); _error = Error::MissingDefaultTag; emit finished(); return; @@ -74,7 +73,6 @@ void BuildsRequest::receivedResponse() { auto results = root["results"]; if (!results.isArray()) { - //setApplicationState(ApplicationState::UnexpectedError); _error = Error::MalformedResponse; emit finished(); return; diff --git a/launchers/qt/src/Launcher.cpp b/launchers/qt/src/Launcher.cpp index b0566eee0a..e2d660e782 100644 --- a/launchers/qt/src/Launcher.cpp +++ b/launchers/qt/src/Launcher.cpp @@ -15,6 +15,7 @@ Launcher::Launcher(int& argc, char**argv) : QGuiApplication(argc, argv) { _launcherWindow = std::make_unique(); _launcherWindow->rootContext()->setContextProperty("LauncherState", _launcherState.get()); _launcherWindow->rootContext()->setContextProperty("PathUtils", new PathUtils()); + _launcherWindow->setTitle("High Fidelity"); _launcherWindow->setFlags(Qt::FramelessWindowHint | Qt::Window); _launcherWindow->setLauncherStatePtr(_launcherState); diff --git a/launchers/qt/src/LauncherState.cpp b/launchers/qt/src/LauncherState.cpp index 90fa6e66f1..ddb5ab2dd8 100644 --- a/launchers/qt/src/LauncherState.cpp +++ b/launchers/qt/src/LauncherState.cpp @@ -111,7 +111,7 @@ static const std::array QML_FILE_ { { "qml/SplashScreen.qml", "qml/HFBase/CreateAccountBase.qml", "qml/HFBase/LoginBase.qml", "qml/Download.qml", "qml/DownloadFinished.qml", "qml/HFBase/Error.qml" } }; -void LauncherState::ASSERT_STATE(LauncherState::ApplicationState state) { +void LauncherState::ASSERT_STATE(ApplicationState state) { if (_applicationState != state) { qDebug() << "Unexpected state, current: " << _applicationState << ", expected: " << state; #ifdef BREAK_ON_ERROR @@ -120,7 +120,7 @@ void LauncherState::ASSERT_STATE(LauncherState::ApplicationState state) { } } -void LauncherState::ASSERT_STATE(const std::vector& states) { +void LauncherState::ASSERT_STATE(const std::vector& states) { for (auto state : states) { if (_applicationState == state) { return; @@ -146,7 +146,7 @@ QString LauncherState::getCurrentUISource() const { } void LauncherState::declareQML() { - qmlRegisterType("HQLauncher", 1, 0, "LauncherStateEnums"); + qmlRegisterType("HQLauncher", 1, 0, "ApplicationState"); } LauncherState::UIState LauncherState::getUIState() const { @@ -535,7 +535,6 @@ void LauncherState::installClient() { auto unzipper = new Unzipper(_clientZipFile.fileName(), QDir(installDir)); unzipper->setAutoDelete(true); connect(unzipper, &Unzipper::progress, this, [this](float progress) { - //qDebug() << "Unzipper progress: " << progress; _interfaceInstallProgress = progress; emit downloadProgressChanged(); }); @@ -549,8 +548,6 @@ void LauncherState::installClient() { } }); QThreadPool::globalInstance()->start(unzipper); - - //launchClient(); } void LauncherState::downloadLauncher() { @@ -772,3 +769,4 @@ void LauncherState::setApplicationState(ApplicationState state) { LauncherState::ApplicationState LauncherState::getApplicationState() const { return _applicationState; } + diff --git a/launchers/qt/src/LauncherState.h b/launchers/qt/src/LauncherState.h index 6c5015fe77..7d902417ac 100644 --- a/launchers/qt/src/LauncherState.h +++ b/launchers/qt/src/LauncherState.h @@ -70,19 +70,18 @@ public: LaunchingHighFidelity, }; + Q_ENUM(ApplicationState) + bool _isDebuggingScreens{ false }; UIState _currentDebugScreen{ UIState::SplashScreen }; void toggleDebugState(); void gotoNextDebugScreen(); void gotoPreviousDebugScreen(); - Q_ENUM(UIState); - Q_ENUM(ApplicationState) - Q_INVOKABLE QString getCurrentUISource() const; - void ASSERT_STATE(LauncherState::ApplicationState state); - void ASSERT_STATE(const std::vector& states); + void ASSERT_STATE(ApplicationState state); + void ASSERT_STATE(const std::vector& states); static void declareQML(); diff --git a/launchers/qt/src/main.cpp b/launchers/qt/src/main.cpp index 95d2c16185..a6d512b593 100644 --- a/launchers/qt/src/main.cpp +++ b/launchers/qt/src/main.cpp @@ -58,10 +58,11 @@ int main(int argc, char *argv[]) { } #endif + QString name { "High Fidelity" }; QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setOrganizationName(name); - QCoreApplication::setApplicationName(name); + QCoreApplication::setApplicationName("HQ Launcher"); Launcher launcher(argc, argv);