Skip to content

Commit cf8884e

Browse files
author
Raphael Dumusc
committed
QmlStreamer: New 'streamname' command line option
Needed by DisplayCluster to programatically enforce the (potentially unknown) name of the AppLauncher Qml streamer.
1 parent ee46e10 commit cf8884e

File tree

6 files changed

+44
-13
lines changed

6 files changed

+44
-13
lines changed

apps/QmlStreamer/main.cpp

+13-3
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,29 @@ int main( int argc, char** argv )
3838
"qrc:/qml/gui.qml" );
3939
parser.addOption( qmlFileOption );
4040

41-
QCommandLineOption streamHostOption( "host", "Stream hostname", "hostname",
42-
"localhost" );
41+
QCommandLineOption streamHostOption( "host", "Stream target hostname "
42+
"(default: localhost)",
43+
"hostname", "localhost" );
4344
parser.addOption( streamHostOption );
4445

46+
// note: the 'name' command line option is already taken by QCoreApplication
47+
QCommandLineOption streamNameOption( "streamname", "Stream name (default: "
48+
"Qml's root objectName "
49+
"property or 'QmlStreamer')",
50+
"name" );
51+
parser.addOption( streamNameOption );
52+
4553
parser.process( app );
4654

4755
const QString qmlFile = parser.value( qmlFileOption );
4856
const QString streamHost = parser.value( streamHostOption );
57+
const QString streamName = parser.value( streamNameOption );
4958

5059
try
5160
{
5261
QScopedPointer< deflect::qt::QmlStreamer > streamer(
53-
new deflect::qt::QmlStreamer( qmlFile, streamHost.toStdString( )));
62+
new deflect::qt::QmlStreamer( qmlFile, streamHost.toStdString(),
63+
streamName.toStdString( )));
5464
return app.exec();
5565
}
5666
catch( const std::runtime_error& exception )

deflect/qt/QmlStreamer.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ namespace qt
4646
{
4747

4848
QmlStreamer::QmlStreamer( const QString& qmlFile,
49-
const std::string& streamHost )
50-
: _impl( new Impl( qmlFile, streamHost ))
49+
const std::string& streamHost,
50+
const std::string& streamName )
51+
: _impl( new Impl( qmlFile, streamHost, streamName ))
5152
{
5253
}
5354

deflect/qt/QmlStreamer.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,13 @@ class QmlStreamer
6868
*
6969
* @param qmlFile URL to QML file to load
7070
* @param streamHost hostname of the Deflect server
71+
* @param streamName name of the Deflect stream (optional). Setting this
72+
* value overrides the 'objectName' property of the root QML item.
73+
* If neither is provided, "QmlStreamer" is used instead.
7174
*/
7275
DEFLECTQT_API QmlStreamer( const QString& qmlFile,
73-
const std::string& streamHost );
76+
const std::string& streamHost,
77+
const std::string& streamName = std::string( ));
7478

7579
DEFLECTQT_API ~QmlStreamer();
7680

deflect/qt/QmlStreamerImpl.cpp

+17-6
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@
5151
#include <QQuickRenderControl>
5252
#include <QQuickWindow>
5353

54+
namespace
55+
{
56+
const std::string DEFAULT_STREAM_NAME( "QmlStreamer" );
57+
}
5458

5559
class RenderControl : public QQuickRenderControl
5660
{
@@ -75,7 +79,8 @@ namespace deflect
7579
namespace qt
7680
{
7781

78-
QmlStreamer::Impl::Impl( const QString& qmlFile, const std::string& streamHost )
82+
QmlStreamer::Impl::Impl( const QString& qmlFile, const std::string& streamHost,
83+
const std::string& streamName )
7984
: QWindow()
8085
, _context( new QOpenGLContext )
8186
, _offscreenSurface( new QOffscreenSurface )
@@ -92,6 +97,7 @@ QmlStreamer::Impl::Impl( const QString& qmlFile, const std::string& streamHost )
9297
, _eventHandler( nullptr )
9398
, _streaming( false )
9499
, _streamHost( streamHost )
100+
, _streamName( streamName )
95101
{
96102
setSurfaceType( QSurface::OpenGLSurface );
97103

@@ -321,14 +327,19 @@ bool QmlStreamer::Impl::_setupRootItem()
321327
return true;
322328
}
323329

330+
std::string QmlStreamer::Impl::_getDeflectStreamName() const
331+
{
332+
if( !_streamName.empty( ))
333+
return _streamName;
334+
335+
const std::string streamName = _rootItem->objectName().toStdString();
336+
return streamName.empty() ? DEFAULT_STREAM_NAME : streamName;
337+
}
338+
324339
bool QmlStreamer::Impl::_setupDeflectStream()
325340
{
326341
if( !_stream )
327-
{
328-
const std::string streamName = _rootItem->objectName().toStdString();
329-
_stream = new Stream( streamName.empty() ? "QmlStreamer" : streamName,
330-
_streamHost );
331-
}
342+
_stream = new Stream( _getDeflectStreamName(), _streamHost );
332343

333344
if( !_stream->isConnected( ))
334345
return false;

deflect/qt/QmlStreamerImpl.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ class QmlStreamer::Impl : public QWindow
7070
Q_OBJECT
7171

7272
public:
73-
Impl( const QString& qmlFile, const std::string& streamHost );
73+
Impl( const QString& qmlFile, const std::string& streamHost,
74+
const std::string& streamName );
7475

7576
~Impl();
7677

@@ -96,6 +97,7 @@ private slots:
9697
void _onWheeled( double, double, double );
9798

9899
private:
100+
std::string _getDeflectStreamName() const;
99101
bool _setupDeflectStream();
100102
void _updateSizes( const QSize& size );
101103

@@ -113,6 +115,7 @@ private slots:
113115
EventReceiver* _eventHandler;
114116
bool _streaming;
115117
const std::string _streamHost;
118+
const std::string _streamName;
116119
SizeHints _sizeHints;
117120
};
118121

doc/Changelog.md

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ Changelog {#Changelog}
33

44
## Deflect 0.9 (git master)
55

6+
* [65](https://github.com/BlueBrain/Deflect/pull/65):
7+
QmlStreamer: New 'streamname' command line option.
68
* [64](https://github.com/BlueBrain/Deflect/pull/64):
79
QmlStreamer: Fix event forwarding, implement wheel event support
810
* [60](https://github.com/BlueBrain/Deflect/pull/60):

0 commit comments

Comments
 (0)