more clean ups

This commit is contained in:
Andreas Preikschat 2012-05-17 18:53:54 +02:00
parent 56c36f355d
commit a379d9ec54
7 changed files with 34 additions and 67 deletions

View File

@ -78,6 +78,7 @@ QToolBar
} }
""" """
class OpenLP(QtGui.QApplication): class OpenLP(QtGui.QApplication):
""" """
The core application class. This class inherits from Qt's QApplication The core application class. This class inherits from Qt's QApplication
@ -97,7 +98,6 @@ class OpenLP(QtGui.QApplication):
""" """
Run the OpenLP application. Run the OpenLP application.
""" """
# On Windows, the args passed into the constructor are # On Windows, the args passed into the constructor are
# ignored. Not very handy, so set the ones we want to use. # ignored. Not very handy, so set the ones we want to use.
self.args.extend(args) self.args.extend(args)
@ -111,8 +111,7 @@ class OpenLP(QtGui.QApplication):
# Decide how many screens we have and their size # Decide how many screens we have and their size
screens = ScreenList(self.desktop()) screens = ScreenList(self.desktop())
# First time checks in settings # First time checks in settings
has_run_wizard = Settings().value( has_run_wizard = Settings().value(u'general/has run wizard', False)
u'general/has run wizard', False)
if not has_run_wizard: if not has_run_wizard:
if FirstTimeForm(screens).exec_() == QtGui.QDialog.Accepted: if FirstTimeForm(screens).exec_() == QtGui.QDialog.Accepted:
Settings().setValue(u'general/has run wizard', True) Settings().setValue(u'general/has run wizard', True)

View File

@ -190,7 +190,6 @@ class Plugin(QtCore.QObject):
""" """
Sets the status of the plugin Sets the status of the plugin
""" """
#TODO: check if [0] is needed.
self.status = Settings().value( self.status = Settings().value(
self.settingsSection + u'/status', PluginStatus.Inactive) self.settingsSection + u'/status', PluginStatus.Inactive)

View File

