From 5a113fd5468b37db652ebfcf83d0a20043f4ea21 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 10 May 2013 12:07:47 -0700 Subject: [PATCH 1/2] Added a stub for a Qt application class that creates a menu (which, since it's unparented, will only appear on OS X) with a test item connected to a slot. --- interface/CMakeLists.txt | 8 ++++++-- interface/src/Application.cpp | 22 ++++++++++++++++++++++ interface/src/Application.h | 26 ++++++++++++++++++++++++++ interface/src/main.cpp | 9 +++------ 4 files changed, 57 insertions(+), 8 deletions(-) create mode 100644 interface/src/Application.cpp create mode 100644 interface/src/Application.h diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index dcef05bdf6..71f459439b 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -54,6 +54,12 @@ if (APPLE) SET(INTERFACE_SRCS ${INTERFACE_SRCS} ${INTERFACE_RSRCS}) endif (APPLE) +find_package(Qt4 REQUIRED QtCore QtGui) +include(${QT_USE_FILE}) + +# run qt moc on qt-enabled headers +qt4_wrap_cpp(INTERFACE_SRCS src/Application.h) + # create the executable, make it a bundle on OS X add_executable(${TARGET_NAME} MACOSX_BUNDLE ${INTERFACE_SRCS}) @@ -77,8 +83,6 @@ include_directories( ${LODEPNG_INCLUDE_DIRS} ) -find_package(Qt4 REQUIRED QtCore QtGui) -include(${QT_USE_FILE}) target_link_libraries(${TARGET_NAME} ${QT_LIBRARIES}) if (NOT APPLE) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp new file mode 100644 index 0000000000..3080f3f3ed --- /dev/null +++ b/interface/src/Application.cpp @@ -0,0 +1,22 @@ +// +// Application.cpp +// interface +// +// Created by Andrzej Kapolka on 5/10/13. +// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. + +#include +#include + +#include "Application.h" + +Application::Application(int& argc, char** argv) : QApplication(argc, argv) { + // simple menu bar (will only appear on OS X, for now) + QMenuBar* menuBar = new QMenuBar(); + QMenu* fileMenu = menuBar->addMenu("File"); + fileMenu->addAction("Quit", this, SLOT(testSlot())); +} + +void Application::testSlot() { + qDebug() << "Hello world."; +} diff --git a/interface/src/Application.h b/interface/src/Application.h new file mode 100644 index 0000000000..c47dc3e33a --- /dev/null +++ b/interface/src/Application.h @@ -0,0 +1,26 @@ +// +// Application.h +// interface +// +// Created by Andrzej Kapolka on 5/10/13. +// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// + +#ifndef __interface__Application__ +#define __interface__Application__ + +#include + +class Application : public QApplication { + Q_OBJECT + +public: + + Application(int& argc, char** argv); + +public slots: + + void testSlot(); +}; + +#endif /* defined(__interface__Application__) */ diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 5ff83bead9..2a2b7445e1 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -31,8 +31,6 @@ #include #endif -#include - #include #include @@ -61,6 +59,7 @@ #include "renderer/ProgramObject.h" #include "renderer/ShaderObject.h" +#include "Application.h" #include "Camera.h" #include "Avatar.h" #include @@ -86,8 +85,6 @@ void loadViewFrustum(ViewFrustum& viewFrustum); // will be defined below glm::vec3 getGravity(glm::vec3 pos); //get the local gravity vector at this location in the universe -QApplication* app; - bool enableNetworkThread = true; pthread_t networkReceiveThread; bool stopNetworkReceiveThread = false; @@ -2032,9 +2029,9 @@ int main(int argc, const char * argv[]) { #endif // we need to create a QApplication instance in order to use Qt's font rendering - app = new QApplication(argc, const_cast(argv)); + Application app(argc, const_cast(argv)); printLog( "Created QT Application.\n" ); - + // Before we render anything, let's set up our viewFrustumOffsetCamera with a sufficiently large // field of view and near and far clip to make it interesting. //viewFrustumOffsetCamera.setFieldOfView(90.0); From 012c2c9c9fc2e2109c6b012b15feed9d36719d50 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 10 May 2013 12:11:32 -0700 Subject: [PATCH 2/2] Changed "Quit" menu item to "Test" (Quit should apparently be added automatically). --- interface/src/Application.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 3080f3f3ed..ff6c80d456 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -14,7 +14,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv) { // simple menu bar (will only appear on OS X, for now) QMenuBar* menuBar = new QMenuBar(); QMenu* fileMenu = menuBar->addMenu("File"); - fileMenu->addAction("Quit", this, SLOT(testSlot())); + fileMenu->addAction("Test", this, SLOT(testSlot())); } void Application::testSlot() {