mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-07 07:02:46 +02:00
do not recompile qml
This commit is contained in:
parent
97460c27cf
commit
7538e100f8
9 changed files with 51 additions and 13 deletions
|
@ -62,7 +62,6 @@ if (WIN32)
|
|||
|
||||
endif ()
|
||||
|
||||
|
||||
if (APPLE)
|
||||
ExternalProject_Add(
|
||||
qtlite
|
||||
|
@ -126,7 +125,9 @@ set(src_files
|
|||
src/LauncherState.h
|
||||
src/LauncherState.cpp
|
||||
src/LauncherWindow.h
|
||||
src/LauncherWindow.cpp)
|
||||
src/LauncherWindow.cpp
|
||||
src/PathUtils.cpp
|
||||
src/PathUtils.h)
|
||||
|
||||
set(TARGET_NAME ${PROJECT_NAME})
|
||||
|
||||
|
@ -195,6 +196,13 @@ add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
|
|||
"${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)
|
||||
install(
|
||||
|
|
|
@ -11,7 +11,7 @@ Item {
|
|||
width: parent.width
|
||||
height: parent.height
|
||||
mirror: true
|
||||
source: "qrc:/images/hifi_window@2x.png"
|
||||
source: PathUtils.resourcePath("images/hifi_window@2x.png");
|
||||
transformOrigin: Item.Center
|
||||
rotation: 0
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ Item {
|
|||
id: logo
|
||||
width: 132
|
||||
height: 134
|
||||
source: "qrc:/images/HiFi_Voxel.png"
|
||||
source: PathUtils.resourcePath("images/HiFi_Voxel.png");
|
||||
|
||||
anchors {
|
||||
top: root.top
|
||||
|
|
|
@ -4,10 +4,21 @@ import QtQuick.Controls 2.1
|
|||
Item {
|
||||
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 {
|
||||
anchors.centerIn: parent
|
||||
width: 225
|
||||
height: 205
|
||||
source: "../images/hifi_logo_large@2x.png"
|
||||
source: PathUtils.resourcePath("images/hifi_logo_large@2x.png");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,17 +6,19 @@
|
|||
|
||||
#include "LauncherWindow.h"
|
||||
#include "LauncherState.h"
|
||||
#include "PathUtils.h"
|
||||
|
||||
Launcher::Launcher(int& argc, char**argv) : QGuiApplication(argc, argv) {
|
||||
QString resourceBinaryLocation = QGuiApplication::applicationDirPath() + "/resources.rcc";
|
||||
QResource::registerResource(resourceBinaryLocation);
|
||||
_launcherState = std::make_shared<LauncherState>();
|
||||
_launcherState->setUIState(LauncherState::DOWNLOAD_FINSISHED);
|
||||
_launcherState->setUIState(LauncherState::SPLASH_SCREEN);
|
||||
_launcherWindow = std::make_unique<LauncherWindow>();
|
||||
_launcherWindow->rootContext()->setContextProperty("LauncherState", _launcherState.get());
|
||||
_launcherWindow->rootContext()->setContextProperty("PathUtils", new PathUtils());
|
||||
_launcherWindow->setFlags(Qt::FramelessWindowHint);
|
||||
LauncherState::declareQML();
|
||||
_launcherWindow->setSource(QUrl("qrc:/qml/root.qml"));
|
||||
_launcherWindow->setSource(QUrl(PathUtils::resourcePath("qml/root.qml")));
|
||||
_launcherWindow->setResizeMode(QQuickView::SizeRootObjectToView);
|
||||
_launcherWindow->show();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "LauncherState.h"
|
||||
|
||||
#include "PathUtils.h"
|
||||
#include <array>
|
||||
|
||||
#include <QNetworkRequest>
|
||||
|
@ -14,8 +15,8 @@
|
|||
#include <QQmlEngine>
|
||||
|
||||
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",
|
||||
"qrc:/qml/Download.qml", "qrc:/qml/DownloadFinished.qml", "qrc:/qml/HFBase/Error.qml" } };
|
||||
{ { "SplashScreen.qml", "HFBase/CreateAccountBase.qml", "DisplayName.qml",
|
||||
"Download.qml", "DownloadFinished.qml", "HFBase/Error.qml" } };
|
||||
|
||||
LauncherState::LauncherState() {
|
||||
// TODO Show splash screen until this request is complete
|
||||
|
@ -75,7 +76,7 @@ void LauncherState::declareQML() {
|
|||
|
||||
void LauncherState::setUIState(UIState state) {
|
||||
_uiState = state;
|
||||
emit updateSourceUrl(getCurrentUISource());
|
||||
emit updateSourceUrl(PathUtils::resourcePath(getCurrentUISource()));
|
||||
}
|
||||
|
||||
LauncherState::UIState LauncherState::getUIState() const {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
#include <QNetworkAccessManager>
|
||||
|
||||
struct Build {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <QQuickView>
|
||||
#include <QPoint>
|
||||
#include <memory>
|
||||
|
||||
class LauncherWindow : public QQuickView {
|
||||
public:
|
||||
|
@ -7,8 +8,10 @@ public:
|
|||
void mousePressEvent(QMouseEvent* event) override;
|
||||
void mouseReleaseEvent(QMouseEvent* event) override;
|
||||
void mouseMoveEvent(QMouseEvent* event) override;
|
||||
|
||||
//void setLauncherState(std::shared_ptr<LauncherState> launcherState) { _launcherState = launcherState; }
|
||||
private:
|
||||
bool _drag { false };
|
||||
QPoint _previousMousePos;
|
||||
|
||||
///std::shared_ptr<LauncherState> _launcherState { nullptr };
|
||||
};
|
||||
|
|
7
launchers/qt/src/PathUtils.cpp
Normal file
7
launchers/qt/src/PathUtils.cpp
Normal file
|
@ -0,0 +1,7 @@
|
|||
#include "PathUtils.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
QString PathUtils::resourcePath(const QString& source) {
|
||||
return QString(RESOURCE_PREFIX_URL + source);
|
||||
}
|
|
@ -1,6 +1,11 @@
|
|||
#pragma once
|
||||
|
||||
class PathUtils {
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
class PathUtils : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
static resourcePath();
|
||||
PathUtils() = default;
|
||||
~PathUtils() = default;
|
||||
Q_INVOKABLE static QString resourcePath(const QString& source);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue