Merge branch 'fix-reselected-theme-stream' into 'master'

Fix reselected theme stream

Closes #576

See merge request openlp/openlp!330
This commit is contained in:
Tim Bentley 2021-06-17 20:56:05 +00:00
commit 47e49dd845
4 changed files with 31 additions and 8 deletions

View File

@ -221,7 +221,8 @@ class BackgroundPage(GridLayoutPage):
"""
if get_vlc():
stream_selector_form = StreamSelectorForm(self, self.set_stream, True)
if self.stream_lineedit.text():
# prefill in the form any device stream already defined
if self.stream_lineedit.text() and self.stream_lineedit.text().startswith("devicestream"):
stream_selector_form.set_mrl(self.stream_lineedit.text())
stream_selector_form.exec()
del stream_selector_form
@ -235,7 +236,8 @@ class BackgroundPage(GridLayoutPage):
"""
if get_vlc():
stream_selector_form = NetworkStreamSelectorForm(self, self.set_stream, True)
if self.stream_lineedit.text():
# prefill in the form any network stream already defined
if self.stream_lineedit.text() and self.stream_lineedit.text().startswith("networkstream"):
stream_selector_form.set_mrl(self.stream_lineedit.text())
stream_selector_form.exec()
del stream_selector_form

View File

@ -20,11 +20,13 @@
##########################################################################
import logging
import re
from PyQt5 import QtWidgets
from openlp.core.common.i18n import translate
from openlp.plugins.media.forms import StreamSelectorFormBase, VLCOptionsWidget
from openlp.core.ui.media import parse_stream_path
log = logging.getLogger(__name__)
@ -79,3 +81,18 @@ class NetworkStreamSelectorForm(StreamSelectorFormBase):
def on_updates(self):
self.update_mrl_options(self.net_mrl_lineedit.text(), '')
def set_mrl(self, network_stream_str):
"""
Setup the stream widgets based on the saved stream string. This is best effort as the string is
editable for the user.
"""
(name, mrl, options) = parse_stream_path(network_stream_str)
self.net_mrl_lineedit.setText(mrl)
cache = re.search(r'live-caching=(\d+)', options)
if cache:
self.more_options_group.caching.setValue(int(cache.group(1)))
self.more_options_group.mrl_lineedit.setText(mrl)
self.more_options_group.vlc_options_lineedit.setText(options)

View File

@ -386,7 +386,7 @@ class CaptureDigitalTVWidget(CaptureModeWidget):
break
freq = re.search(r'frequency=(\d+)000', main)
if freq:
self.freq.setValue(int(freq.group(1)))
self.dvb_freq.setValue(int(freq.group(1)))
modulation = re.search(r'modulation=([\w-]+)', main)
if modulation and system:
if system.group(1) in ['dvb-c', 'cqam']:
@ -529,7 +529,7 @@ class JackAudioKitWidget(CaptureModeWidget):
options += ' :jack-input-auto-connect'
self.callback(main_file, options)
def has_support_for_mrl(self, mrl):
def has_support_for_mrl(self, mrl, options):
return mrl.startswith('jack')
def set_mrl(self, main, options):
@ -584,7 +584,7 @@ https://github.com/videolan/vlc/blob/13e18f3182e2a7b425411ce70ed83161108c3d1f/mo
# options = 'input-slave=qtsound://{adev}'.format(adev=adev)
self.callback(main_file, '')
def has_support_for_mrl(self, mrl):
def has_support_for_mrl(self, mrl, options):
return mrl.startswith('avcapture')
def set_mrl(self, main, options):
@ -632,17 +632,20 @@ class CaptureVideoDirectShowWidget(CaptureVideoQtDetectWidget):
options += ':dshow-size={vsize}'.format(vsize=vsize)
self.callback(main_file, options)
def has_support_for_mrl(self, mrl):
def has_support_for_mrl(self, mrl, options):
return mrl.startswith('dshow')
def set_mrl(self, main, options):
vdev = re.search(r'"dshow-vdev=(.+)"', main)
vsize = re.search(r'dshow-size=(\d+)', options)
vdev = re.search(r'"dshow-vdev=(.+)"', options)
if vdev:
for i in range(self.video_devices_combo_box.count()):
if self.video_devices_combo_box.itemText(i) == vdev.group(1):
self.video_devices_combo_box.setCurrentIndex(i)
if vsize:
self.video_size_lineedit.setText(vsize.group(1))
break
adev = re.search(r'"dshow-adev=(.+)"', main)
adev = re.search(r'"dshow-adev=(.+)"', options)
if adev:
for i in range(self.audio_devices_combo_box.count()):
if self.audio_devices_combo_box.itemText(i) == adev.group(1):

View File

@ -60,6 +60,7 @@ class StreamSelectorForm(StreamSelectorFormBase, Ui_StreamSelector):
for i in range(self.stacked_modes_layout.count()):
if self.stacked_modes_layout.widget(i).has_support_for_mrl(mrl, options):
self.stacked_modes_layout.setCurrentIndex(i)
self.capture_mode_combo_box.setCurrentIndex(i)
self.stacked_modes_layout.widget(i).set_mrl(mrl, options)
break
cache = re.search(r'live-caching=(\d+)', options)