1515
1616class Command (QtCore .QObject ):
1717
18- videoTask = QtCore .pyqtSignal (str , str , QFont , int , int , int , int , str , str )
18+ videoTask = QtCore .pyqtSignal (str , str , QFont , int , int , int , int , tuple , tuple , str , str )
1919
2020 def __init__ (self ):
2121 QtCore .QObject .__init__ (self )
@@ -28,12 +28,24 @@ def __init__(self):
2828 self .parser .add_argument ('-t' , '--text' , dest = 'text' , help = 'title text' , required = True )
2929 self .parser .add_argument ('-f' , '--font' , dest = 'font' , help = 'title font' , required = False )
3030 self .parser .add_argument ('-s' , '--fontsize' , dest = 'fontsize' , help = 'title font size' , required = False )
31+ self .parser .add_argument ('-c' , '--textcolor' , dest = 'textcolor' , help = 'title text color in r,g,b format' , required = False )
32+ self .parser .add_argument ('-C' , '--viscolor' , dest = 'viscolor' , help = 'visualization color in r,g,b format' , required = False )
3133 self .parser .add_argument ('-x' , '--xposition' , dest = 'xposition' , help = 'x position' , required = False )
3234 self .parser .add_argument ('-y' , '--yposition' , dest = 'yposition' , help = 'y position' , required = False )
3335 self .parser .add_argument ('-a' , '--alignment' , dest = 'alignment' , help = 'title alignment' , required = False , type = int , choices = [0 , 1 , 2 ])
3436 self .args = self .parser .parse_args ()
3537
3638 self .settings = QSettings ('settings.ini' , QSettings .IniFormat )
39+
40+ # load colours as tuples from comma-separated strings
41+ self .textColor = core .Core .RGBFromString (self .settings .value ("textColor" , '255, 255, 255' ))
42+ self .visColor = core .Core .RGBFromString (self .settings .value ("visColor" , '255, 255, 255' ))
43+ if self .args .textcolor :
44+ self .textColor = core .Core .RGBFromString (self .args .textcolor )
45+ if self .args .viscolor :
46+ self .visColor = core .Core .RGBFromString (self .args .viscolor )
47+
48+ # font settings
3749 if self .args .font :
3850 self .font = QFont (self .args .font )
3951 else :
@@ -43,7 +55,6 @@ def __init__(self):
4355 self .fontsize = int (self .args .fontsize )
4456 else :
4557 self .fontsize = int (self .settings .value ("fontSize" , 35 ))
46-
4758 if self .args .alignment :
4859 self .alignment = int (self .args .alignment )
4960 else :
@@ -75,6 +86,8 @@ def __init__(self):
7586 self .alignment ,
7687 self .textX ,
7788 self .textY ,
89+ self .textColor ,
90+ self .visColor ,
7891 self .args .input ,
7992 self .args .output )
8093
@@ -89,23 +102,27 @@ def cleanUp(self):
89102 self .settings .setValue ("fontSize" , str (self .fontsize ))
90103 self .settings .setValue ("xPosition" , str (self .textX ))
91104 self .settings .setValue ("yPosition" , str (self .textY ))
105+ self .settings .setValue ("visColor" , '%s,%s,%s' % self .visColor )
106+ self .settings .setValue ("textColor" , '%s,%s,%s' % self .textColor )
92107 sys .exit (0 )
93108
94109class Main (QtCore .QObject ):
95110
96- newTask = QtCore .pyqtSignal (str , str , QFont , int , int , int , int )
111+ newTask = QtCore .pyqtSignal (str , str , QFont , int , int , int , int , tuple , tuple )
97112 processTask = QtCore .pyqtSignal ()
98- videoTask = QtCore .pyqtSignal (str , str , QFont , int , int , int , int , str , str )
113+ videoTask = QtCore .pyqtSignal (str , str , QFont , int , int , int , int , tuple , tuple , str , str )
99114
100115 def __init__ (self , window ):
101-
102116 QtCore .QObject .__init__ (self )
103117
104118 # print('main thread id: {}'.format(QtCore.QThread.currentThreadId()))
105119 self .window = window
106120 self .core = core .Core ()
107-
108121 self .settings = QSettings ('settings.ini' , QSettings .IniFormat )
122+
123+ # load colors as tuples from a comma-separated string
124+ self .textColor = core .Core .RGBFromString (self .settings .value ("textColor" , '255, 255, 255' ))
125+ self .visColor = core .Core .RGBFromString (self .settings .value ("visColor" , '255, 255, 255' ))
109126
110127 self .previewQueue = Queue ()
111128
@@ -133,8 +150,11 @@ def __init__(self, window):
133150 window .pushButton_selectBackground .setText ("Select Background Image" )
134151 window .label_font .setText ("Title Font" )
135152 window .label_alignment .setText ("Title Options" )
153+ window .label_colorOptions .setText ("Colors" )
136154 window .label_fontsize .setText ("Fontsize" )
137155 window .label_title .setText ("Title Text" )
156+ window .label_textColor .setText ("Text:" )
157+ window .label_visColor .setText ("Visualizer:" )
138158 window .pushButton_createVideo .setText ("Create Video" )
139159 window .groupBox_create .setTitle ("Create" )
140160 window .groupBox_settings .setTitle ("Settings" )
@@ -146,6 +166,14 @@ def __init__(self, window):
146166 window .fontsizeSpinBox .setValue (35 )
147167 window .textXSpinBox .setValue (70 )
148168 window .textYSpinBox .setValue (375 )
169+ window .lineEdit_textColor .setText ('%s,%s,%s' % self .textColor )
170+ window .lineEdit_visColor .setText ('%s,%s,%s' % self .visColor )
171+ window .pushButton_textColor .clicked .connect (lambda : self .pickColor ('text' ))
172+ window .pushButton_visColor .clicked .connect (lambda : self .pickColor ('vis' ))
173+ btnStyle = "QPushButton { background-color : %s; outline: none; }" % QColor (* self .textColor ).name ()
174+ window .pushButton_textColor .setStyleSheet (btnStyle )
175+ btnStyle = "QPushButton { background-color : %s; outline: none; }" % QColor (* self .visColor ).name ()
176+ window .pushButton_visColor .setStyleSheet (btnStyle )
149177
150178 titleFont = self .settings .value ("titleFont" )
151179 if not titleFont == None :
@@ -170,6 +198,8 @@ def __init__(self, window):
170198 window .textXSpinBox .valueChanged .connect (self .drawPreview )
171199 window .textYSpinBox .valueChanged .connect (self .drawPreview )
172200 window .fontsizeSpinBox .valueChanged .connect (self .drawPreview )
201+ window .lineEdit_textColor .textChanged .connect (self .drawPreview )
202+ window .lineEdit_visColor .textChanged .connect (self .drawPreview )
173203
174204 self .drawPreview ()
175205
@@ -179,13 +209,14 @@ def cleanUp(self):
179209 self .timer .stop ()
180210 self .previewThread .quit ()
181211 self .previewThread .wait ()
182-
212+
183213 self .settings .setValue ("titleFont" , self .window .fontComboBox .currentFont ().toString ())
184214 self .settings .setValue ("alignment" , str (self .window .alignmentComboBox .currentIndex ()))
185215 self .settings .setValue ("fontSize" , str (self .window .fontsizeSpinBox .value ()))
186216 self .settings .setValue ("xPosition" , str (self .window .textXSpinBox .value ()))
187217 self .settings .setValue ("yPosition" , str (self .window .textYSpinBox .value ()))
188- sys .exit (0 )
218+ self .settings .setValue ("visColor" , self .window .lineEdit_visColor .text ())
219+ self .settings .setValue ("textColor" , self .window .lineEdit_textColor .text ())
189220
190221 def openInputFileDialog (self ):
191222 inputDir = self .settings .value ("inputDir" , expanduser ("~" ))
@@ -237,6 +268,8 @@ def createAudioVisualisation(self):
237268 self .window .alignmentComboBox .currentIndex (),
238269 self .window .textXSpinBox .value (),
239270 self .window .textYSpinBox .value (),
271+ core .Core .RGBFromString (self .window .lineEdit_textColor .text ()),
272+ core .Core .RGBFromString (self .window .lineEdit_visColor .text ()),
240273 self .window .label_input .text (),
241274 self .window .label_output .text ())
242275
@@ -258,7 +291,9 @@ def drawPreview(self):
258291 self .window .fontsizeSpinBox .value (),
259292 self .window .alignmentComboBox .currentIndex (),
260293 self .window .textXSpinBox .value (),
261- self .window .textYSpinBox .value ())
294+ self .window .textYSpinBox .value (),
295+ core .Core .RGBFromString (self .window .lineEdit_textColor .text ()),
296+ core .Core .RGBFromString (self .window .lineEdit_visColor .text ()))
262297 # self.processTask.emit()
263298
264299 def showPreviewImage (self , image ):
@@ -267,6 +302,18 @@ def showPreviewImage(self, image):
267302
268303 self .window .label_preview .setPixmap (self ._previewPixmap )
269304
305+ def pickColor (self , colorTarget ):
306+ color = QtGui .QColorDialog .getColor ()
307+ if color .isValid ():
308+ RGBstring = '%s,%s,%s' % (str (color .red ()), str (color .green ()), str (color .blue ()))
309+ btnStyle = "QPushButton { background-color : %s; outline: none; }" % color .name ()
310+ if colorTarget == 'text' :
311+ self .window .lineEdit_textColor .setText (RGBstring )
312+ window .pushButton_textColor .setStyleSheet (btnStyle )
313+ elif colorTarget == 'vis' :
314+ self .window .lineEdit_visColor .setText (RGBstring )
315+ window .pushButton_visColor .setStyleSheet (btnStyle )
316+
270317if len (sys .argv ) > 1 :
271318 # command line mode
272319 app = QtGui .QApplication (sys .argv , False )
0 commit comments