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,18 +5,21 @@ class Component:
|
||||||
return self.__doc__
|
return self.__doc__
|
||||||
|
|
||||||
def version(self):
|
def version(self):
|
||||||
|
# change this number to identify new versions of a component
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def preFrameRender(self, **kwargs):
|
def preFrameRender(self, **kwargs):
|
||||||
for kwarg, value in kwargs.items():
|
for item in kwargs.items():
|
||||||
exec('self.%s = value' % kwarg)
|
exec('self.%s = %s' % item)
|
||||||
|
|
||||||
def pickColor(self):
|
def pickColor(self):
|
||||||
color = QtGui.QColorDialog.getColor()
|
color = QtGui.QColorDialog.getColor()
|
||||||
if color.isValid():
|
if color.isValid():
|
||||||
RGBstring = '%s,%s,%s' % (str(color.red()), str(color.green()), str(color.blue()))
|
RGBstring = '%s,%s,%s' % (str(color.red()), str(color.green()), str(color.blue()))
|
||||||
btnStyle = "QPushButton { background-color : %s; outline: none; }" % color.name()
|
btnStyle = "QPushButton { background-color : %s; outline: none; }" % color.name()
|
||||||
return RGBstring, btnStyle
|
return RGBstring, btnStyle
|
||||||
|
else:
|
||||||
|
return None, None
|
||||||
|
|
||||||
def RGBFromString(self, string):
|
def RGBFromString(self, string):
|
||||||
''' turns an RGB string like "255, 255, 255" into a tuple '''
|
''' 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))
|
image = Image.new("RGBA", (width, height), (0,0,0,0))
|
||||||
return image
|
return image
|
||||||
|
|
||||||
def version(self):
|
def loadPreset(self, presetDict):
|
||||||
# change this number to identify new versions of your component
|
# update widgets using a preset dict
|
||||||
return 1
|
|
||||||
|
def savePreset(self):
|
||||||
|
return {}
|
||||||
'''
|
'''
|
||||||
|
|
|
@ -32,12 +32,15 @@ class Component(__base__.Component):
|
||||||
self.visColor = self.RGBFromString(self.page.lineEdit_visColor.text())
|
self.visColor = self.RGBFromString(self.page.lineEdit_visColor.text())
|
||||||
self.parent.drawPreview()
|
self.parent.drawPreview()
|
||||||
|
|
||||||
def loadPreset(self, presetDict):
|
def loadPreset(self, pr):
|
||||||
self.preFrameRender(**presetDict)
|
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):
|
def savePreset(self):
|
||||||
return { 'layout' : self.page.comboBox_visLayout.currentIndex(),
|
return { 'layout' : self.layout,
|
||||||
'visColor' : self.page.lineEdit_visColor.text(),
|
'visColor' : self.visColor,
|
||||||
}
|
}
|
||||||
|
|
||||||
def previewRender(self, previewWorker):
|
def previewRender(self, previewWorker):
|
||||||
|
@ -61,6 +64,8 @@ class Component(__base__.Component):
|
||||||
|
|
||||||
def pickColor(self):
|
def pickColor(self):
|
||||||
RGBstring, btnStyle = super().pickColor()
|
RGBstring, btnStyle = super().pickColor()
|
||||||
|
if not RGBstring:
|
||||||
|
return
|
||||||
self.page.lineEdit_visColor.setText(RGBstring)
|
self.page.lineEdit_visColor.setText(RGBstring)
|
||||||
self.page.pushButton_visColor.setStyleSheet(btnStyle)
|
self.page.pushButton_visColor.setStyleSheet(btnStyle)
|
||||||
|
|
||||||
|
|
|
@ -53,9 +53,6 @@ class Component(__base__.Component):
|
||||||
self.page = page
|
self.page = page
|
||||||
return page
|
return page
|
||||||
|
|
||||||
def version(self):
|
|
||||||
return 1
|
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
self.title = self.page.lineEdit_title.text()
|
self.title = self.page.lineEdit_title.text()
|
||||||
self.alignment = self.page.comboBox_textAlign.currentIndex()
|
self.alignment = self.page.comboBox_textAlign.currentIndex()
|
||||||
|
@ -71,11 +68,27 @@ class Component(__base__.Component):
|
||||||
self.xPosition = self.xPosition - fm.width(self.title)/2
|
self.xPosition = self.xPosition - fm.width(self.title)/2
|
||||||
if self.alignment == 2: #Right
|
if self.alignment == 2: #Right
|
||||||
self.xPosition = self.xPosition - fm.width(self.title)
|
self.xPosition = self.xPosition - fm.width(self.title)
|
||||||
|
|
||||||
self.parent.drawPreview()
|
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):
|
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):
|
def previewRender(self, previewWorker):
|
||||||
width = int(previewWorker.core.settings.value('outputWidth'))
|
width = int(previewWorker.core.settings.value('outputWidth'))
|
||||||
|
@ -117,5 +130,7 @@ class Component(__base__.Component):
|
||||||
|
|
||||||
def pickColor(self):
|
def pickColor(self):
|
||||||
RGBstring, btnStyle = super().pickColor()
|
RGBstring, btnStyle = super().pickColor()
|
||||||
|
if not RGBstring:
|
||||||
|
return
|
||||||
self.page.lineEdit_textColor.setText(RGBstring)
|
self.page.lineEdit_textColor.setText(RGBstring)
|
||||||
self.page.pushButton_textColor.setStyleSheet(btnStyle)
|
self.page.pushButton_textColor.setStyleSheet(btnStyle)
|
||||||
|
|
5
main.py
5
main.py
|
@ -400,9 +400,8 @@ class Main(QtCore.QObject):
|
||||||
for line in f:
|
for line in f:
|
||||||
saveValueStore = eval(line.strip())
|
saveValueStore = eval(line.strip())
|
||||||
break
|
break
|
||||||
print(saveValueStore)
|
self.selectedComponents[index].loadPreset(saveValueStore)
|
||||||
|
self.drawPreview()
|
||||||
|
|
||||||
|
|
||||||
def LoadDefaultSettings(self):
|
def LoadDefaultSettings(self):
|
||||||
self.resolutions = [
|
self.resolutions = [
|
||||||
|
|
Reference in New Issue