Add the option to change the default display.

bzr-revno: 1328
This commit is contained in:
Raoul Snyman 2011-02-23 23:43:47 +00:00 committed by Jon Tibble
commit 7b382123ff
2 changed files with 77 additions and 43 deletions

View File

@ -28,8 +28,9 @@ The :mod:`advancedtab` provides an advanced settings facility.
"""
from PyQt4 import QtCore, QtGui
from openlp.core.lib import SettingsTab, translate
from openlp.core.lib import SettingsTab, translate, build_icon
from openlp.core.lib.ui import UiStrings
from openlp.core.utils import get_images_filter
class AdvancedTab(SettingsTab):
"""
@ -41,6 +42,8 @@ class AdvancedTab(SettingsTab):
Initialise the settings tab
"""
SettingsTab.__init__(self, u'Advanced')
self.default_image = u':/graphics/openlp-splash-screen.png'
self.default_color = u'#ffffff'
def setupUi(self):
"""
@ -81,33 +84,38 @@ class AdvancedTab(SettingsTab):
self.hideMouseCheckBox.setObjectName(u'hideMouseCheckBox')
self.hideMouseLayout.addWidget(self.hideMouseCheckBox)
self.leftLayout.addWidget(self.hideMouseGroupBox)
# self.sharedDirGroupBox = QtGui.QGroupBox(self.leftColumn)
# self.sharedDirGroupBox.setObjectName(u'sharedDirGroupBox')
# self.sharedDirLayout = QtGui.QFormLayout(self.sharedDirGroupBox)
# self.sharedCheckBox = QtGui.QCheckBox(self.sharedDirGroupBox)
# self.sharedCheckBox.setObjectName(u'sharedCheckBox')
# self.sharedDirLayout.addRow(self.sharedCheckBox)
# self.sharedLabel = QtGui.QLabel(self.sharedDirGroupBox)
# self.sharedLabel.setObjectName(u'sharedLabel')
# self.sharedSubLayout = QtGui.QHBoxLayout()
# self.sharedSubLayout.setObjectName(u'sharedSubLayout')
# self.sharedLineEdit = QtGui.QLineEdit(self.sharedDirGroupBox)
# self.sharedLineEdit.setObjectName(u'sharedLineEdit')
# self.sharedSubLayout.addWidget(self.sharedLineEdit)
# self.sharedPushButton = QtGui.QPushButton(self.sharedDirGroupBox)
# self.sharedPushButton.setObjectName(u'sharedPushButton')
# self.sharedSubLayout.addWidget(self.sharedPushButton)
# self.sharedDirLayout.addRow(self.sharedLabel, self.sharedSubLayout)
# self.leftLayout.addWidget(self.sharedDirGroupBox)
self.leftLayout.addStretch()
# self.databaseGroupBox = QtGui.QGroupBox(self.rightColumn)
# self.databaseGroupBox.setObjectName(u'databaseGroupBox')
# self.databaseGroupBox.setEnabled(False)
# self.databaseLayout = QtGui.QVBoxLayout(self.databaseGroupBox)
# self.rightLayout.addWidget(self.databaseGroupBox)
self.defaultImageGroupBox = QtGui.QGroupBox(self.rightColumn)
self.defaultImageGroupBox.setObjectName(u'defaultImageGroupBox')
self.defaultImageLayout = QtGui.QFormLayout(self.defaultImageGroupBox)
self.defaultImageLayout.setObjectName(u'defaultImageLayout')
self.defaultColorLabel = QtGui.QLabel(self.defaultImageGroupBox)
self.defaultColorLabel.setObjectName(u'defaultColorLabel')
self.defaultColorButton = QtGui.QPushButton(self.defaultImageGroupBox)
self.defaultColorButton.setObjectName(u'defaultColorButton')
self.defaultImageLayout.addRow(self.defaultColorLabel,
self.defaultColorButton)
self.defaultFileLabel = QtGui.QLabel(self.defaultImageGroupBox)
self.defaultFileLabel.setObjectName(u'defaultFileLabel')
self.defaultFileEdit = QtGui.QLineEdit(self.defaultImageGroupBox)
self.defaultFileEdit.setObjectName(u'defaultFileEdit')
self.defaultBrowseButton = QtGui.QToolButton(self.defaultImageGroupBox)
self.defaultBrowseButton.setObjectName(u'defaultBrowseButton')
self.defaultBrowseButton.setIcon(
build_icon(u':/general/general_open.png'))
self.defaultFileLayout = QtGui.QHBoxLayout()
self.defaultFileLayout.setObjectName(u'defaultFileLayout')
self.defaultFileLayout.addWidget(self.defaultFileEdit)
self.defaultFileLayout.addWidget(self.defaultBrowseButton)
self.defaultImageLayout.addRow(self.defaultFileLabel,
self.defaultFileLayout)
self.rightLayout.addWidget(self.defaultImageGroupBox)
self.rightLayout.addStretch()
# QtCore.QObject.connect(self.sharedCheckBox,
# QtCore.SIGNAL(u'stateChanged(int)'), self.onSharedCheckBoxChanged)
QtCore.QObject.connect(self.defaultColorButton,
QtCore.SIGNAL(u'pressed()'), self.onDefaultColorButtonPressed)
QtCore.QObject.connect(self.defaultBrowseButton,
QtCore.SIGNAL(u'pressed()'), self.onDefaultBrowseButtonPressed)
def retranslateUi(self):
"""
@ -129,14 +137,13 @@ class AdvancedTab(SettingsTab):
self.hideMouseGroupBox.setTitle(translate('OpenLP.AdvancedTab',
'Mouse Cursor'))
self.hideMouseCheckBox.setText(translate('OpenLP.AdvancedTab',
'Hide the mouse cursor when moved over the display window'))
# self.sharedDirGroupBox.setTitle(
# translate('AdvancedTab', 'Central Data Store'))
# self.sharedCheckBox.setText(
# translate('AdvancedTab', 'Enable a shared data location'))
# self.sharedLabel.setText(translate('AdvancedTab', 'Store location:'))
# self.sharedPushButton.setText(UiStrings.Browse)
# self.databaseGroupBox.setTitle(translate('AdvancedTab', 'Databases'))
'Hide mouse cursor when over display window'))
self.defaultImageGroupBox.setTitle(translate('OpenLP.AdvancedTab',
'Default Image'))
self.defaultColorLabel.setText(translate('OpenLP.AdvancedTab',
'Background color:'))
self.defaultFileLabel.setText(translate('OpenLP.AdvancedTab',
'Image file:'))
def load(self):
"""
@ -165,7 +172,14 @@ class AdvancedTab(SettingsTab):
QtCore.QVariant(True)).toBool())
self.hideMouseCheckBox.setChecked(
settings.value(u'hide mouse', QtCore.QVariant(False)).toBool())
self.default_color = settings.value(u'default color',
QtCore.QVariant(u'#ffffff')).toString()
self.defaultFileEdit.setText(settings.value(u'default image',
QtCore.QVariant(u':/graphics/openlp-splash-screen.png'))\
.toString())
settings.endGroup()
self.defaultColorButton.setStyleSheet(
u'background-color: %s' % self.default_color)
def save(self):
"""
@ -185,12 +199,24 @@ class AdvancedTab(SettingsTab):
QtCore.QVariant(self.enableAutoCloseCheckBox.isChecked()))
settings.setValue(u'hide mouse',
QtCore.QVariant(self.hideMouseCheckBox.isChecked()))
settings.setValue(u'default color', self.default_color)
settings.setValue(u'default image', self.defaultFileEdit.text())
settings.endGroup()
# def onSharedCheckBoxChanged(self, checked):
# """
# Enables the widgets to allow a shared data location
# """
# self.sharedLabel.setEnabled(checked)
# self.sharedTextEdit.setEnabled(checked)
# self.sharedPushButton.setEnabled(checked)
def onDefaultColorButtonPressed(self):
new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.default_color), self)
if new_color.isValid():
self.default_color = new_color.name()
self.defaultColorButton.setStyleSheet(
u'background-color: %s' % self.default_color)
def onDefaultBrowseButtonPressed(self):
file_filters = u'%s;;%s (*.*) (*)' % (get_images_filter(),
UiStrings.AllFiles)
filename = QtGui.QFileDialog.getOpenFileName(self,
translate('OpenLP.AdvancedTab', 'Open File'), '',
file_filters)
if filename:
self.defaultFileEdit.setText(filename)
self.defaultFileEdit.setFocus()

View File

@ -132,14 +132,22 @@ class MainDisplay(DisplayWidget):
painter_image.begin(self.black)
painter_image.fillRect(self.black.rect(), QtCore.Qt.black)
# Build the initial frame.
image_file = QtCore.QSettings().value(u'advanced/default image',
QtCore.QVariant(u':/graphics/openlp-splash-screen.png'))\
.toString()
background_color = QtGui.QColor(QtCore.QSettings().value(
u'advanced/default color',
QtCore.QVariant(u'#ffffff')).toString())
if not background_color.isValid():
background_color = QtCore.Qt.white
splash_image = QtGui.QImage(image_file)
initialFrame = QtGui.QImage(
self.screens.current[u'size'].width(),
self.screens.current[u'size'].height(),
QtGui.QImage.Format_ARGB32_Premultiplied)
splash_image = QtGui.QImage(u':/graphics/openlp-splash-screen.png')
painter_image = QtGui.QPainter()
painter_image.begin(initialFrame)
painter_image.fillRect(initialFrame.rect(), QtCore.Qt.white)
painter_image.fillRect(initialFrame.rect(), background_color)
painter_image.drawImage(
(self.screens.current[u'size'].width() -
splash_image.width()) / 2,