Merge branch 'qt-launcher' of github.com:danteruiz/hifi into qt-launcher

This commit is contained in:
dante ruiz 2019-10-07 09:15:18 -07:00
commit e1a3b24a6d
18 changed files with 228 additions and 186 deletions

View file

@ -97,7 +97,6 @@ Item {
}
Component.onCompleted: {
root.parent.setStateInfoState("right");
root.parent.setBuildInfoState("left");
}
}

View file

@ -56,7 +56,6 @@ Item {
}
Component.onCompleted: {
root.parent.setStateInfoState("right");
root.parent.setBuildInfoState("left");
}
}

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
@ -24,10 +28,9 @@ Item {
HFTextHeader {
id: title
width: 481
height: 27
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
@ -40,7 +43,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 +59,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 +76,9 @@ Item {
HFTextField {
id: email
width: 430
height: 50
enabled: root.enabled
placeholderText: "Email Address"
seperatorColor: Qt.rgba(1, 1, 1, 0.3)
anchors {
@ -89,7 +92,9 @@ Item {
HFTextField {
id: username
width: 430
height: 50
enabled: root.enabled
placeholderText: root.usernamePlaceholder
seperatorColor: Qt.rgba(1, 1, 1, 0.3)
anchors {
@ -103,7 +108,9 @@ Item {
HFTextField {
id: passwordField
width: 430
height: 50
enabled: root.enabled
placeholderText: root.passwordPlaceholder
seperatorColor: Qt.rgba(1, 1, 1, 0.3)
togglePasswordField: true
@ -136,7 +143,9 @@ Item {
HFTextField {
id: displayName
width: 430
height: 50
enabled: root.enabled
placeholderText: "Display Name"
seperatorColor: Qt.rgba(1, 1, 1, 0.3)
anchors {
@ -152,7 +161,8 @@ Item {
HFButton {
id: button
width: 134
height: 50
enabled: root.enabled
text: "NEXT"
@ -201,7 +211,6 @@ Item {
}
Component.onCompleted: {
root.parent.setStateInfoState("right");
root.parent.setBuildInfoState("left");
}
}

View file

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

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
@ -15,165 +19,181 @@ 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
horizontalCenter: parent.horizontalCenter
}
}
onAccepted: LauncherState.login(username.text, password.text, displayName.text)
}
HFTextRegular {
id: instruction
HFButton {
id: button
width: 110
visible: LauncherState.lastLoginErrorMessage.length == 0
text: "Use the account credentials you created at sign-up"
anchors {
left: parent.left
right: parent.right;
text: "NEXT"
anchors {
top: displayName.bottom
left: displayName.left
topMargin: 25
top: title.bottom
topMargin: 18
}
}
onClicked: LauncherState.login(username.text, password.text, displayName.text)
}
HFTextError {
id: error
Text {
text: "Create New Account"
font.family: "Graphik"
font.pixelSize: 14
color: "#009EE0"
visible: LauncherState.lastLoginErrorMessage.length > 0
text: LauncherState.lastLoginErrorMessage
anchors {
top: title.bottom
topMargin: 18
anchors {
top: button.bottom
topMargin: 16
left: button.left
left: parent.left
right: parent.right;
}
}
MouseArea {
anchors.fill: parent
HFTextField {
id: username
cursorShape: Qt.PointingHandCursor
enabled: root.enabled
onClicked: {
console.log("clicked");
LauncherState.gotoSignup();
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
enabled: root.enabled
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
enabled: root.enabled
placeholderText: "Display name"
seperatorColor: Qt.rgba(1, 1, 1, 0.3)
anchors {
top: displayText.bottom
topMargin: 4
left: parent.left
right: parent.right;
}
onAccepted: LauncherState.login(username.text, password.text, displayName.text)
}
HFButton {
id: button
width: 110
enabled: root.enabled
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");
}
}

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

@ -4,9 +4,11 @@ import QtQuick.Controls 2.1
TextField {
id: control
height: 50
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

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

View file

@ -5,7 +5,6 @@ Item {
id: root
anchors.fill: parent
Image {
anchors.centerIn: parent
width: parent.width
@ -24,7 +23,6 @@ Item {
}
Component.onCompleted: {
root.parent.setStateInfoState("left");
root.parent.setBuildInfoState("right");
}
}

View file

@ -17,10 +17,6 @@ Item {
function setBuildInfoState(state) {
buildInfo.state = state;
}
function setStateInfoState(state) {
//stateInfo.state = state;
}
}
Component.onCompleted: {

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

@ -40,8 +40,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

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 {
@ -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]() {
@ -533,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();
});
@ -547,8 +548,6 @@ void LauncherState::installClient() {
}
});
QThreadPool::globalInstance()->start(unzipper);
//launchClient();
}
void LauncherState::downloadLauncher() {
@ -770,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

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

View file

@ -5,7 +5,7 @@
class LauncherWindow : public QQuickView {
public:
LauncherWindow() = default;
LauncherWindow();
~LauncherWindow() = default;
void keyPressEvent(QKeyEvent* event) override;
void mousePressEvent(QMouseEvent* event) override;

View file

@ -58,9 +58,11 @@ int main(int argc, char *argv[]) {
}
#endif
QString name { "High Fidelity" };
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QCoreApplication::setOrganizationName(name);
QCoreApplication::setApplicationName("HQ Launcher");
Launcher launcher(argc, argv);