forked from openlp/openlp
Review Fixes
This commit is contained in:
parent
ead2daeed4
commit
23990c168a
@ -34,7 +34,7 @@ from subprocess import Popen, PIPE
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import Receiver, checkDirectoryExists
|
from openlp.core.lib import Receiver, check_directory_exists
|
||||||
from openlp.core.resources import qInitResources
|
from openlp.core.resources import qInitResources
|
||||||
from openlp.core.ui.mainwindow import MainWindow
|
from openlp.core.ui.mainwindow import MainWindow
|
||||||
from openlp.core.ui.exceptionform import ExceptionForm
|
from openlp.core.ui.exceptionform import ExceptionForm
|
||||||
@ -243,7 +243,7 @@ def main():
|
|||||||
help='Set the Qt4 style (passed directly to Qt4).')
|
help='Set the Qt4 style (passed directly to Qt4).')
|
||||||
# Set up logging
|
# Set up logging
|
||||||
log_path = AppLocation.get_directory(AppLocation.CacheDir)
|
log_path = AppLocation.get_directory(AppLocation.CacheDir)
|
||||||
checkDirectoryExists(log_path)
|
check_directory_exists(log_path)
|
||||||
filename = os.path.join(log_path, u'openlp.log')
|
filename = os.path.join(log_path, u'openlp.log')
|
||||||
logfile = logging.FileHandler(filename, u'w')
|
logfile = logging.FileHandler(filename, u'w')
|
||||||
logfile.setFormatter(logging.Formatter(
|
logfile.setFormatter(logging.Formatter(
|
||||||
@ -280,4 +280,4 @@ if __name__ == u'__main__':
|
|||||||
"""
|
"""
|
||||||
Instantiate and run the application.
|
Instantiate and run the application.
|
||||||
"""
|
"""
|
||||||
main()
|
main()
|
@ -306,14 +306,14 @@ def expand_tags(text):
|
|||||||
text = text.replace(tag[u'end tag'], tag[u'end html'])
|
text = text.replace(tag[u'end tag'], tag[u'end html'])
|
||||||
return text
|
return text
|
||||||
|
|
||||||
def checkDirectoryExists(dir):
|
def check_directory_exists(dir):
|
||||||
"""
|
"""
|
||||||
Check a theme directory exists and if not create it
|
Check a theme directory exists and if not create it
|
||||||
|
|
||||||
``dir``
|
``dir``
|
||||||
Theme directory to make sure exists
|
Theme directory to make sure exists
|
||||||
"""
|
"""
|
||||||
log.debug(u'checkDirectoryExists')
|
log.debug(u'check_directory_exists')
|
||||||
if not os.path.exists(dir):
|
if not os.path.exists(dir):
|
||||||
os.mkdir(dir)
|
os.mkdir(dir)
|
||||||
|
|
||||||
@ -337,4 +337,4 @@ from dockwidget import OpenLPDockWidget
|
|||||||
from renderer import Renderer
|
from renderer import Renderer
|
||||||
from rendermanager import RenderManager
|
from rendermanager import RenderManager
|
||||||
from mediamanageritem import MediaManagerItem
|
from mediamanageritem import MediaManagerItem
|
||||||
from baselistwithdnd import BaseListWithDnD
|
from baselistwithdnd import BaseListWithDnD
|
@ -29,57 +29,39 @@ Provide Html Tag management and Display Tag access class
|
|||||||
|
|
||||||
from openlp.core.lib import base_html_expands
|
from openlp.core.lib import base_html_expands
|
||||||
|
|
||||||
class HtmlTags(object):
|
|
||||||
"""
|
|
||||||
"""
|
|
||||||
def __init__(self):
|
|
||||||
self.html_expands = []
|
|
||||||
self.reset_list()
|
|
||||||
|
|
||||||
def reset_list(self):
|
|
||||||
"""
|
|
||||||
"""
|
|
||||||
self.html_expands = []
|
|
||||||
for html in base_html_expands:
|
|
||||||
self.html_expands.append(html)
|
|
||||||
|
|
||||||
def add_tag(self, html):
|
|
||||||
"""
|
|
||||||
"""
|
|
||||||
self.html_expands.append(html)
|
|
||||||
|
|
||||||
|
|
||||||
class DisplayTags(object):
|
class DisplayTags(object):
|
||||||
"""
|
"""
|
||||||
Static Class to HTML Tags to be access around the code the list is managed
|
Static Class to HTML Tags to be access around the code the list is managed
|
||||||
by the Options Tab.
|
by the Options Tab.
|
||||||
"""
|
"""
|
||||||
html_tags = HtmlTags()
|
html_expands = []
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_html_tags():
|
def get_html_tags():
|
||||||
"""
|
"""
|
||||||
Provide access to the html_expands list.
|
Provide access to the html_expands list.
|
||||||
"""
|
"""
|
||||||
return DisplayTags.html_tags.html_expands
|
return DisplayTags.html_expands
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def reset_html_tags():
|
def reset_html_tags():
|
||||||
"""
|
"""
|
||||||
Resets the html_expands list.
|
Resets the html_expands list.
|
||||||
"""
|
"""
|
||||||
return DisplayTags.html_tags.reset_list()
|
DisplayTags.html_expands = []
|
||||||
|
for html in base_html_expands:
|
||||||
|
DisplayTags.html_expands.append(html)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def add_html_tag(tag):
|
def add_html_tag(tag):
|
||||||
"""
|
"""
|
||||||
Add a new tag to the list
|
Add a new tag to the list
|
||||||
"""
|
"""
|
||||||
return DisplayTags.html_tags.add_tag(tag)
|
DisplayTags.html_expands.append(tag)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def remove_html_tag(id):
|
def remove_html_tag(id):
|
||||||
"""
|
"""
|
||||||
Removes amd individual html_expands list.
|
Removes amd individual html_expands list.
|
||||||
"""
|
"""
|
||||||
return DisplayTags.html_tags.html_expands.pop(id)
|
DisplayTags.html_expands.pop(id)
|
||||||
|
@ -88,7 +88,7 @@ class SpellTextEdit(QtGui.QPlainTextEdit):
|
|||||||
popupMenu.insertMenu(popupMenu.actions()[0], spell_menu)
|
popupMenu.insertMenu(popupMenu.actions()[0], spell_menu)
|
||||||
tagMenu = QtGui.QMenu(translate('OpenLP.SpellTextEdit',
|
tagMenu = QtGui.QMenu(translate('OpenLP.SpellTextEdit',
|
||||||
'Formatting Tags'))
|
'Formatting Tags'))
|
||||||
for html in DisplayTags.get_html_tags().html_expands:
|
for html in DisplayTags.get_html_tags():
|
||||||
action = SpellAction( html[u'desc'], tagMenu)
|
action = SpellAction( html[u'desc'], tagMenu)
|
||||||
action.correct.connect(self.htmlTag)
|
action.correct.connect(self.htmlTag)
|
||||||
tagMenu.addAction(action)
|
tagMenu.addAction(action)
|
||||||
@ -110,7 +110,7 @@ class SpellTextEdit(QtGui.QPlainTextEdit):
|
|||||||
"""
|
"""
|
||||||
Replaces the selected text with word.
|
Replaces the selected text with word.
|
||||||
"""
|
"""
|
||||||
for html in DisplayTags.get_html_tags().html_expands:
|
for html in DisplayTags.get_html_tags():
|
||||||
if tag == html[u'desc']:
|
if tag == html[u'desc']:
|
||||||
cursor = self.textCursor()
|
cursor = self.textCursor()
|
||||||
if self.textCursor().hasSelection():
|
if self.textCursor().hasSelection():
|
||||||
@ -158,4 +158,4 @@ class SpellAction(QtGui.QAction):
|
|||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
QtGui.QAction.__init__(self, *args)
|
QtGui.QAction.__init__(self, *args)
|
||||||
self.triggered.connect(lambda x: self.correct.emit(
|
self.triggered.connect(lambda x: self.correct.emit(
|
||||||
unicode(self.text())))
|
unicode(self.text())))
|
||||||
|
@ -57,7 +57,7 @@ class DisplayTagTab(SettingsTab):
|
|||||||
user_expands = QtCore.QSettings().value(u'displayTags/html_tags',
|
user_expands = QtCore.QSettings().value(u'displayTags/html_tags',
|
||||||
QtCore.QVariant(u'')).toString()
|
QtCore.QVariant(u'')).toString()
|
||||||
# cPickle only accepts str not unicode strings
|
# cPickle only accepts str not unicode strings
|
||||||
user_tags = cPickle.loads(str(user_expands))
|
user_tags = cPickle.loads(str(unicode(user_expands).encode(u'utf8')))
|
||||||
# If we have some user ones added them as well
|
# If we have some user ones added them as well
|
||||||
for t in user_tags:
|
for t in user_tags:
|
||||||
DisplayTags.add_html_tag(t)
|
DisplayTags.add_html_tag(t)
|
||||||
|
@ -36,7 +36,7 @@ from openlp.core.ui import FileRenameForm, ThemeForm
|
|||||||
from openlp.core.theme import Theme
|
from openlp.core.theme import Theme
|
||||||
from openlp.core.lib import OpenLPToolbar, ThemeXML, get_text_file_string, \
|
from openlp.core.lib import OpenLPToolbar, ThemeXML, get_text_file_string, \
|
||||||
build_icon, Receiver, SettingsManager, translate, check_item_selected, \
|
build_icon, Receiver, SettingsManager, translate, check_item_selected, \
|
||||||
BackgroundType, BackgroundGradientType, checkDirectoryExists
|
BackgroundType, BackgroundGradientType, check_directory_exists
|
||||||
from openlp.core.utils import AppLocation, get_filesystem_encoding
|
from openlp.core.utils import AppLocation, get_filesystem_encoding
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -130,9 +130,9 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
# Variables
|
# Variables
|
||||||
self.themelist = []
|
self.themelist = []
|
||||||
self.path = AppLocation.get_section_data_path(self.settingsSection)
|
self.path = AppLocation.get_section_data_path(self.settingsSection)
|
||||||
checkDirectoryExists(self.path)
|
check_directory_exists(self.path)
|
||||||
self.thumbPath = os.path.join(self.path, u'thumbnails')
|
self.thumbPath = os.path.join(self.path, u'thumbnails')
|
||||||
checkDirectoryExists(self.thumbPath)
|
check_directory_exists(self.thumbPath)
|
||||||
self.themeForm.path = self.path
|
self.themeForm.path = self.path
|
||||||
self.oldBackgroundImage = None
|
self.oldBackgroundImage = None
|
||||||
# Last little bits of setting up
|
# Last little bits of setting up
|
||||||
@ -492,7 +492,7 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
theme_dir = None
|
theme_dir = None
|
||||||
if osfile.endswith(os.path.sep):
|
if osfile.endswith(os.path.sep):
|
||||||
theme_dir = os.path.join(dir, osfile)
|
theme_dir = os.path.join(dir, osfile)
|
||||||
checkDirectoryExists(theme_dir)
|
check_directory_exists(theme_dir)
|
||||||
else:
|
else:
|
||||||
fullpath = os.path.join(dir, osfile)
|
fullpath = os.path.join(dir, osfile)
|
||||||
names = osfile.split(os.path.sep)
|
names = osfile.split(os.path.sep)
|
||||||
@ -502,7 +502,7 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
themename = names[0]
|
themename = names[0]
|
||||||
if theme_dir is None:
|
if theme_dir is None:
|
||||||
theme_dir = os.path.join(dir, names[0])
|
theme_dir = os.path.join(dir, names[0])
|
||||||
checkDirectoryExists(theme_dir)
|
check_directory_exists(theme_dir)
|
||||||
if os.path.splitext(ucsfile)[1].lower() in [u'.xml']:
|
if os.path.splitext(ucsfile)[1].lower() in [u'.xml']:
|
||||||
xml_data = zip.read(file)
|
xml_data = zip.read(file)
|
||||||
try:
|
try:
|
||||||
@ -522,7 +522,7 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
self.generateAndSaveImage(dir, themename, theme)
|
self.generateAndSaveImage(dir, themename, theme)
|
||||||
else:
|
else:
|
||||||
Receiver.send_message(u'openlp_error_message', {
|
Receiver.send_message(u'openlp_error_message', {
|
||||||
u'title': translate('OpenLP.ThemeManager', \
|
u'title': translate('OpenLP.ThemeManager',
|
||||||
'Validation Error'),
|
'Validation Error'),
|
||||||
u'message':translate('OpenLP.ThemeManager',
|
u'message':translate('OpenLP.ThemeManager',
|
||||||
'File is not a valid theme.')})
|
'File is not a valid theme.')})
|
||||||
@ -530,7 +530,7 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
filename)
|
filename)
|
||||||
except (IOError, NameError):
|
except (IOError, NameError):
|
||||||
Receiver.send_message(u'openlp_error_message', {
|
Receiver.send_message(u'openlp_error_message', {
|
||||||
u'title': translate('OpenLP.ThemeManager', \
|
u'title': translate('OpenLP.ThemeManager',
|
||||||
'Validation Error'),
|
'Validation Error'),
|
||||||
u'message':translate('OpenLP.ThemeManager',
|
u'message':translate('OpenLP.ThemeManager',
|
||||||
'File is not a valid theme.')})
|
'File is not a valid theme.')})
|
||||||
@ -567,7 +567,7 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
theme_dir = os.path.join(self.path, themeName)
|
theme_dir = os.path.join(self.path, themeName)
|
||||||
if os.path.exists(theme_dir):
|
if os.path.exists(theme_dir):
|
||||||
Receiver.send_message(u'openlp_error_message', {
|
Receiver.send_message(u'openlp_error_message', {
|
||||||
u'title': translate('OpenLP.ThemeManager', \
|
u'title': translate('OpenLP.ThemeManager',
|
||||||
'Validation Error'),
|
'Validation Error'),
|
||||||
u'message':translate('OpenLP.ThemeManager',
|
u'message':translate('OpenLP.ThemeManager',
|
||||||
'A theme with this name already exists.')})
|
'A theme with this name already exists.')})
|
||||||
@ -583,7 +583,7 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
theme_pretty_xml = theme.extract_formatted_xml()
|
theme_pretty_xml = theme.extract_formatted_xml()
|
||||||
log.debug(u'saveTheme %s %s', name, theme_pretty_xml)
|
log.debug(u'saveTheme %s %s', name, theme_pretty_xml)
|
||||||
theme_dir = os.path.join(self.path, name)
|
theme_dir = os.path.join(self.path, name)
|
||||||
checkDirectoryExists(theme_dir)
|
check_directory_exists(theme_dir)
|
||||||
theme_file = os.path.join(theme_dir, name + u'.xml')
|
theme_file = os.path.join(theme_dir, name + u'.xml')
|
||||||
if imageTo and self.oldBackgroundImage and \
|
if imageTo and self.oldBackgroundImage and \
|
||||||
imageTo != self.oldBackgroundImage:
|
imageTo != self.oldBackgroundImage:
|
||||||
@ -701,7 +701,7 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
for plugin in self.parent.pluginManager.plugins:
|
for plugin in self.parent.pluginManager.plugins:
|
||||||
if plugin.usesTheme(theme):
|
if plugin.usesTheme(theme):
|
||||||
Receiver.send_message(u'openlp_error_message', {
|
Receiver.send_message(u'openlp_error_message', {
|
||||||
u'title': translate('OpenLP.ThemeManager', \
|
u'title': translate('OpenLP.ThemeManager',
|
||||||
'Validation Error'),
|
'Validation Error'),
|
||||||
u'message': unicode(translate('OpenLP.ThemeManager',
|
u'message': unicode(translate('OpenLP.ThemeManager',
|
||||||
'Theme %s is used in the %s plugin.')) % \
|
'Theme %s is used in the %s plugin.')) % \
|
||||||
@ -765,4 +765,4 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
vAlignCorrection = 2
|
vAlignCorrection = 2
|
||||||
newtheme.display_horizontal_align = theme.HorizontalAlign
|
newtheme.display_horizontal_align = theme.HorizontalAlign
|
||||||
newtheme.display_vertical_align = vAlignCorrection
|
newtheme.display_vertical_align = vAlignCorrection
|
||||||
return newtheme.extract_xml()
|
return newtheme.extract_xml()
|
@ -31,7 +31,7 @@ from PyQt4 import QtCore, QtGui
|
|||||||
|
|
||||||
from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \
|
from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \
|
||||||
ItemCapabilities, SettingsManager, translate, check_item_selected, \
|
ItemCapabilities, SettingsManager, translate, check_item_selected, \
|
||||||
Receiver, checkDirectoryExists
|
Receiver, check_directory_exists
|
||||||
from openlp.core.utils import AppLocation, get_images_filter
|
from openlp.core.utils import AppLocation, get_images_filter
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -88,7 +88,7 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
self.servicePath = os.path.join(
|
self.servicePath = os.path.join(
|
||||||
AppLocation.get_section_data_path(self.settingsSection),
|
AppLocation.get_section_data_path(self.settingsSection),
|
||||||
u'thumbnails')
|
u'thumbnails')
|
||||||
checkDirectoryExists(self.servicePath)
|
check_directory_exists(self.servicePath)
|
||||||
self.loadList(SettingsManager.load_list(
|
self.loadList(SettingsManager.load_list(
|
||||||
self.settingsSection, self.settingsSection))
|
self.settingsSection, self.settingsSection))
|
||||||
|
|
||||||
@ -216,4 +216,4 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
'the image file "%s" no longer exists.')) % filename})
|
'the image file "%s" no longer exists.')) % filename})
|
||||||
|
|
||||||
def onPreviewClick(self):
|
def onPreviewClick(self):
|
||||||
MediaManagerItem.onPreviewClick(self)
|
MediaManagerItem.onPreviewClick(self)
|
Loading…
Reference in New Issue
Block a user