mirror of
https://github.com/overte-org/overte.git
synced 2025-08-12 10:34:16 +02:00
working on ui pages
This commit is contained in:
parent
1689096967
commit
476b7605d5
9 changed files with 132 additions and 73 deletions
|
@ -33,6 +33,8 @@ set(src_files
|
||||||
src/main.cpp
|
src/main.cpp
|
||||||
src/Launcher.h
|
src/Launcher.h
|
||||||
src/Launcher.cpp
|
src/Launcher.cpp
|
||||||
|
src/LauncherState.h
|
||||||
|
src/LauncherState.cpp
|
||||||
src/LauncherWindow.h
|
src/LauncherWindow.h
|
||||||
src/LauncherWindow.cpp)
|
src/LauncherWindow.cpp)
|
||||||
|
|
||||||
|
|
13
launchers/qt/resources/qml/SplashScreen.qml
Normal file
13
launchers/qt/resources/qml/SplashScreen.qml
Normal 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"
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import QtQuick 2.3
|
import QtQuick 2.3
|
||||||
import QtQuick.Controls 2.1
|
import QtQuick.Controls 2.1
|
||||||
|
import HQLauncher 1.0
|
||||||
import "HFControls"
|
import "HFControls"
|
||||||
Image {
|
Image {
|
||||||
id: root
|
id: root
|
||||||
|
@ -9,59 +10,16 @@ Image {
|
||||||
height: 450
|
height: 450
|
||||||
source: "../images/hifi_window@2x.png"
|
source: "../images/hifi_window@2x.png"
|
||||||
|
|
||||||
Text {
|
Loader {
|
||||||
id: text
|
anchors.centerIn: parent
|
||||||
width: 325
|
anchors.fill: parent
|
||||||
height: 26
|
id: loader
|
||||||
anchors {
|
|
||||||
left: root.left
|
|
||||||
leftMargin: 95
|
|
||||||
top: root.top
|
|
||||||
topMargin: 29
|
|
||||||
}
|
|
||||||
text: "Please log in"
|
|
||||||
font.pointSize: 24
|
|
||||||
color: "#FFFFFF"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HFTextField {
|
Component.onCompleted: {
|
||||||
id: textField
|
loader.source = LauncherState.getCurrentUISource();
|
||||||
width: 150
|
LauncherState.updateSourceUrl.connect(function(url) {
|
||||||
height: 50
|
loader.source = url;
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,23 @@
|
||||||
#include "Launcher.h"
|
#include "Launcher.h"
|
||||||
|
|
||||||
|
#include <QResource>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QQmlContext>
|
||||||
|
|
||||||
|
#include "LauncherWindow.h"
|
||||||
|
#include "LauncherState.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";
|
||||||
|
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() {
|
Launcher::~Launcher() {
|
||||||
|
|
|
@ -1,7 +1,15 @@
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
|
|
||||||
|
class LauncherWindow;
|
||||||
|
class LauncherState;
|
||||||
class Launcher : public QGuiApplication {
|
class Launcher : public QGuiApplication {
|
||||||
public:
|
public:
|
||||||
Launcher(int& argc, char** argv);
|
Launcher(int& argc, char** argv);
|
||||||
~Launcher();
|
~Launcher();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::unique_ptr<LauncherWindow> _launcherWindow;
|
||||||
|
std::shared_ptr<LauncherState> _launcherState;
|
||||||
};
|
};
|
||||||
|
|
33
launchers/qt/src/LauncherState.cpp
Normal file
33
launchers/qt/src/LauncherState.cpp
Normal 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;
|
||||||
|
}
|
45
launchers/qt/src/LauncherState.h
Normal file
45
launchers/qt/src/LauncherState.h
Normal 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 };
|
||||||
|
};
|
|
@ -5,27 +5,27 @@
|
||||||
void LauncherWindow::keyPressEvent(QKeyEvent* event) {
|
void LauncherWindow::keyPressEvent(QKeyEvent* event) {
|
||||||
QQuickView::keyPressEvent(event);
|
QQuickView::keyPressEvent(event);
|
||||||
if (!event->isAccepted()) {
|
if (!event->isAccepted()) {
|
||||||
std::cout << "Key press event\n";
|
// std::cout << "Key press event\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherWindow::mousePressEvent(QMouseEvent* event) {
|
void LauncherWindow::mousePressEvent(QMouseEvent* event) {
|
||||||
QQuickView::mousePressEvent(event);
|
QQuickView::mousePressEvent(event);
|
||||||
if (!event->isAccepted()) {
|
if (!event->isAccepted()) {
|
||||||
std::cout << "mouse press event\n";
|
//std::cout << "mouse press event\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherWindow::mouseReleaseEvent(QMouseEvent* event) {
|
void LauncherWindow::mouseReleaseEvent(QMouseEvent* event) {
|
||||||
QQuickView::mouseReleaseEvent(event);
|
QQuickView::mouseReleaseEvent(event);
|
||||||
if (!event->isAccepted()) {
|
if (!event->isAccepted()) {
|
||||||
std::cout << "mouse release event\n";
|
//std::cout << "mouse release event\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherWindow::mouseMoveEvent(QMouseEvent* event) {
|
void LauncherWindow::mouseMoveEvent(QMouseEvent* event) {
|
||||||
QQuickView::mouseMoveEvent(event);
|
QQuickView::mouseMoveEvent(event);
|
||||||
if (!event->isAccepted()) {
|
if (!event->isAccepted()) {
|
||||||
std::cout << "mouse move event\n";
|
// std::cout << "mouse move event\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,4 @@
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
#include <QtPlugin>
|
#include <QtPlugin>
|
||||||
#include <QResource>
|
|
||||||
#include <QFileInfo>
|
|
||||||
|
|
||||||
#include "LauncherWindow.h"
|
#include "LauncherWindow.h"
|
||||||
#include "Launcher.h"
|
#include "Launcher.h"
|
||||||
|
@ -19,17 +14,5 @@ int main(int argc, char *argv[])
|
||||||
QCoreApplication::setOrganizationName(name);
|
QCoreApplication::setOrganizationName(name);
|
||||||
|
|
||||||
Launcher launcher(argc, argv);
|
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();
|
return launcher.exec();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue