working on ui pages

This commit is contained in:
danteruiz 2019-08-28 20:18:51 -07:00
parent 1689096967
commit 476b7605d5
9 changed files with 132 additions and 73 deletions

View file

@ -33,6 +33,8 @@ set(src_files
src/main.cpp
src/Launcher.h
src/Launcher.cpp
src/LauncherState.h
src/LauncherState.cpp
src/LauncherWindow.h
src/LauncherWindow.cpp)

View file

@ -0,0 +1,13 @@
import QtQuick 2.3
import QtQuick.Controls 2.1
Item {
anchors.fill: parent
Image {
anchors.centerIn: parent
width: 225
height: 205
source: "../images/hifi_logo_large@2x.png"
}
}

View file

@ -2,6 +2,7 @@
import QtQuick 2.3
import QtQuick.Controls 2.1
import HQLauncher 1.0
import "HFControls"
Image {
id: root
@ -9,59 +10,16 @@ Image {
height: 450
source: "../images/hifi_window@2x.png"
Text {
id: text
width: 325
height: 26
anchors {
left: root.left
leftMargin: 95
top: root.top
topMargin: 29
}
text: "Please log in"
font.pointSize: 24
color: "#FFFFFF"
Loader {
anchors.centerIn: parent
anchors.fill: parent
id: loader
}
HFTextField {
id: textField
width: 150
height: 50
anchors {
left: root.left
leftMargin: 40
top: text.bottom
topMargin: 20
}
echoMode: TextInput.Password
placeholderText: "Organization"
}
HFButton {
anchors {
left: root.left
leftMargin: 40
top: textField.bottom
topMargin: 20
}
id: button
text: "NEXT"
}
Image {
id: spinner
source: "../images/HiFi_Voxel.png"
anchors.bottom: root.bottom
RotationAnimator {
target: spinner;
loops: Animation.Infinite
from: 0;
to: 360;
duration: 5000
running: true
}
Component.onCompleted: {
loader.source = LauncherState.getCurrentUISource();
LauncherState.updateSourceUrl.connect(function(url) {
loader.source = url;
});
}
}

View file

@ -1,6 +1,23 @@
#include "Launcher.h"
#include <QResource>
#include <QFileInfo>
#include <QQmlContext>
#include "LauncherWindow.h"
#include "LauncherState.h"
Launcher::Launcher(int& argc, char**argv) : QGuiApplication(argc, argv) {
QString resourceBinaryLocation = QGuiApplication::applicationDirPath() + "/resources.rcc";
QResource::registerResource(resourceBinaryLocation);
_launcherState = std::make_shared<LauncherState>();
_launcherWindow = std::make_unique<LauncherWindow>();
_launcherWindow->rootContext()->setContextProperty("LauncherState", _launcherState.get());
_launcherWindow->setFlags(Qt::FramelessWindowHint);
LauncherState::declareQML();
_launcherWindow->setSource(QUrl("qrc:/qml/root.qml"));
_launcherWindow->setResizeMode(QQuickView::SizeRootObjectToView);
_launcherWindow->show();
}
Launcher::~Launcher() {

View file

@ -1,7 +1,15 @@
#include <memory>
#include <QGuiApplication>
class LauncherWindow;
class LauncherState;
class Launcher : public QGuiApplication {
public:
Launcher(int& argc, char** argv);
~Launcher();
private:
std::unique_ptr<LauncherWindow> _launcherWindow;
std::shared_ptr<LauncherState> _launcherState;
};

View file

@ -0,0 +1,33 @@
#include "LauncherState.h"
#include <array>
#include <QQmlEngine>
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",
"qrc:/qml/Download.qml", "qrc:/qml/DownloadFinshed.qml", "qrc:/qml/Error.qml" } };
QString LauncherState::getCurrentUISource() const {
return QML_FILE_FOR_UI_STATE[getUIState()];
}
void LauncherState::declareQML() {
qmlRegisterType<LauncherState>("HQLauncher", 1, 0, "LauncherStateEnums");
}
void LauncherState::setUIState(UIState state) {
_uiState = state;
}
LauncherState::UIState LauncherState::getUIState() const {
return _uiState;
}
void LauncherState::setLastLoginError(LastLoginError lastLoginError) {
_lastLoginError = lastLoginError;
}
LauncherState::LastLoginError LauncherState::getLastLoginError() const {
return _lastLoginError;
}

View file

@ -0,0 +1,45 @@
#include <QObject>
#include <QString>
class LauncherState : public QObject {
Q_OBJECT
public:
LauncherState() = default;
~LauncherState() = default;
enum UIState {
SPLASH_SCREEN = 0,
LOGIN_SCREEN,
DISPLAY_NAME_SCREEN,
DOWNLOAD_SCREEN,
DOWNLOAD_FINSISHED,
ERROR_SCREEN,
UI_STATE_NUM
};
Q_ENUMS(UIState);
enum LastLoginError {
NONE = 0,
ORGINIZATION,
CREDENTIALS,
LAST_ERROR_NUM
};
Q_ENUMS(LastLoginError);
Q_INVOKABLE QString getCurrentUISource() const;
static void declareQML();
void setUIState(UIState state);
UIState getUIState() const;
void setLastLoginError(LastLoginError lastLoginError);
LastLoginError getLastLoginError() const;
signals:
void updateSourceUrl(QString sourceUrl);
private:
UIState _uiState { SPLASH_SCREEN };
LastLoginError _lastLoginError { NONE };
};

View file

@ -5,27 +5,27 @@
void LauncherWindow::keyPressEvent(QKeyEvent* event) {
QQuickView::keyPressEvent(event);
if (!event->isAccepted()) {
std::cout << "Key press event\n";
// std::cout << "Key press event\n";
}
}
void LauncherWindow::mousePressEvent(QMouseEvent* event) {
QQuickView::mousePressEvent(event);
if (!event->isAccepted()) {
std::cout << "mouse press event\n";
//std::cout << "mouse press event\n";
}
}
void LauncherWindow::mouseReleaseEvent(QMouseEvent* event) {
QQuickView::mouseReleaseEvent(event);
if (!event->isAccepted()) {
std::cout << "mouse release event\n";
//std::cout << "mouse release event\n";
}
}
void LauncherWindow::mouseMoveEvent(QMouseEvent* event) {
QQuickView::mouseMoveEvent(event);
if (!event->isAccepted()) {
std::cout << "mouse move event\n";
// std::cout << "mouse move event\n";
}
}

View file

@ -1,9 +1,4 @@
#include <iostream>
#include <QString>
#include <QtPlugin>
#include <QResource>
#include <QFileInfo>
#include "LauncherWindow.h"
#include "Launcher.h"
@ -19,17 +14,5 @@ int main(int argc, char *argv[])
QCoreApplication::setOrganizationName(name);
Launcher launcher(argc, argv);
QString resourceBinaryLocation = QGuiApplication::applicationDirPath() + "/resources.rcc";
QResource::registerResource(resourceBinaryLocation);
LauncherWindow launcherWindow;
launcherWindow.setFlags(Qt::FramelessWindowHint);
launcherWindow.setSource(QUrl("qrc:/qml/root.qml"));
if (launcherWindow.status() == QQuickView::Error) {
return -1;
}
launcherWindow.setResizeMode(QQuickView::SizeRootObjectToView);
launcherWindow.show();
return launcher.exec();
}