forked from openlp/openlp
Fix line calculation for the theme preview. Try to make VLC loading more robust.
This commit is contained in:
parent
8b489de954
commit
f27fded597
@ -463,7 +463,7 @@ class ThemePreviewRenderer(LogMixin, DisplayWindow):
|
||||
'title': TITLE,
|
||||
'authors_none_label': translate('OpenLP.Ui', 'Written by'),
|
||||
'authors_words_label': translate('SongsPlugin.AuthorType', 'Words', 'Author who wrote the lyrics of a song'),
|
||||
'authors_words': AUTHOR,
|
||||
'authors_words': [AUTHOR],
|
||||
'copyright': FOOTER_COPYRIGHT,
|
||||
'ccli_license': Settings().value('core/ccli number'),
|
||||
'ccli_license_label': translate('SongsPlugin.MediaItem', 'CCLI License'),
|
||||
@ -489,10 +489,10 @@ class ThemePreviewRenderer(LogMixin, DisplayWindow):
|
||||
if not self.force_page:
|
||||
self.set_theme(theme_data)
|
||||
self.theme_height = theme_data.font_main_height
|
||||
slides = self.format_slide(render_tags(VERSE), None)
|
||||
slides = self.format_slide(VERSE, None)
|
||||
verses = dict()
|
||||
verses['title'] = TITLE
|
||||
verses['text'] = slides[0]
|
||||
verses['text'] = render_tags(slides[0])
|
||||
verses['verse'] = 'V1'
|
||||
verses['footer'] = self.generate_footer()
|
||||
self.load_verses([verses])
|
||||
@ -734,7 +734,7 @@ class ThemePreviewRenderer(LogMixin, DisplayWindow):
|
||||
:param text: The text to check. It may contain HTML tags.
|
||||
"""
|
||||
self.clear_slides()
|
||||
self.run_javascript('Display.addTextSlide("v1", "{text}", "Dummy Footer");'.format(text=text), is_sync=True)
|
||||
self.run_javascript('Display.addTextSlide("v1", "{text}", "Dummy Footer");'.format(text=text.replace('"', '\\"')), is_sync=True)
|
||||
does_text_fits = self.run_javascript('Display.doesContentFit();', is_sync=True)
|
||||
return does_text_fits
|
||||
|
||||
|
@ -28,7 +28,6 @@ import os
|
||||
import sys
|
||||
import threading
|
||||
from datetime import datetime
|
||||
import vlc
|
||||
|
||||
from PyQt5 import QtWidgets
|
||||
|
||||
@ -65,25 +64,27 @@ def get_vlc():
|
||||
|
||||
:return: The "vlc" module, or None
|
||||
"""
|
||||
if 'vlc' in sys.modules:
|
||||
# If VLC has already been imported, no need to do all the stuff below again
|
||||
is_vlc_available = False
|
||||
# Import the VLC module if not already done
|
||||
if 'vlc' not in sys.modules:
|
||||
try:
|
||||
is_vlc_available = bool(sys.modules['vlc'].get_default_instance())
|
||||
except Exception:
|
||||
pass
|
||||
if is_vlc_available:
|
||||
return sys.modules['vlc']
|
||||
else:
|
||||
import vlc
|
||||
except ImportError:
|
||||
return None
|
||||
else:
|
||||
return vlc
|
||||
# Verify that VLC is also loadable
|
||||
is_vlc_available = False
|
||||
try:
|
||||
is_vlc_available = bool(sys.modules['vlc'].get_default_instance())
|
||||
except Exception:
|
||||
pass
|
||||
if is_vlc_available:
|
||||
return sys.modules['vlc']
|
||||
return None
|
||||
|
||||
|
||||
# On linux we need to initialise X threads, but not when running tests.
|
||||
# This needs to happen on module load and not in get_vlc(), otherwise it can cause crashes on some DE on some setups
|
||||
# (reported on Gnome3, Unity, Cinnamon, all GTK+ based) when using native filedialogs...
|
||||
if is_linux() and 'nose' not in sys.argv[0] and get_vlc():
|
||||
if is_linux() and 'pytest' not in sys.argv[0] and get_vlc():
|
||||
try:
|
||||
try:
|
||||
x11 = ctypes.cdll.LoadLibrary('libX11.so.6')
|
||||
|
@ -178,8 +178,10 @@ class ThemeForm(QtWidgets.QWizard, Ui_ThemeWizard, RegistryProperties):
|
||||
self.display_aspect_ratio = self.renderer.width() / self.renderer.height()
|
||||
except ZeroDivisionError:
|
||||
self.display_aspect_ratio = 1
|
||||
self.preview_area_layout.set_aspect_ratio(self.display_aspect_ratio)
|
||||
self.preview_box.set_scale(float(self.preview_box.width()) / self.renderer.width())
|
||||
# Make sure we don't resize before the widgets are actually created
|
||||
if hasattr(self, 'preview_area_layout'):
|
||||
self.preview_area_layout.set_aspect_ratio(self.display_aspect_ratio)
|
||||
self.preview_box.set_scale(float(self.preview_box.width()) / self.renderer.width())
|
||||
|
||||
def validateCurrentPage(self):
|
||||
"""
|
||||
@ -212,9 +214,9 @@ class ThemeForm(QtWidgets.QWizard, Ui_ThemeWizard, RegistryProperties):
|
||||
except ZeroDivisionError:
|
||||
self.display_aspect_ratio = 1
|
||||
self.preview_area_layout.set_aspect_ratio(self.display_aspect_ratio)
|
||||
self.preview_box.generate_preview(self.theme, False, False)
|
||||
self.preview_box.show()
|
||||
self.resizeEvent()
|
||||
self.preview_box.show()
|
||||
self.preview_box.generate_preview(self.theme, False, False)
|
||||
|
||||
def on_custom_1_button_clicked(self, number):
|
||||
"""
|
||||
|
@ -476,7 +476,7 @@ class ThemeManager(QtWidgets.QWidget, RegistryBase, Ui_ThemeManager, LogMixin, R
|
||||
if not theme_paths:
|
||||
theme = Theme()
|
||||
theme.theme_name = UiStrings().Default
|
||||
self._write_theme(theme)
|
||||
self.save_theme(theme)
|
||||
Settings().setValue(self.settings_section + '/global theme', theme.theme_name)
|
||||
self.application.set_normal_cursor()
|
||||
|
||||
|
@ -259,35 +259,36 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties):
|
||||
# TODO needs to be fixed as no idea why this fails
|
||||
# media.sort(key=lambda file_path: get_natural_key(file_path.name))
|
||||
for track in media:
|
||||
track_info = QtCore.QFileInfo(track)
|
||||
track_str = str(track)
|
||||
track_info = QtCore.QFileInfo(track_str)
|
||||
item_name = None
|
||||
if track.startswith('optical:'):
|
||||
if track_str.startswith('optical:'):
|
||||
# Handle optical based item
|
||||
(file_name, title, audio_track, subtitle_track, start, end, clip_name) = parse_optical_path(track)
|
||||
(file_name, title, audio_track, subtitle_track, start, end, clip_name) = parse_optical_path(track_str)
|
||||
item_name = QtWidgets.QListWidgetItem(clip_name)
|
||||
item_name.setIcon(UiIcons().optical)
|
||||
item_name.setData(QtCore.Qt.UserRole, track)
|
||||
item_name.setData(QtCore.Qt.UserRole, track_str)
|
||||
item_name.setToolTip('{name}@{start}-{end}'.format(name=file_name,
|
||||
start=format_milliseconds(start),
|
||||
end=format_milliseconds(end)))
|
||||
elif not os.path.exists(track):
|
||||
# File doesn't exist, mark as error.
|
||||
file_name = os.path.split(str(track))[1]
|
||||
file_name = os.path.split(track_str)[1]
|
||||
item_name = QtWidgets.QListWidgetItem(file_name)
|
||||
item_name.setIcon(UiIcons().error)
|
||||
item_name.setData(QtCore.Qt.UserRole, track)
|
||||
item_name.setToolTip(track)
|
||||
item_name.setData(QtCore.Qt.UserRole, track_str)
|
||||
item_name.setToolTip(track_str)
|
||||
elif track_info.isFile():
|
||||
# Normal media file handling.
|
||||
file_name = os.path.split(str(track))[1]
|
||||
file_name = os.path.split(track_str)[1]
|
||||
item_name = QtWidgets.QListWidgetItem(file_name)
|
||||
search = file_name.split('.')[-1].lower()
|
||||
if '*.{text}'.format(text=search) in self.media_controller.audio_extensions_list:
|
||||
item_name.setIcon(UiIcons().audio)
|
||||
else:
|
||||
item_name.setIcon(UiIcons().video)
|
||||
item_name.setData(QtCore.Qt.UserRole, track)
|
||||
item_name.setToolTip(track)
|
||||
item_name.setData(QtCore.Qt.UserRole, track_str)
|
||||
item_name.setToolTip(track_str)
|
||||
if item_name:
|
||||
self.list_view.addItem(item_name)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user