Few tweeks, and comments

This commit is contained in:
Phill Ridout 2014-10-24 21:46:14 +01:00
parent 2f9df8cfbd
commit 8696482f39
3 changed files with 27 additions and 5 deletions

View File

@ -1,5 +1,7 @@
from PyQt4 import QtCore, QtGui
from openlp.core.common import translate
class ColorButton(QtGui.QPushButton):
"""
Subclasses QPushbutton to create a "Color Chooser" button
@ -8,26 +10,47 @@ class ColorButton(QtGui.QPushButton):
colorChanged = QtCore.pyqtSignal(str)
def __init__(self, parent):
"""
Initialise the ColorButton
"""
super(ColorButton, self).__init__()
self._color = '#ffffff'
self.parent = parent
self._color = '#ffffff'
self.setToolTip(translate('OpenLP.ColorButton', 'Click to select a color.'))
self.clicked.connect(self.on_clicked)
def change_color(self, color):
"""
Sets the _color variable and the background color.
:param color: String representation of a hexidecimal color
"""
self._color = color
self.setStyleSheet('background-color: %s' % color)
@property
def color(self):
"""
Property method to return the color variable
:return: String representation of a hexidecimal color
"""
return self._color
@color.setter
def color(self, color):
"""
Property setter to change the imstamce color
:param color: String representation of a hexidecimal color
"""
self.change_color(color)
def on_clicked(self):
"""
Handle the PushButton clicked signal, showing the ColorDialog and validating the input
"""
new_color = QtGui.QColorDialog.getColor(QtGui.QColor(self._color), self.parent)
if new_color.isValid() and self._color != new_color.name():
self.change_color(new_color.name())
print("changed")
self.colorChanged.emit(new_color.name())
self.colorChanged.emit(new_color.name())

View File

@ -299,7 +299,6 @@ class AdvancedTab(SettingsTab):
self.hide_mouse_check_box.setText(translate('OpenLP.AdvancedTab', 'Hide mouse cursor when over display window'))
self.default_image_group_box.setTitle(translate('OpenLP.AdvancedTab', 'Default Image'))
self.default_color_label.setText(translate('OpenLP.AdvancedTab', 'Background color:'))
self.default_color_button.setToolTip(translate('OpenLP.AdvancedTab', 'Click to select a color.'))
self.default_file_label.setText(translate('OpenLP.AdvancedTab', 'Image file:'))
self.default_browse_button.setToolTip(translate('OpenLP.AdvancedTab', 'Browse for an image file to display.'))
self.default_revert_button.setToolTip(translate('OpenLP.AdvancedTab', 'Revert to the default OpenLP logo.'))

View File

@ -73,7 +73,7 @@ class ImageTab(SettingsTab):
translate('ImagesPlugin.ImageTab', 'Visible background for images with aspect ratio different to screen.'))
def on_background_color_button_changed(self, color):
self.background_color = new_color.name()
self.background_color = color
def load(self):
settings = Settings()