aboutsummaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
Diffstat (limited to 'components')
-rw-r--r--components/__base__.py22
-rw-r--r--components/original.py13
-rw-r--r--components/text.py25
3 files changed, 47 insertions, 13 deletions
diff --git a/components/__base__.py b/components/__base__.py
index 87440bb..05d5cb6 100644
--- a/components/__base__.py
+++ b/components/__base__.py
@@ -3,17 +3,23 @@ from PyQt4 import QtGui
class Component:
def __str__(self):
return self.__doc__
+
+ def version(self):
+ # change this number to identify new versions of a component
+ return 1
def preFrameRender(self, **kwargs):
- for kwarg, value in kwargs.items():
- exec('self.%s = value' % kwarg)
+ for item in kwargs.items():
+ exec('self.%s = %s' % item)
def pickColor(self):
color = QtGui.QColorDialog.getColor()
if color.isValid():
- RGBstring = '%s,%s,%s' % (str(color.red()), str(color.green()), str(color.blue()))
- btnStyle = "QPushButton { background-color : %s; outline: none; }" % color.name()
- return RGBstring, btnStyle
+ RGBstring = '%s,%s,%s' % (str(color.red()), str(color.green()), str(color.blue()))
+ btnStyle = "QPushButton { background-color : %s; outline: none; }" % color.name()
+ return RGBstring, btnStyle
+ else:
+ return None, None
def RGBFromString(self, string):
''' turns an RGB string like "255, 255, 255" into a tuple '''
@@ -54,4 +60,10 @@ class Component:
height = int(self.worker.core.settings.value('outputHeight'))
image = Image.new("RGBA", (width, height), (0,0,0,0))
return image
+
+ def loadPreset(self, presetDict):
+ # update widgets using a preset dict
+
+ def savePreset(self):
+ return {}
'''
diff --git a/components/original.py b/components/original.py
index 47e53b8..bebfdf2 100644
--- a/components/original.py
+++ b/components/original.py
@@ -32,11 +32,16 @@ class Component(__base__.Component):
self.visColor = self.RGBFromString(self.page.lineEdit_visColor.text())
self.parent.drawPreview()
- def version(self):
- return 1
+ def loadPreset(self, pr):
+ self.page.lineEdit_visColor.setText('%s,%s,%s' % pr['visColor'])
+ btnStyle = "QPushButton { background-color : %s; outline: none; }" % QColor(*pr['visColor']).name()
+ self.page.pushButton_visColor.setStyleSheet(btnStyle)
+ self.page.comboBox_visLayout.setCurrentIndex(pr['layout'])
def savePreset(self):
- return {}
+ return { 'layout' : self.layout,
+ 'visColor' : self.visColor,
+ }
def previewRender(self, previewWorker):
spectrum = numpy.fromfunction(lambda x: 0.008*(x-128)**2, (255,), dtype="int16")
@@ -59,6 +64,8 @@ class Component(__base__.Component):
def pickColor(self):
RGBstring, btnStyle = super().pickColor()
+ if not RGBstring:
+ return
self.page.lineEdit_visColor.setText(RGBstring)
self.page.pushButton_visColor.setStyleSheet(btnStyle)
diff --git a/components/text.py b/components/text.py
index c9359f2..23e65eb 100644
--- a/components/text.py
+++ b/components/text.py
@@ -53,9 +53,6 @@ class Component(__base__.Component):
self.page = page
return page
- def version(self):
- return 1
-
def update(self):
self.title = self.page.lineEdit_title.text()
self.alignment = self.page.comboBox_textAlign.currentIndex()
@@ -71,11 +68,27 @@ class Component(__base__.Component):
self.xPosition = self.xPosition - fm.width(self.title)/2
if self.alignment == 2: #Right
self.xPosition = self.xPosition - fm.width(self.title)
-
self.parent.drawPreview()
+
+ def loadPreset(self, pr):
+ self.page.lineEdit_title.setText(pr['title'])
+ self.page.spinBox_fontSize.setValue(pr['fontSize'])
+ self.page.spinBox_xTextAlign.setValue(pr['xPosition'])
+ self.page.spinBox_yTextAlign.setValue(pr['yPosition'])
+ self.page.comboBox_textAlign.setCurrentIndex(pr['alignment'])
+ self.page.lineEdit_textColor.setText('%s,%s,%s' % pr['textColor'])
+ btnStyle = "QPushButton { background-color : %s; outline: none; }" % QColor(*pr['textColor']).name()
+ self.page.pushButton_textColor.setStyleSheet(btnStyle)
def savePreset(self):
- return {}
+ return {
+ 'title' : self.title,
+ 'alignment' : self.alignment,
+ 'fontSize' : self.fontSize,
+ 'xPosition' : self.xPosition,
+ 'yPosition' : self.yPosition,
+ 'textColor' : self.textColor
+ }
def previewRender(self, previewWorker):
width = int(previewWorker.core.settings.value('outputWidth'))
@@ -117,5 +130,7 @@ class Component(__base__.Component):
def pickColor(self):
RGBstring, btnStyle = super().pickColor()
+ if not RGBstring:
+ return
self.page.lineEdit_textColor.setText(RGBstring)
self.page.pushButton_textColor.setStyleSheet(btnStyle)