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

This commit is contained in:
Ryan Huffman 2019-09-13 15:25:44 -07:00
commit f4bca3511e
15 changed files with 399 additions and 21 deletions

View file

@ -62,7 +62,6 @@ if (WIN32)
endif () endif ()
if (APPLE) if (APPLE)
ExternalProject_Add( ExternalProject_Add(
qtlite qtlite
@ -127,6 +126,8 @@ set(src_files
src/LauncherState.cpp src/LauncherState.cpp
src/LauncherWindow.h src/LauncherWindow.h
src/LauncherWindow.cpp src/LauncherWindow.cpp
src/PathUtils.cpp
src/PathUtils.h
src/Unzipper.h src/Unzipper.h
src/Unzipper.cpp src/Unzipper.cpp
deps/miniz/miniz.h deps/miniz/miniz.h
@ -201,6 +202,13 @@ add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
"${INTERFACE_EXEC_DIR}") "${INTERFACE_EXEC_DIR}")
if (LAUNCHER_SOURCE_TREE_RESOURCES)
target_compile_definitions(${PROJECT_NAME} PRIVATE RESOURCE_PREFIX_URL="${CMAKE_CURRENT_SOURCE_DIR}/resources/")
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()
if (APPLE) if (APPLE)
install( install(

View file

@ -0,0 +1,68 @@
import QtQuick 2.3
import QtQuick.Controls 2.1
import "HFControls"
Item {
id: root
anchors.centerIn: parent
Image {
anchors.centerIn: parent
width: parent.width
height: parent.height
mirror: true
source: PathUtils.resourcePath("images/hifi_window@2x.png");
transformOrigin: Item.Center
rotation: 0
}
Image {
id: logo
width: 132
height: 134
source: PathUtils.resourcePath("images/HiFi_Voxel.png");
anchors {
top: root.top
topMargin: 84
horizontalCenter: root.horizontalCenter
}
}
Text {
id: header
width: 87
height: 31
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
font.family: "Graphik"
font.bold: true
font.pixelSize: 28
color: "#FFFFFF"
text: "You're all set!"
anchors {
top: logo.bottom
topMargin: 26
horizontalCenter: logo.horizontalCenter
}
}
Text {
id: description
width: 100
height: 40
font.family: "Graphik"
font.pixelSize: 14
color: "#FFFFFF"
text: "We will see you in world."
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
anchors {
top: header.bottom
topMargin: 8
horizontalCenter: header.horizontalCenter
}
}
}

View file

@ -0,0 +1,159 @@
import QtQuick 2.3
import QtQuick 2.1
import "../HFControls"
Item {
id: root
anchors.centerIn: parent
property string titleText: "Create your account"
property string usernamePlaceholder: "User name"
property string passwordPlaceholder: "Set a password"
property int marginLeft: root.width * 0.15
Image {
anchors.centerIn: parent
width: parent.width
height: parent.height
mirror: true
source: "qrc:/images/hifi_window@2x.png"
transformOrigin: Item.Center
rotation: 180
}
Text {
id: title
width: 325
height: 26
font.family: "Graphik"
font.bold: true
font.pixelSize: 24
color: "#FFFFFF"
text: root.titleText
anchors {
top: root.top
topMargin: 29
left: root.left
leftMargin: root.marginLeft
}
}
Text {
id: instruction
width: 425
height: 22
font.family: "Graphik"
font.pixelSize: 10
color: "#C4C4C4"
text: "Use the email address that you regisetered with."
anchors {
left: root.left
leftMargin: root.marginLeft
top: title.bottom
topMargin: 9
}
}
HFTextField {
id: organization
width: 353
height: 40
font.family: "Graphik"
font.pixelSize: 18
placeholderText: "Organization name"
color: "#808080"
seperatorColor: Qt.rgba(1, 1, 1, 0.3)
anchors {
top: instruction.bottom
left: root.left
leftMargin: root.marginLeft
topMargin: 4
}
}
HFTextField {
id: username
width: 353
height: 40
font.family: "Graphik"
font.pixelSize: 18
placeholderText: root.usernamePlaceholder
color: "#808080"
seperatorColor: Qt.rgba(1, 1, 1, 0.3)
anchors {
top: organization.bottom
left: root.left
leftMargin: root.marginLeft
topMargin: 10
}
}
HFTextField {
id: passwordField
width: 353
height: 40
font.family: "Graphik"
font.pixelSize: 18
placeholderText: root.passwordPlaceholder
color: "#808080"
seperatorColor: Qt.rgba(1, 1, 1, 0.3)
echoMode: TextInput.Password
anchors {
top: username.bottom
left: root.left
leftMargin: root.marginLeft
topMargin: 10
}
}
Text {
id: displayNameText
text: "This is the display name other people see in world. It can be changed at \nanytime, from your profile"
font.family: "Graphik"
font.pixelSize: 10
color: "#FFFFFF"
anchors {
top: passwordField.bottom
left: root.left
leftMargin: root.marginLeft
topMargin: 15
}
}
HFTextField {
id: displayName
width: 353
height: 40
font.family: "Graphik"
font.pixelSize: 18
placeholderText: "Password"
color: "#C4C4C4"
seperatorColor: Qt.rgba(1, 1, 1, 0.3)
anchors {
top: displayNameText.bottom
left: root.left
leftMargin: root.marginLeft
topMargin: 8
}
}
HFButton {
id: button
width: 122
height: 36
font.family: "Graphik"
font.pixelSize: 18
text: "NEXT"
anchors {
top: displayName.bottom
left: root.left
leftMargin: root.marginLeft
topMargin: 15
}
onClicked: LauncherState.login(username.text, password.text)
}
}

View file

@ -0,0 +1,105 @@
import QtQuick 2.3
import QtQuick 2.1
import "../HFControls"
Item {
id: root
anchors.centerIn: parent
Image {
anchors.centerIn: parent
width: parent.width
height: parent.height
mirror: false
source: "qrc:/images/hifi_window@2x.png"
//fillMode: Image.PreserveAspectFit
transformOrigin: Item.Center
//rotation: 90
}
Image {
id: logo
width: 132
height: 134
source: "qrc:/images/HiFi_Voxel.png"
anchors {
top: root.top
topMargin: 84
horizontalCenter: root.horizontalCenter
}
}
Text {
id: header
width: 87
height: 31
font.family: "Graphik"
font.bold: true
font.pixelSize: 28
color: "#FFFFFF"
text: "Uh oh."
anchors {
top: logo.bottom
topMargin: 26
horizontalCenter: logo.horizontalCenter
}
}
Text {
id: description
width: 100
height: 40
font.family: "Graphik"
font.pixelSize: 14
color: "#FFFFFF"
text: "We seem to have a problem.\n Please restart HQ Launcher"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
anchors {
top: header.bottom
topMargin: 8
horizontalCenter: header.horizontalCenter
}
}
HFButton {
id: button
width: 166
height: 35
font.family: "Graphik"
font.pixelSize: 18
text: "Restart"
anchors {
top: description.bottom
topMargin: 15
horizontalCenter: description.horizontalCenter
}
}
Text {
id: hifilogo
width: 100
height: 18
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
font.family: "Graphik"
font.pixelSize: 18
font.bold: true
color: "#FFFFFF"
text: "High Fidelity"
anchors {
right: root.right
rightMargin: 17
bottom: root.bottom
bottomMargin: 17
}
}
}

View file

@ -3,7 +3,7 @@ import QtQuick.Controls 2.1
TextField { TextField {
id: control id: control
color: "#FFFFFF" //color: "#000000"
font.family: "Graphik Medium" font.family: "Graphik Medium"
font.pixelSize: 22 font.pixelSize: 22
verticalAlignment: TextInput.AlignVCenter verticalAlignment: TextInput.AlignVCenter
@ -14,14 +14,8 @@ TextField {
background: Item { background: Item {
anchors.fill: parent anchors.fill: parent
Rectangle { Rectangle {
anchors { color: "#FFFFFF"
bottom: parent.bottom anchors.fill: parent
left: parent.left
leftMargin: 7
right: parent.right
}
height: 1
color: control.seperatorColor
} }
} }
} }

View file

@ -4,10 +4,21 @@ import QtQuick.Controls 2.1
Item { Item {
anchors.fill: parent anchors.fill: parent
Image {
anchors.centerIn: parent
width: parent.width
height: parent.height
mirror: true
source: PathUtils.resourcePath("images/hifi_window@2x.png");
transformOrigin: Item.Center
rotation: 0
}
Image { Image {
anchors.centerIn: parent anchors.centerIn: parent
width: 225 width: 225
height: 205 height: 205
source: "../images/hifi_logo_large@2x.png" source: PathUtils.resourcePath("images/hifi_logo_large@2x.png");
} }
} }

View file

@ -5,11 +5,11 @@ import QtQuick.Controls 2.1
import HQLauncher 1.0 import HQLauncher 1.0
import "HFControls" import "HFControls"
Image { Item {
id: root id: root
width: 515 width: 515
height: 450 height: 390
source: "../images/hifi_window@2x.png" //source: "../images/hifi_window@2x.png"
Loader { Loader {
anchors.fill: parent anchors.fill: parent

View file

@ -6,6 +6,7 @@
#include "LauncherWindow.h" #include "LauncherWindow.h"
#include "LauncherState.h" #include "LauncherState.h"
#include "PathUtils.h"
Launcher::Launcher(int& argc, char**argv) : QGuiApplication(argc, argv) { Launcher::Launcher(int& argc, char**argv) : QGuiApplication(argc, argv) {
QString resourceBinaryLocation = QGuiApplication::applicationDirPath() + "/resources.rcc"; QString resourceBinaryLocation = QGuiApplication::applicationDirPath() + "/resources.rcc";
@ -14,9 +15,10 @@ Launcher::Launcher(int& argc, char**argv) : QGuiApplication(argc, argv) {
//_launcherState->setUIState(LauncherState::SPLASH_SCREEN); //_launcherState->setUIState(LauncherState::SPLASH_SCREEN);
_launcherWindow = std::make_unique<LauncherWindow>(); _launcherWindow = std::make_unique<LauncherWindow>();
_launcherWindow->rootContext()->setContextProperty("LauncherState", _launcherState.get()); _launcherWindow->rootContext()->setContextProperty("LauncherState", _launcherState.get());
_launcherWindow->rootContext()->setContextProperty("PathUtils", new PathUtils());
_launcherWindow->setFlags(Qt::FramelessWindowHint); _launcherWindow->setFlags(Qt::FramelessWindowHint);
LauncherState::declareQML(); LauncherState::declareQML();
_launcherWindow->setSource(QUrl("qrc:/qml/root.qml")); _launcherWindow->setSource(QUrl(PathUtils::resourcePath("qml/root.qml")));
_launcherWindow->setResizeMode(QQuickView::SizeRootObjectToView); _launcherWindow->setResizeMode(QQuickView::SizeRootObjectToView);
_launcherWindow->show(); _launcherWindow->show();
} }

View file

@ -1,3 +1,4 @@
#pragma once
#include <memory> #include <memory>
#include <QGuiApplication> #include <QGuiApplication>

View file

@ -1,9 +1,11 @@
#include "LauncherState.h" #include "LauncherState.h"
#include "PathUtils.h"
#include "Unzipper.h" #include "Unzipper.h"
#ifdef Q_OS_WIN
#include <Windows.h> #include <Windows.h>
#endif
#include <array> #include <array>
#include <QNetworkRequest> #include <QNetworkRequest>
@ -43,8 +45,8 @@ bool LatestBuilds::getBuild(QString tag, Build* outBuild) {
} }
static const std::array<QString, LauncherState::UIState::UI_STATE_NUM> QML_FILE_FOR_UI_STATE = static const std::array<QString, LauncherState::UIState::UI_STATE_NUM> QML_FILE_FOR_UI_STATE =
{ { "qrc:/qml/SplashScreen.qml", "qrc:/qml/Login.qml", "qrc:/qml/DisplayName.qml", { { "SplashScreen.qml", "qml/HFBase/CreateAccountBase.qml", "DisplayName.qml",
"qrc:/qml/Download.qml", "qrc:/qml/DownloadFinshed.qml", "qrc:/qml/Error.qml" } }; "Download.qml", "DownloadFinished.qml", "qml/HFBase/Error.qml" } };
void LauncherState::ASSERT_STATE(LauncherState::ApplicationState state) { void LauncherState::ASSERT_STATE(LauncherState::ApplicationState state) {
if (_applicationState != state) { if (_applicationState != state) {
@ -61,6 +63,7 @@ void LauncherState::ASSERT_STATE(std::vector<LauncherState::ApplicationState> st
return; return;
} }
} }
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
__debugbreak(); __debugbreak();
#endif #endif
@ -99,11 +102,15 @@ LauncherState::UIState LauncherState::getUIState() const {
case ApplicationState::LaunchingHighFidelity: case ApplicationState::LaunchingHighFidelity:
return DOWNLOAD_FINSISHED; return DOWNLOAD_FINSISHED;
case ApplicationState::UnexpectedError: case ApplicationState::UnexpectedError:
#ifdef Q_OS_WIN
__debugbreak(); __debugbreak();
#endif
return ERROR_SCREEN; return ERROR_SCREEN;
default: default:
qDebug() << "FATAL: No UI for" << _applicationState; qDebug() << "FATAL: No UI for" << _applicationState;
#ifdef Q_OS_WIN
__debugbreak(); __debugbreak();
#endif
return ERROR_SCREEN; return ERROR_SCREEN;
} }
} }
@ -477,13 +484,15 @@ void LauncherState::setApplicationState(ApplicationState state) {
qDebug() << "Changing application state: " << _applicationState << " -> " << state; qDebug() << "Changing application state: " << _applicationState << " -> " << state;
if (state == ApplicationState::UnexpectedError) { if (state == ApplicationState::UnexpectedError) {
#ifdef Q_OS_WIN
__debugbreak(); __debugbreak();
#endif
} }
_applicationState = state; _applicationState = state;
emit uiStateChanged(); emit uiStateChanged();
emit updateSourceUrl(getCurrentUISource()); emit updateSourceUrl(PathUtils::resourcePath(getCurrentUISource()));
emit applicationStateChanged(); emit applicationStateChanged();
} }

View file

@ -3,6 +3,7 @@
#include <QDir> #include <QDir>
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include <QUrl>
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
#include <QFile> #include <QFile>

View file

@ -1,5 +1,6 @@
#include <QQuickView> #include <QQuickView>
#include <QPoint> #include <QPoint>
#include <memory>
class LauncherWindow : public QQuickView { class LauncherWindow : public QQuickView {
public: public:
@ -7,8 +8,10 @@ public:
void mousePressEvent(QMouseEvent* event) override; void mousePressEvent(QMouseEvent* event) override;
void mouseReleaseEvent(QMouseEvent* event) override; void mouseReleaseEvent(QMouseEvent* event) override;
void mouseMoveEvent(QMouseEvent* event) override; void mouseMoveEvent(QMouseEvent* event) override;
//void setLauncherState(std::shared_ptr<LauncherState> launcherState) { _launcherState = launcherState; }
private: private:
bool _drag { false }; bool _drag { false };
QPoint _previousMousePos; QPoint _previousMousePos;
///std::shared_ptr<LauncherState> _launcherState { nullptr };
}; };

View file

@ -0,0 +1,7 @@
#include "PathUtils.h"
#include <QDebug>
QString PathUtils::resourcePath(const QString& source) {
return QString(RESOURCE_PREFIX_URL + source);
}

View file

@ -0,0 +1,11 @@
#pragma once
#include <QObject>
#include <QString>
class PathUtils : public QObject {
Q_OBJECT
public:
PathUtils() = default;
~PathUtils() = default;
Q_INVOKABLE static QString resourcePath(const QString& source);
};

View file

@ -3,7 +3,6 @@
#include <QDir> #include <QDir>
#include <QDebug> #include <QDebug>
#include <miniz/miniz.h> #include <miniz/miniz.h>
#include <Shlobj.h>
Unzipper::Unzipper(const QString& zipFilePath, const QDir& outputDirectory) : Unzipper::Unzipper(const QString& zipFilePath, const QDir& outputDirectory) :
_zipFilePath(zipFilePath), _outputDirectory(outputDirectory) { _zipFilePath(zipFilePath), _outputDirectory(outputDirectory) {