Add Class instead of magic numbers

This commit is contained in:
Tim Bentley 2011-10-29 14:21:54 +01:00
parent 8e853f10b1
commit ea4cb7f7ed
3 changed files with 23 additions and 4 deletions

View File

@ -52,6 +52,24 @@ class HideMode(object):
Theme = 2
Screen = 3
class Location(object):
"""
This is an enumeration class which specifies the different modes of hiding
the display.
``Top``
Place the text at the top of the screen.
``Middle``
Place the text in the middle of the screen.
``Bottom``
Place the text at the bottom of the screen.
"""
Top = 0
Middle = 1
Bottom = 2
from firsttimeform import FirstTimeForm
from firsttimelanguageform import FirstTimeLanguageForm
from themelayoutform import ThemeLayoutForm

View File

@ -37,7 +37,7 @@ from PyQt4.phonon import Phonon
from openlp.core.lib import Receiver, build_html, ServiceItem, image_to_byte, \
translate, PluginManager
from openlp.core.ui import HideMode, ScreenList
from openlp.core.ui import HideMode, ScreenList, Location
log = logging.getLogger(__name__)
@ -241,10 +241,10 @@ class MainDisplay(QtGui.QGraphicsView):
alert_height = int(height.toString())
shrinkItem.resize(self.width(), alert_height)
shrinkItem.setVisible(True)
if location == 1:
if location == Location.Middle:
shrinkItem.move(self.screen[u'size'].left(),
(self.screen[u'size'].height() - alert_height) / 2)
elif location == 2:
elif location == Location.Bottom:
shrinkItem.move(self.screen[u'size'].left(),
self.screen[u'size'].height() - alert_height)
else:

View File

@ -28,6 +28,7 @@
from PyQt4 import QtCore, QtGui
from openlp.core.lib import SettingsTab, translate, Receiver
from openlp.core.ui import Location
from openlp.core.lib.ui import UiStrings, create_valign_combo
class AlertsTab(SettingsTab):
@ -159,7 +160,7 @@ class AlertsTab(SettingsTab):
self.font_face = unicode(settings.value(
u'font face', QtCore.QVariant(QtGui.QFont().family())).toString())
self.location = settings.value(
u'location', QtCore.QVariant(2)).toInt()[0]
u'location', QtCore.QVariant(Location.Bottom)).toInt()[0]
settings.endGroup()
self.fontSizeSpinBox.setValue(self.font_size)
self.timeoutSpinBox.setValue(self.timeout)