Tidy up Video and Bible tab code.

bzr-revno: 381
This commit is contained in:
Tim Bentley 2009-03-06 06:05:01 +00:00
parent 6af1637550
commit 980ed505e2
3 changed files with 55 additions and 59 deletions

View File

@ -57,3 +57,9 @@ class SettingsTab(QtGui.QWidget):
def save(self):
pass
def convertStringToBoolean(self, stringvalue):
if stringvalue.lower() == 'true':
return True
else:
return False

View File

@ -110,70 +110,65 @@ class BiblesTab(SettingsTab):
QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.BibleRightLayout.addItem(self.BibleRightSpacer)
self.BibleLayout.addWidget(self.BibleRightWidget)
QtCore.QObject.connect(self.NewChaptersCheckBox,\
QtCore.SIGNAL("stateChanged(int)"), self.onNewChaptersCheckBoxchanged)
QtCore.QObject.connect(self.BibleSearchCheckBox,\
QtCore.SIGNAL("stateChanged(int)"), self.onBibleSearchCheckBoxchanged)
# Signals and slots
QtCore.QObject.connect(self.NewChaptersCheckBox,
QtCore.SIGNAL("stateChanged(int)"), self.onNewChaptersCheckBoxChanged)
QtCore.QObject.connect(self.BibleSearchCheckBox,
QtCore.SIGNAL("stateChanged(int)"), self.onBibleSearchCheckBoxChanged)
QtCore.QObject.connect(self.VerseRadioButton,
QtCore.SIGNAL("pressed()"), self.onVerseRadioButtonPressed)
QtCore.QObject.connect(self.ParagraphRadioButton,
QtCore.SIGNAL("pressed()"), self.onParagraphRadioButtonPressed)
def retranslateUi(self):
self.VerseDisplayGroupBox.setTitle(translate("SettingsForm", "Verse Display"))
self.VerseRadioButton.setText(translate("SettingsForm", "Verse style"))
self.ParagraphRadioButton.setText(translate("SettingsForm", "Paragraph style"))
self.NewChaptersCheckBox.setText(translate("SettingsForm", "Only show new chapter numbers"))
self.DisplayStyleLabel.setText(translate("SettingsForm", "Display Style:"))
self.DisplayStyleComboBox.setItemText(0, translate("SettingsForm", "No brackets"))
self.DisplayStyleComboBox.setItemText(1, translate("SettingsForm", "( and )"))
self.DisplayStyleComboBox.setItemText(2, translate("SettingsForm", "{ and }"))
self.DisplayStyleComboBox.setItemText(3, translate("SettingsForm", "[ and ]"))
self.ChangeNoteLabel.setText(translate("SettingsForm", "Note:\nChanges don\'t affect verses already in the service"))
self.BibleSearchGroupBox.setTitle(translate("SettingsForm", "Search"))
self.BibleSearchCheckBox.setText(translate("SettingsForm", "Search-as-you-type"))
self.VerseDisplayGroupBox.setTitle(translate('SettingsForm', 'Verse Display'))
self.VerseRadioButton.setText(translate('SettingsForm', 'Verse style'))
self.ParagraphRadioButton.setText(translate('SettingsForm','Paragraph style'))
self.NewChaptersCheckBox.setText(translate('SettingsForm', 'Only show new chapter numbers'))
self.DisplayStyleLabel.setText(translate('SettingsForm', 'Display Style:'))
self.DisplayStyleComboBox.setItemText(0, translate('SettingsForm', 'No brackets'))
self.DisplayStyleComboBox.setItemText(1, translate('SettingsForm', '( and )'))
self.DisplayStyleComboBox.setItemText(2, translate('SettingsForm', '{ and }'))
self.DisplayStyleComboBox.setItemText(3, translate('SettingsForm', '[ and ]'))
self.ChangeNoteLabel.setText(translate('SettingsForm', 'Note:\nChanges don\'t affect verses already in the service'))
self.BibleSearchGroupBox.setTitle(translate('SettingsForm', 'Search'))
self.BibleSearchCheckBox.setText(translate('SettingsForm', 'Search-as-you-type'))
def onNewChaptersCheckBoxchanged(self):
def onVerseRadioButtonPressed(self):
self.paragraph_style = False
def onParagraphRadioButtonPressed(self):
self.paragraph_style = True
def onNewChaptersCheckBoxChanged(self):
check_box = self.NewChaptersCheckBox.checkState()
self.new_chapter_check = False
if check_box == 2: # we have a set value convert to True/False
self.new_chapter_check = True
def onBibleSearchCheckBoxchanged(self):
def onBibleSearchCheckBoxChanged(self):
bible_search = self.BibleSearchCheckBox.checkState()
self.bible_search_check = False
if bible_search == 2: # we have a set value convert to True/False
self.bible_search_check = True
def load(self):
bible_output_style = self.config.get_config("output style", "P")
if bible_output_style == "P":
self.paragraph_style = self.convertStringToBoolean(self.config.get_config('paragraph style', u'True'))
self.new_chapter_check = self.convertStringToBoolean(self.config.get_config('display new chapter', u"False"))
self.display_style = int(self.config.get_config('display brackets', '0'))
self.search_as_type = self.convertStringToBoolean(self.config.get_config('search as type', u'True'))
if self.paragraph_style:
self.ParagraphRadioButton.setChecked(True)
self.paragraph_format = True
else:
self.VerseRadioButton.setChecked(True)
self.paragraph_format = False
check_box = self.config.get_config("display new chapter", "0")
self.new_chapter_check = True
# used for first time initialisation
# mode_layout will be a string with True/False so need to fix and make boolean
if check_box == '0'or check_box == "False":
self.new_chapter_check = False
else:
if self.new_chapter_check:
self.NewChaptersCheckBox.setChecked(True)
self.display_style = int(self.config.get_config("display brackets", "0"))
self.DisplayStyleComboBox.setCurrentIndex(self.display_style)
search_type = self.config.get_config("search as type", "2")
self.bible_search_check = True
# used for first time initialisation
# mode_layout will be a string with True/False so need to fix and make boolean
if search_type == '0'or search_type == "False":
self.bible_search_check = False
else:
if self.search_as_type:
self.BibleSearchCheckBox.setChecked(True)
def save(self):
if self.ParagraphRadioButton.isChecked():
self.config.set_config("output style", "P")
else:
self.config.set_config("output style", "V")
self.config.set_config("paragraph style", str(self.paragraph_style))
self.config.set_config("display new chapter", str(self.new_chapter_check))
self.config.set_config("display brackets", str(self.DisplayStyleComboBox.currentIndex()))
self.config.set_config("search as type", str(self.bible_search_check))

