forked from openlp/openlp
Cleanup magic numbers and more UiStrings
This commit is contained in:
parent
a7f8d5ca84
commit
12607020be
@ -28,7 +28,8 @@ import logging
|
||||
|
||||
from PyQt4 import QtWebKit
|
||||
|
||||
from openlp.core.lib import BackgroundType, BackgroundGradientType
|
||||
from openlp.core.lib import BackgroundType, BackgroundGradientType, \
|
||||
VerticalType
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -536,12 +537,7 @@ def build_lyrics_format_css(theme, width, height):
|
||||
align = u'right'
|
||||
else:
|
||||
align = u'left'
|
||||
if theme.display_vertical_align == 2:
|
||||
valign = u'bottom'
|
||||
elif theme.display_vertical_align == 1:
|
||||
valign = u'middle'
|
||||
else:
|
||||
valign = u'top'
|
||||
valign = VerticalType.to_string(theme.display_vertical_align)
|
||||
if theme.font_main_outline:
|
||||
left_margin = int(theme.font_main_outline_size) * 2
|
||||
else:
|
||||
@ -634,13 +630,7 @@ def build_alert_css(alertTab, width):
|
||||
"""
|
||||
if not alertTab:
|
||||
return u''
|
||||
align = u''
|
||||
if alertTab.location == 2:
|
||||
align = u'bottom'
|
||||
elif alertTab.location == 1:
|
||||
align = u'middle'
|
||||
else:
|
||||
align = u'top'
|
||||
align = VerticalType.to_string(alertTab.location)
|
||||
alert = style % (width, align, alertTab.font_face, alertTab.font_size,
|
||||
alertTab.font_color, alertTab.bg_color)
|
||||
return alert
|
||||
|
@ -164,6 +164,7 @@ class BackgroundGradientType(object):
|
||||
elif type_string == u'leftBottom':
|
||||
return BackgroundGradientType.LeftBottom
|
||||
|
||||
|
||||
class HorizontalType(object):
|
||||
"""
|
||||
Type enumeration for horizontal alignment.
|
||||
@ -172,6 +173,19 @@ class HorizontalType(object):
|
||||
Center = 1
|
||||
Right = 2
|
||||
|
||||
@staticmethod
|
||||
def to_string(horizontal_type):
|
||||
"""
|
||||
Return a string representation of a horizontal type.
|
||||
"""
|
||||
If horizontal_type == Horizontal.Right:
|
||||
return u'right'
|
||||
elif horizontal_type == Horizontal.Center:
|
||||
return u'center'
|
||||
else
|
||||
return u'left'
|
||||
|
||||
|
||||
class VerticalType(object):
|
||||
"""
|
||||
Type enumeration for vertical alignment.
|
||||
@ -180,6 +194,19 @@ class VerticalType(object):
|
||||
Middle = 1
|
||||
Bottom = 2
|
||||
|
||||
@staticmethod
|
||||
def to_string(vertical_type):
|
||||
"""
|
||||
Return a string representation of a vertical type.
|
||||
"""
|
||||
If vertical_type == VerticalType.Bottom:
|
||||
return u'bottom'
|
||||
elif vertical_type == VerticalType.Middle:
|
||||
return u'middle'
|
||||
else
|
||||
return u'top'
|
||||
|
||||
|
||||
BOOLEAN_LIST = [u'bold', u'italics', u'override', u'outline', u'shadow',
|
||||
u'slide_transition']
|
||||
|
||||
|
@ -64,12 +64,14 @@ class UiStrings(object):
|
||||
New = translate('OpenLP.Ui', 'New')
|
||||
NewType = unicode(translate('OpenLP.Ui', 'New %s'))
|
||||
OLPV2 = translate('OpenLP.Ui', 'OpenLP 2.0')
|
||||
OpenType = unicode(translate('OpenLP.Ui', 'Open %s'))
|
||||
Preview = translate('OpenLP.Ui', 'Preview')
|
||||
PreviewSelect = unicode(translate('OpenLP.Ui', 'Preview the selected %s.'))
|
||||
ReplaceBG = translate('OpenLP.Ui', 'Replace Background')
|
||||
ReplaceLiveBG = translate('OpenLP.Ui', 'Replace Live Background')
|
||||
ResetBG = translate('OpenLP.Ui', 'Reset Background')
|
||||
ResetLiveBG = translate('OpenLP.Ui', 'Reset Live Background')
|
||||
SaveType = unicode(translate('OpenLP.Ui', 'Save %s'))
|
||||
SendSelectLive = unicode(translate('OpenLP.Ui',
|
||||
'Send the selected %s live.'))
|
||||
Service = translate('OpenLP.Ui', 'Service')
|
||||
|
@ -324,14 +324,12 @@ class Ui_MainWindow(object):
|
||||
UiStrings.CreateANew % UiStrings.Service.toLower())
|
||||
self.FileNewItem.setShortcut(translate('OpenLP.MainWindow', 'Ctrl+N'))
|
||||
self.FileOpenItem.setText(translate('OpenLP.MainWindow', '&Open'))
|
||||
self.FileOpenItem.setToolTip(
|
||||
translate('OpenLP.MainWindow', 'Open Service'))
|
||||
self.FileOpenItem.setToolTip(UiStrings.OpenType % UiStrings.Service)
|
||||
self.FileOpenItem.setStatusTip(
|
||||
translate('OpenLP.MainWindow', 'Open an existing service.'))
|
||||
self.FileOpenItem.setShortcut(translate('OpenLP.MainWindow', 'Ctrl+O'))
|
||||
self.FileSaveItem.setText(translate('OpenLP.MainWindow', '&Save'))
|
||||
self.FileSaveItem.setToolTip(
|
||||
translate('OpenLP.MainWindow', 'Save Service'))
|
||||
self.FileSaveItem.setToolTip(UiStrings.SaveType % UiStrings.Service)
|
||||
self.FileSaveItem.setStatusTip(
|
||||
translate('OpenLP.MainWindow', 'Save the current service to disk.'))
|
||||
self.FileSaveItem.setShortcut(translate('OpenLP.MainWindow', 'Ctrl+S'))
|
||||
|
@ -100,12 +100,12 @@ class ServiceManager(QtGui.QWidget):
|
||||
UiStrings.CreateANew % UiStrings.Service.toLower(),
|
||||
self.onNewServiceClicked)
|
||||
self.toolbar.addToolbarButton(
|
||||
translate('OpenLP.ServiceManager', 'Open Service'),
|
||||
UiStrings.OpenType % UiStrings.Service,
|
||||
u':/general/general_open.png',
|
||||
translate('OpenLP.ServiceManager', 'Load an existing service'),
|
||||
self.onLoadServiceClicked)
|
||||
self.toolbar.addToolbarButton(
|
||||
translate('OpenLP.ServiceManager', 'Save Service'),
|
||||
UiStrings.SaveType % UiStrings.Service,
|
||||
u':/general/general_save.png',
|
||||
translate('OpenLP.ServiceManager', 'Save this service'),
|
||||
self.saveFile)
|
||||
@ -465,7 +465,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
save the file.
|
||||
"""
|
||||
fileName = unicode(QtGui.QFileDialog.getSaveFileName(self.mainwindow,
|
||||
translate('OpenLP.ServiceManager', 'Save Service'),
|
||||
UiStrings.SaveType % UiStrings.Service,
|
||||
SettingsManager.get_last_dir(
|
||||
self.mainwindow.serviceSettingsSection),
|
||||
translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz)')))
|
||||
|
@ -34,7 +34,8 @@ from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import OpenLPToolbar, ThemeXML, get_text_file_string, \
|
||||
build_icon, Receiver, SettingsManager, translate, check_item_selected, \
|
||||
BackgroundType, BackgroundGradientType, check_directory_exists
|
||||
BackgroundType, BackgroundGradientType, check_directory_exists, \
|
||||
VerticalType
|
||||
from openlp.core.lib.ui import UiStrings, critical_error_message_box
|
||||
from openlp.core.theme import Theme
|
||||
from openlp.core.ui import FileRenameForm, ThemeForm
|
||||
@ -762,11 +763,11 @@ class ThemeManager(QtGui.QWidget):
|
||||
newtheme.font_main_outline = True
|
||||
newtheme.font_main_outline_color = \
|
||||
unicode(theme.OutlineColor.name())
|
||||
vAlignCorrection = 0
|
||||
vAlignCorrection = VerticalType.Top
|
||||
if theme.VerticalAlign == 2:
|
||||
vAlignCorrection = 1
|
||||
vAlignCorrection = VerticalType.Middle
|
||||
elif theme.VerticalAlign == 1:
|
||||
vAlignCorrection = 2
|
||||
vAlignCorrection = VerticalType.Bottom
|
||||
newtheme.display_horizontal_align = theme.HorizontalAlign
|
||||
newtheme.display_vertical_align = vAlignCorrection
|
||||
return newtheme.extract_xml()
|
||||
|
Loading…
Reference in New Issue
Block a user