aboutsummaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
authortassaron2017-08-01 17:57:39 -0400
committertassaron2017-08-01 17:57:39 -0400
commit3c1b52205f183e9a2c943c5f666ed2c01db3aaf5 (patch)
tree0b92d6d2a1a21b87bd9f2f19181da15c09a1408b /src/components
parenta472246dab69d0676c3c78ecd61659e432c960b4 (diff)
component class now tracks colorwidgets
so adding new color-selection widgets is now simple
Diffstat (limited to 'src/components')
-rw-r--r--src/components/color.py58
-rw-r--r--src/components/original.py35
-rw-r--r--src/components/text.py27
-rw-r--r--src/components/waveform.py40
4 files changed, 20 insertions, 140 deletions
diff --git a/src/components/color.py b/src/components/color.py
index 2abd79a..d6fffc6 100644
--- a/src/components/color.py
+++ b/src/components/color.py
@@ -6,7 +6,6 @@ import os
from component import Component
from toolkit.frame import BlankFrame, FloodFrame, FramePainter, PaintColor
-from toolkit import rgbFromString, pickColor
class Component(Component):
@@ -14,25 +13,12 @@ class Component(Component):
version = '1.0.0'
def widget(self, *args):
- self.color1 = (0, 0, 0)
- self.color2 = (133, 133, 133)
self.x = 0
self.y = 0
super().widget(*args)
- self.page.lineEdit_color1.setText('%s,%s,%s' % self.color1)
- self.page.lineEdit_color2.setText('%s,%s,%s' % self.color2)
-
- btnStyle1 = "QPushButton { background-color : %s; outline: none; }" \
- % QColor(*self.color1).name()
-
- btnStyle2 = "QPushButton { background-color : %s; outline: none; }" \
- % QColor(*self.color2).name()
-
- self.page.pushButton_color1.setStyleSheet(btnStyle1)
- self.page.pushButton_color2.setStyleSheet(btnStyle2)
- self.page.pushButton_color1.clicked.connect(lambda: self.pickColor(1))
- self.page.pushButton_color2.clicked.connect(lambda: self.pickColor(2))
+ self.page.lineEdit_color1.setText('0,0,0')
+ self.page.lineEdit_color2.setText('133,133,133')
# disable color #2 until non-default 'fill' option gets changed
self.page.lineEdit_color2.setDisabled(True)
@@ -66,16 +52,18 @@ class Component(Component):
'LG_end': self.page.spinBox_linearGradient_end,
'RG_centre': self.page.spinBox_radialGradient_spread,
'fillType': self.page.comboBox_fill,
+ 'color1': self.page.lineEdit_color1,
+ 'color2': self.page.lineEdit_color2,
}, presetNames={
'sizeWidth': 'width',
'sizeHeight': 'height',
- }
+ }, colorWidgets={
+ 'color1': self.page.pushButton_color1,
+ 'color2': self.page.pushButton_color2,
+ },
)
def update(self):
- self.color1 = rgbFromString(self.page.lineEdit_color1.text())
- self.color2 = rgbFromString(self.page.lineEdit_color2.text())
-
fillType = self.page.comboBox_fill.currentIndex()
if fillType == 0:
self.page.lineEdit_color2.setEnabled(False)
@@ -161,36 +149,6 @@ class Component(Component):
return image.finalize()
- def loadPreset(self, pr, *args):
- super().loadPreset(pr, *args)
-
- self.page.lineEdit_color1.setText('%s,%s,%s' % pr['color1'])
- self.page.lineEdit_color2.setText('%s,%s,%s' % pr['color2'])
-
- btnStyle1 = "QPushButton { background-color : %s; outline: none; }" \
- % QColor(*pr['color1']).name()
- btnStyle2 = "QPushButton { background-color : %s; outline: none; }" \
- % QColor(*pr['color2']).name()
- self.page.pushButton_color1.setStyleSheet(btnStyle1)
- self.page.pushButton_color2.setStyleSheet(btnStyle2)
-
- def savePreset(self):
- saveValueStore = super().savePreset()
- saveValueStore['color1'] = self.color1
- saveValueStore['color2'] = self.color2
- return saveValueStore
-
- def pickColor(self, num):
- RGBstring, btnStyle = pickColor()
- if not RGBstring:
- return
- if num == 1:
- self.page.lineEdit_color1.setText(RGBstring)
- self.page.pushButton_color1.setStyleSheet(btnStyle)
- else:
- self.page.lineEdit_color2.setText(RGBstring)
- self.page.pushButton_color2.setStyleSheet(btnStyle)
-
def commandHelp(self):
print('Specify a color:\n color=255,255,255')
diff --git a/src/components/original.py b/src/components/original.py
index 621af6f..950ac7b 100644
--- a/src/components/original.py
+++ b/src/components/original.py
@@ -8,7 +8,6 @@ from copy import copy
from component import Component
from toolkit.frame import BlankFrame
-from toolkit import rgbFromString, pickColor
class Component(Component):
@@ -22,7 +21,6 @@ class Component(Component):
return ['pcm']
def widget(self, *args):
- self.visColor = (255, 255, 255)
self.scale = 20
self.y = 0
super().widget(*args)
@@ -33,35 +31,17 @@ class Component(Component):
self.page.comboBox_visLayout.addItem("Top")
self.page.comboBox_visLayout.setCurrentIndex(0)
- self.page.lineEdit_visColor.setText('%s,%s,%s' % self.visColor)
- self.page.pushButton_visColor.clicked.connect(lambda: self.pickColor())
- btnStyle = "QPushButton { background-color : %s; outline: none; }" \
- % QColor(*self.visColor).name()
- self.page.pushButton_visColor.setStyleSheet(btnStyle)
+ self.page.lineEdit_visColor.setText('255,255,255')
self.trackWidgets({
+ 'visColor': self.page.lineEdit_visColor,
'layout': self.page.comboBox_visLayout,
'scale': self.page.spinBox_scale,
'y': self.page.spinBox_y,
+ }, colorWidgets={
+ 'visColor': self.page.pushButton_visColor,
})
- def update(self):
- self.visColor = rgbFromString(self.page.lineEdit_visColor.text())
- super().update()
-
- def loadPreset(self, pr, *args):
- super().loadPreset(pr, *args)
-
- 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)
-
- def savePreset(self):
- saveValueStore = super().savePreset()
- saveValueStore['visColor'] = self.visColor
- return saveValueStore
-
def previewRender(self):
spectrum = numpy.fromfunction(
lambda x: float(self.scale)/2500*(x-128)**2, (255,), dtype="int16")
@@ -99,13 +79,6 @@ class Component(Component):
self.spectrumArray[arrayNo],
self.visColor, self.layout)
- def pickColor(self):
- RGBstring, btnStyle = pickColor()
- if not RGBstring:
- return
- self.page.lineEdit_visColor.setText(RGBstring)
- self.page.pushButton_visColor.setStyleSheet(btnStyle)
-
def transformData(
self, i, completeAudioArray, sampleSize,
smoothConstantDown, smoothConstantUp, lastSpectrum):
diff --git a/src/components/text.py b/src/components/text.py
index 8a302ff..1fe3467 100644
--- a/src/components/text.py
+++ b/src/components/text.py
@@ -5,7 +5,6 @@ import os
from component import Component
from toolkit.frame import FramePainter
-from toolkit import rgbFromString, pickColor
class Component(Component):
@@ -33,11 +32,6 @@ class Component(Component):
self.page.comboBox_textAlign.addItem("Right")
self.page.lineEdit_textColor.setText('%s,%s,%s' % self.textColor)
- self.page.pushButton_textColor.clicked.connect(self.pickColor)
- btnStyle = "QPushButton { background-color : %s; outline: none; }" \
- % QColor(*self.textColor).name()
- self.page.pushButton_textColor.setStyleSheet(btnStyle)
-
self.page.lineEdit_title.setText(self.title)
self.page.comboBox_textAlign.setCurrentIndex(int(self.alignment))
self.page.spinBox_fontSize.setValue(int(self.fontSize))
@@ -48,21 +42,18 @@ class Component(Component):
self.update
)
self.trackWidgets({
+ 'textColor': self.page.lineEdit_textColor,
'title': self.page.lineEdit_title,
'alignment': self.page.comboBox_textAlign,
'fontSize': self.page.spinBox_fontSize,
'xPosition': self.page.spinBox_xTextAlign,
'yPosition': self.page.spinBox_yTextAlign,
+ }, colorWidgets={
+ 'textColor': self.page.pushButton_textColor,
})
def update(self):
self.titleFont = self.page.fontComboBox_titleFont.currentFont()
- self.textColor = rgbFromString(
- self.page.lineEdit_textColor.text())
- btnStyle = "QPushButton { background-color : %s; outline: none; }" \
- % QColor(*self.textColor).name()
- self.page.pushButton_textColor.setStyleSheet(btnStyle)
-
super().update()
def getXY(self):
@@ -86,15 +77,10 @@ class Component(Component):
font = QFont()
font.fromString(pr['titleFont'])
self.page.fontComboBox_titleFont.setCurrentFont(font)
- 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):
saveValueStore = super().savePreset()
saveValueStore['titleFont'] = self.titleFont.toString()
- saveValueStore['textColor'] = self.textColor
return saveValueStore
def previewRender(self):
@@ -122,13 +108,6 @@ class Component(Component):
return image.finalize()
- def pickColor(self):
- RGBstring, btnStyle = pickColor()
- if not RGBstring:
- return
- self.page.lineEdit_textColor.setText(RGBstring)
- self.page.pushButton_textColor.setStyleSheet(btnStyle)
-
def commandHelp(self):
print('Enter a string to use as centred white text:')
print(' "title=User Error"')
diff --git a/src/components/waveform.py b/src/components/waveform.py
index 6c5133d..9c3cf86 100644
--- a/src/components/waveform.py
+++ b/src/components/waveform.py
@@ -7,7 +7,7 @@ import subprocess
from component import Component
from toolkit.frame import BlankFrame, scale
-from toolkit import checkOutput, rgbFromString, pickColor
+from toolkit import checkOutput
from toolkit.ffmpeg import (
openPipe, closePipe, getAudioDuration, FfmpegVideo, exampleSound
)
@@ -18,15 +18,9 @@ class Component(Component):
version = '1.0.0'
def widget(self, *args):
- self.color = (255, 255, 255)
super().widget(*args)
- self.page.lineEdit_color.setText('%s,%s,%s' % self.color)
- btnStyle = "QPushButton { background-color : %s; outline: none; }" \
- % QColor(*self.color).name()
- self.page.pushButton_color.setStyleSheet(btnStyle)
- self.page.pushButton_color.clicked.connect(lambda: self.pickColor())
- self.page.spinBox_scale.valueChanged.connect(self.updateChunksize)
+ self.page.lineEdit_color.setText('255,255,255')
if hasattr(self.parent, 'window'):
self.parent.window.lineEdit_audioFile.textChanged.connect(
@@ -35,6 +29,7 @@ class Component(Component):
self.trackWidgets(
{
+ 'color': self.page.lineEdit_color,
'mode': self.page.comboBox_mode,
'amplitude': self.page.comboBox_amplitude,
'x': self.page.spinBox_x,
@@ -44,36 +39,11 @@ class Component(Component):
'opacity': self.page.spinBox_opacity,
'compress': self.page.checkBox_compress,
'mono': self.page.checkBox_mono,
+ }, colorWidgets={
+ 'color': self.page.pushButton_color,
}
)
- def update(self):
- self.color = rgbFromString(self.page.lineEdit_color.text())
- btnStyle = "QPushButton { background-color : %s; outline: none; }" \
- % QColor(*self.color).name()
- self.page.pushButton_color.setStyleSheet(btnStyle)
- super().update()
-
- def loadPreset(self, pr, *args):
- super().loadPreset(pr, *args)
-
- self.page.lineEdit_color.setText('%s,%s,%s' % pr['color'])
- btnStyle = "QPushButton { background-color : %s; outline: none; }" \
- % QColor(*pr['color']).name()
- self.page.pushButton_color.setStyleSheet(btnStyle)
-
- def savePreset(self):
- saveValueStore = super().savePreset()
- saveValueStore['color'] = self.color
- return saveValueStore
-
- def pickColor(self):
- RGBstring, btnStyle = pickColor()
- if not RGBstring:
- return
- self.page.lineEdit_color.setText(RGBstring)
- self.page.pushButton_color.setStyleSheet(btnStyle)
-
def previewRender(self):
self.updateChunksize()
frame = self.getPreviewFrame(self.width, self.height)