forked from openlp/openlp
add custom colorbutton widget
This commit is contained in:
parent
5662f4b2af
commit
a4f788599f
@ -318,6 +318,7 @@ def create_separated_list(string_list):
|
|||||||
return translate('OpenLP.core.lib', '%s, %s', 'Locale list separator: start') % (string_list[0], merged)
|
return translate('OpenLP.core.lib', '%s, %s', 'Locale list separator: start') % (string_list[0], merged)
|
||||||
|
|
||||||
|
|
||||||
|
from .colorbutton import ColorButton
|
||||||
from .filedialog import FileDialog
|
from .filedialog import FileDialog
|
||||||
from .screen import ScreenList
|
from .screen import ScreenList
|
||||||
from .listwidgetwithdnd import ListWidgetWithDnD
|
from .listwidgetwithdnd import ListWidgetWithDnD
|
||||||
|
33
openlp/core/lib/colorbutton.py
Normal file
33
openlp/core/lib/colorbutton.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
|
class ColorButton(QtGui.QPushButton):
|
||||||
|
"""
|
||||||
|
Subclasses QPushbutton to create a "Color Chooser" button
|
||||||
|
"""
|
||||||
|
|
||||||
|
colorChanged = QtCore.pyqtSignal(str)
|
||||||
|
|
||||||
|
def __init__(self, parent):
|
||||||
|
super(ColorButton, self).__init__()
|
||||||
|
self._color = '#ffffff'
|
||||||
|
self.parent = parent
|
||||||
|
self.clicked.connect(self.on_clicked)
|
||||||
|
|
||||||
|
def change_color(self, color):
|
||||||
|
self._color = color
|
||||||
|
self.setStyleSheet('background-color: %s' % color)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def color(self):
|
||||||
|
return self._color
|
||||||
|
|
||||||
|
@color.setter
|
||||||
|
def color(self, color):
|
||||||
|
self.change_color(color)
|
||||||
|
|
||||||
|
def on_clicked(self):
|
||||||
|
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())
|
Loading…
Reference in New Issue
Block a user