From fe64f6e9ecb61a224ff7a2da1eeb4148690350fc Mon Sep 17 00:00:00 2001
From: Ryan Huffman <ryanhuffman@gmail.com>
Date: Fri, 4 Oct 2019 10:50:03 -0700
Subject: [PATCH] Update qt launcher styling, make unpinnable, and update name

---
 launchers/qt/resources/qml/Download.qml       |   1 -
 .../qt/resources/qml/DownloadFinished.qml     |   1 -
 .../qml/HFBase/CreateAccountBase.qml          |  18 +-
 launchers/qt/resources/qml/HFBase/Error.qml   |   6 +-
 .../qt/resources/qml/HFBase/LoginBase.qml     | 279 +++++++++---------
 .../resources/qml/HFControls/HFTextField.qml  |   2 +
 .../resources/qml/HFControls/HFTextLogo.qml   |   3 -
 launchers/qt/resources/qml/SplashScreen.qml   |   1 -
 launchers/qt/resources/qml/root.qml           |   4 -
 launchers/qt/src/Helper_windows.cpp           |   4 +-
 launchers/qt/src/LauncherState.cpp            |  12 +-
 launchers/qt/src/LauncherWindow.cpp           |  26 ++
 launchers/qt/src/LauncherWindow.h             |   2 +-
 launchers/qt/src/main.cpp                     |   1 +
 14 files changed, 190 insertions(+), 170 deletions(-)

diff --git a/launchers/qt/resources/qml/Download.qml b/launchers/qt/resources/qml/Download.qml
index 04c2adacd2..00542d02d0 100644
--- a/launchers/qt/resources/qml/Download.qml
+++ b/launchers/qt/resources/qml/Download.qml
@@ -97,7 +97,6 @@ Item {
     }
 
     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 efe5b26925..9a4b3e2f3d 100644
