Skip to content

Commit

Permalink
DesktopStreamer: added some command line options
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphael Dumusc committed Oct 23, 2017
1 parent 6e30fda commit 79a04db
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
11 changes: 9 additions & 2 deletions apps/DesktopStreamer/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const int FAILURE_UPDATE_DELAY = 100;
const float FRAME_RATE_DAMPING = 0.1f; // influence of new value between 0-1
}

MainWindow::MainWindow()
MainWindow::MainWindow(Options options)
: _streamID(0)
, _averageUpdate(0)
{
Expand All @@ -95,6 +95,9 @@ MainWindow::MainWindow()
_listView->setEnabled(!text.isEmpty());
});

if (!options.initialHost.isEmpty())
_hostComboBox->setCurrentText(options.initialHost);

const auto username = nameutils::getFullUsername();
if (username.isEmpty())
_streamIdLineEdit->setText(QHostInfo::localHostName());
Expand Down Expand Up @@ -141,8 +144,12 @@ MainWindow::MainWindow()
#ifndef DEFLECT_USE_QT5MACEXTRAS
_actionMultiWindowMode->setVisible(false);
#endif
_showAdvancedSettings(false);
_actionAdvancedSettings->setChecked(options.showAdvancedSettings);
_showAdvancedSettings(options.showAdvancedSettings);
_showSingleWindowMode();

if (options.enableStream)
_streamButton->click();
}

MainWindow::~MainWindow()
Expand Down
9 changes: 8 additions & 1 deletion apps/DesktopStreamer/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,14 @@ class MainWindow : public QMainWindow, public Ui::MainWindow
Q_OBJECT

public:
MainWindow();
struct Options
{
QString initialHost;
bool enableStream;
bool showAdvancedSettings;
};

MainWindow(Options options);
~MainWindow();

const QAbstractItemModel* getItemModel() const
Expand Down
16 changes: 15 additions & 1 deletion apps/DesktopStreamer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,27 @@ int main(int argc, char* argv[])

QCommandLineParser parser;
parser.setApplicationDescription("Stream your desktop to a remote host");
QCommandLineOption streamEnabledOption(QStringList() << "e"
<< "enable",
"Enable streaming on startup.");
parser.addOption(streamEnabledOption);
QCommandLineOption advancedOption(QStringList() << "a"
<< "advanced",
"Show advanced settings.");
parser.addOption(advancedOption);
parser.addPositionalArgument("host", "Default host to stream to.");
parser.addHelpOption();
parser.addVersionOption();
parser.process(app);

const auto posArgs = parser.positionalArguments();
const auto host = posArgs.isEmpty() ? QString() : posArgs.at(0);
const auto enable = parser.isSet(streamEnabledOption);
const auto advanced = parser.isSet(advancedOption);

Q_INIT_RESOURCE(resources);

MainWindow mainWindow;
MainWindow mainWindow{{host, enable, advanced}};
mainWindow.show();

// enter Qt event loop
Expand Down
3 changes: 3 additions & 0 deletions doc/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Changelog {#Changelog}

### 0.14.0 (git master)

* [191](https://github.com/BlueBrain/Deflect/pull/191):
DesktopStreamer: default host and other options can be specified on the
command line.
* [190](https://github.com/BlueBrain/Deflect/pull/190):
DesktopStreamer: jpeg compression can be turned on or off.
* [188](https://github.com/BlueBrain/Deflect/pull/188):
Expand Down

0 comments on commit 79a04db

Please sign in to comment.