Cleanups and sizePolicy refactor

bzr-revno: 905
This commit is contained in:
Jon Tibble 2010-07-01 20:59:45 +01:00
commit 32702d48a2
4 changed files with 76 additions and 150 deletions

View File

@ -178,13 +178,11 @@ class Ui_AmendThemeDialog(object):
self.MainFontLayout.setWidget(2, QtGui.QFormLayout.LabelRole,
self.FontMainSize)
self.FontMainSizeSpinBox = QtGui.QSpinBox(self.FontMainGroupBox)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum,
defaultSizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum,
QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(
defaultSizePolicy.setHeightForWidth(
self.FontMainSizeSpinBox.sizePolicy().hasHeightForWidth())
self.FontMainSizeSpinBox.setSizePolicy(sizePolicy)
self.FontMainSizeSpinBox.setSizePolicy(defaultSizePolicy)
self.FontMainSizeSpinBox.setMinimumSize(QtCore.QSize(70, 0))
self.FontMainSizeSpinBox.setProperty(u'value', QtCore.QVariant(16))
self.FontMainSizeSpinBox.setMaximum(999)
@ -230,8 +228,7 @@ class Ui_AmendThemeDialog(object):
self.FontMainLineSpacingSpinBox)
self.FontMainLinesPageLabel = QtGui.QLabel(self.FontMainGroupBox)
self.FontMainLinesPageLabel.setObjectName(u'FontMainLinesPageLabel')
self.MainFontLayout.setWidget(6, QtGui.QFormLayout.LabelRole,
self.FontMainLinesPageLabel)
self.MainFontLayout.addRow(self.FontMainLinesPageLabel)
spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum,
QtGui.QSizePolicy.Expanding)
self.MainLeftLayout.addItem(spacerItem1)
@ -275,13 +272,9 @@ class Ui_AmendThemeDialog(object):
self.MainLocationLayout.setWidget(4, QtGui.QFormLayout.LabelRole,
self.FontMainHeightLabel)
self.FontMainXSpinBox = QtGui.QSpinBox(self.MainLocationGroupBox)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum,
QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(
defaultSizePolicy.setHeightForWidth(
self.FontMainXSpinBox.sizePolicy().hasHeightForWidth())
self.FontMainXSpinBox.setSizePolicy(sizePolicy)
self.FontMainXSpinBox.setSizePolicy(defaultSizePolicy)
self.FontMainXSpinBox.setMinimumSize(QtCore.QSize(78, 0))
self.FontMainXSpinBox.setProperty(u'value', QtCore.QVariant(0))
self.FontMainXSpinBox.setMaximum(9999)
@ -289,39 +282,27 @@ class Ui_AmendThemeDialog(object):
self.MainLocationLayout.setWidget(1, QtGui.QFormLayout.FieldRole,
self.FontMainXSpinBox)
self.FontMainYSpinBox = QtGui.QSpinBox(self.MainLocationGroupBox)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum,
QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(
defaultSizePolicy.setHeightForWidth(
self.FontMainYSpinBox.sizePolicy().hasHeightForWidth())
self.FontMainYSpinBox.setSizePolicy(sizePolicy)
self.FontMainYSpinBox.setSizePolicy(defaultSizePolicy)
self.FontMainYSpinBox.setMinimumSize(QtCore.QSize(78, 0))
self.FontMainYSpinBox.setMaximum(9999)
self.FontMainYSpinBox.setObjectName(u'FontMainYSpinBox')
self.MainLocationLayout.setWidget(2, QtGui.QFormLayout.FieldRole,
self.FontMainYSpinBox)
self.FontMainWidthSpinBox = QtGui.QSpinBox(self.MainLocationGroupBox)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum,
QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(
defaultSizePolicy.setHeightForWidth(
self.FontMainWidthSpinBox.sizePolicy().hasHeightForWidth())
self.FontMainWidthSpinBox.setSizePolicy(sizePolicy)
self.FontMainWidthSpinBox.setSizePolicy(defaultSizePolicy)
self.FontMainWidthSpinBox.setMinimumSize(QtCore.QSize(78, 0))
self.FontMainWidthSpinBox.setMaximum(9999)
self.FontMainWidthSpinBox.setObjectName(u'FontMainWidthSpinBox')
self.MainLocationLayout.setWidget(3, QtGui.QFormLayout.FieldRole,
self.FontMainWidthSpinBox)
self.FontMainHeightSpinBox = QtGui.QSpinBox(self.MainLocationGroupBox)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum,
QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(
defaultSizePolicy.setHeightForWidth(
self.FontMainHeightSpinBox.sizePolicy().hasHeightForWidth())
self.FontMainHeightSpinBox.setSizePolicy(sizePolicy)
self.FontMainHeightSpinBox.setSizePolicy(defaultSizePolicy)
self.FontMainHeightSpinBox.setMinimumSize(QtCore.QSize(78, 0))
self.FontMainHeightSpinBox.setMaximum(9999)
self.FontMainHeightSpinBox.setObjectName(u'FontMainHeightSpinBox')
@ -378,13 +359,9 @@ class Ui_AmendThemeDialog(object):
self.FooterFontLayout.setWidget(2, QtGui.QFormLayout.LabelRole,
self.FontFooterSizeLabel)
self.FontFooterSizeSpinBox = QtGui.QSpinBox(self.FooterFontGroupBox)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum,
QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(
defaultSizePolicy.setHeightForWidth(
self.FontFooterSizeSpinBox.sizePolicy().hasHeightForWidth())
self.FontFooterSizeSpinBox.setSizePolicy(sizePolicy)
self.FontFooterSizeSpinBox.setSizePolicy(defaultSizePolicy)
self.FontFooterSizeSpinBox.setMinimumSize(QtCore.QSize(70, 0))
self.FontFooterSizeSpinBox.setProperty(u'value', QtCore.QVariant(10))
self.FontFooterSizeSpinBox.setMaximum(999)
@ -453,13 +430,9 @@ class Ui_AmendThemeDialog(object):
self.LocationFooterLayout.setWidget(4, QtGui.QFormLayout.LabelRole,
self.FontFooterHeightLabel)
self.FontFooterXSpinBox = QtGui.QSpinBox(self.LocationFooterGroupBox)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum,
QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(
defaultSizePolicy.setHeightForWidth(
self.FontFooterXSpinBox.sizePolicy().hasHeightForWidth())
self.FontFooterXSpinBox.setSizePolicy(sizePolicy)
self.FontFooterXSpinBox.setSizePolicy(defaultSizePolicy)
self.FontFooterXSpinBox.setMinimumSize(QtCore.QSize(78, 0))
self.FontFooterXSpinBox.setProperty(u'value', QtCore.QVariant(0))
self.FontFooterXSpinBox.setMaximum(9999)
@ -467,13 +440,9 @@ class Ui_AmendThemeDialog(object):
self.LocationFooterLayout.setWidget(1, QtGui.QFormLayout.FieldRole,
self.FontFooterXSpinBox)
self.FontFooterYSpinBox = QtGui.QSpinBox(self.LocationFooterGroupBox)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum,
QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(
self.FontFooterYSpinBox.sizePolicy().hasHeightForWidth())
self.FontFooterYSpinBox.setSizePolicy(sizePolicy)
defaultSizePolicy.setHeightForWidth(
self.FontFooterXSpinBox.sizePolicy().hasHeightForWidth())
self.FontFooterYSpinBox.setSizePolicy(defaultSizePolicy)
self.FontFooterYSpinBox.setMinimumSize(QtCore.QSize(78, 0))
self.FontFooterYSpinBox.setProperty(u'value', QtCore.QVariant(0))
self.FontFooterYSpinBox.setMaximum(9999)
@ -901,4 +870,3 @@ class Ui_AmendThemeDialog(object):
self.ThemeTabWidget.indexOf(self.OtherOptionsTab),
translate('AmendThemeForm', '&Other Options'))
self.PreviewGroupBox.setTitle(translate('AmendThemeForm', 'Preview'))

View File

@ -242,4 +242,3 @@ class DisplayTab(SettingsTab):
if self.amend_display_start != self.amend_display:
self.amend_display_start = self.amend_display
Receiver.send_message(u'config_screen_changed')

View File

@ -32,13 +32,16 @@ class GeneralTab(SettingsTab):
GeneralTab is the general settings tab in the settings dialog.
"""
def __init__(self, screens):
"""
Initialise the general settings tab
"""
self.screens = screens
self.MonitorNumber = 0
SettingsTab.__init__(self, u'General')
def preLoad(self):
"""
Set up the display screen and set correct screen
values.
Set up the display screen and set correct screen values.
If not set before default to last screen.
"""
settings = QtCore.QSettings()
@ -47,12 +50,14 @@ class GeneralTab(SettingsTab):
QtCore.QVariant(self.screens.display_count - 1)).toInt()[0]
self.screens.set_current_display(self.MonitorNumber)
self.screens.monitor_number = self.MonitorNumber
self.DisplayOnMonitor = settings.value(
self.screens.display = settings.value(
u'display on monitor', QtCore.QVariant(True)).toBool()
self.screens.display = self.DisplayOnMonitor
settings.endGroup()
def setupUi(self):
"""
Create the user interface for the general settings tab
"""
self.setObjectName(u'GeneralTab')
self.tabTitleVisible = translate('GeneralTab', 'General')
self.GeneralLayout = QtGui.QHBoxLayout(self)
@ -152,31 +157,11 @@ class GeneralTab(SettingsTab):
QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.GeneralRightLayout.addItem(self.GeneralRightSpacer)
self.GeneralLayout.addWidget(self.GeneralRightWidget)
QtCore.QObject.connect(self.MonitorComboBox,
QtCore.SIGNAL(u'activated(int)'), self.onMonitorComboBoxChanged)
QtCore.QObject.connect(self.DisplayOnMonitorCheck,
QtCore.SIGNAL(u'stateChanged(int)'),
self.onDisplayOnMonitorCheckChanged)
QtCore.QObject.connect(self.WarningCheckBox,
QtCore.SIGNAL(u'stateChanged(int)'), self.onWarningCheckBoxChanged)
QtCore.QObject.connect(self.AutoOpenCheckBox,
QtCore.SIGNAL(u'stateChanged(int)'), self.onAutoOpenCheckBoxChanged)
QtCore.QObject.connect(self.ShowSplashCheckBox,
QtCore.SIGNAL(u'stateChanged(int)'),
self.onShowSplashCheckBoxChanged)
QtCore.QObject.connect(self.SaveCheckServiceCheckBox,
QtCore.SIGNAL(u'stateChanged(int)'),
self.onSaveCheckServiceCheckBox)
QtCore.QObject.connect(self.AutoPreviewCheckBox,
QtCore.SIGNAL(u'stateChanged(int)'), self.onAutoPreviewCheckBox)
QtCore.QObject.connect(self.NumberEdit,
QtCore.SIGNAL(u'editingFinished()'), self.onNumberEditLostFocus)
QtCore.QObject.connect(self.UsernameEdit,
QtCore.SIGNAL(u'editingFinished()'), self.onUsernameEditLostFocus)
QtCore.QObject.connect(self.PasswordEdit,
QtCore.SIGNAL(u'editingFinished()'), self.onPasswordEditLostFocus)
def retranslateUi(self):
"""
Translate the general settings tab to the currently selected language
"""
self.MonitorGroupBox.setTitle(translate('GeneralTab', 'Monitors'))
self.MonitorLabel.setText(
translate('GeneralTab', 'Select monitor for output display:'))
@ -204,37 +189,10 @@ class GeneralTab(SettingsTab):
self.PasswordLabel.setText(
translate('GeneralTab', 'SongSelect Password:'))
def onMonitorComboBoxChanged(self):
self.MonitorNumber = self.MonitorComboBox.currentIndex()
def onDisplayOnMonitorCheckChanged(self, value):
self.DisplayOnMonitor = (value == QtCore.Qt.Checked)
def onAutoOpenCheckBoxChanged(self, value):
self.AutoOpen = (value == QtCore.Qt.Checked)
def onShowSplashCheckBoxChanged(self, value):
self.ShowSplash = (value == QtCore.Qt.Checked)
def onWarningCheckBoxChanged(self, value):
self.Warning = (value == QtCore.Qt.Checked)
def onSaveCheckServiceCheckBox(self, value):
self.PromptSaveService = (value == QtCore.Qt.Checked)
def onAutoPreviewCheckBox(self, value):
self.AutoPreview = (value == QtCore.Qt.Checked)
def onNumberEditLostFocus(self):
self.CCLINumber = self.NumberEdit.displayText()
def onUsernameEditLostFocus(self):
self.Username = self.UsernameEdit.displayText()
def onPasswordEditLostFocus(self):
self.Password = self.PasswordEdit.displayText()
def load(self):
"""
Load the settings to populate the form
"""
settings = QtCore.QSettings()
settings.beginGroup(self.settingsSection)
for screen in self.screens.screen_list:
@ -244,55 +202,54 @@ class GeneralTab(SettingsTab):
screen_name = u'%s (%s)' % (screen_name,
translate('GeneralTab', 'primary'))
self.MonitorComboBox.addItem(screen_name)
# Get the configs
self.Warning = settings.value(
u'blank warning', QtCore.QVariant(False)).toBool()
self.AutoOpen = settings.value(
u'auto open', QtCore.QVariant(False)).toBool()
self.ShowSplash = settings.value(
u'show splash', QtCore.QVariant(True)).toBool()
self.PromptSaveService = settings.value(
u'save prompt', QtCore.QVariant(False)).toBool()
self.AutoPreview = settings.value(
u'auto preview', QtCore.QVariant(False)).toBool()
self.CCLINumber = unicode(settings.value(
u'ccli number', QtCore.QVariant(u'')).toString())
self.Username = unicode(settings.value(
u'songselect username', QtCore.QVariant(u'')).toString())
self.Password = unicode(settings.value(
u'songselect password', QtCore.QVariant(u'')).toString())
settings.endGroup()
self.SaveCheckServiceCheckBox.setChecked(self.PromptSaveService)
# Set a few things up
self.NumberEdit.setText(unicode(settings.value(
u'ccli number', QtCore.QVariant(u'')).toString()))
self.UsernameEdit.setText(unicode(settings.value(
u'songselect username', QtCore.QVariant(u'')).toString()))
self.PasswordEdit.setText(unicode(settings.value(
u'songselect password', QtCore.QVariant(u'')).toString()))
self.SaveCheckServiceCheckBox.setChecked(settings.value(u'save prompt',
QtCore.QVariant(False)).toBool())
self.MonitorComboBox.setCurrentIndex(self.MonitorNumber)
self.DisplayOnMonitorCheck.setChecked(self.DisplayOnMonitor)
self.WarningCheckBox.setChecked(self.Warning)
self.AutoOpenCheckBox.setChecked(self.AutoOpen)
self.ShowSplashCheckBox.setChecked(self.ShowSplash)
self.AutoPreviewCheckBox.setChecked(self.AutoPreview)
self.NumberEdit.setText(self.CCLINumber)
self.UsernameEdit.setText(self.Username)
self.PasswordEdit.setText(self.Password)
self.DisplayOnMonitorCheck.setChecked(self.screens.display)
self.WarningCheckBox.setChecked(settings.value(u'blank warning',
QtCore.QVariant(False)).toBool())
self.AutoOpenCheckBox.setChecked(settings.value(u'auto open',
QtCore.QVariant(False)).toBool())
self.ShowSplashCheckBox.setChecked(settings.value(u'show splash',
QtCore.QVariant(True)).toBool())
self.AutoPreviewCheckBox.setChecked(settings.value(u'auto preview',
QtCore.QVariant(False)).toBool())
settings.endGroup()
def save(self):
"""
Save the settings from the form
"""
self.MonitorNumber = self.MonitorComboBox.currentIndex()
settings = QtCore.QSettings()
settings.beginGroup(self.settingsSection)
settings.setValue(u'monitor', QtCore.QVariant(self.MonitorNumber))
settings.setValue(u'display on monitor',
QtCore.QVariant(self.DisplayOnMonitor))
settings.setValue(u'blank warning', QtCore.QVariant(self.Warning))
settings.setValue(u'auto open', QtCore.QVariant(self.AutoOpen))
settings.setValue(u'show splash', QtCore.QVariant(self.ShowSplash))
QtCore.QVariant(self.DisplayOnMonitorCheck.isChecked()))
settings.setValue(u'blank warning',
QtCore.QVariant(self.WarningCheckBox.isChecked()))
settings.setValue(u'auto open',
QtCore.QVariant(self.AutoOpenCheckBox.isChecked()))
settings.setValue(u'show splash',
QtCore.QVariant(self.ShowSplashCheckBox.isChecked()))
settings.setValue(u'save prompt',
QtCore.QVariant(self.PromptSaveService))
settings.setValue(u'auto preview', QtCore.QVariant(self.AutoPreview))
settings.setValue(u'ccli number', QtCore.QVariant(self.CCLINumber))
QtCore.QVariant(self.SaveCheckServiceCheckBox.isChecked()))
settings.setValue(u'auto preview',
QtCore.QVariant(self.AutoPreviewCheckBox.isChecked()))
settings.setValue(u'ccli number',
QtCore.QVariant(self.NumberEdit.displayText()))
settings.setValue(u'songselect username',
QtCore.QVariant(self.Username))
QtCore.QVariant(self.UsernameEdit.displayText()))
settings.setValue(u'songselect password',
QtCore.QVariant(self.Password))
QtCore.QVariant(self.PasswordEdit.displayText()))
settings.endGroup()
self.screens.display = self.DisplayOnMonitor
self.screens.display = self.DisplayOnMonitorCheck.isChecked()
#Monitor Number has changed.
if self.screens.monitor_number != self.MonitorNumber:
self.screens.monitor_number = self.MonitorNumber

View File

@ -25,7 +25,7 @@
import logging
from PyQt4 import QtCore, QtGui
from PyQt4 import QtCore
from openlp.core.lib import Receiver, translate
@ -95,7 +95,8 @@ class AlertsManager(QtCore.QObject):
alertTab = self.parent.alertsTab
text = HTMLCODE % (alertTab.font_color, alertTab.bg_color,
alertTab.font_face, alertTab.font_size, text)
self.parent.preview_controller.parent.displayManager.addAlert(text, alertTab.location)
self.parent.preview_controller.parent.displayManager.addAlert(text,
alertTab.location)
# check to see if we have a timer running
if self.timer_id == 0:
self.timer_id = self.startTimer(int(alertTab.timeout) * 1000)
@ -111,7 +112,8 @@ class AlertsManager(QtCore.QObject):
log.debug(u'timer event')
alertTab = self.parent.alertsTab
if event.timerId() == self.timer_id:
self.parent.preview_controller.parent.displayManager.addAlert(u'', alertTab.location)
self.parent.preview_controller.parent.displayManager.addAlert(u'',
alertTab.location)
self.killTimer(self.timer_id)
self.timer_id = 0
self.generateAlert()