diff --git a/openlp/core/lib/colorbutton.py b/openlp/core/lib/colorbutton.py index 00ef9dffe..69ccc0027 100644 --- a/openlp/core/lib/colorbutton.py +++ b/openlp/core/lib/colorbutton.py @@ -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()) \ No newline at end of file + self.colorChanged.emit(new_color.name()) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index b0d48a21e..800bd791d 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -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.')) diff --git a/openlp/plugins/images/lib/imagetab.py b/openlp/plugins/images/lib/imagetab.py index ceac8545d..5fbfd2502 100644 --- a/openlp/plugins/images/lib/imagetab.py +++ b/openlp/plugins/images/lib/imagetab.py @@ -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()