Various fixes:

- Remove a traceback on exiting OpenLP
- Add back toolbar separator
- Fix biblegateway webpage parsing for tests
- Remove live_display argument from VlcPlayer.setup, is incorrectly passed the preview value
This commit is contained in:
Mattias Põldaru 2020-05-18 18:00:40 +00:00 committed by Raoul Snyman
parent a9a96146b0
commit 4c2c7b6ab1
6 changed files with 17 additions and 16 deletions

View File

@ -191,7 +191,7 @@ class MediaManagerItem(QtWidgets.QWidget, RegistryProperties):
if self.can_add_to_service: if self.can_add_to_service:
toolbar_actions.append(['Service', StringContent.Service, UiIcons().add, self.on_add_click]) toolbar_actions.append(['Service', StringContent.Service, UiIcons().add, self.on_add_click])
for action in toolbar_actions: for action in toolbar_actions:
if action[0] == StringContent.Preview: if action[1] == StringContent.Preview:
self.toolbar.addSeparator() self.toolbar.addSeparator()
self.toolbar.add_toolbar_action('{name}{action}Action'.format(name=self.plugin.name, action=action[0]), self.toolbar.add_toolbar_action('{name}{action}Action'.format(name=self.plugin.name, action=action[0]),
text=self.plugin.get_string(action[1])['title'], icon=action[2], text=self.plugin.get_string(action[1])['title'], icon=action[2],

View File

@ -115,6 +115,6 @@ def make_remove_thread(thread_name):
:param str thread_name: The name of the thread to stop and remove :param str thread_name: The name of the thread to stop and remove
""" """
application = Registry().get('application') application = Registry().get('application')
if thread_name in application.worker_threads: if application and thread_name in application.worker_threads:
del application.worker_threads[thread_name] del application.worker_threads[thread_name]
return remove_thread return remove_thread

View File

@ -186,7 +186,7 @@ class MediaController(RegistryBase, LogMixin, RegistryProperties):
controller.has_audio = True controller.has_audio = True
if preview: if preview:
controller.has_audio = False controller.has_audio = False
self.vlc_player.setup(controller, self._define_display(controller), preview) self.vlc_player.setup(controller, self._define_display(controller))
@staticmethod @staticmethod
def set_controls_visible(controller, value): def set_controls_visible(controller, value):

View File

@ -97,12 +97,11 @@ class VlcPlayer(MediaPlayer):
self.parent = parent self.parent = parent
self.can_folder = True self.can_folder = True
def setup(self, controller, display, live_display): def setup(self, controller, display):
""" """
Set up the media player Set up the media player
:param controller: The display where the media is :param controller: The display where the media is.
:param live_display: Is the display a live one.
:return: :return:
""" """
vlc = get_vlc() vlc = get_vlc()
@ -115,7 +114,7 @@ class VlcPlayer(MediaPlayer):
controller.vlc_widget.setFrameStyle(QtWidgets.QFrame.NoFrame) controller.vlc_widget.setFrameStyle(QtWidgets.QFrame.NoFrame)
# creating a basic vlc instance # creating a basic vlc instance
command_line_options = '--no-video-title-show ' command_line_options = '--no-video-title-show '
if self.settings.value('advanced/hide mouse') and live_display: if self.settings.value('advanced/hide mouse') and controller.is_live:
command_line_options += '--mouse-hide-timeout=0 ' command_line_options += '--mouse-hide-timeout=0 '
if self.settings.value('media/vlc arguments'): if self.settings.value('media/vlc arguments'):
options = command_line_options + ' ' + self.settings.value('media/vlc arguments') options = command_line_options + ' ' + self.settings.value('media/vlc arguments')

View File

@ -363,9 +363,11 @@ class BGExtract(RegistryProperties):
return None return None
books = [] books = []
for book in content: for book in content:
book = book.find('td') td_element = book.find('td', {'class': 'book-name'})
if book: span_element = td_element.find('span', {'class': 'collapse-icon'})
books.append(book.contents[1]) book_name = span_element.next_sibling.strip()
if book_name:
books.append(book_name)
return books return books
def get_bibles_from_http(self): def get_bibles_from_http(self):
@ -379,7 +381,7 @@ class BGExtract(RegistryProperties):
soup = get_soup_for_bible_ref(bible_url) soup = get_soup_for_bible_ref(bible_url)
if not soup: if not soup:
return None return None
bible_select = soup.find('select', {'class': 'search-translation-select'}) bible_select = soup.find('select', {'class': 'search-dropdown'})
if not bible_select: if not bible_select:
log.debug('No select tags found - did site change?') log.debug('No select tags found - did site change?')
return None return None

View File

@ -109,7 +109,7 @@ def test_setup(MockedQtWidgets, mocked_get_vlc, mocked_is_macosx, mocked_is_win,
vlc_player = VlcPlayer(None) vlc_player = VlcPlayer(None)
# WHEN: setup() is run # WHEN: setup() is run
vlc_player.setup(mocked_output_display, mocked_controller, True) vlc_player.setup(mocked_output_display, mocked_controller)
# THEN: The VLC widget should be set up correctly # THEN: The VLC widget should be set up correctly
assert mocked_output_display.vlc_widget == mocked_qframe assert mocked_output_display.vlc_widget == mocked_qframe
@ -157,7 +157,7 @@ def test_setup_has_audio(MockedQtWidgets, mocked_get_vlc, mocked_is_macosx, mock
vlc_player = VlcPlayer(None) vlc_player = VlcPlayer(None)
# WHEN: setup() is run # WHEN: setup() is run
vlc_player.setup(mocked_output_display, mocked_controller, True) vlc_player.setup(mocked_output_display, mocked_controller)
# THEN: The VLC instance should be created with the correct options # THEN: The VLC instance should be created with the correct options
mocked_vlc.Instance.assert_called_with('--no-video-title-show ') mocked_vlc.Instance.assert_called_with('--no-video-title-show ')
@ -192,7 +192,7 @@ def test_setup_visible_mouse(MockedQtWidgets, mocked_get_vlc, mocked_is_macosx,
vlc_player = VlcPlayer(None) vlc_player = VlcPlayer(None)
# WHEN: setup() is run # WHEN: setup() is run
vlc_player.setup(mocked_output_display, mocked_controller, True) vlc_player.setup(mocked_output_display, mocked_controller)
# THEN: The VLC instance should be created with the correct options # THEN: The VLC instance should be created with the correct options
mocked_vlc.Instance.assert_called_with('--no-video-title-show ') mocked_vlc.Instance.assert_called_with('--no-video-title-show ')
@ -227,7 +227,7 @@ def test_setup_windows(MockedQtWidgets, mocked_get_vlc, mocked_is_macosx, mocked
vlc_player = VlcPlayer(None) vlc_player = VlcPlayer(None)
# WHEN: setup() is run # WHEN: setup() is run
vlc_player.setup(mocked_output_display, mocked_controller, True) vlc_player.setup(mocked_output_display, mocked_controller)
# THEN: set_hwnd should be called # THEN: set_hwnd should be called
mocked_media_player_new.set_hwnd.assert_called_with(2) mocked_media_player_new.set_hwnd.assert_called_with(2)
@ -262,7 +262,7 @@ def test_setup_osx(MockedQtWidgets, mocked_get_vlc, mocked_is_macosx, mocked_is_
vlc_player = VlcPlayer(None) vlc_player = VlcPlayer(None)
# WHEN: setup() is run # WHEN: setup() is run
vlc_player.setup(mocked_output_display, mocked_controller, True) vlc_player.setup(mocked_output_display, mocked_controller)
# THEN: set_nsobject should be called # THEN: set_nsobject should be called
mocked_media_player_new.set_nsobject.assert_called_with(2) mocked_media_player_new.set_nsobject.assert_called_with(2)