diff --git a/launchers/qt/CMakeLists.txt b/launchers/qt/CMakeLists.txt index 05b89c27f1..d95ff79aa8 100644 --- a/launchers/qt/CMakeLists.txt +++ b/launchers/qt/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 3.11) project(HQLauncher) set(CMAKE_CXX_STANDARD_REQUIRED_ON) +include("cmake/init.cmake") find_package(Qt5 COMPONENTS Core Gui Qml Quick QuickControls2 Network REQUIRED) find_package(OpenGL) set(CMAKE_AUTOMOC ON) @@ -8,16 +9,26 @@ set(CMAKE_AUTORCC ON) #set(CMAKE_AUTOUIC ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) +set(CUSTOM_LAUNCHER_QRC_PATHS "") +set(RESOURCES_QRC ${CMAKE_CURRENT_BINARY_DIR}/resources.qrc) +set(RESOURCES_RCC ${CMAKE_CURRENT_SOURCE_DIR}/resources.rcc) +generate_qrc(OUTPUT ${RESOURCES_QRC} PATH ${CMAKE_CURRENT_SOURCE_DIR}/resources CUSTOM_PATHS ${CUSTOM_LAUNCHER_QRC_PATHS} GLOBS *) + +add_custom_command( + OUTPUT ${RESOURCES_RCC} + DEPENDS ${RESOURCES_QRC} ${GENERATE_QRC_DEPENDS} + COMMAND "${_qt5Core_install_prefix}/bin/rcc" + ARGS ${RESOURCES_QRC} -binary -o ${RESOURCES_RCC}) + +list(APPEND GENERATE_QRC_DEPENDS ${RESOURCES_RCC}) +add_custom_target(resources ALL DEPENDS ${GENERATE_QRC_DEPENDS}) + foreach(plugin ${Qt5Gui_PLUGINS}) get_target_property(_loc ${plugin} LOCATION) message("Plugin ${plugin} is at location ${_loc}") set(plugin_libs ${plugin_libs} ${_loc}) endforeach() -foreach(qt_lib_name ${Qt_LIBRARIES}) - message("lib ${qt_lib_name} is at location") -endforeach() - set(src_files src/main.cpp) @@ -54,3 +65,11 @@ target_include_directories(${PROJECT_NAME} PUBLIC ${Qt5Quick_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Qml_INCLUDE_DIRS}) + + +set(INTERFACE_EXEC_DIR "$") +set(RESOURCES_DEV_DIR "${INTERFACE_EXEC_DIR}/resources") +add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E copy_if_different + "${RESOURCES_RCC}" + "${INTERFACE_EXEC_DIR}") diff --git a/launchers/qt/cmake/init.cmake b/launchers/qt/cmake/init.cmake new file mode 100644 index 0000000000..5b88c933a0 --- /dev/null +++ b/launchers/qt/cmake/init.cmake @@ -0,0 +1,14 @@ + +# Hide automoc folders (for IDEs) +set(AUTOGEN_TARGETS_FOLDER "hidden/generated") +# Find includes in corresponding build directories +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +# CMAKE_CURRENT_SOURCE_DIR is the parent folder here +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/") + +file(GLOB LAUNCHER_CUSTOM_MACROS "cmake/macros/*.cmake") +foreach(CUSTOM_MACRO ${LAUNCHER_CUSTOM_MACROS}) + include(${CUSTOM_MACRO}) +endforeach() +unset(LAUNCHER_CUSTOM_MACROS) diff --git a/launchers/qt/cmake/macros/GenerateQrc.cmake b/launchers/qt/cmake/macros/GenerateQrc.cmake new file mode 100644 index 0000000000..95a075916f --- /dev/null +++ b/launchers/qt/cmake/macros/GenerateQrc.cmake @@ -0,0 +1,31 @@ +function(GENERATE_QRC) + set(oneValueArgs OUTPUT PREFIX PATH) + set(multiValueArgs CUSTOM_PATHS 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}) + if (${FILENAME} MATCHES "^\\.\\.") + continue() + endif() + list(APPEND ALL_FILES "${GENERATE_QRC_PATH}/${FILENAME}") + set(QRC_CONTENTS "${QRC_CONTENTS}${GENERATE_QRC_PATH}/${FILENAME}\n") + endforeach() + endforeach() + + foreach(CUSTOM_PATH ${GENERATE_QRC_CUSTOM_PATHS}) + string(REPLACE "=" ";" CUSTOM_PATH ${CUSTOM_PATH}) + list(GET CUSTOM_PATH 0 IMPORT_PATH) + list(GET CUSTOM_PATH 1 LOCAL_PATH) + set(QRC_CONTENTS "${QRC_CONTENTS}${IMPORT_PATH}\n") + endforeach() + + set(GENERATE_QRC_DEPENDS ${ALL_FILES} PARENT_SCOPE) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/resources.qrc.in" ${GENERATE_QRC_OUTPUT}) +endfunction() diff --git a/launchers/qt/cmake/templates/resources.qrc.in b/launchers/qt/cmake/templates/resources.qrc.in new file mode 100644 index 0000000000..6466b9ec51 --- /dev/null +++ b/launchers/qt/cmake/templates/resources.qrc.in @@ -0,0 +1,5 @@ + + +@QRC_CONTENTS@ + + diff --git a/launchers/darwin/images/HiFi_Voxel.png b/launchers/qt/resources/images/HiFi_Voxel.png similarity index 100% rename from launchers/darwin/images/HiFi_Voxel.png rename to launchers/qt/resources/images/HiFi_Voxel.png diff --git a/launchers/darwin/images/HiFi_Window.png b/launchers/qt/resources/images/HiFi_Window.png similarity index 100% rename from launchers/darwin/images/HiFi_Window.png rename to launchers/qt/resources/images/HiFi_Window.png diff --git a/launchers/darwin/images/hifi_logo_large@2x.png b/launchers/qt/resources/images/hifi_logo_large@2x.png similarity index 100% rename from launchers/darwin/images/hifi_logo_large@2x.png rename to launchers/qt/resources/images/hifi_logo_large@2x.png diff --git a/launchers/darwin/images/hifi_logo_small@2x.png b/launchers/qt/resources/images/hifi_logo_small@2x.png similarity index 100% rename from launchers/darwin/images/hifi_logo_small@2x.png rename to launchers/qt/resources/images/hifi_logo_small@2x.png diff --git a/launchers/darwin/images/hifi_window@2x.png b/launchers/qt/resources/images/hifi_window@2x.png similarity index 100% rename from launchers/darwin/images/hifi_window@2x.png rename to launchers/qt/resources/images/hifi_window@2x.png diff --git a/launchers/darwin/images/interface.icns b/launchers/qt/resources/images/interface.icns similarity index 100% rename from launchers/darwin/images/interface.icns rename to launchers/qt/resources/images/interface.icns diff --git a/launchers/qt/resources/qml/root.qml b/launchers/qt/resources/qml/root.qml new file mode 100644 index 0000000000..1b0ab8123d --- /dev/null +++ b/launchers/qt/resources/qml/root.qml @@ -0,0 +1,89 @@ +// root.qml + +import QtQuick 2.3 +import QtQuick.Controls 2.1 +Image { + id: root + width: 515 + 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" + } + + TextField { + id: textField + background: Rectangle { + color: "#00000000" + } + anchors { + left: root.left + leftMargin: 40 + top: text.bottom + topMargin: 20 + } + echoMode: TextInput.Password + placeholderText: "Organization" + } + + Rectangle { + id: seperator + anchors { + left: textField.left + right: textField.right + top: textField.bottom + topMargin: 1 + } + + height: 1 + color: "#FFFFFF" + } + + + Button { + anchors { + left: root.left + leftMargin: 40 + top: textField.bottom + topMargin: 20 + } + id: button + text: "NEXT" + background: Rectangle { + implicitWidth: 100 + implicitHeight: 40 + color: "#00000000" + opacity: 1 + border.color: "#FFFFFF" + border.width: 4 + radius: 2 + } + } + + + 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 + } + } +} diff --git a/launchers/qt/src/main.cpp b/launchers/qt/src/main.cpp index 9d0afc98a9..947ee242c6 100644 --- a/launchers/qt/src/main.cpp +++ b/launchers/qt/src/main.cpp @@ -3,6 +3,8 @@ #include #include #include +#include +#include //Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin); Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin); Q_IMPORT_PLUGIN(QtQuick2Plugin); @@ -19,9 +21,12 @@ int main(int argc, char *argv[]) QGuiApplication app(argc, argv); + QString resourceBinaryLocation = QGuiApplication::applicationDirPath() + "/resources.rcc"; + QResource::registerResource(resourceBinaryLocation); + QQuickView view; view.setFlags(Qt::FramelessWindowHint); - //view.setSource(QUrl("/Users/danteruiz/github/test/qml/root.qml")); + view.setSource(QUrl("qrc:/qml/root.qml")); if (view.status() == QQuickView::Error) return -1; view.setResizeMode(QQuickView::SizeRootObjectToView);