@ -348,28 +348,20 @@ class AdvancedTab(SettingsTab):
# 20 will always be used. # 20 will always be used.
self.recentSpinBox.setMaximum(Settings().value( self.recentSpinBox.setMaximum(Settings().value(
u'max recent files', 20)) u'max recent files', 20))
self.recentSpinBox.setValue(settings.value(u'recent file count', self.recentSpinBox.setValue(settings.value(u'recent file count', 4))
4))
self.mediaPluginCheckBox.setChecked( self.mediaPluginCheckBox.setChecked(
settings.value(u'save current plugin', settings.value(u'save current plugin', False))
False))
self.doubleClickLiveCheckBox.setChecked( self.doubleClickLiveCheckBox.setChecked(
settings.value(u'double click live', settings.value(u'double click live', False))
False))
self.singleClickPreviewCheckBox.setChecked( self.singleClickPreviewCheckBox.setChecked(
settings.value(u'single click preview', settings.value(u'single click preview', False))
False))
self.expandServiceItemCheckBox.setChecked( self.expandServiceItemCheckBox.setChecked(
settings.value(u'expand service item', settings.value(u'expand service item', False))
False))
self.enableAutoCloseCheckBox.setChecked( self.enableAutoCloseCheckBox.setChecked(
settings.value(u'enable exit confirmation', settings.value(u'enable exit confirmation', True))
True)) self.hideMouseCheckBox.setChecked(settings.value(u'hide mouse', False))
self.hideMouseCheckBox.setChecked(
settings.value(u'hide mouse', False))
self.serviceNameDay.setCurrentIndex( self.serviceNameDay.setCurrentIndex(
settings.value(u'default service day', settings.value(u'default service day', self.defaultServiceDay))
self.defaultServiceDay))
self.serviceNameTime.setTime(QtCore.QTime( self.serviceNameTime.setTime(QtCore.QTime(
settings.value(u'default service hour', self.defaultServiceHour), settings.value(u'default service hour', self.defaultServiceHour),
settings.value(u'default service minute', settings.value(u'default service minute',

View File

@ -113,8 +113,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
check_directory_exists(os.path.join(gettempdir(), u'openlp')) check_directory_exists(os.path.join(gettempdir(), u'openlp'))
self.noInternetFinishButton.setVisible(False) self.noInternetFinishButton.setVisible(False)
# Check if this is a re-run of the wizard. # Check if this is a re-run of the wizard.
self.hasRunWizard = Settings().value( self.hasRunWizard = Settings().value(u'general/has run wizard', False)
u'general/has run wizard', False)
# Sort out internet access for downloads # Sort out internet access for downloads
if self.webAccess: if self.webAccess:
songs = self.config.get(u'songs', u'languages') songs = self.config.get(u'songs', u'languages')

View File

@ -280,18 +280,14 @@ class GeneralTab(SettingsTab):
self.autoUnblankCheckBox.setChecked(settings.value(u'auto unblank', self.autoUnblankCheckBox.setChecked(settings.value(u'auto unblank',
False)) False))
self.displayOnMonitorCheck.setChecked(self.screens.display) self.displayOnMonitorCheck.setChecked(self.screens.display)
self.warningCheckBox.setChecked(settings.value(u'blank warning', self.warningCheckBox.setChecked(settings.value(u'blank warning', False))
False)) self.autoOpenCheckBox.setChecked(settings.value(u'auto open', False))
self.autoOpenCheckBox.setChecked(settings.value(u'auto open', self.showSplashCheckBox.setChecked(settings.value(u'show splash', True))
False))
self.showSplashCheckBox.setChecked(settings.value(u'show splash',
True))
self.checkForUpdatesCheckBox.setChecked(settings.value(u'update check', self.checkForUpdatesCheckBox.setChecked(settings.value(u'update check',
True)) True))
self.autoPreviewCheckBox.setChecked(settings.value(u'auto preview', self.autoPreviewCheckBox.setChecked(settings.value(u'auto preview',
False)) False))
self.timeoutSpinBox.setValue(settings.value(u'loop delay', self.timeoutSpinBox.setValue(settings.value(u'loop delay', 5))
5))
self.monitorRadioButton.setChecked( self.monitorRadioButton.setChecked(
not settings.value(u'override position', not settings.value(u'override position',
False)) False))

View File

@ -198,8 +198,7 @@ class MainDisplay(Display):
u':/graphics/openlp-splash-screen.png') u':/graphics/openlp-splash-screen.png')
background_color = QtGui.QColor() background_color = QtGui.QColor()
background_color.setNamedColor(Settings().value( background_color.setNamedColor(Settings().value(
u'advanced/default color', u'advanced/default color', u'#ffffff'))
u'#ffffff'))
if not background_color.isValid(): if not background_color.isValid():
background_color = QtCore.Qt.white background_color = QtCore.Qt.white
splash_image = QtGui.QImage(image_file) splash_image = QtGui.QImage(image_file)
@ -350,8 +349,7 @@ class MainDisplay(Display):
# Single screen active # Single screen active
if self.screens.display_count == 1: if self.screens.display_count == 1:
# Only make visible if setting enabled. # Only make visible if setting enabled.
if Settings().value( if Settings().value(u'general/display on monitor', True):
u'general/display on monitor', True):
self.setVisible(True) self.setVisible(True)
else: else:
self.setVisible(True) self.setVisible(True)
@ -399,8 +397,7 @@ class MainDisplay(Display):
self.footer(serviceItem.foot_text) self.footer(serviceItem.foot_text)
# if was hidden keep it hidden # if was hidden keep it hidden
if self.hideMode and self.isLive and not serviceItem.is_media(): if self.hideMode and self.isLive and not serviceItem.is_media():
if Settings().value(u'general/auto unblank', if Settings().value(u'general/auto unblank', False):
False):
Receiver.send_message(u'slidecontroller_live_unblank') Receiver.send_message(u'slidecontroller_live_unblank')
else: else:
self.hideDisplay(self.hideMode) self.hideDisplay(self.hideMode)
@ -423,8 +420,7 @@ class MainDisplay(Display):
log.debug(u'hideDisplay mode = %d', mode) log.debug(u'hideDisplay mode = %d', mode)
if self.screens.display_count == 1: if self.screens.display_count == 1:
# Only make visible if setting enabled. # Only make visible if setting enabled.
if not Settings().value(u'general/display on monitor', if not Settings().value(u'general/display on monitor', True):
True):
return return
if mode == HideMode.Screen: if mode == HideMode.Screen:
self.frame.evaluateJavaScript(u'show_blank("desktop");') self.frame.evaluateJavaScript(u'show_blank("desktop");')
@ -448,8 +444,7 @@ class MainDisplay(Display):
log.debug(u'showDisplay') log.debug(u'showDisplay')
if self.screens.display_count == 1: if self.screens.display_count == 1:
# Only make visible if setting enabled. # Only make visible if setting enabled.
if not Settings().value(u'general/display on monitor', if not Settings().value(u'general/display on monitor', True):
True):
return return
self.frame.evaluateJavaScript('show_blank("show");') self.frame.evaluateJavaScript('show_blank("show");')
if self.isHidden(): if self.isHidden():
@ -463,8 +458,7 @@ class MainDisplay(Display):
""" """
Hide mouse cursor when moved over display. Hide mouse cursor when moved over display.
""" """
if Settings().value(u'advanced/hide mouse', if Settings().value(u'advanced/hide mouse', False):
False):
self.setCursor(QtCore.Qt.BlankCursor) self.setCursor(QtCore.Qt.BlankCursor)
self.frame.evaluateJavaScript('document.body.style.cursor = "none"') self.frame.evaluateJavaScript('document.body.style.cursor = "none"')
else: else:

View File

@ -99,13 +99,10 @@ class Ui_MainWindow(object):
# Create slide controllers # Create slide controllers
self.previewController = SlideController(self) self.previewController = SlideController(self)
self.liveController = SlideController(self, True) self.liveController = SlideController(self, True)
previewVisible = Settings().value( previewVisible = Settings().value(u'user interface/preview panel', True)
u'user interface/preview panel', True)
self.previewController.panel.setVisible(previewVisible) self.previewController.panel.setVisible(previewVisible)
liveVisible = Settings().value(u'user interface/live panel', liveVisible = Settings().value(u'user interface/live panel', True)
True) panelLocked = Settings().value(u'user interface/lock panel', False)
panelLocked = Settings().value(u'user interface/lock panel',
False)
self.liveController.panel.setVisible(liveVisible) self.liveController.panel.setVisible(liveVisible)
# Create menu # Create menu
self.menuBar = QtGui.QMenuBar(mainWindow) self.menuBar = QtGui.QMenuBar(mainWindow)
@ -685,8 +682,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.liveController.screenSizeChanged() self.liveController.screenSizeChanged()
log.info(u'Load data from Settings') log.info(u'Load data from Settings')
if Settings().value(u'advanced/save current plugin', False): if Settings().value(u'advanced/save current plugin', False):
savedPlugin = Settings().value( savedPlugin = Settings().value(u'advanced/current media plugin', -1)
u'advanced/current media plugin', )
if savedPlugin != -1: if savedPlugin != -1:
self.mediaToolBox.setCurrentIndex(savedPlugin) self.mediaToolBox.setCurrentIndex(savedPlugin)
self.settingsForm.postSetUp() self.settingsForm.postSetUp()
@ -738,10 +734,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
filename = unicode(filename, sys.getfilesystemencoding()) filename = unicode(filename, sys.getfilesystemencoding())
self.serviceManagerContents.loadFile(filename) self.serviceManagerContents.loadFile(filename)
elif Settings().value( elif Settings().value(
self.generalSettingsSection + u'/auto open', self.generalSettingsSection + u'/auto open', False):
False):
self.serviceManagerContents.loadLastFile() self.serviceManagerContents.loadLastFile()
view_mode = Settings().value(u'%s/view mode' % \ view_mode = Settings().value(u'%s/view mode' %
self.generalSettingsSection, u'default') self.generalSettingsSection, u'default')
if view_mode == u'default': if view_mode == u'default':
self.modeDefaultItem.setChecked(True) self.modeDefaultItem.setChecked(True)
@ -954,8 +949,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
for plugin in self.pluginManager.plugins: for plugin in self.pluginManager.plugins:
setting_sections.extend([plugin.name]) setting_sections.extend([plugin.name])
settings = Settings() settings = Settings()
import_settings = Settings(import_file_name, import_settings = Settings(import_file_name, QtCore.QSettings.IniFormat)
QtCore.QSettings.IniFormat)
import_keys = import_settings.allKeys() import_keys = import_settings.allKeys()
for section_key in import_keys: for section_key in import_keys:
# We need to handle the really bad files. # We need to handle the really bad files.
@ -988,8 +982,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
now = datetime.now() now = datetime.now()
settings.beginGroup(self.headerSection) settings.beginGroup(self.headerSection)
settings.setValue(u'file_imported', import_file_name) settings.setValue(u'file_imported', import_file_name)
settings.setValue(u'file_date_imported', settings.setValue(u'file_date_imported', now.strftime("%Y-%m-%d %H:%M"))
now.strftime("%Y-%m-%d %H:%M"))
settings.endGroup() settings.endGroup()
settings.sync() settings.sync()
# We must do an immediate restart or current configuration will # We must do an immediate restart or current configuration will
@ -1043,8 +1036,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
settings.remove(self.headerSection) settings.remove(self.headerSection)
# Get the settings. # Get the settings.
keys = settings.allKeys() keys = settings.allKeys()
export_settings = Settings(temp_file, export_settings = Settings(temp_file, QtCore.QSettings.IniFormat)
QtCore.QSettings.IniFormat)
# Add a header section. # Add a header section.
# This is to insure it's our conf file for import. # This is to insure it's our conf file for import.
now = datetime.now() now = datetime.now()
@ -1147,8 +1139,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
else: else:
event.ignore() event.ignore()
else: else:
if Settings().value(u'advanced/enable exit confirmation', if Settings().value(u'advanced/enable exit confirmation', True):
True):
ret = QtGui.QMessageBox.question(self, ret = QtGui.QMessageBox.question(self,
translate('OpenLP.MainWindow', 'Close OpenLP'), translate('OpenLP.MainWindow', 'Close OpenLP'),
translate('OpenLP.MainWindow', translate('OpenLP.MainWindow',
@ -1172,8 +1163,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
""" """
# Clean temporary files used by services # Clean temporary files used by services
self.serviceManagerContents.cleanUp() self.serviceManagerContents.cleanUp()
if Settings().value(u'advanced/save current plugin', if Settings().value(u'advanced/save current plugin', False):
False):
Settings().setValue(u'advanced/current media plugin', Settings().setValue(u'advanced/current media plugin',
self.mediaToolBox.currentIndex()) self.mediaToolBox.currentIndex())
# Call the cleanup method to shutdown plugins. # Call the cleanup method to shutdown plugins.
@ -1368,8 +1358,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
Updates the recent file menu with the latest list of service files Updates the recent file menu with the latest list of service files
accessed. accessed.
""" """
recentFileCount = Settings().value( recentFileCount = Settings().value(u'advanced/recent file count', 4)
u'advanced/recent file count', 4)
existingRecentFiles = [recentFile for recentFile in self.recentFiles existingRecentFiles = [recentFile for recentFile in self.recentFiles
if os.path.isfile(unicode(recentFile))] if os.path.isfile(unicode(recentFile))]
recentFilesToDisplay = existingRecentFiles[0:recentFileCount] recentFilesToDisplay = existingRecentFiles[0:recentFileCount]
@ -1401,8 +1390,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
# The maxRecentFiles value does not have an interface and so never gets # The maxRecentFiles value does not have an interface and so never gets
# actually stored in the settings therefore the default value of 20 will # actually stored in the settings therefore the default value of 20 will
# always be used. # always be used.
maxRecentFiles = Settings().value( maxRecentFiles = Settings().value(u'advanced/max recent files', 20)
u'advanced/max recent files', 20)
if filename: if filename:
# Add some cleanup to reduce duplication in the recent file list # Add some cleanup to reduce duplication in the recent file list
filename = os.path.abspath(filename) filename = os.path.abspath(filename)