diff options
author | Mateusz Łukasik <mati75@linuxmint.pl> | 2017-02-03 08:16:09 +0100 |
---|---|---|
committer | Mateusz Łukasik <mati75@linuxmint.pl> | 2017-02-03 08:16:09 +0100 |
commit | bcae744b1bae2f5015cb3efdd0d2226150cd79e5 (patch) | |
tree | 872701745b36fbfbeb16dd1d59d485bc1e494dbd /src/prefnetwork.cpp | |
parent | 634cd2063f449c5d38046de88a395af77e2c9ea5 (diff) |
New upstream version 17.2.0~ds0
Diffstat (limited to 'src/prefnetwork.cpp')
-rw-r--r-- | src/prefnetwork.cpp | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/src/prefnetwork.cpp b/src/prefnetwork.cpp index 6d3647a..118556d 100644 --- a/src/prefnetwork.cpp +++ b/src/prefnetwork.cpp @@ -1,5 +1,5 @@ /* smplayer, GUI front-end for mplayer. - Copyright (C) 2006-2016 Ricardo Villalba <rvm@users.sourceforge.net> + Copyright (C) 2006-2017 Ricardo Villalba <rvm@users.sourceforge.net> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,6 +25,10 @@ #include "retrieveyoutubeurl.h" #endif +#ifdef CHROMECAST_SUPPORT +#include "chromecast.h" +#endif + PrefNetwork::PrefNetwork(QWidget * parent, Qt::WindowFlags f) : PrefWidget(parent, f ) { @@ -105,6 +109,13 @@ void PrefNetwork::setData(Preferences * pref) { setYTQuality( pref->yt_quality ); yt_user_agent_edit->setText( pref->yt_user_agent ); #endif + +#ifdef CHROMECAST_SUPPORT + Chromecast * cc = Chromecast::instance(); + setLocalIP(cc->localAddress(), cc->localAddresses()); + port_spin->setValue(cc->serverPort()); + directory_listing_check->setChecked(cc->directoryListing()); +#endif } void PrefNetwork::getData(Preferences * pref) { @@ -123,6 +134,13 @@ void PrefNetwork::getData(Preferences * pref) { pref->yt_quality = YTQuality(); pref->yt_user_agent = yt_user_agent_edit->text(); #endif + +#ifdef CHROMECAST_SUPPORT + Chromecast * cc = Chromecast::instance(); + cc->setLocalAddress(localIP()); + cc->setServerPort(port_spin->value()); + cc->setDirectoryListing(directory_listing_check->isChecked()); +#endif } void PrefNetwork::setProxyType(int type) { @@ -163,6 +181,33 @@ void PrefNetwork::streaming_type_combo_changed(int i) { youtube_box->setEnabled(i == Preferences::StreamingYT || i == Preferences::StreamingAuto); } +#ifdef CHROMECAST_SUPPORT +void PrefNetwork::setLocalIP(const QString & ip, const QStringList & values) { + local_ip_combo->clear(); + local_ip_combo->addItem(tr("Auto")); + local_ip_combo->addItems(values); + + if (ip.isEmpty()) { + local_ip_combo->setCurrentIndex(0); + } else { + int pos = local_ip_combo->findText(ip); + if (pos > -1) { + local_ip_combo->setCurrentIndex(pos); + } else { + local_ip_combo->setEditText(ip); + } + } +} + +QString PrefNetwork::localIP() { + if (local_ip_combo->currentIndex() == 0) { + return ""; + } else { + return local_ip_combo->currentText(); + } +} +#endif + void PrefNetwork::createHelp() { clearHelp(); @@ -203,6 +248,23 @@ void PrefNetwork::createHelp() { */ #endif +#ifdef CHROMECAST_SUPPORT + addSectionTitle(tr("Chromecast")); + + setWhatsThis(local_ip_combo, tr("Local IP"), + tr("The local IP address of this computer. It will be passed to Chromecast " + "so that it can access the files from this computer.") ); + + setWhatsThis(port_spin, tr("Port"), + tr("The port that the web server will use.") ); + + setWhatsThis(directory_listing_check, tr("Directory listing"), + tr("When the web server is running, any device in your network can access the " + "files from this computer. If this option is on, any device can get a listing " + "of the files in this computer. " + "If this option is off, the list won't be available.") ); +#endif + addSectionTitle(tr("Proxy")); setWhatsThis(use_proxy_check, tr("Enable proxy"), |