mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-05-29 13:19:55 +02:00
Merge pull request #11588 from jherico/future/qrc
Package all UI resources into a QRC built into the application.
This commit is contained in:
commit
aa6c841357
4 changed files with 43 additions and 6 deletions
20
cmake/macros/GenerateQrc.cmake
Normal file
20
cmake/macros/GenerateQrc.cmake
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
function(GENERATE_QRC)
|
||||||
|
set(oneValueArgs OUTPUT PREFIX PATH)
|
||||||
|
set(multiValueArgs GLOBS)
|
||||||
|
cmake_parse_arguments(GENERATE_QRC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
|
||||||
|
if ("${GENERATE_QRC_PREFIX}" STREQUAL "")
|
||||||
|
set(QRC_PREFIX_PATH /)
|
||||||
|
else()
|
||||||
|
set(QRC_PREFIX_PATH ${GENERATE_QRC_PREFIX})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
foreach(GLOB ${GENERATE_QRC_GLOBS})
|
||||||
|
file(GLOB_RECURSE FOUND_FILES RELATIVE ${GENERATE_QRC_PATH} ${GLOB})
|
||||||
|
foreach(FILENAME ${FOUND_FILES})
|
||||||
|
set(QRC_CONTENTS "${QRC_CONTENTS}<file alias=\"${FILENAME}\">${GENERATE_QRC_PATH}/${FILENAME}</file>\n")
|
||||||
|
endforeach()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
configure_file("${HF_CMAKE_DIR}/templates/resources.qrc.in" ${GENERATE_QRC_OUTPUT})
|
||||||
|
endfunction()
|
5
cmake/templates/resources.qrc.in
Normal file
5
cmake/templates/resources.qrc.in
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<!DOCTYPE RCC><RCC version="1.0">
|
||||||
|
<qresource prefix="@QRC_PREFIX_PATH@">
|
||||||
|
@QRC_CONTENTS@
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
|
@ -1,6 +1,20 @@
|
||||||
set(TARGET_NAME interface)
|
set(TARGET_NAME interface)
|
||||||
project(${TARGET_NAME})
|
project(${TARGET_NAME})
|
||||||
|
|
||||||
|
file(GLOB_RECURSE QML_SRC resources/qml/*.qml resources/qml/*.js)
|
||||||
|
add_custom_target(qml SOURCES ${QML_SRC})
|
||||||
|
GroupSources("resources/qml")
|
||||||
|
|
||||||
|
function(JOIN VALUES GLUE OUTPUT)
|
||||||
|
string (REGEX REPLACE "([^\\]|^);" "\\1${GLUE}" _TMP_STR "${VALUES}")
|
||||||
|
string (REGEX REPLACE "[\\](.)" "\\1" _TMP_STR "${_TMP_STR}") #fixes escaping
|
||||||
|
set (${OUTPUT} "${_TMP_STR}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
|
set(INTERFACE_QML_QRC ${CMAKE_CURRENT_BINARY_DIR}/qml.qrc)
|
||||||
|
generate_qrc(OUTPUT ${INTERFACE_QML_QRC} PATH ${CMAKE_CURRENT_SOURCE_DIR}/resources GLOBS *.qml *.qss *.js *.html *.ttf *.gif *.svg *.png *.jpg)
|
||||||
|
|
||||||
# set a default root dir for each of our optional externals if it was not passed
|
# set a default root dir for each of our optional externals if it was not passed
|
||||||
set(OPTIONAL_EXTERNALS "LeapMotion")
|
set(OPTIONAL_EXTERNALS "LeapMotion")
|
||||||
|
|
||||||
|
@ -66,9 +80,7 @@ qt5_wrap_ui(QT_UI_HEADERS "${QT_UI_FILES}")
|
||||||
# add them to the interface source files
|
# add them to the interface source files
|
||||||
set(INTERFACE_SRCS ${INTERFACE_SRCS} "${QT_UI_HEADERS}" "${QT_RESOURCES}")
|
set(INTERFACE_SRCS ${INTERFACE_SRCS} "${QT_UI_HEADERS}" "${QT_RESOURCES}")
|
||||||
|
|
||||||
file(GLOB_RECURSE QML_SRC resources/qml/*.qml resources/qml/*.js)
|
list(APPEND INTERFACE_SRCS ${INTERFACE_QML_QRC})
|
||||||
add_custom_target(qml SOURCES ${QML_SRC})
|
|
||||||
GroupSources("resources/qml")
|
|
||||||
|
|
||||||
if (UNIX)
|
if (UNIX)
|
||||||
install(
|
install(
|
||||||
|
@ -131,10 +143,10 @@ if (APPLE)
|
||||||
|
|
||||||
# append the discovered resources to our list of interface sources
|
# append the discovered resources to our list of interface sources
|
||||||
list(APPEND INTERFACE_SRCS ${DISCOVERED_RESOURCES})
|
list(APPEND INTERFACE_SRCS ${DISCOVERED_RESOURCES})
|
||||||
|
list(APPEND INTERFACE_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/icon/${INTERFACE_ICON_FILENAME})
|
||||||
set(INTERFACE_SRCS ${INTERFACE_SRCS} "${CMAKE_CURRENT_SOURCE_DIR}/icon/${INTERFACE_ICON_FILENAME}")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
# create the executable, make it a bundle on OS X
|
# create the executable, make it a bundle on OS X
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
add_executable(${TARGET_NAME} MACOSX_BUNDLE ${INTERFACE_SRCS} ${QM})
|
add_executable(${TARGET_NAME} MACOSX_BUNDLE ${INTERFACE_SRCS} ${QM})
|
||||||
|
|
|
@ -2255,7 +2255,7 @@ void Application::initializeUi() {
|
||||||
offscreenUi->setBaseUrl(QUrl::fromLocalFile(PathUtils::resourcesPath() + "/qml/"));
|
offscreenUi->setBaseUrl(QUrl::fromLocalFile(PathUtils::resourcesPath() + "/qml/"));
|
||||||
// OffscreenUi is a subclass of OffscreenQmlSurface specifically designed to
|
// OffscreenUi is a subclass of OffscreenQmlSurface specifically designed to
|
||||||
// support the window management and scripting proxies for VR use
|
// support the window management and scripting proxies for VR use
|
||||||
offscreenUi->createDesktop(QString("hifi/Desktop.qml"));
|
offscreenUi->createDesktop(QString("qrc:///qml/hifi/Desktop.qml"));
|
||||||
|
|
||||||
// FIXME either expose so that dialogs can set this themselves or
|
// FIXME either expose so that dialogs can set this themselves or
|
||||||
// do better detection in the offscreen UI of what has focus
|
// do better detection in the offscreen UI of what has focus
|
||||||
|
|
Loading…
Reference in a new issue