Skip to content

Commit 593cfc1

Browse files
committed
DesktopStreamer: Grid-view like layout in apps listview, added stream all apps/stream none button
1 parent 6b96694 commit 593cfc1

File tree

4 files changed

+102
-47
lines changed

4 files changed

+102
-47
lines changed

apps/DesktopStreamer/DesktopWindowsModel.mm

Lines changed: 5 additions & 2 deletions
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

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ const std::vector< std::pair< QString, QString > > defaultHosts = {
7272
{ "DisplayWall 6th floor", "bbpav06.epfl.ch" }
7373
};
7474

75+
const QString streamOne = "Stream";
76+
const QString streamSelected = "Stream selection";
77+
const QString stopStream = "Stop streaming";
78+
7579
MainWindow::MainWindow()
7680
: _streamID( 0 )
7781
, _averageUpdate( 0 )
@@ -80,11 +84,16 @@ MainWindow::MainWindow()
8084

8185
connect( _hostnameComboBox, &QComboBox::currentTextChanged,
8286
[&]( const QString& text )
83-
{ _streamButton->setEnabled( !text.isEmpty( )); });
87+
{
88+
_streamButton->setEnabled( !text.isEmpty( ));
89+
_listView->setEnabled( !text.isEmpty( ));
90+
});
8491

8592
for( const auto& entry : defaultHosts )
8693
_hostnameComboBox->addItem( entry.first, entry.second );
8794

95+
_hostnameComboBox->setCurrentIndex( -1 );
96+
8897
char hostname[256] = { 0 };
8998
gethostname( hostname, 256 );
9099
_streamnameLineEdit->setText( QString( "%1" ).arg( hostname ));
@@ -94,22 +103,43 @@ MainWindow::MainWindow()
94103

95104
connect( _listView->selectionModel(),
96105
&QItemSelectionModel::selectionChanged,
97-
[=]( const QItemSelection&, const QItemSelection& )
106+
[this]( const QItemSelection&, const QItemSelection& )
98107
{
108+
_streamButton->setText(
109+
_listView->selectionModel()->selectedIndexes().empty()
110+
? streamSelected : stopStream );
99111
_update();
100112
});
101-
_streamButton->setHidden( true );
113+
114+
_streamButton->setText( streamSelected );
115+
connect( _streamButton, &QPushButton::clicked, this,
116+
[this] { _streamButton->isChecked() ? _listView->selectAll()
117+
: _listView->clearSelection(); });
118+
119+
const int itemsHorizontal = std::min( 3.f,
120+
std::ceil( std::sqrt( float(_listView->model()->rowCount( )))));
121+
const int itemsVertical = std::min( 3.f,
122+
std::ceil(float( _listView->model()->rowCount( )) / itemsHorizontal ));
123+
124+
// 210 (itemSize + spacing), frameWidth for decorations
125+
resize( QSize( 210 * itemsHorizontal + 2 * _listView->frameWidth(),
126+
210 * itemsVertical + 2 * _listView->frameWidth() + 100 ));
102127
#else
103128
_listView->setHidden( true );
104129
adjustSize();
130+
131+
connect( _streamButton, &QPushButton::clicked,
132+
[this]
133+
{
134+
_streamButton->setText( _streamButton->isChecked()
135+
? stopStream : streamOne );
136+
_update();
137+
});
105138
#endif
106139

107140
connect( _desktopInteractionCheckBox, &QCheckBox::clicked,
108141
this, &MainWindow::_onStreamEventsBoxClicked );
109142

110-
connect( _streamButton, &QPushButton::clicked,
111-
this, &MainWindow::_update );
112-
113143
connect( _actionAbout, &QAction::triggered,
114144
this, &MainWindow::_openAboutWidget );
115145

apps/DesktopStreamer/MainWindow.ui

Lines changed: 57 additions & 39 deletions
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>406</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">
@@ -117,6 +92,19 @@
11792
</property>
11893
</widget>
11994
</item>
95+
<item row="1" column="1">
96+
<widget class="QLineEdit" name="_streamnameLineEdit">
97+
<property name="sizePolicy">
98+
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
99+
<horstretch>0</horstretch>
100+
<verstretch>0</verstretch>
101+
</sizepolicy>
102+
</property>
103+
<property name="clearButtonEnabled">
104+
<bool>false</bool>
105+
</property>
106+
</widget>
107+
</item>
120108
<item row="2" column="0">
121109
<widget class="QLabel" name="desktopInteractionLabel">
122110
<property name="text">
@@ -197,21 +185,51 @@
197185
</property>
198186
</widget>
199187
</item>
200-
<item row="1" column="1">
201-
<widget class="QLineEdit" name="_streamnameLineEdit">
202-
<property name="sizePolicy">
203-
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
204-
<horstretch>0</horstretch>
205-
<verstretch>0</verstretch>
206-
</sizepolicy>
207-
</property>
208-
<property name="clearButtonEnabled">
209-
<bool>false</bool>
210-
</property>
211-
</widget>
212-
</item>
213188
</layout>
214189
</item>
190+
<item>
191+
<widget class="QListView" name="_listView">
192+
<property name="sizePolicy">
193+
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
194+
<horstretch>0</horstretch>
195+
<verstretch>0</verstretch>
196+
</sizepolicy>
197+
</property>
198+
<property name="contextMenuPolicy">
199+
<enum>Qt::NoContextMenu</enum>
200+
</property>
201+
<property name="sizeAdjustPolicy">
202+
<enum>QAbstractScrollArea::AdjustIgnored</enum>
203+
</property>
204+
<property name="selectionMode">
205+
<enum>QAbstractItemView::MultiSelection</enum>
206+
</property>
207+
<property name="movement">
208+
<enum>QListView::Static</enum>
209+
</property>
210+
<property name="flow">
211+
<enum>QListView::LeftToRight</enum>
212+
</property>
213+
<property name="isWrapping" stdset="0">
214+
<bool>true</bool>
215+
</property>
216+
<property name="resizeMode">
217+
<enum>QListView::Adjust</enum>
218+
</property>
219+
<property name="layoutMode">
220+
<enum>QListView::Batched</enum>
221+
</property>
222+
<property name="spacing">
223+
<number>1</number>
224+
</property>
225+
<property name="viewMode">
226+
<enum>QListView::IconMode</enum>
227+
</property>
228+
<property name="uniformItemSizes">
229+
<bool>false</bool>
230+
</property>
231+
</widget>
232+
</item>
215233
</layout>
216234
</widget>
217235
<widget class="QMenuBar" name="menubar">

doc/Changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ 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, added stream all
8+
apps/stream none button
9+
610
## Deflect 0.10
711
* [79](https://github.com/BlueBrain/Deflect/pull/79):
812
DesktopStreamer: Support multi-window streaming on OS X, fix mouse

0 commit comments

Comments
 (0)