Update qt launcher to disable inputs when making requests

This commit is contained in:
Ryan Huffman 2019-10-04 16:43:58 -07:00
parent a661d62959
commit f912268129
10 changed files with 42 additions and 19 deletions

View file

@ -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 {

View file

@ -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 {

View file

@ -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

View file

@ -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

View file

@ -5,7 +5,6 @@ Item {
id: root
anchors.fill: parent
Image {
anchors.centerIn: parent
width: parent.width

View file

@ -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;

View file

@ -15,6 +15,7 @@ Launcher::Launcher(int& argc, char**argv) : QGuiApplication(argc, argv) {
_launcherWindow = std::make_unique<LauncherWindow>();
_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);

View file

@ -111,7 +111,7 @@ static const std::array<QString, LauncherState::UIState::UI_STATE_NUM> 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<LauncherState::ApplicationState>& states) {
void LauncherState::ASSERT_STATE(const std::vector<ApplicationState>& states) {
for (auto state : states) {
if (_applicationState == state) {
return;
@ -146,7 +146,7 @@ QString LauncherState::getCurrentUISource() const {
}
void LauncherState::declareQML() {
qmlRegisterType<LauncherState>("HQLauncher", 1, 0, "LauncherStateEnums");
qmlRegisterType<LauncherState>("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;
}

View file

@ -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<LauncherState::ApplicationState>& states);
void ASSERT_STATE(ApplicationState state);
void ASSERT_STATE(const std::vector<ApplicationState>& states);
static void declareQML();

View file

@ -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);