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/baseguiplus.cpp | |
parent | 634cd2063f449c5d38046de88a395af77e2c9ea5 (diff) |
New upstream version 17.2.0~ds0
Diffstat (limited to 'src/baseguiplus.cpp')
-rw-r--r-- | src/baseguiplus.cpp | 100 |
1 files changed, 91 insertions, 9 deletions
diff --git a/src/baseguiplus.cpp b/src/baseguiplus.cpp index 7cf5f24..0ccbdbb 100644 --- a/src/baseguiplus.cpp +++ b/src/baseguiplus.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 @@ -63,6 +63,10 @@ #include "prefinput.h" #endif +#ifdef CHROMECAST_SUPPORT +#include "chromecast.h" +#endif + using namespace Global; BaseGuiPlus::BaseGuiPlus( QWidget * parent, Qt::WindowFlags flags) @@ -169,6 +173,11 @@ BaseGuiPlus::BaseGuiPlus( QWidget * parent, Qt::WindowFlags flags) connect(detachVideoAct, SIGNAL(toggled(bool)), this, SLOT(detachVideo(bool))); #endif +#ifdef CHROMECAST_SUPPORT + playOnChromecastAct = new MyAction(this, "play_on_chromecast"); + connect(playOnChromecastAct, SIGNAL(triggered()), this, SLOT(playOnChromecast())); +#endif + #ifdef SCREENS_SUPPORT sendToScreen_menu = new QMenu(this); sendToScreen_menu->menuAction()->setObjectName("send_to_screen_menu"); @@ -213,6 +222,10 @@ BaseGuiPlus::BaseGuiPlus( QWidget * parent, Qt::WindowFlags flags) connect(this, SIGNAL(preferencesChanged()), this, SLOT(updateGlobalShortcuts())); #endif +#ifdef CHROMECAST_SUPPORT + Chromecast::instance()->setSettings(settings); +#endif + retranslateStrings(); loadConfig(); } @@ -220,6 +233,10 @@ BaseGuiPlus::BaseGuiPlus( QWidget * parent, Qt::WindowFlags flags) BaseGuiPlus::~BaseGuiPlus() { saveConfig(); tray->hide(); + +#ifdef CHROMECAST_SUPPORT + Chromecast::deleteInstance(); +#endif } void BaseGuiPlus::populateMainMenu() { @@ -250,6 +267,11 @@ void BaseGuiPlus::populateMainMenu() { #ifdef SEND_AUDIO_OPTION audioMenu->insertMenu(audiofilter_menu->menuAction(), sendAudio_menu); #endif + +#ifdef CHROMECAST_SUPPORT + playMenu->addSeparator(); + playMenu->addAction(playOnChromecastAct); +#endif } bool BaseGuiPlus::startHidden() { @@ -269,6 +291,16 @@ void BaseGuiPlus::closeEvent( QCloseEvent * e ) { closeWindow(); } +void BaseGuiPlus::updateWidgets() { + qDebug("BaseGuiPlus::updateWidgets"); + + BaseGui::updateWidgets(); + +#ifdef CHROMECAST_SUPPORT + playOnChromecastAct->setEnabled(!core->mdat.filename.isEmpty()); +#endif +} + void BaseGuiPlus::closeWindow() { qDebug("BaseGuiPlus::closeWindow"); @@ -315,6 +347,10 @@ void BaseGuiPlus::retranslateStrings() { detachVideoAct->change("Detach video"); #endif +#ifdef CHROMECAST_SUPPORT + playOnChromecastAct->change(Images::icon("chromecast"), tr("Play on &Chromecast")); +#endif + #ifdef SCREENS_SUPPORT sendToScreen_menu->menuAction()->setText( tr("Send &video to screen") ); sendToScreen_menu->menuAction()->setIcon(Images::icon("send_to_screen")); @@ -486,7 +522,7 @@ void BaseGuiPlus::resizeWindow(int w, int h) { } void BaseGuiPlus::updateMediaInfo() { - qDebug("BaseGuiPlus::updateMediaInfo"); + qDebug("BaseGuiPlus::updateMediaInfo"); BaseGui::updateMediaInfo(); tray->setToolTip( windowTitle() ); @@ -989,24 +1025,39 @@ void BaseGuiPlus::updateSendAudioMenu() { sendAudio_menu->addAction(a); #if USE_PULSEAUDIO_DEVICES - addListToSendAudioMenu( DeviceInfo::paDevices(), "pulse", "pulse::"); + addListToSendAudioMenu( DeviceInfo::paDevices(), "pulse"); #endif #if USE_ALSA_DEVICES - addListToSendAudioMenu( DeviceInfo::alsaDevices(), "alsa", "alsa:device=hw="); + addListToSendAudioMenu( DeviceInfo::alsaDevices(), "alsa"); #endif #if USE_DSOUND_DEVICES - addListToSendAudioMenu( DeviceInfo::dsoundDevices(), "dsound", "dsound:device="); + if (PlayerID::player(pref->mplayer_bin) == PlayerID::MPLAYER) { + addListToSendAudioMenu( DeviceInfo::dsoundDevices(), "dsound"); + } +#endif + +#if MPV_AUDIO_DEVICES + if (PlayerID::player(pref->mplayer_bin) == PlayerID::MPV) { + DeviceInfo::setMpvBin(pref->mplayer_bin); + + #if USE_MPV_ALSA_DEVICES + addListToSendAudioMenu( DeviceInfo::mpvAlsaDevices(), "alsa"); + #endif + + #if USE_MPV_WASAPI_DEVICES + addListToSendAudioMenu( DeviceInfo::mpvWasapiDevices(), "wasapi"); + #endif + } #endif } -void BaseGuiPlus::addListToSendAudioMenu(const DeviceList & audio_devices, const QString & prefix_name, const QString & prefix_device) { +void BaseGuiPlus::addListToSendAudioMenu(const DeviceList & audio_devices, const QString & device_name) { for (int n = 0; n < audio_devices.count(); n++) { QAction * a = new QAction(sendAudio_menu); - QString device_id = audio_devices[n].ID().toString(); - a->setText(prefix_name + " (" + device_id + " - " + audio_devices[n].desc() + ")"); - a->setData(prefix_device + device_id); + a->setText( DeviceInfo::printableName(device_name, audio_devices[n]) ); + a->setData( DeviceInfo::internalName(device_name, audio_devices[n]) ); connect(a, SIGNAL(triggered()), this, SLOT(sendAudioClicked())); sendAudio_menu->addAction(a); } @@ -1022,4 +1073,35 @@ void BaseGuiPlus::sendAudioClicked() { } #endif +#ifdef CHROMECAST_SUPPORT +void BaseGuiPlus::playOnChromecast() { + qDebug("BaseGuiPlus::playOnChromecast"); + + qDebug() << "BaseGuiPlus::playOnChromecast: type:" << core->mdat.type; + qDebug() << "BaseGuiPlus::playOnChromecast: filename:" << core->mdat.filename; + qDebug() << "BaseGuiPlus::playOnChromecast: stream_url:" << core->mdat.stream_url; + qDebug() << "BaseGuiPlus::playOnChromecast: stream_title:" << core->mdat.stream_title; + qDebug() << "BaseGuiPlus::playOnChromecast: stream_path:" << core->mdat.stream_path; + + QString title = core->mdat.displayName(true); + if (core->mdat.type == TYPE_STREAM) { + QString url = core->mdat.filename; + if (!core->mdat.stream_path.isEmpty()) url = core->mdat.stream_path; + Chromecast::instance()->openStream(url, title); + } + else + if (core->mdat.type == TYPE_FILE) { + QString subtitle; + /* + if (MediaSettings::SubNone != core->mset.current_sub_id && MediaSettings::NoneSelected != core->mset.current_sub_id) { + SubData sub = core->mdat.subs.itemAt(core->mset.current_sub_id); + qDebug() << "BaseGuiPlus::playOnChromecast: current sub name:" << sub.name() << "filename:" << sub.filename(); + if (!sub.filename().isEmpty()) subtitle = sub.filename(); else subtitle = sub.name(); + } + */ + Chromecast::instance()->openLocal(core->mdat.filename, title, subtitle); + } +} +#endif + #include "moc_baseguiplus.cpp" |