diff --git a/.gitignore b/.gitignore index cebf9eb113..9dc509bc19 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ CMakeFiles/ CMakeScripts/ cmake_install.cmake build/ +Makefile # Xcode *.xcodeproj diff --git a/CMakeLists.txt b/CMakeLists.txt index 8af8081975..d803ff373e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,13 @@ cmake_minimum_required(VERSION 2.8) project(hifi) +set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} $ENV{QT_CMAKE_PREFIX_PATH}) + +# Find includes in corresponding build directories +set(CMAKE_INCLUDE_CURRENT_DIR ON) +# Instruct CMake to run moc automatically when needed. +set(CMAKE_AUTOMOC ON) + add_subdirectory(animation-server) add_subdirectory(avatar-mixer) add_subdirectory(audio-mixer) diff --git a/cmake/macros/SetupHifiLibrary.cmake b/cmake/macros/SetupHifiLibrary.cmake index b7d0af7499..79bf16e1a0 100644 --- a/cmake/macros/SetupHifiLibrary.cmake +++ b/cmake/macros/SetupHifiLibrary.cmake @@ -3,13 +3,13 @@ MACRO(SETUP_HIFI_LIBRARY TARGET) # grab the implemenation and header files file(GLOB LIB_SRCS src/*.h src/*.cpp) + set(LIB_SRCS ${LIB_SRCS} ${WRAPPED_SRCS}) # create a library and set the property so it can be referenced later add_library(${TARGET} ${LIB_SRCS}) - find_package(Qt4 REQUIRED QtCore) - include(${QT_USE_FILE}) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${QT_QTGUI_INCLUDE_DIR}") + find_package(Qt5Core REQUIRED) + qt5_use_modules(${TARGET} Core) target_link_libraries(${TARGET} ${QT_LIBRARIES}) ENDMACRO(SETUP_HIFI_LIBRARY _target) \ No newline at end of file diff --git a/cmake/macros/SetupHifiProject.cmake b/cmake/macros/SetupHifiProject.cmake index 8360dc66b6..455ca89701 100644 --- a/cmake/macros/SetupHifiProject.cmake +++ b/cmake/macros/SetupHifiProject.cmake @@ -8,9 +8,8 @@ MACRO(SETUP_HIFI_PROJECT TARGET INCLUDE_QT) add_executable(${TARGET} ${TARGET_SRCS}) IF (${INCLUDE_QT}) - find_package(Qt4 REQUIRED QtCore) - include(${QT_USE_FILE}) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${QT_QTGUI_INCLUDE_DIR}") + find_package(Qt5Core REQUIRED) + qt5_use_modules(${TARGET} Core) ENDIF() target_link_libraries(${TARGET} ${QT_LIBRARIES}) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index ae87d53939..e5a2880cfd 100755 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -67,21 +67,22 @@ if (APPLE) endif (APPLE) -find_package(Qt4 REQUIRED QtCore QtGui QtNetwork QtOpenGL QtWebKit QtSvg) -include(${QT_USE_FILE}) -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${QT_QTGUI_INCLUDE_DIR}") +find_package(Qt5Core REQUIRED) +find_package(Qt5Gui REQUIRED) +find_package(Qt5Network REQUIRED) +find_package(Qt5OpenGL REQUIRED) +find_package(Qt5WebKit REQUIRED) +find_package(Qt5Svg REQUIRED) set(QUAZIP_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/quazip) add_subdirectory(external/fervor/) include_directories(external/fervor/) -# run qt moc on qt-enabled headers -qt4_wrap_cpp(INTERFACE_SRCS src/Application.h src/Webcam.h src/avatar/AvatarVoxelSystem.h - src/avatar/Face.h src/ui/BandwidthDialog.h src/ui/VoxelStatsDialog.h) - # create the executable, make it a bundle on OS X add_executable(${TARGET_NAME} MACOSX_BUNDLE ${INTERFACE_SRCS}) +qt5_use_modules(${TARGET_NAME} Core Gui Network OpenGL WebKit Svg) + # link in the hifi shared library include(${MACRO_DIR}/LinkHifiLibrary.cmake) diff --git a/interface/external/fervor/CMakeLists.txt b/interface/external/fervor/CMakeLists.txt index f257bb4431..62968d8833 100644 --- a/interface/external/fervor/CMakeLists.txt +++ b/interface/external/fervor/CMakeLists.txt @@ -1,21 +1,24 @@ cmake_minimum_required(VERSION 2.8) project(Fervor) -find_package(Qt4 REQUIRED) +find_package(Qt5Core REQUIRED) +find_package(Qt5Network REQUIRED) +find_package(Qt5Widgets REQUIRED) add_definitions(-DFV_GUI) file(GLOB FERVOR_SOURCES *.cpp) file(GLOB FERVOR_HEADERS *.h) +file(GLOB FERVOR_UI *.ui) + +qt5_wrap_ui(FERVOR_WRAPPED_UI ${FERVOR_UI}) + LIST(GET FERVOR_HEADERS 1 FIRST_HEADER) GET_FILENAME_COMPONENT(HEADER_PATH ${FIRST_HEADER} PATH) list(REMOVE_ITEM FERVOR_HEADERS ${HEADER_PATH}/fvversioncomparator.h) file(GLOB FERVOR_UI *.ui) -qt4_wrap_ui(FERVOR_WRAPPED_UI ${FERVOR_UI}) -qt4_wrap_cpp(FERVOR_MOC_SOURCES ${FERVOR_HEADERS}) - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules/") find_package(Quazip REQUIRED) @@ -25,4 +28,6 @@ include_directories( ) add_library(fervor ${FERVOR_SOURCES} ${FERVOR_HEADERS} ${FERVOR_MOC_SOURCES} ${FERVOR_WRAPPED_UI}) -target_link_libraries(fervor ${QUAZIP_LIBRARIES}) \ No newline at end of file +target_link_libraries(fervor ${QUAZIP_LIBRARIES}) + +qt5_use_modules(fervor Core Network Widgets) \ No newline at end of file diff --git a/interface/external/fervor/fvplatform.h b/interface/external/fervor/fvplatform.h index a527518097..a98f04a1ce 100755 --- a/interface/external/fervor/fvplatform.h +++ b/interface/external/fervor/fvplatform.h @@ -1,7 +1,7 @@ #ifndef FVPLATFORM_H #define FVPLATFORM_H -#include +#include class FvPlatform : public QObject { diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index f331ee9407..737dae8d0f 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -164,9 +164,9 @@ void GLCanvas::wheelEvent(QWheelEvent* event) { Application::getInstance()->wheelEvent(event); } -void messageHandler(QtMsgType type, const char* message) { - fprintf(stdout, "%s", message); - LogDisplay::instance.addMessage(message); +void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) { + fprintf(stdout, "%s", message.toLocal8Bit().constData()); + LogDisplay::instance.addMessage(message.toLocal8Bit().constData()); } Application::Application(int& argc, char** argv, timeval &startup_time) : @@ -222,7 +222,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : _applicationStartupTime = startup_time; _window->setWindowTitle("Interface"); - qInstallMsgHandler(messageHandler); + qInstallMessageHandler(messageHandler); unsigned int listenPort = 0; // bind to an ephemeral port by default const char** constArgv = const_cast(argv); @@ -1216,7 +1216,7 @@ void Application::editPreferences() { if (domainServerHostname->text().size() > 0) { // the user input a new hostname, use that - newHostname = domainServerHostname->text().toAscii(); + newHostname = domainServerHostname->text().toLocal8Bit(); } else { // the user left the field blank, use the default hostname newHostname = QByteArray(DEFAULT_DOMAIN_HOSTNAME); @@ -1512,12 +1512,12 @@ bool Application::sendVoxelsOperation(VoxelNode* node, void* extraData) { } void Application::exportVoxels() { - QString desktopLocation = QDesktopServices::storageLocation(QDesktopServices::DesktopLocation); + QString desktopLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); QString suggestedName = desktopLocation.append("/voxels.svo"); QString fileNameString = QFileDialog::getSaveFileName(_glWidget, tr("Export Voxels"), suggestedName, tr("Sparse Voxel Octree Files (*.svo)")); - QByteArray fileNameAscii = fileNameString.toAscii(); + QByteArray fileNameAscii = fileNameString.toLocal8Bit(); const char* fileName = fileNameAscii.data(); VoxelNode* selectedNode = _voxels.getVoxelAt(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s); if (selectedNode) { @@ -1532,11 +1532,11 @@ void Application::exportVoxels() { const char* IMPORT_FILE_TYPES = "Sparse Voxel Octree Files, Square PNG, Schematic Files (*.svo *.png *.schematic)"; void Application::importVoxelsToClipboard() { - QString desktopLocation = QDesktopServices::storageLocation(QDesktopServices::DesktopLocation); + QString desktopLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); QString fileNameString = QFileDialog::getOpenFileName(_glWidget, tr("Import Voxels to Clipboard"), desktopLocation, tr(IMPORT_FILE_TYPES)); - QByteArray fileNameAscii = fileNameString.toAscii(); + QByteArray fileNameAscii = fileNameString.toLocal8Bit(); const char* fileName = fileNameAscii.data(); _clipboardTree.eraseAllVoxels(); @@ -1566,11 +1566,11 @@ void Application::importVoxelsToClipboard() { } void Application::importVoxels() { - QString desktopLocation = QDesktopServices::storageLocation(QDesktopServices::DesktopLocation); + QString desktopLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); QString fileNameString = QFileDialog::getOpenFileName(_glWidget, tr("Import Voxels"), desktopLocation, tr(IMPORT_FILE_TYPES)); - QByteArray fileNameAscii = fileNameString.toAscii(); + QByteArray fileNameAscii = fileNameString.toLocal8Bit(); const char* fileName = fileNameAscii.data(); VoxelTree importVoxels; @@ -1984,8 +1984,11 @@ const float MAX_VOXEL_EDIT_DISTANCE = 20.0f; const float HEAD_SPHERE_RADIUS = 0.07; +static uint16_t DEFAULT_NODE_ID_REF = 1; + + bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection, - glm::vec3& eyePosition, uint16_t& nodeID) { + glm::vec3& eyePosition, uint16_t& nodeID = DEFAULT_NODE_ID_REF) { NodeList* nodeList = NodeList::getInstance(); for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { @@ -2042,8 +2045,8 @@ void Application::update(float deltaTime) { // Set where I am looking based on my mouse ray (so that other people can see) glm::vec3 eyePosition; - uint16_t ignored; - _isLookingAtOtherAvatar = isLookingAtOtherAvatar(mouseRayOrigin, mouseRayDirection, eyePosition, ignored); + + _isLookingAtOtherAvatar = isLookingAtOtherAvatar(mouseRayOrigin, mouseRayDirection, eyePosition); if (_isLookingAtOtherAvatar) { // If the mouse is over another avatar's head... glm::vec3 myLookAtFromMouse(eyePosition); @@ -2309,8 +2312,8 @@ void Application::updateAvatar(float deltaTime) { _viewFrustum.computePickRay(MIDPOINT_OF_SCREEN, MIDPOINT_OF_SCREEN, screenCenterRayOrigin, screenCenterRayDirection); glm::vec3 eyePosition; - uint16_t ignored; - _isLookingAtOtherAvatar = isLookingAtOtherAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition, ignored); + + _isLookingAtOtherAvatar = isLookingAtOtherAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition); if (_isLookingAtOtherAvatar) { glm::vec3 myLookAtFromMouse(eyePosition); _myAvatar.getHead().setLookAtPosition(myLookAtFromMouse); @@ -3624,7 +3627,7 @@ void Application::saveSettings(QSettings* settings) { } void Application::importSettings() { - QString locationDir(QDesktopServices::displayName(QDesktopServices::DesktopLocation)); + QString locationDir(QStandardPaths::displayName(QStandardPaths::DesktopLocation)); QString fileName = QFileDialog::getOpenFileName(_window, tr("Open .ini config file"), locationDir, @@ -3636,7 +3639,7 @@ void Application::importSettings() { } void Application::exportSettings() { - QString locationDir(QDesktopServices::displayName(QDesktopServices::DesktopLocation)); + QString locationDir(QStandardPaths::displayName(QStandardPaths::DesktopLocation)); QString fileName = QFileDialog::getSaveFileName(_window, tr("Save .ini config file"), locationDir, diff --git a/interface/src/avatar/AvatarVoxelSystem.cpp b/interface/src/avatar/AvatarVoxelSystem.cpp index c85ea1a343..a9f6b31072 100644 --- a/interface/src/avatar/AvatarVoxelSystem.cpp +++ b/interface/src/avatar/AvatarVoxelSystem.cpp @@ -121,7 +121,7 @@ void AvatarVoxelSystem::setVoxelURL(const QUrl& url) { // handle "file://" urls... if (url.isLocalFile()) { QString pathString = url.path(); - QByteArray pathAsAscii = pathString.toAscii(); + QByteArray pathAsAscii = pathString.toLocal8Bit(); const char* path = pathAsAscii.data(); readFromSVOFile(path); return; @@ -255,7 +255,7 @@ void AvatarVoxelSystem::handleVoxelDownloadProgress(qint64 bytesReceived, qint64 } void AvatarVoxelSystem::handleVoxelReplyError() { - qDebug("%s\n", _voxelReply->errorString().toAscii().constData()); + qDebug("%s\n", _voxelReply->errorString().toLocal8Bit().constData()); _voxelReply->disconnect(this); _voxelReply->deleteLater(); diff --git a/interface/src/ui/ChatEntry.cpp b/interface/src/ui/ChatEntry.cpp index 588c394eb1..f9ea4eb1f6 100644 --- a/interface/src/ui/ChatEntry.cpp +++ b/interface/src/ui/ChatEntry.cpp @@ -66,7 +66,7 @@ bool ChatEntry::keyPressEvent(QKeyEvent* event) { return true; } if (_contents.size() < MAX_CONTENT_LENGTH) { - _contents.insert(_cursorPos, 1, text.at(0).toAscii()); + _contents.insert(_cursorPos, 1, text.at(0).toLatin1()); _cursorPos++; } return true; diff --git a/libraries/avatars/CMakeLists.txt b/libraries/avatars/CMakeLists.txt index 207057e244..7968b5a003 100644 --- a/libraries/avatars/CMakeLists.txt +++ b/libraries/avatars/CMakeLists.txt @@ -8,9 +8,13 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cm set(TARGET_NAME avatars) +find_package(Qt5Core) + include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) +qt5_use_modules(${TARGET_NAME} Core) + include(${MACRO_DIR}/IncludeGLM.cmake) include_glm(${TARGET_NAME} ${ROOT_DIR}) diff --git a/libraries/shared/CMakeLists.txt b/libraries/shared/CMakeLists.txt index cf1c603b7d..b0c2771f48 100644 --- a/libraries/shared/CMakeLists.txt +++ b/libraries/shared/CMakeLists.txt @@ -6,9 +6,13 @@ set(MACRO_DIR ${ROOT_DIR}/cmake/macros) set(TARGET_NAME shared) project(${TARGET_NAME}) +find_package(Qt5Core REQUIRED) + include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) +qt5_use_modules(${TARGET_NAME} Core) + set(EXTERNAL_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external) if (WIN32) diff --git a/libraries/shared/src/NodeList.cpp b/libraries/shared/src/NodeList.cpp index 9406c6b14d..42aa024e9d 100644 --- a/libraries/shared/src/NodeList.cpp +++ b/libraries/shared/src/NodeList.cpp @@ -512,7 +512,7 @@ void NodeList::loadData(QSettings *settings) { if (domainServerHostname.size() > 0) { memset(_domainHostname, 0, MAX_HOSTNAME_BYTES); - memcpy(_domainHostname, domainServerHostname.toAscii().constData(), domainServerHostname.size()); + memcpy(_domainHostname, domainServerHostname.toLocal8Bit().constData(), domainServerHostname.size()); } settings->endGroup(); diff --git a/libraries/shared/src/SharedUtil.cpp b/libraries/shared/src/SharedUtil.cpp index 72b5b02f15..b6674fdb32 100644 --- a/libraries/shared/src/SharedUtil.cpp +++ b/libraries/shared/src/SharedUtil.cpp @@ -188,8 +188,8 @@ bool cmdOptionExists(int argc, const char * argv[],const char* option) { return false; } -void sharedMessageHandler(QtMsgType type, const char* message) { - fprintf(stdout, "%s", message); +void sharedMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) { + fprintf(stdout, "%s", message.toLocal8Bit().constData()); } ////////////////////////////////////////////////////////////////////////////////////////// diff --git a/libraries/shared/src/SharedUtil.h b/libraries/shared/src/SharedUtil.h index 37443c2778..d840a83ed9 100644 --- a/libraries/shared/src/SharedUtil.h +++ b/libraries/shared/src/SharedUtil.h @@ -68,7 +68,7 @@ void loadRandomIdentifier(unsigned char* identifierBuffer, int numBytes); const char* getCmdOption(int argc, const char * argv[],const char* option); bool cmdOptionExists(int argc, const char * argv[],const char* option); -void sharedMessageHandler(QtMsgType type, const char* message); +void sharedMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message); struct VoxelDetail { float x; diff --git a/voxel-server/src/main.cpp b/voxel-server/src/main.cpp index c009eec2a5..0854dfa4b7 100644 --- a/voxel-server/src/main.cpp +++ b/voxel-server/src/main.cpp @@ -429,7 +429,7 @@ void attachVoxelNodeDataToNode(Node* newNode) { int main(int argc, const char * argv[]) { pthread_mutex_init(&::treeLock, NULL); - qInstallMsgHandler(sharedMessageHandler); + qInstallMessageHandler(sharedMessageHandler); NodeList* nodeList = NodeList::createInstance(NODE_TYPE_VOXEL_SERVER, VOXEL_LISTEN_PORT); setvbuf(stdout, NULL, _IOLBF, 0);