Skip to content

Commit 33ecc71

Browse files
author
Raphael Dumusc
committed
Merge pull request #84 from tribal-tec/master
DesktopStreamer: Grid-view like layout in apps listview
2 parents 6b96694 + 8d66d16 commit 33ecc71

File tree

5 files changed

+129
-93
lines changed

5 files changed

+129
-93
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ include(GitExternal)
1212

1313
set(VERSION_MAJOR 0)
1414
set(VERSION_MINOR 10)
15-
set(VERSION_PATCH 0)
15+
set(VERSION_PATCH 1)
1616
set(VERSION_ABI 3)
1717

1818
set(DEFLECT_DESCRIPTION "A fast C++ library for streaming pixels and events")

apps/DesktopStreamer/DesktopWindowsModel.mm

+5-2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
namespace
3333
{
3434
const int PREVIEWIMAGEWIDTH = 200;
35+
const int PREVIEWIMAGEHEIGHT = PREVIEWIMAGEWIDTH * 0.6;
3536

3637
/**
3738
* Based on: http://www.qtcentre.org/threads/34752-NSString-to-QString
@@ -66,8 +67,10 @@ QString NSStringToQString( const NSString* nsstr )
6667

6768
QPixmap getPreviewPixmap( const QPixmap& pixmap )
6869
{
69-
return QPixmap::fromImage( pixmap.toImage().scaledToWidth(
70-
PREVIEWIMAGEWIDTH, Qt::SmoothTransformation ));
70+
return QPixmap::fromImage(
71+
pixmap.toImage().scaled( PREVIEWIMAGEWIDTH, PREVIEWIMAGEHEIGHT,
72+
Qt::KeepAspectRatio,
73+
Qt::SmoothTransformation ));
7174
}
7275

7376
QPixmap getWindowPixmap( const CGWindowID windowID )

apps/DesktopStreamer/MainWindow.cpp

+23-11
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ const std::vector< std::pair< QString, QString > > defaultHosts = {
7272
{ "DisplayWall 6th floor", "bbpav06.epfl.ch" }
7373
};
7474

75+
const QString streamSelected = "Stream selected item(s)";
76+
7577
MainWindow::MainWindow()
7678
: _streamID( 0 )
7779
, _averageUpdate( 0 )
@@ -80,25 +82,36 @@ MainWindow::MainWindow()
8082

8183
connect( _hostnameComboBox, &QComboBox::currentTextChanged,
8284
[&]( const QString& text )
83-
{ _streamButton->setEnabled( !text.isEmpty( )); });
85+
{
86+
_streamButton->setEnabled( !text.isEmpty( ));
87+
_listView->setEnabled( !text.isEmpty( ));
88+
});
8489

8590
for( const auto& entry : defaultHosts )
8691
_hostnameComboBox->addItem( entry.first, entry.second );
8792

93+
// no default host selected initially
94+
_hostnameComboBox->setCurrentIndex( -1 );
95+
8896
char hostname[256] = { 0 };
8997
gethostname( hostname, 256 );
9098
_streamnameLineEdit->setText( QString( "%1" ).arg( hostname ));
9199

92100
#ifdef DEFLECT_USE_QT5MACEXTRAS
93101
_listView->setModel( new DesktopWindowsModel );
94102

95-
connect( _listView->selectionModel(),
96-
&QItemSelectionModel::selectionChanged,
97-
[=]( const QItemSelection&, const QItemSelection& )
98-
{
99-
_update();
100-
});
101-
_streamButton->setHidden( true );
103+
// select 'Desktop' item as initial default stream item
104+
_listView->setCurrentIndex( _listView->model()->index( 0, 0 ));
105+
_streamButton->setText( streamSelected );
106+
107+
const int itemsHorizontal = std::min( 3.f,
108+
std::ceil( std::sqrt( float(_listView->model()->rowCount( )))));
109+
const int itemsVertical = std::min( 3.f,
110+
std::ceil(float( _listView->model()->rowCount( )) / itemsHorizontal ));
111+
112+
// 230 (itemSize + spacing), frameWidth for decorations
113+
resize( QSize( 230 * itemsHorizontal + 2 * _listView->frameWidth(),
114+
230 * itemsVertical + 2 * _listView->frameWidth() + 50 ));
102115
#else
103116
_listView->setHidden( true );
104117
adjustSize();
@@ -154,9 +167,9 @@ void MainWindow::closeEvent( QCloseEvent* closeEvt )
154167
void MainWindow::_update()
155168
{
156169
_frameTime.start();
157-
_updateStreams();
158170
if( _streamButton->isChecked( ))
159171
{
172+
_updateStreams();
160173
_processStreamEvents();
161174
_shareDesktopUpdate();
162175
_regulateFrameRate();
@@ -208,8 +221,7 @@ void MainWindow::_updateStreams()
208221
{
209222
_streamButton->setChecked( true );
210223
_startStreaming();
211-
}
212-
_streamButton->setChecked( !windowIndices.empty( ));
224+
};
213225

214226
#else // No window list: Stream button toggles
215227

apps/DesktopStreamer/MainWindow.ui

+97-79
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<x>0</x>
88
<y>0</y>
99
<width>350</width>
10-
<height>700</height>
10+
<height>412</height>
1111
</rect>
1212
</property>
1313
<property name="sizePolicy">
@@ -30,31 +30,6 @@
3030
<property name="sizeConstraint">
3131
<enum>QLayout::SetMinimumSize</enum>
3232
</property>
33-
<item>
34-
<widget class="QListView" name="_listView">
35-
<property name="sizePolicy">
36-
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
37-
<horstretch>0</horstretch>
38-
<verstretch>0</verstretch>
39-
</sizepolicy>
40-
</property>
41-
<property name="selectionMode">
42-
<enum>QAbstractItemView::MultiSelection</enum>
43-
</property>
44-
<property name="flow">
45-
<enum>QListView::LeftToRight</enum>
46-
</property>
47-
<property name="isWrapping" stdset="0">
48-
<bool>true</bool>
49-
</property>
50-
<property name="viewMode">
51-
<enum>QListView::ListMode</enum>
52-
</property>
53-
<property name="uniformItemSizes">
54-
<bool>true</bool>
55-
</property>
56-
</widget>
57-
</item>
5833
<item>
5934
<layout class="QFormLayout" name="formLayout">
6035
<property name="sizeConstraint">
@@ -78,7 +53,7 @@
7853
<item row="0" column="0">
7954
<widget class="QLabel" name="hostnameLabel">
8055
<property name="text">
81-
<string>Hostname</string>
56+
<string>Stream to</string>
8257
</property>
8358
</widget>
8459
</item>
@@ -110,57 +85,7 @@
11085
</property>
11186
</widget>
11287
</item>
113-
<item row="1" column="0">
114-
<widget class="QLabel" name="streamnameLabel">
115-
<property name="text">
116-
<string>Streamname</string>
117-
</property>
118-
</widget>
119-
</item>
120-
<item row="2" column="0">
121-
<widget class="QLabel" name="desktopInteractionLabel">
122-
<property name="text">
123-
<string>Interaction</string>
124-
</property>
125-
</widget>
126-
</item>
127-
<item row="2" column="1">
128-
<widget class="QCheckBox" name="_desktopInteractionCheckBox">
129-
<property name="checked">
130-
<bool>true</bool>
131-
</property>
132-
</widget>
133-
</item>
134-
<item row="3" column="0">
135-
<widget class="QLabel" name="maxFrameRateLabel">
136-
<property name="text">
137-
<string>Max frame rate</string>
138-
</property>
139-
</widget>
140-
</item>
141-
<item row="3" column="1">
142-
<widget class="QSpinBox" name="_maxFrameRateSpinBox">
143-
<property name="sizePolicy">
144-
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
145-
<horstretch>0</horstretch>
146-
<verstretch>0</verstretch>
147-
</sizepolicy>
148-
</property>
149-
<property name="suffix">
150-
<string> fps</string>
151-
</property>
152-
<property name="minimum">
153-
<number>1</number>
154-
</property>
155-
<property name="maximum">
156-
<number>60</number>
157-
</property>
158-
<property name="value">
159-
<number>30</number>
160-
</property>
161-
</widget>
162-
</item>
163-
<item row="4" column="0" colspan="2">
88+
<item row="1" column="0" colspan="2">
16489
<widget class="QPushButton" name="_streamButton">
16590
<property name="minimumSize">
16691
<size>
@@ -197,7 +122,57 @@
197122
</property>
198123
</widget>
199124
</item>
200-
<item row="1" column="1">
125+
<item row="2" column="0" colspan="2">
126+
<widget class="QListView" name="_listView">
127+
<property name="sizePolicy">
128+
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
129+
<horstretch>0</horstretch>
130+
<verstretch>1</verstretch>
131+
</sizepolicy>
132+
</property>
133+
<property name="contextMenuPolicy">
134+
<enum>Qt::NoContextMenu</enum>
135+
</property>
136+
<property name="sizeAdjustPolicy">
137+
<enum>QAbstractScrollArea::AdjustIgnored</enum>
138+
</property>
139+
<property name="selectionMode">
140+
<enum>QAbstractItemView::MultiSelection</enum>
141+
</property>
142+
<property name="movement">
143+
<enum>QListView::Static</enum>
144+
</property>
145+
<property name="flow">
146+
<enum>QListView::LeftToRight</enum>
147+
</property>
148+
<property name="isWrapping" stdset="0">
149+
<bool>true</bool>
150+
</property>
151+
<property name="resizeMode">
152+
<enum>QListView::Adjust</enum>
153+
</property>
154+
<property name="layoutMode">
155+
<enum>QListView::Batched</enum>
156+
</property>
157+
<property name="spacing">
158+
<number>1</number>
159+
</property>
160+
<property name="viewMode">
161+
<enum>QListView::IconMode</enum>
162+
</property>
163+
<property name="uniformItemSizes">
164+
<bool>false</bool>
165+
</property>
166+
</widget>
167+
</item>
168+
<item row="3" column="0">
169+
<widget class="QLabel" name="streamnameLabel">
170+
<property name="text">
171+
<string>Stream name</string>
172+
</property>
173+
</widget>
174+
</item>
175+
<item row="3" column="1">
201176
<widget class="QLineEdit" name="_streamnameLineEdit">
202177
<property name="sizePolicy">
203178
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@@ -210,6 +185,49 @@
210185
</property>
211186
</widget>
212187
</item>
188+
<item row="4" column="0">
189+
<widget class="QLabel" name="desktopInteractionLabel">
190+
<property name="text">
191+
<string>Interaction</string>
192+
</property>
193+
</widget>
194+
</item>
195+
<item row="4" column="1">
196+
<widget class="QCheckBox" name="_desktopInteractionCheckBox">
197+
<property name="checked">
198+
<bool>true</bool>
199+
</property>
200+
</widget>
201+
</item>
202+
<item row="5" column="0">
203+
<widget class="QLabel" name="maxFrameRateLabel">
204+
<property name="text">
205+
<string>Frame rate</string>
206+
</property>
207+
</widget>
208+
</item>
209+
<item row="5" column="1">
210+
<widget class="QSpinBox" name="_maxFrameRateSpinBox">
211+
<property name="sizePolicy">
212+
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
213+
<horstretch>0</horstretch>
214+
<verstretch>0</verstretch>
215+
</sizepolicy>
216+
</property>
217+
<property name="suffix">
218+
<string> fps</string>
219+
</property>
220+
<property name="minimum">
221+
<number>1</number>
222+
</property>
223+
<property name="maximum">
224+
<number>60</number>
225+
</property>
226+
<property name="value">
227+
<number>30</number>
228+
</property>
229+
</widget>
230+
</item>
213231
</layout>
214232
</item>
215233
</layout>

doc/Changelog.md

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

44
## git master
55

6+
* [79](https://github.com/BlueBrain/Deflect/pull/79):
7+
DesktopStreamer: Grid-view like layout in apps listview
8+
69
## Deflect 0.10
710
* [79](https://github.com/BlueBrain/Deflect/pull/79):
811
DesktopStreamer: Support multi-window streaming on OS X, fix mouse

0 commit comments

Comments
 (0)