--- a/launchers/qt/resources/qml/DownloadFinished.qml
+++ b/launchers/qt/resources/qml/DownloadFinished.qml
@@ -56,7 +56,6 @@ 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 84633da3ac..7b122b12db 100644
--- a/launchers/qt/resources/qml/HFBase/CreateAccountBase.qml
+++ b/launchers/qt/resources/qml/HFBase/CreateAccountBase.qml
@@ -24,7 +24,6 @@ Item {
     HFTextHeader {
         id: title
         width: 481
-        height: 27
         lineHeight: 35
         lineHeightMode: Text.FixedHeight
         text: root.titleText
@@ -40,7 +39,6 @@ Item {
     HFTextRegular {
         id: instruction
         width: 425
-        height: 22
 
         text: "Use the email address that you registered with."
         visible: LauncherState.lastSignupErrorMessage.length == 0
@@ -57,16 +55,15 @@ Item {
         id: error
 
         width: 425
-        height: 22
 
-        horizontalAlignment: Text.AlignHCenter
-        verticalAlignment: Text.AlignVCenter
+        wrapMode: Text.Wrap
 
         visible: LauncherState.lastSignupErrorMessage.length > 0
         text: LauncherState.lastSignupErrorMessage
+
         anchors {
             left: root.left
-            right: root.right
+            leftMargin: root.marginLeft
             top: title.bottom
             topMargin: 18
         }
@@ -75,7 +72,7 @@ Item {
     HFTextField {
         id: email
         width: 430
-        height: 50
+
         placeholderText: "Email Address"
         seperatorColor: Qt.rgba(1, 1, 1, 0.3)
         anchors {
@@ -89,7 +86,7 @@ Item {
     HFTextField {
         id: username
         width: 430
-        height: 50
+
         placeholderText: root.usernamePlaceholder
         seperatorColor: Qt.rgba(1, 1, 1, 0.3)
         anchors {
@@ -103,7 +100,7 @@ Item {
     HFTextField {
         id: passwordField
         width: 430
-        height: 50
+
         placeholderText: root.passwordPlaceholder
         seperatorColor: Qt.rgba(1, 1, 1, 0.3)
         togglePasswordField: true
@@ -136,7 +133,6 @@ Item {
      HFTextField {
         id: displayName
         width: 430
-        height: 50
         placeholderText: "Display Name"
         seperatorColor: Qt.rgba(1, 1, 1, 0.3)
         anchors {
@@ -150,7 +146,6 @@ Item {
     HFButton {
         id: button
         width: 134
-        height: 50
 
         text: "NEXT"
 
@@ -199,7 +194,6 @@ Item {
     }
 
     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 9c176d5349..6f30a8a464 100644
--- a/launchers/qt/resources/qml/HFBase/Error.qml
+++ b/launchers/qt/resources/qml/HFBase/Error.qml
@@ -49,10 +49,7 @@ Item {
     HFTextRegular {
         id: description
 
-        width: 100
-        height: 40
-
-        text: "We seem to have a problem.\n Please restart HQ Launcher"
+        text: "We seem to have a problem.\nPlease restart HQ Launcher"
 
         horizontalAlignment: Text.AlignHCenter
         verticalAlignment: Text.AlignVCenter
@@ -83,7 +80,6 @@ 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 fd9a52bc94..cedad8cc32 100644
--- a/launchers/qt/resources/qml/HFBase/LoginBase.qml
+++ b/launchers/qt/resources/qml/HFBase/LoginBase.qml
@@ -15,163 +15,172 @@ Item {
         transformOrigin: Item.Center
         rotation: 0
     }
-    HFTextHeader {
-        id: title
-        width: 325
-        height: 26
-        font.bold: true
-        text: "Please Log in"
-        horizontalAlignment: Text.AlignHCenter
-        verticalAlignment: Text.AlignVCenter
+
+    Item {
+        width: 353
+        height: root.height
+
+
         anchors {
             top: root.top
-            topMargin: 40
             horizontalCenter: root.horizontalCenter
         }
-    }
 
-    HFTextRegular {
-        id: instruction
-        width: 425
-        height: 22
+        HFTextHeader {
+            id: title
 
-        horizontalAlignment: Text.AlignHCenter
-        verticalAlignment: Text.AlignVCenter
+            font.bold: true
 
-        visible: LauncherState.lastLoginErrorMessage.length == 0
-        text: "Use the account credentials you created at sign-up"
-        anchors {
-            left: root.left
-            right: root.right
-            top: title.bottom
-            topMargin: 18
-        }
-    }
+            text: "Please Log in"
 
-    HFTextError {
-        id: error
-        width: 425
-        height: 22
+            anchors {
+                top: parent.top
+                topMargin: 40
 
-        horizontalAlignment: Text.AlignHCenter
-        verticalAlignment: Text.AlignVCenter
-
-        visible: LauncherState.lastLoginErrorMessage.length > 0
-        text: LauncherState.lastLoginErrorMessage
-        anchors {
-            left: root.left
-            right: root.right
-            top: title.bottom
-            topMargin: 18
-        }
-    }
-
-    HFTextField {
-        id: username
-        width: 353
-        height: 50
-
-        placeholderText: "Username"
-
-        seperatorColor: Qt.rgba(1, 1, 1, 0.3)
-        anchors {
-            top: error.bottom
-            horizontalCenter: error.horizontalCenter
-            topMargin: 24
-        }
-    }
-
-    HFTextField {
-        id: password
-        width: 353
-        height: 50
-        placeholderText: "Password"
-        togglePasswordField: true
-        echoMode: TextInput.Password
-        seperatorColor: Qt.rgba(1, 1, 1, 0.3)
-        anchors {
-            top: username.bottom
-            horizontalCenter: instruction.horizontalCenter
-            topMargin: 25
-        }
-    }
-
-
-    HFTextRegular {
-        id: displayText
-
-        text: "You can change this at anytime from your profile."
-
-        anchors {
-            top: password.bottom
-            topMargin: 50
-            left: password.left
-        }
-    }
-
-    HFTextField {
-        id: displayName
-        width: 353
-        height: 50
-        placeholderText: "Display name"
-        seperatorColor: Qt.rgba(1, 1, 1, 0.3)
-        anchors {
-            top: displayText.bottom
-            horizontalCenter: instruction.horizontalCenter
-            topMargin: 4
-        }
-    }
-
-    HFButton {
-        id: button
-        width: 110
-
-        text: "NEXT"
-
-        anchors {
-            top: displayName.bottom
-            left: displayName.left
-            topMargin: 25
+                horizontalCenter: parent.horizontalCenter
+            }
         }
 
-        onClicked: LauncherState.login(username.text, password.text, displayName.text)
-    }
+        HFTextRegular {
+            id: instruction
 
-    Text {
-        text: "Create New Account"
-        font.family: "Graphik"
-        font.pixelSize: 14
-        color: "#009EE0"
+            visible: LauncherState.lastLoginErrorMessage.length == 0
+            text: "Use the account credentials you created at sign-up"
+            anchors {
+                left: parent.left
+                right: parent.right;
 
-        anchors {
-            top: button.bottom
-            topMargin: 16
-            left: button.left
+                top: title.bottom
+                topMargin: 18
+            }
         }
 
-        MouseArea {
-            anchors.fill: parent
+        HFTextError {
+            id: error
 
-            cursorShape: Qt.PointingHandCursor
+            visible: LauncherState.lastLoginErrorMessage.length > 0
+            text: LauncherState.lastLoginErrorMessage
+            anchors {
+                top: title.bottom
+                topMargin: 18
 
-            onClicked: {
-                console.log("clicked");
-                LauncherState.gotoSignup();
+                left: parent.left
+                right: parent.right;
+            }
+        }
+
+        HFTextField {
+            id: username
+
+            placeholderText: "Username"
+
+            seperatorColor: Qt.rgba(1, 1, 1, 0.3)
+            anchors {
+                top: error.bottom
+                topMargin: 24
+
+                left: parent.left
+                right: parent.right;
+            }
+        }
+
+        HFTextField {
+            id: password
+
+            placeholderText: "Password"
+            togglePasswordField: true
+            echoMode: TextInput.Password
+            seperatorColor: Qt.rgba(1, 1, 1, 0.3)
+            anchors {
+                top: username.bottom
+                topMargin: 25
+
+                left: parent.left
+                right: parent.right;
+            }
+        }
+
+
+        HFTextRegular {
+            id: displayText
+
+            text: "You can change this at anytime from your profile."
+
+            anchors {
+                top: password.bottom
+                topMargin: 50
+
+                left: parent.left
+                right: parent.right;
+            }
+        }
+
+        HFTextField {
+            id: displayName
+
+            placeholderText: "Display name"
+            seperatorColor: Qt.rgba(1, 1, 1, 0.3)
+            anchors {
+                top: displayText.bottom
+                topMargin: 4
+
+                left: parent.left
+                right: parent.right;
+            }
+        }
+
+        HFButton {
+            id: button
+            width: 110
+
+            text: "NEXT"
+
+            anchors {
+                top: displayName.bottom
+                topMargin: 25
+
+                left: parent.left
+            }
+
+            onClicked: LauncherState.login(username.text, password.text, displayName.text)
+        }
+
+        Text {
+            id: createAccountLink
+
+            text: "Create New Account"
+            font.family: "Graphik"
+            font.pixelSize: 14
+            color: "#009EE0"
+
+            anchors {
+                top: button.bottom
+                topMargin: 16
+                left: parent.left
+            }
+
+            MouseArea {
+                anchors.fill: parent
+
+                cursorShape: Qt.PointingHandCursor
+
+                onClicked: {
+                    console.log("clicked");
+                    LauncherState.gotoSignup();
+                }
+            }
+        }
+
+        HFTextLogo {
+            anchors {
+                bottom: createAccountLink.bottom
+
+                right: parent.right
             }
         }
     }
 
-    HFTextLogo {
-        anchors {
-            bottom: root.bottom
-            bottomMargin: 58
-            right: root.right
-            rightMargin: 136
-        }
-    }
-
     Component.onCompleted: {
-        root.parent.setStateInfoState("left");
         root.parent.setBuildInfoState("right");
     }
 }
diff --git a/launchers/qt/resources/qml/HFControls/HFTextField.qml b/launchers/qt/resources/qml/HFControls/HFTextField.qml
index 361e81b951..cce0a0fc1e 100644
--- a/launchers/qt/resources/qml/HFControls/HFTextField.qml
+++ b/launchers/qt/resources/qml/HFControls/HFTextField.qml
@@ -4,6 +4,8 @@ import QtQuick.Controls 2.1
 TextField {
     id: control
 
+    height: 50
+
     font.family: "Graphik Regular"
     font.pointSize: 10.5
     color: text.length == 0 ? "#7e8c81" : "#000000"
diff --git a/launchers/qt/resources/qml/HFControls/HFTextLogo.qml b/launchers/qt/resources/qml/HFControls/HFTextLogo.qml
index f3c7468373..08025ef715 100644
--- a/launchers/qt/resources/qml/HFControls/HFTextLogo.qml
+++ b/launchers/qt/resources/qml/HFControls/HFTextLogo.qml
@@ -2,9 +2,6 @@ import QtQuick 2.3
 import QtQuick 2.1
 
 Text {
-    width: 100
-    height: 17
-
     text: "High Fidelity"
     font.bold: true
     font.family: "Graphik Semibold"
diff --git a/launchers/qt/resources/qml/SplashScreen.qml b/launchers/qt/resources/qml/SplashScreen.qml
index 47dff2aa9d..0e2e522232 100644
--- a/launchers/qt/resources/qml/SplashScreen.qml
+++ b/launchers/qt/resources/qml/SplashScreen.qml
@@ -24,7 +24,6 @@ Item {
     }
 
     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 f26bb1ec4b..e3f82450f2 100644
--- a/launchers/qt/resources/qml/root.qml
+++ b/launchers/qt/resources/qml/root.qml
@@ -17,10 +17,6 @@ Item {
         function setBuildInfoState(state) {
             buildInfo.state = state;
         }
-
-        function setStateInfoState(state) {
-            stateInfo.state = state;
-        }
     }
 
     Component.onCompleted: {
diff --git a/launchers/qt/src/Helper_windows.cpp b/launchers/qt/src/Helper_windows.cpp
index f31f5c7c7c..fdaf5c3a4a 100644
--- a/launchers/qt/src/Helper_windows.cpp
+++ b/launchers/qt/src/Helper_windows.cpp
@@ -39,8 +39,8 @@ void launchClient(const QString& clientPath, const QString& homePath, const QStr
 
     // start the program up
     BOOL success = CreateProcess(
-        clientPath.toUtf8().data(),
-        params.toUtf8().data(),
+        clientPath.toLatin1().data(),
+        params.toLatin1().data(),
         nullptr,                 // Process handle not inheritable
         nullptr,                 // Thread handle not inheritable
         FALSE,                   // Set handle inheritance to FALSE
diff --git a/launchers/qt/src/LauncherState.cpp b/launchers/qt/src/LauncherState.cpp
index a2f5892055..90fa6e66f1 100644
--- a/launchers/qt/src/LauncherState.cpp
+++ b/launchers/qt/src/LauncherState.cpp
@@ -325,15 +325,19 @@ void LauncherState::signup(QString email, QString username, QString password, QS
             setApplicationState(ApplicationState::WaitingForSignup);
             return;
         } else if (err == SignupRequest::Error::BadPassword) {
-            setLastSignupErrorMessage("That's an invalid password - please try another password.");
+            setLastSignupErrorMessage("That's an invalid password - passwords 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.");
             setApplicationState(ApplicationState::WaitingForSignup);
             return;
-        } else if (err == SignupRequest::Error::UserProfileAlreadyCompleted || err == SignupRequest::Error::NoSuchEmail) {
-            setLastSignupErrorMessage("That email does not have an account setup for it, or it was previously completed.");
+        } else if (err == SignupRequest::Error::UserProfileAlreadyCompleted) {
+            setLastSignupErrorMessage("That email has already been completed.");
+            setApplicationState(ApplicationState::WaitingForSignup);
+            return;
+        } else if (err == SignupRequest::Error::NoSuchEmail) {
+            setLastSignupErrorMessage("That email does not have an account setup for it.");
             setApplicationState(ApplicationState::WaitingForSignup);
             return;
         } else if (err != SignupRequest::Error::None) {
@@ -383,8 +387,6 @@ void LauncherState::login(QString username, QString password, QString displayNam
 
     _displayName = displayName;
 
-    qDebug() << "Got login: " << username << password;
-
     auto request = new LoginRequest();
 
     connect(request, &LoginRequest::finished, this, [this, request]() {
diff --git a/launchers/qt/src/LauncherWindow.cpp b/launchers/qt/src/LauncherWindow.cpp
index 3c13e5908a..53a781f1e1 100644
--- a/launchers/qt/src/LauncherWindow.cpp
+++ b/launchers/qt/src/LauncherWindow.cpp
@@ -4,6 +4,32 @@
 
 #include <QCursor>
 
+#ifdef Q_OS_WIN
+#include <shellapi.h>
+#include <propsys.h>
+#include <propkey.h>
+#endif
+
+LauncherWindow::LauncherWindow() {
+#ifdef Q_OS_WIN
+    // On Windows, disable pinning of the launcher.
+    IPropertyStore* pps;
+    HWND id = (HWND)this->winId();
+    if (id == NULL) {
+        qDebug() << "Failed to disable pinning, window id is null";
+    } else {
+        HRESULT hr = SHGetPropertyStoreForWindow(id, IID_PPV_ARGS(&pps));
+        if (SUCCEEDED(hr)) {
+            PROPVARIANT var;
+            var.vt = VT_BOOL;
+            var.boolVal = VARIANT_TRUE;
+            hr = pps->SetValue(PKEY_AppUserModel_PreventPinning, var);
+            pps->Release();
+        }
+    }
+#endif
+}
+
 void LauncherWindow::keyPressEvent(QKeyEvent* event) {
     QQuickView::keyPressEvent(event);
     if (!event->isAccepted()) {
diff --git a/launchers/qt/src/LauncherWindow.h b/launchers/qt/src/LauncherWindow.h
index 08e8cf4825..52b83b88c0 100644
--- a/launchers/qt/src/LauncherWindow.h
+++ b/launchers/qt/src/LauncherWindow.h
@@ -5,7 +5,7 @@
 
 class LauncherWindow : public QQuickView {
 public:
-    LauncherWindow() = default;
+    LauncherWindow();
     ~LauncherWindow() = default;
     void keyPressEvent(QKeyEvent* event) override;
     void mousePressEvent(QMouseEvent* event) override;
diff --git a/launchers/qt/src/main.cpp b/launchers/qt/src/main.cpp
index 0965a5742f..95d2c16185 100644
--- a/launchers/qt/src/main.cpp
+++ b/launchers/qt/src/main.cpp
@@ -61,6 +61,7 @@ int main(int argc, char *argv[]) {
     QString name { "High Fidelity" };
     QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
     QCoreApplication::setOrganizationName(name);
+    QCoreApplication::setApplicationName(name);
 
     Launcher launcher(argc, argv);