From a5b278b87129b65d7e1ab9d671e1806ee8588c7e Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Wed, 23 Feb 2011 08:42:33 +0200 Subject: [PATCH 1/3] Added a setting in the advanced tab to give the users the option of changing the default display screen. --- openlp/core/ui/advancedtab.py | 86 +++++++++++++++++++---------------- openlp/core/ui/maindisplay.py | 12 ++++- 2 files changed, 56 insertions(+), 42 deletions(-) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 39fec1f9d..5395e59ef 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -41,6 +41,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 +83,28 @@ 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.defaultImageLayout.addRow(self.defaultFileLabel, + self.defaultFileEdit) + 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) def retranslateUi(self): """ @@ -129,14 +126,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 +161,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 +188,15 @@ class AdvancedTab(SettingsTab): QtCore.QVariant(self.enableAutoCloseCheckBox.isChecked())) settings.setValue(u'hide mouse', QtCore.QVariant(self.hideMouseCheckBox.isChecked())) + settings.setValue(u'default background color', self.default_color) + settings.setValue(u'default image', self.default_image) 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) + diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 90042f80b..91d61f1d7 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -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, From 99635299ead388ddd99b3a363564e41fc1d0cc5d Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Wed, 23 Feb 2011 15:55:36 +0200 Subject: [PATCH 2/3] Updated with browse button. --- openlp/core/ui/advancedtab.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 5395e59ef..35bc167c0 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -98,8 +98,14 @@ class AdvancedTab(SettingsTab): 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.defaultFileLayout = QtGui.QHBoxLayout() + self.defaultFileLayout.setObjectName(u'defaultFileLayout') + self.defaultFileLayout.addWidget(self.defaultFileEdit) + self.defaultFileLayout.addWidget(self.defaultBrowseButton) self.defaultImageLayout.addRow(self.defaultFileLabel, - self.defaultFileEdit) + self.defaultFileLayout) self.rightLayout.addWidget(self.defaultImageGroupBox) self.rightLayout.addStretch() @@ -133,6 +139,7 @@ class AdvancedTab(SettingsTab): 'Background color:')) self.defaultFileLabel.setText(translate('OpenLP.AdvancedTab', 'Image file:')) + self.defaultBrowseButton.setTitle('...') def load(self): """ From c74b2fc964fa34d9c8fe84e7db6b74d12da9452e Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Wed, 23 Feb 2011 22:55:55 +0200 Subject: [PATCH 3/3] Updated the settings tab. --- openlp/core/ui/advancedtab.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 35bc167c0..5cb22cb8b 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -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): """ @@ -100,6 +101,8 @@ class AdvancedTab(SettingsTab): 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) @@ -111,6 +114,8 @@ class AdvancedTab(SettingsTab): 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): """ @@ -139,7 +144,6 @@ class AdvancedTab(SettingsTab): 'Background color:')) self.defaultFileLabel.setText(translate('OpenLP.AdvancedTab', 'Image file:')) - self.defaultBrowseButton.setTitle('...') def load(self): """ @@ -195,8 +199,8 @@ class AdvancedTab(SettingsTab): QtCore.QVariant(self.enableAutoCloseCheckBox.isChecked())) settings.setValue(u'hide mouse', QtCore.QVariant(self.hideMouseCheckBox.isChecked())) - settings.setValue(u'default background color', self.default_color) - settings.setValue(u'default image', self.default_image) + settings.setValue(u'default color', self.default_color) + settings.setValue(u'default image', self.defaultFileEdit.text()) settings.endGroup() def onDefaultColorButtonPressed(self): @@ -207,3 +211,12 @@ class AdvancedTab(SettingsTab): 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()