View File

@ -29,7 +29,7 @@ class VideoTab(SettingsTab):
VideoTab is the video settings tab in the settings dialog.
"""
def __init__(self):
SettingsTab.__init__(self, u'Video')
SettingsTab.__init__(self, u'Videos')
def setupUi(self):
self.setObjectName(u'VideoTab')
@ -51,9 +51,9 @@ class VideoTab(SettingsTab):
self.VideoModeLayout.addWidget(self.UseVMRLabel)
self.VideoLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.VideoModeGroupBox)
QtCore.QObject.connect(self.UseVMRCheckBox,\
QtCore.SIGNAL("stateChanged(int)"), self.onVMRCheckBoxchanged)
# Signals and slots
QtCore.QObject.connect(self.UseVMRCheckBox,
QtCore.SIGNAL("stateChanged(int)"), self.onVMRCheckBoxChanged)
def retranslateUi(self):
self.VideoModeGroupBox.setTitle(translate("SettingsForm", "Video Mode"))
@ -64,21 +64,16 @@ class VideoTab(SettingsTab):
"</style></head><body style=\" font-family:\'DejaVu Sans\'; font-size:10pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-style:italic;\">No video preview available with VMR enabled</span></p></body></html>"))
def onVMRCheckBoxchanged(self):
mode_layout = self.UseVMRCheckBox.checkState()
self.mode_layout = False
if mode_layout == 2: # we have a set value convert to True/False
self.mode_layout = True
def onVMRCheckBoxChanged(self):
use_vmr_mode = self.UseVMRCheckBox.checkState()
self.use_vmr_mode = False
if use_vmr_mode == 2: # we have a set value convert to True/False
self.use_vmr_mode = True
def load(self):
mode_layout = self.config.get_config("use mode layout",u"0" )
self.mode_layout = True
# used for first time initialisation
# mode_layout will be a string with True/False so need to fix and make boolean
if mode_layout == '0'or mode_layout == "False":
self.mode_layout = False
else:
self.use_vmr_mode = self.convertStringToBoolean(self.config.get_config('use mode layout', u'False'))
if self.use_vmr_mode :
self.UseVMRCheckBox.setChecked(True)
def save(self):
self.config.set_config("use mode layout", str(self.mode_layout))
self.config.set_config('use mode layout', str(self.use_vmr_mode))