forked from openlp/openlp
Cleanups and fixes
bzr-revno: 670
This commit is contained in:
commit
ce81d177a0
@ -27,6 +27,7 @@ The :mod:`lib` module contains most of the components and libraries that make
|
|||||||
OpenLP work.
|
OpenLP work.
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
import os.path
|
||||||
import types
|
import types
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
@ -49,26 +50,28 @@ def translate(context, text):
|
|||||||
return QtGui.QApplication.translate(
|
return QtGui.QApplication.translate(
|
||||||
context, text, None, QtGui.QApplication.UnicodeUTF8)
|
context, text, None, QtGui.QApplication.UnicodeUTF8)
|
||||||
|
|
||||||
def file_to_xml(xmlfile):
|
def get_text_file_string(text_file):
|
||||||
"""
|
"""
|
||||||
Open a file and return the contents of the file.
|
Open a file and return the contents of the file. If the supplied file name
|
||||||
|
is not a file then the function returns False. If there is an error
|
||||||
|
loading the file then the function will return None.
|
||||||
|
|
||||||
``xmlfile``
|
``textfile``
|
||||||
The name of the file.
|
The name of the file.
|
||||||
"""
|
"""
|
||||||
file = None
|
if not os.path.isfile(text_file):
|
||||||
xml = None
|
return False
|
||||||
|
file_handle = None
|
||||||
|
content_string = None
|
||||||
try:
|
try:
|
||||||
file = open(xmlfile, u'r')
|
file_handle = open(text_file, u'r')
|
||||||
xml = file.read()
|
content_string = file_handle.read()
|
||||||
except IOError:
|
except IOError:
|
||||||
#This may not be an error as this is also used to check
|
log.error(u'Failed to open text file %s' % text_file)
|
||||||
#that a file exist
|
|
||||||
log.error(u'Failed to open XML file %s' % xmlfile)
|
|
||||||
finally:
|
finally:
|
||||||
if file:
|
if file_handle:
|
||||||
file.close()
|
file_handle.close()
|
||||||
return xml
|
return content_string
|
||||||
|
|
||||||
def str_to_bool(stringvalue):
|
def str_to_bool(stringvalue):
|
||||||
"""
|
"""
|
||||||
@ -152,5 +155,5 @@ from rendermanager import RenderManager
|
|||||||
from mediamanageritem import MediaManagerItem
|
from mediamanageritem import MediaManagerItem
|
||||||
from baselistwithdnd import BaseListWithDnD
|
from baselistwithdnd import BaseListWithDnD
|
||||||
|
|
||||||
__all__ = [ 'translate', 'file_to_xml', 'str_to_bool',
|
__all__ = [ 'translate', 'get_text_file_string', 'str_to_bool',
|
||||||
'contextMenuAction', 'contextMenuSeparator', 'ServiceItem']
|
'contextMenuAction', 'contextMenuSeparator', 'ServiceItem']
|
||||||
|
@ -184,7 +184,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
|||||||
|
|
||||||
def loadTheme(self, theme):
|
def loadTheme(self, theme):
|
||||||
log.debug(u'LoadTheme %s', theme)
|
log.debug(u'LoadTheme %s', theme)
|
||||||
self.theme = self.thememanager.getThemeData(theme)
|
self.theme = theme
|
||||||
# Stop the initial screen setup generating 1 preview per field!
|
# Stop the initial screen setup generating 1 preview per field!
|
||||||
self.allowPreview = False
|
self.allowPreview = False
|
||||||
self.paintUi(self.theme)
|
self.paintUi(self.theme)
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import time
|
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
from PyQt4.phonon import Phonon
|
from PyQt4.phonon import Phonon
|
||||||
@ -279,6 +278,7 @@ class MainDisplay(DisplayWidget):
|
|||||||
self.mediaLoaded = True
|
self.mediaLoaded = True
|
||||||
self.display.hide()
|
self.display.hide()
|
||||||
self.video.setFullScreen(True)
|
self.video.setFullScreen(True)
|
||||||
|
self.video.setVisible(True)
|
||||||
self.mediaObject.play()
|
self.mediaObject.play()
|
||||||
if self.primary:
|
if self.primary:
|
||||||
self.setVisible(True)
|
self.setVisible(True)
|
||||||
@ -290,7 +290,6 @@ class MainDisplay(DisplayWidget):
|
|||||||
def onMediaStop(self):
|
def onMediaStop(self):
|
||||||
log.debug(u'Media stopped by user')
|
log.debug(u'Media stopped by user')
|
||||||
self.mediaObject.stop()
|
self.mediaObject.stop()
|
||||||
self.display.show()
|
|
||||||
|
|
||||||
def onMediaFinish(self):
|
def onMediaFinish(self):
|
||||||
log.debug(u'Reached end of media playlist')
|
log.debug(u'Reached end of media playlist')
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import string
|
|
||||||
import logging
|
import logging
|
||||||
import cPickle
|
import cPickle
|
||||||
import zipfile
|
import zipfile
|
||||||
@ -481,11 +480,8 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
try:
|
try:
|
||||||
zip = zipfile.ZipFile(unicode(filename))
|
zip = zipfile.ZipFile(unicode(filename))
|
||||||
for file in zip.namelist():
|
for file in zip.namelist():
|
||||||
if os.name == u'nt':
|
osfile = unicode(QtCore.QDir.toNativeSeparators(file))
|
||||||
winfile = string.replace(file, '/', os.path.sep)
|
names = osfile.split(os.path.sep)
|
||||||
names = winfile.split(os.path.sep)
|
|
||||||
else:
|
|
||||||
names = file.split(os.path.sep)
|
|
||||||
file_to = os.path.join(self.servicePath,
|
file_to = os.path.join(self.servicePath,
|
||||||
names[len(names) - 1])
|
names[len(names) - 1])
|
||||||
f = open(file_to, u'wb')
|
f = open(file_to, u'wb')
|
||||||
|
@ -28,8 +28,7 @@ import os
|
|||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
from PyQt4.phonon import Phonon
|
from PyQt4.phonon import Phonon
|
||||||
|
|
||||||
from openlp.core.lib import OpenLPToolbar, Receiver, ServiceItemType, \
|
from openlp.core.lib import OpenLPToolbar, Receiver, str_to_bool, PluginConfig
|
||||||
str_to_bool, PluginConfig
|
|
||||||
|
|
||||||
class SlideList(QtGui.QTableWidget):
|
class SlideList(QtGui.QTableWidget):
|
||||||
"""
|
"""
|
||||||
@ -424,7 +423,7 @@ class SlideController(QtGui.QWidget):
|
|||||||
def addServiceManagerItem(self, item, slideno):
|
def addServiceManagerItem(self, item, slideno):
|
||||||
"""
|
"""
|
||||||
Method to install the service item into the controller and
|
Method to install the service item into the controller and
|
||||||
request the correct the toolbar of the plugin
|
request the correct toolbar for the plugin.
|
||||||
Called by ServiceManager
|
Called by ServiceManager
|
||||||
"""
|
"""
|
||||||
log.debug(u'addServiceManagerItem')
|
log.debug(u'addServiceManagerItem')
|
||||||
|
@ -33,7 +33,7 @@ from PyQt4 import QtCore, QtGui
|
|||||||
from openlp.core.ui import AmendThemeForm
|
from openlp.core.ui import AmendThemeForm
|
||||||
from openlp.core.theme import Theme
|
from openlp.core.theme import Theme
|
||||||
from openlp.core.lib import PluginConfig, OpenLPToolbar, ThemeXML, \
|
from openlp.core.lib import PluginConfig, OpenLPToolbar, ThemeXML, \
|
||||||
str_to_bool, file_to_xml, buildIcon, Receiver, contextMenuAction, \
|
str_to_bool, get_text_file_string, buildIcon, Receiver, contextMenuAction, \
|
||||||
contextMenuSeparator
|
contextMenuSeparator
|
||||||
from openlp.core.utils import ConfigHelper
|
from openlp.core.utils import ConfigHelper
|
||||||
|
|
||||||
@ -150,15 +150,17 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
self.pushThemes()
|
self.pushThemes()
|
||||||
|
|
||||||
def onAddTheme(self):
|
def onAddTheme(self):
|
||||||
self.amendThemeForm.loadTheme(None)
|
theme = self.createThemeFromXml(self.baseTheme(), self.path)
|
||||||
|
self.amendThemeForm.loadTheme(theme)
|
||||||
self.saveThemeName = u''
|
self.saveThemeName = u''
|
||||||
self.amendThemeForm.exec_()
|
self.amendThemeForm.exec_()
|
||||||
|
|
||||||
def onEditTheme(self):
|
def onEditTheme(self):
|
||||||
item = self.ThemeListWidget.currentItem()
|
item = self.ThemeListWidget.currentItem()
|
||||||
if item:
|
if item:
|
||||||
self.amendThemeForm.loadTheme(
|
theme = self.getThemeData(
|
||||||
unicode(item.data(QtCore.Qt.UserRole).toString()))
|
unicode(item.data(QtCore.Qt.UserRole).toString()))
|
||||||
|
self.amendThemeForm.loadTheme(theme)
|
||||||
self.saveThemeName = unicode(
|
self.saveThemeName = unicode(
|
||||||
item.data(QtCore.Qt.UserRole).toString())
|
item.data(QtCore.Qt.UserRole).toString())
|
||||||
self.amendThemeForm.exec_()
|
self.amendThemeForm.exec_()
|
||||||
@ -274,7 +276,7 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
log.debug(u'getthemedata for theme %s', themename)
|
log.debug(u'getthemedata for theme %s', themename)
|
||||||
xml_file = os.path.join(self.path, unicode(themename),
|
xml_file = os.path.join(self.path, unicode(themename),
|
||||||
unicode(themename) + u'.xml')
|
unicode(themename) + u'.xml')
|
||||||
xml = file_to_xml(xml_file)
|
xml = get_text_file_string(xml_file)
|
||||||
if not xml:
|
if not xml:
|
||||||
xml = self.baseTheme()
|
xml = self.baseTheme()
|
||||||
return self.createThemeFromXml(xml, self.path)
|
return self.createThemeFromXml(xml, self.path)
|
||||||
@ -501,6 +503,8 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
theme.display_wrapStyle = theme.display_wrapStyle.strip()
|
theme.display_wrapStyle = theme.display_wrapStyle.strip()
|
||||||
theme.font_footer_color = theme.font_footer_color.strip()
|
theme.font_footer_color = theme.font_footer_color.strip()
|
||||||
theme.font_footer_height = int(theme.font_footer_height.strip())
|
theme.font_footer_height = int(theme.font_footer_height.strip())
|
||||||
|
theme.font_footer_indentation = \
|
||||||
|
int(theme.font_footer_indentation.strip())
|
||||||
theme.font_footer_italics = str_to_bool(theme.font_footer_italics)
|
theme.font_footer_italics = str_to_bool(theme.font_footer_italics)
|
||||||
theme.font_footer_name = theme.font_footer_name.strip()
|
theme.font_footer_name = theme.font_footer_name.strip()
|
||||||
#theme.font_footer_override
|
#theme.font_footer_override
|
||||||
|
@ -101,10 +101,10 @@ class Registry(object):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def _load(self):
|
def _load(self):
|
||||||
file_handle = None
|
|
||||||
try:
|
|
||||||
if not os.path.isfile(self.file_name):
|
if not os.path.isfile(self.file_name):
|
||||||
return False
|
return False
|
||||||
|
file_handle = None
|
||||||
|
try:
|
||||||
file_handle = open(self.file_name, u'r')
|
file_handle = open(self.file_name, u'r')
|
||||||
self.config.readfp(file_handle)
|
self.config.readfp(file_handle)
|
||||||
return True
|
return True
|
||||||
|
@ -1 +1 @@
|
|||||||
1.9.0-669
|
1.9.0-670
|
||||||
|
Loading…
Reference in New Issue
Block a user