presets are working
except for font because it can't be represented as a string
This commit is contained in:
parent
ca7e8bdb0d
commit
5295a6d9ae
|
@ -5,11 +5,12 @@ class Component:
|
|||
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()
|
||||
|
@ -17,6 +18,8 @@ class Component:
|
|||
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 '''
|
||||
|
@ -58,7 +61,9 @@ class Component:
|
|||
image = Image.new("RGBA", (width, height), (0,0,0,0))
|
||||
return image
|
||||
|
||||
def version(self):
|
||||
# change this number to identify new versions of your component
|
||||
return 1
|
||||
def loadPreset(self, presetDict):
|
||||
# update widgets using a preset dict
|
||||
|
||||
def savePreset(self):
|
||||
return {}
|
||||
'''
|
||||
|
|
|
@ -32,12 +32,15 @@ class Component(__base__.Component):
|
|||
self.visColor = self.RGBFromString(self.page.lineEdit_visColor.text())
|
||||
self.parent.drawPreview()
|
||||
|
||||
def loadPreset(self, presetDict):
|
||||
self.preFrameRender(**presetDict)
|
||||
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 { 'layout' : self.page.comboBox_visLayout.currentIndex(),
|
||||
'visColor' : self.page.lineEdit_visColor.text(),
|
||||
return { 'layout' : self.layout,
|
||||
'visColor' : self.visColor,
|
||||
}
|
||||
|
||||
def previewRender(self, previewWorker):
|
||||
|
@ -61,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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Reference in New Issue