Skip to content

Commit

Permalink
very basic build system changes for compiling Qt5 GUI
Browse files Browse the repository at this point in the history
Signed-off-by: Tolga Cakir <tolga@cevel.net>
  • Loading branch information
tolga9009 committed May 10, 2016
1 parent 9935940 commit 64667e0
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11)
PROJECT(elgato-gchd)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra")

ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(src/gui)
1 change: 0 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ AUX_SOURCE_DIRECTORY("${CMAKE_CURRENT_SOURCE_DIR}/gchd" GCHD_SRC)
LIST(APPEND SOURCE_LIST ${ROOT_SRC} ${GCHD_SRC})

ADD_EXECUTABLE(${PROJECT_NAME} ${SOURCE_LIST})

TARGET_LINK_LIBRARIES(${PROJECT_NAME} stdc++ ${LIBUSB_LIBRARIES})

INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
2 changes: 1 addition & 1 deletion src/gchd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void GCHD::stream(unsigned char *data, int length) {

int transfer;

libusb_bulk_transfer(devh_, 0x81, data, length, &transfer, 5000);
libusb_bulk_transfer(devh_, 0x81, data, length, &transfer, TIMEOUT);
}

int GCHD::checkFirmware() {
Expand Down
1 change: 1 addition & 0 deletions src/gchd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
// endpoints
#define EP_OUT 0x02
#define DATA_BUF 0x4000
#define TIMEOUT 5000

// system commands
#define SCMD_IDLE 1
Expand Down
2 changes: 1 addition & 1 deletion src/gchd/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,5 +352,5 @@ void GCHD::receiveData() {
int transfer;
unsigned char data[DATA_BUF] = {0};

libusb_bulk_transfer(devh_, 0x81, data, DATA_BUF, &transfer, 5000);
libusb_bulk_transfer(devh_, 0x81, data, DATA_BUF, &transfer, TIMEOUT);
}
15 changes: 15 additions & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FIND_PACKAGE(Qt5Core)
FIND_PACKAGE(Qt5Widgets)

IF(Qt5Core_FOUND AND Qt5Widgets_FOUND)
SET(CMAKE_AUTOMOC ON)
SET(CMAKE_AUTOUIC ON)
SET(CMAKE_INCLUDE_CURRENT_DIR ON)

AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} GUI_SRC)

ADD_EXECUTABLE("q${PROJECT_NAME}" ${GUI_SRC})
TARGET_LINK_LIBRARIES("q${PROJECT_NAME}" stdc++ ${LIBUSB_LIBRARIES} Qt5::Core Qt5::Widgets)

INSTALL(TARGETS "q${PROJECT_NAME}" DESTINATION bin)
ENDIF()
11 changes: 11 additions & 0 deletions src/gui/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "widget.hpp"
#include <QApplication>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
w.show();

return a.exec();
}
14 changes: 14 additions & 0 deletions src/gui/widget.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "widget.hpp"
#include "ui_widget.h"

Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
}

Widget::~Widget()
{
delete ui;
}
22 changes: 22 additions & 0 deletions src/gui/widget.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef WIDGET_HPP
#define WIDGET_HPP

#include <QWidget>

namespace Ui {
class Widget;
}

class Widget : public QWidget
{
Q_OBJECT

public:
explicit Widget(QWidget *parent = 0);
~Widget();

private:
Ui::Widget *ui;
};

#endif // WIDGET_HPP
20 changes: 20 additions & 0 deletions src/gui/widget.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<ui version="4.0">
<class>Widget</class>
<widget class="QWidget" name="Widget" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle" >
<string>Widget</string>
</property>
</widget>
<layoutDefault spacing="6" margin="11" />
<pixmapfunction></pixmapfunction>
<resources/>
<connections/>
</ui>

0 comments on commit 64667e0

Please sign in to comment.