do not recompile qml

This commit is contained in:
dante ruiz 2019-09-13 15:04:28 -07:00
parent 97460c27cf
commit 7538e100f8
9 changed files with 51 additions and 13 deletions

View file

@ -62,7 +62,6 @@ if (WIN32)
endif () endif ()
if (APPLE) if (APPLE)
ExternalProject_Add( ExternalProject_Add(
qtlite qtlite
@ -126,7 +125,9 @@ set(src_files
src/LauncherState.h src/LauncherState.h
src/LauncherState.cpp src/LauncherState.cpp
src/LauncherWindow.h src/LauncherWindow.h
src/LauncherWindow.cpp) src/LauncherWindow.cpp
src/PathUtils.cpp
src/PathUtils.h)
set(TARGET_NAME ${PROJECT_NAME}) set(TARGET_NAME ${PROJECT_NAME})
@ -195,6 +196,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

@ -11,7 +11,7 @@ Item {
width: parent.width width: parent.width
height: parent.height height: parent.height
mirror: true mirror: true
source: "qrc:/images/hifi_window@2x.png" source: PathUtils.resourcePath("images/hifi_window@2x.png");
transformOrigin: Item.Center transformOrigin: Item.Center
rotation: 0 rotation: 0
} }
@ -21,7 +21,7 @@ Item {
id: logo id: logo
width: 132 width: 132
height: 134 height: 134
source: "qrc:/images/HiFi_Voxel.png" source: PathUtils.resourcePath("images/HiFi_Voxel.png");
anchors { anchors {
top: root.top top: root.top

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

@ -6,17 +6,19 @@
#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";
QResource::registerResource(resourceBinaryLocation); QResource::registerResource(resourceBinaryLocation);
_launcherState = std::make_shared<LauncherState>(); _launcherState = std::make_shared<LauncherState>();
_launcherState->setUIState(LauncherState::DOWNLOAD_FINSISHED); _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,5 +1,6 @@
#include "LauncherState.h" #include "LauncherState.h"
#include "PathUtils.h"
#include <array> #include <array>
#include <QNetworkRequest> #include <QNetworkRequest>
@ -14,8 +15,8 @@
#include <QQmlEngine> #include <QQmlEngine>
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/HFBase/CreateAccountBase.qml", "qrc:/qml/DisplayName.qml", { { "SplashScreen.qml", "HFBase/CreateAccountBase.qml", "DisplayName.qml",
"qrc:/qml/Download.qml", "qrc:/qml/DownloadFinished.qml", "qrc:/qml/HFBase/Error.qml" } }; "Download.qml", "DownloadFinished.qml", "HFBase/Error.qml" } };
LauncherState::LauncherState() { LauncherState::LauncherState() {
// TODO Show splash screen until this request is complete // TODO Show splash screen until this request is complete
@ -75,7 +76,7 @@ void LauncherState::declareQML() {
void LauncherState::setUIState(UIState state) { void LauncherState::setUIState(UIState state) {
_uiState = state; _uiState = state;
emit updateSourceUrl(getCurrentUISource()); emit updateSourceUrl(PathUtils::resourcePath(getCurrentUISource()));
} }
LauncherState::UIState LauncherState::getUIState() const { LauncherState::UIState LauncherState::getUIState() const {

View file

@ -1,5 +1,6 @@
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include <QUrl>
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
struct Build { struct Build {

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

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