Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ common_find_package(LibJpegTurbo REQUIRED)
common_find_package(OpenGL)
common_find_package(Qt5Concurrent REQUIRED SYSTEM)
common_find_package(Qt5Core REQUIRED)
common_find_package(Qt5Gui COMPONENTS Private) # For Qml WebEngineView
if(APPLE)
common_find_package(Qt5MacExtras)
endif()
Expand Down
12 changes: 9 additions & 3 deletions deflect/qt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@

# Copyright (c) 2015, EPFL/Blue Brain Project
# Daniel Nachbaur <daniel.nachbaur@epfl.ch>
# Copyright (c) 2015-2016, EPFL/Blue Brain Project
# Daniel Nachbaur <daniel.nachbaur@epfl.ch>
# Raphael Dumusc <raphael.dumusc@epfl.ch>

set(DEFLECTQT_HEADERS EventReceiver.h QmlStreamerImpl.h)
set(DEFLECTQT_HEADERS EventReceiver.h QmlGestures.h QmlStreamerImpl.h)
set(DEFLECTQT_PUBLIC_HEADERS QmlStreamer.h)
set(DEFLECTQT_SOURCES EventReceiver.cpp QmlStreamer.cpp QmlStreamerImpl.cpp)
set(DEFLECTQT_LINK_LIBRARIES
PUBLIC Deflect Qt5::Quick PRIVATE Qt5::Qml)
set(DEFLECTQT_INCLUDE_NAME deflect/qt)
set(DEFLECTQT_NAMESPACE deflectqt)
common_library(DeflectQt)

if(TARGET Qt5::Gui)
target_include_directories(DeflectQt SYSTEM PRIVATE
"$<BUILD_INTERFACE:${Qt5Gui_PRIVATE_INCLUDE_DIRS}>")
endif()
13 changes: 10 additions & 3 deletions deflect/qt/EventReceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,18 @@ void EventReceiver::_onEvent( int socket )
emit wheeled( deflectEvent.mouseX, deflectEvent.mouseY,
deflectEvent.dy );
break;

case Event::EVT_CLICK:
case Event::EVT_DOUBLECLICK:
case Event::EVT_SWIPE_LEFT:
emit swipeLeft();
break;
case Event::EVT_SWIPE_RIGHT:
emit swipeRight();
break;
case Event::EVT_SWIPE_UP:
emit swipeUp();
break;
case Event::EVT_SWIPE_DOWN:
emit swipeDown();
break;
case Event::EVT_KEY_PRESS:
emit keyPress( deflectEvent.key, deflectEvent.modifiers,
QString::fromStdString( deflectEvent.text ));
Expand All @@ -112,6 +117,8 @@ void EventReceiver::_onEvent( int socket )
emit keyRelease( deflectEvent.key, deflectEvent.modifiers,
QString::fromStdString( deflectEvent.text ));
break;
case Event::EVT_CLICK:
case Event::EVT_DOUBLECLICK:
default:
break;
}
Expand Down
4 changes: 4 additions & 0 deletions deflect/qt/EventReceiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ class EventReceiver : public QObject
void wheeled( double x, double y, double dy );
void keyPress( int key, int modifiers, QString text );
void keyRelease( int key, int modifiers, QString text );
void swipeLeft();
void swipeRight();
void swipeUp();
void swipeDown();

private slots:
void _onEvent( int socket );
Expand Down
67 changes: 67 additions & 0 deletions deflect/qt/QmlGestures.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*********************************************************************/
/* Copyright (c) 2016, EPFL/Blue Brain Project */
/* Raphael Dumusc <raphael.dumusc@epfl.ch> */
/* All rights reserved. */
/* */
/* Redistribution and use in source and binary forms, with or */
/* without modification, are permitted provided that the following */
/* conditions are met: */
/* */
/* 1. Redistributions of source code must retain the above */
/* copyright notice, this list of conditions and the following */
/* disclaimer. */
/* */
/* 2. Redistributions in binary form must reproduce the above */
/* copyright notice, this list of conditions and the following */
/* disclaimer in the documentation and/or other materials */
/* provided with the distribution. */
/* */
/* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */
/* AUSTIN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, */
/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
/* DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT */
/* AUSTIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
/* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
/* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */
/* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR */
/* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
/* POSSIBILITY OF SUCH DAMAGE. */
/* */
/* The views and conclusions contained in the software and */
/* documentation are those of the authors and should not be */
/* interpreted as representing official policies, either expressed */
/* or implied, of Ecole polytechnique federale de Lausanne. */
/*********************************************************************/

#ifndef QMLGESTURES_H
#define QMLGESTURES_H

#include <QObject>

namespace deflect
{
namespace qt
{

/**
* Expose gesture events as a Qml context property object.
*/
class QmlGestures : public QObject
{
Q_OBJECT

signals:
void swipeLeft();
void swipeRight();
void swipeUp();
void swipeDown();
};

}
}

#endif
7 changes: 7 additions & 0 deletions deflect/qt/QmlStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
#include "QmlStreamer.h"
#include "QmlStreamerImpl.h"

#include "../Stream.h"

namespace deflect
{
namespace qt
Expand Down Expand Up @@ -68,5 +70,10 @@ QQmlEngine* QmlStreamer::getQmlEngine()
return _impl->getQmlEngine();
}

bool QmlStreamer::sendData( const QByteArray data )
{
return _impl->getStream()->sendData( data.constData(), data.size( ));
}

}
}
16 changes: 16 additions & 0 deletions deflect/qt/QmlStreamer.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ namespace qt
* This class renders the given QML file in an offscreen fashion and streams
* on each update on the given Deflect stream. It automatically register also
* for Deflect events, which can be directly handled in the QML.

* Users can make connections to the "deflectgestures" context property to react
* to certain gestures received as Event, currently swipe[Left|Right|Up|Down].
*
* When using a WebEngineView, users must call QtWebEngine::initialize() in the
* QApplication before creating the streamer. Also, due to a limitiation in Qt,
* the objectName property of any WebEngineView must be set to "webengineview"
* for it to receive keyboard events.
*/
class QmlStreamer : public QObject
{
Expand Down Expand Up @@ -87,6 +95,14 @@ class QmlStreamer : public QObject
/** @return the QML engine. */
DEFLECTQT_API QQmlEngine* getQmlEngine();

/**
* Send data to the Server.
*
* @param data the data buffer
* @return true if the data could be sent, false otherwise
*/
DEFLECTQT_API bool sendData( QByteArray data );

signals:
/** Emitted when the stream has been closed. */
void streamClosed();
Expand Down
Loading