From 980ed505e20fa252021a53abbbf236f52d0f7bdd Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 6 Mar 2009 06:05:01 +0000 Subject: [PATCH] Tidy up Video and Bible tab code. bzr-revno: 381 --- openlp/core/lib/settingstab.py | 6 ++ openlp/plugins/bibles/lib/biblestab.py | 79 ++++++++++++-------------- openlp/plugins/videos/lib/videotab.py | 29 ++++------ 3 files changed, 55 insertions(+), 59 deletions(-) diff --git a/openlp/core/lib/settingstab.py b/openlp/core/lib/settingstab.py index 5c93c4a11..672be9f9f 100644 --- a/openlp/core/lib/settingstab.py +++ b/openlp/core/lib/settingstab.py @@ -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 diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index f819484b9..3f6bc3514 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -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)) diff --git a/openlp/plugins/videos/lib/videotab.py b/openlp/plugins/videos/lib/videotab.py index 38394ccac..c6c041a98 100644 --- a/openlp/plugins/videos/lib/videotab.py +++ b/openlp/plugins/videos/lib/videotab.py @@ -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): "\n" "

No video preview available with VMR enabled

")) - 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))