Fixed Qtractor
[klaudia.git] / src / w_klaudia.py
blobd361d8fc41d8f5d025643f825a92a2137ca8a2b9
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
5 # Imports
6 from commands import getoutput
7 from random import randint
8 from PyQt4.QtCore import Qt, QString, SIGNAL
9 from PyQt4.QtGui import QTableWidgetItem
10 from PyKDE4.kdecore import i18n
11 from PyKDE4.kdeui import KIcon, KIconLoader, KMessageBox, KXmlGuiWindow
12 import dbus, os, sys
13 import database, ui_klaudia
17 # DBus connections
18 class DBus(object):
19 __slots__ = [
20 'loopBus',
21 'jackBus',
22 'controlBus',
23 'studioBus',
24 'appBus',
26 DBus = DBus()
30 # Main Window
31 class KlaudiaMainW(KXmlGuiWindow, ui_klaudia.Ui_KlaudiaMainW):
32 def __init__(self, *args):
33 KXmlGuiWindow.__init__(self, *args)
34 self.setupUi(self)
36 # Check for Jack first of all
37 if not bool(DBus.jackBus.IsStarted()):
38 if not bool(DBus.jackBus.StartServer()):
39 KMessageBox.error(self, i18n("Jack is not started!\n"
40 "Please start it first, then run Klaudia again"), i18n("Error"))
41 exit(-1)
43 # For the missing icons
44 self.MyIcons = KIconLoader("klaudia")
46 # Set-up GUI
47 self.b_start.setEnabled(False)
48 self.b_start.setIcon(KIcon("arrow-right"))
49 self.b_add.setEnabled(False)
50 self.b_add.setIcon(KIcon("list-add"))
52 self.listDAW.setColumnWidth(0, 22)
53 self.listDAW.setColumnWidth(1, 150)
54 self.listDAW.setColumnWidth(2, 125)
56 self.listHost.setColumnWidth(0, 22)
57 self.listHost.setColumnWidth(1, 125)
59 self.listInstrument.setColumnWidth(0, 22)
60 self.listInstrument.setColumnWidth(1, 125)
61 self.listInstrument.setColumnWidth(2, 125)
63 self.listEffect.setColumnWidth(0, 22)
64 self.listEffect.setColumnWidth(1, 200)
65 self.listEffect.setColumnWidth(2, 100)
67 self.listTool.setColumnWidth(0, 22)
68 self.listTool.setColumnWidth(1, 175)
69 self.listTool.setColumnWidth(2, 125)
71 self.listDAW.setContextMenuPolicy(Qt.CustomContextMenu)
72 self.listHost.setContextMenuPolicy(Qt.CustomContextMenu)
73 self.listInstrument.setContextMenuPolicy(Qt.CustomContextMenu)
74 self.listEffect.setContextMenuPolicy(Qt.CustomContextMenu)
75 self.listTool.setContextMenuPolicy(Qt.CustomContextMenu)
77 self.co_sample_rate.addItem(str(DBus.jackBus.GetSampleRate()))
78 self.b_refresh.setText("")
80 self.studio_root_folder = QString(os.getenv("HOME"))
81 self.kurl_folder.setText(self.studio_root_folder)
82 self.test_url = True
83 self.test_selected = False
85 self.clearInfo_DAW()
86 self.clearInfo_Host()
87 self.clearInfo_Intrument()
88 self.clearInfo_Effect()
89 self.clearInfo_Tool()
91 self.refreshAll()
92 self.refreshStudioList()
95 self.connect(self.b_start, SIGNAL("clicked()"), self.startApp)
96 self.connect(self.b_add, SIGNAL("clicked()"), self.addApp)
97 self.connect(self.b_refresh, SIGNAL("clicked()"), self.refreshStudioList)
99 self.connect(self.co_ladi_room, SIGNAL("currentIndexChanged(int)"), self.checkSelectedRoom)
101 self.connect(self.kurl_folder, SIGNAL("textChanged(QString)"), self.checkFolderUrl)
102 self.connect(self.tabWidget, SIGNAL("currentChanged(int)"), self.checkSelectedTab)
104 self.connect(self.listDAW, SIGNAL("currentCellChanged(int, int, int, int)"), self.checkSelectedDAW)
105 self.connect(self.listHost, SIGNAL("currentCellChanged(int, int, int, int)"), self.checkSelectedHost)
106 self.connect(self.listInstrument, SIGNAL("currentCellChanged(int, int, int, int)"), self.checkSelectedInstrument)
107 self.connect(self.listEffect, SIGNAL("currentCellChanged(int, int, int, int)"), self.checkSelectedEffect)
108 self.connect(self.listTool, SIGNAL("currentCellChanged(int, int, int, int)"), self.checkSelectedTool)
109 self.connect(self.listDAW, SIGNAL("cellDoubleClicked(int, int)"), self.doubleClickedListDAW)
110 self.connect(self.listHost, SIGNAL("cellDoubleClicked(int, int)"), self.doubleClickedListHost)
111 self.connect(self.listInstrument, SIGNAL("cellDoubleClicked(int, int)"), self.doubleClickedListInstrument)
112 self.connect(self.listEffect, SIGNAL("cellDoubleClicked(int, int)"), self.doubleClickedListEffect)
113 self.connect(self.listTool, SIGNAL("cellDoubleClicked(int, int)"), self.doubleClickedListTool)
115 self.connect(self.url_documentation_daw, SIGNAL("leftClickedUrl(QString)"), self.openUrl)
116 self.connect(self.url_website_daw, SIGNAL("leftClickedUrl(QString)"), self.openUrl)
117 self.connect(self.url_documentation_host, SIGNAL("leftClickedUrl(QString)"), self.openUrl)
118 self.connect(self.url_website_host, SIGNAL("leftClickedUrl(QString)"), self.openUrl)
119 self.connect(self.url_documentation_ins, SIGNAL("leftClickedUrl(QString)"), self.openUrl)
120 self.connect(self.url_website_ins, SIGNAL("leftClickedUrl(QString)"), self.openUrl)
121 self.connect(self.url_documentation_effect, SIGNAL("leftClickedUrl(QString)"), self.openUrl)
122 self.connect(self.url_website_effect, SIGNAL("leftClickedUrl(QString)"), self.openUrl)
123 self.connect(self.url_documentation_tool, SIGNAL("leftClickedUrl(QString)"), self.openUrl)
124 self.connect(self.url_website_tool, SIGNAL("leftClickedUrl(QString)"), self.openUrl)
127 def refreshStudioList(self):
128 self.co_ladi_room.clear()
129 self.co_ladi_room.addItem("<Studio Root>")
130 studio_bus = DBus.loopBus.get_object("org.ladish", "/org/ladish/Studio")
131 studio_list_dump = studio_bus.GetRoomList()
132 for i in range(len(studio_list_dump)):
133 self.co_ladi_room.addItem(str(studio_list_dump[i][0]).replace("/org/ladish/Room","")+" - "+studio_list_dump[i][1]['name'])
135 def checkSelectedRoom(self, co_n):
136 if (co_n == -1):
137 print "going -1"
138 elif (co_n == 0):
139 print "selected studio room"
140 DBus.studioBus = DBus.loopBus.get_object("org.ladish", "/org/ladish/Studio")
141 DBus.appBus = dbus.Interface(DBus.studioBus, 'org.ladish.AppSupervisor')
142 self.kurl_folder.setEnabled(True)
143 self.kurl_folder.setText(self.studio_root_folder)
144 else:
145 print "selected a room", co_n
146 room_name = "/org/ladish/Room"+str(self.co_ladi_room.currentText()).split()[0]
147 DBus.studioBus = DBus.loopBus.get_object("org.ladish", room_name)
148 DBus.appBus = dbus.Interface(DBus.studioBus, 'org.ladish.AppSupervisor')
149 room_properties = DBus.studioBus.GetProjectProperties()
150 if (len(room_properties[1])):
151 self.kurl_folder.setEnabled(False)
152 self.kurl_folder.setText(QString(room_properties[1]['dir']))
153 else:
154 self.kurl_folder.setEnabled(True)
155 self.studio_root_folder = self.kurl_folder.text()
157 def getSelectedApp(self):
158 tab = self.tabWidget.currentIndex()
159 if (tab == 0):
160 listSel = self.listDAW
161 elif (tab == 1):
162 listSel = self.listHost
163 elif (tab == 2):
164 listSel = self.listInstrument
165 elif (tab == 3):
166 listSel = self.listEffect
167 elif (tab == 4):
168 listSel = self.listTool
169 else:
170 return ""
172 return listSel.item(listSel.currentRow(), 1).text()
174 def getBinaryFromAppName(self, appname):
175 list_DAW = database.list_DAW
176 for i in range(len(list_DAW)):
177 if (appname == list_DAW[i][1]):
178 binary = list_DAW[i][3]
179 break
181 list_Host = database.list_Host
182 for i in range(len(list_Host)):
183 if (appname == list_Host[i][1]):
184 binary = list_Host[i][4]
185 break
187 list_Instrument = database.list_Instrument
188 for i in range(len(list_Instrument)):
189 if (appname == list_Instrument[i][1]):
190 binary = list_Instrument[i][3]
191 break
193 list_Effect = database.list_Effect
194 for i in range(len(list_Effect)):
195 if (appname == list_Effect[i][1]):
196 binary = list_Effect[i][3]
197 break
199 list_Tool = database.list_Tool
200 for i in range(len(list_Tool)):
201 if (appname == list_Tool[i][1]):
202 binary = list_Tool[i][3]
203 break
205 if (binary):
206 return binary
207 else:
208 print "Error here, cod.002"
209 return ""
211 def doubleClickedListDAW(self, row, column):
212 app = self.listDAW.item(row, 1).text()
213 self.startApp(app)
215 def doubleClickedListHost(self, row, column):
216 app = self.listHost.item(row, 1).text()
217 self.startApp(app)
219 def doubleClickedListInstrument(self, row, column):
220 app = self.listInstrument.item(row, 1).text()
221 self.startApp(app)
223 def doubleClickedListEffect(self, row, column):
224 app = self.listEffect.item(row, 1).text()
225 self.startApp(app)
227 def doubleClickedListTool(self, row, column):
228 app = self.listTool.item(row, 1).text()
229 self.startApp(app)
231 def startApp(self, app=None):
232 if (not app):
233 app = self.getSelectedApp()
234 binary = self.getBinaryFromAppName(app)
235 os.system("cd "+str(self.kurl_folder.text())+" && "+binary+" &")
237 def addApp(self):
238 app = self.getSelectedApp()
239 binary = self.getBinaryFromAppName(app)
241 ran_check = str(randint(1, 99999))
242 sample_rate = str(self.co_sample_rate.currentText())
243 url_folder = str(self.kurl_folder.text())
244 proj_bpm = str(self.sb_bpm.text())
246 if (url_folder[-1] != "/"):
247 print url_folder[-1]
248 url_folder += "/"
250 if (app == "Ardour" or app == "ArdourVST" or app == "ArdourVST (32bit)"):
251 proj_folder = url_folder+"Ardour2_"+ran_check
252 os.mkdir(proj_folder)
253 os.system("cp "+sys.path[0]+"/../templates/Ardour2/* '"+proj_folder+"'")
254 os.system('sed -i "s/X_BPM_X-KLAUDIA-X_BPM_X/'+proj_bpm+'/" "'+proj_folder+'/Ardour2.ardour"')
255 os.system('sed -i "s/X_SR_X-KLAUDIA-X_SR_X/'+sample_rate+'/" "'+proj_folder+'/Ardour2.ardour"')
256 os.system("cd '"+proj_folder+"' && mv Ardour2.ardour Ardour2_"+ran_check+".ardour")
257 os.mkdir(proj_folder+"/analysis")
258 os.mkdir(proj_folder+"/dead_sounds")
259 os.mkdir(proj_folder+"/export")
260 os.mkdir(proj_folder+"/interchange")
261 os.mkdir(proj_folder+"/interchange/Ardour")
262 os.mkdir(proj_folder+"/interchange/Ardour/audiofiles")
263 os.mkdir(proj_folder+"/peaks")
264 if (not self.kurl_folder.isEnabled()): proj_folder = proj_folder.replace(url_folder,"")
265 DBus.appBus.RunCustom(False, binary+" '"+proj_folder+"'", str(app), 1)
266 elif (app == "Hydrogen" or app == "Hydrogen (SVN)"):
267 if (app == "Hydrogen (SVN)"):
268 level = 1
269 else:
270 level = 0
271 proj_file = url_folder+"Hydrogen_"+ran_check+".h2song"
272 os.system("cp "+sys.path[0]+"/../templates/Hydrogen.h2song '"+proj_file+"'")
273 os.system('sed -i "s/X_BPM_X-KLAUDIA-X_BPM_X/'+proj_bpm+'/" "'+proj_file+'"')
274 if (not self.kurl_folder.isEnabled()): proj_file = proj_file.replace(url_folder,"")
275 DBus.appBus.RunCustom(False, "hydrogen -s '"+proj_file+"'", str(app), level)
276 elif (app == "MusE" or app == "MusE (SVN)"):
277 proj_file = url_folder+"MusE_"+ran_check+".med"
278 os.system("cp "+sys.path[0]+"/../templates/MusE.med '"+proj_file+"'")
279 if (not self.kurl_folder.isEnabled()): proj_file = proj_file.replace(url_folder,"")
280 DBus.appBus.RunCustom(False, "muse '"+proj_file+"'", str(app), 0)
281 elif (app == "Non-DAW"):
282 proj_file = url_folder+"Non-DAW_"+ran_check
283 os.system("cp -r "+sys.path[0]+"/../templates/Non-DAW '"+proj_file+"'")
284 os.system('sed -i "s/X_BPM_X-KLAUDIA-X_BPM_X/'+proj_bpm+'/" "'+proj_file+'/history"')
285 os.system('sed -i "s/X_SR_X-KLAUDIA-X_SR_X/'+sample_rate+'/" "'+proj_file+'/info"')
286 if (not self.kurl_folder.isEnabled()): proj_file = proj_file.replace(url_folder,"")
287 DBus.appBus.RunCustom(False, "non-daw '"+proj_file+"'", str(app), 0)
288 elif (app == "Non-Sequencer"):
289 proj_file = url_folder+"Non-Sequencer_"+ran_check+".non"
290 os.system("cp "+sys.path[0]+"/../templates/Non-Sequencer.non '"+proj_file+"'")
291 if (not self.kurl_folder.isEnabled()): proj_file = proj_file.replace(url_folder,"")
292 DBus.appBus.RunCustom(False, "non-sequencer '"+proj_file+"'", str(app), 0)
293 elif (app == "Qtractor" or app == "QtractorVST" or app == "QtractorVST (32bit)" or app == "Qtractor (SVN)"):
294 proj_file = url_folder+"Qtractor_"+ran_check+".qtr"
295 os.system("cp "+sys.path[0]+"/../templates/Qtractor.qtr '"+proj_file+"'")
296 os.system('sed -i "s/X_BPM_X-KLAUDIA-X_BPM_X/'+proj_bpm+'/" "'+proj_file+'"')
297 os.system('sed -i "s/X_SR_X-KLAUDIA-X_SR_X/'+sample_rate+'/" "'+proj_file+'"')
298 os.system('sed -i "s/X_FOLDER_X-KLAUDIA-X_FOLDER_X/'+url_folder.replace("/","\/")+'/" "'+proj_file+'"')
299 if (not self.kurl_folder.isEnabled()): proj_file = proj_file.replace(url_folder,"")
300 DBus.appBus.RunCustom(False, binary+" '"+proj_file+"'", str(app), 1)
301 elif (app == "Renoise" or app == "Renoise (64bit)"):
302 os.mkdir(url_folder+"tmp_bu")
303 os.system("cp "+sys.path[0]+"/../templates/Renoise.xml "+url_folder+"/tmp_bu")
304 os.system('sed -i "s/X_BPM_X-KLAUDIA-X_BPM_X/'+proj_bpm+'/" "'+url_folder+'/tmp_bu/Renoise.xml"')
305 os.system("cd '"+url_folder+"tmp_bu' && mv Renoise.xml Song.xml && zip ../Renoise_"+ran_check+".xrns Song.xml")
306 os.system("rm -rf '"+url_folder+"tmp_bu'")
307 if (not self.kurl_folder.isEnabled()): url_folder = ""
308 DBus.appBus.RunCustom(False, binary+" '"+url_folder+"Renoise_"+ran_check+".xrns'", str(app), 0)
309 elif (app == "Rosegarden"):
310 proj_file = url_folder+"Rosegarden_"+ran_check+".rg"
311 os.system("cp "+sys.path[0]+"/../templates/Rosegarden.rg '"+proj_file+"'")
312 os.system('sed -i "s/X_BPM_X-KLAUDIA-X_BPM_X/'+proj_bpm+'/" "'+proj_file+'"')
313 if (not self.kurl_folder.isEnabled()): proj_file = proj_file.replace(url_folder,"")
314 DBus.appBus.RunCustom(False, "rosegarden '"+proj_file+"'", str(app), 1)
315 elif (app == "Seq24" or app == "Seq24 (BZR)"):
316 proj_file = url_folder+"Seq24_"+ran_check+".midi"
317 os.system("cp "+sys.path[0]+"/../templates/Seq24.midi '"+proj_file+"'")
318 if (not self.kurl_folder.isEnabled()): proj_file = proj_file.replace(url_folder,"")
319 DBus.appBus.RunCustom(False, "seq24 --file '"+proj_file+"'", str(app), 0)
321 elif (app == "Calf Jack Host" or app == "Calf Jack Host (GIT)"):
322 if (app == "Calf Jack Host (GIT)"):
323 level = 1
324 else:
325 level = 0
326 proj_file = url_folder+"CalfJackHost_"+ran_check
327 os.system("cp "+sys.path[0]+"/../templates/CalfJackHost '"+proj_file+"'")
328 if (not self.kurl_folder.isEnabled()): proj_file = proj_file.replace(url_folder,"")
329 DBus.appBus.RunCustom(False, "calfjackhost --load '"+proj_file+"'", str(app), level)
330 elif (app == "FeSTige"):
331 room_name = "" if (self.co_ladi_room.currentIndex() <= 0) else "\""+str(self.co_ladi_room.currentText()).split(" - ")[1]+"\""
332 DBus.appBus.RunCustom(False, "festige "+url_folder+" "+room_name, str(app), 0)
333 #elif (app == "Ingen" or app == "Ingen (SVN)"):
334 #if (app == "Ingen (SVN)"):
335 #binary = "ingen-svn"
336 #else:
337 #binary = "ingen"
338 #proj_file = url_folder+"/"+"ingen_"+ran_check+".ing.lv2"
339 #os.system("cp -r "+sys.path[0]+"/../templates/ingen.ing.lv2 '"+proj_file+"'")
340 #if (not self.kurl_folder.isEnabled()): proj_file = proj_file.replace(url_folder,"")
341 #DBus.appBus.RunCustom(False, binary+" -egl '"+proj_file+"'", str(app), 0)
342 elif (app == "Jack Rack"):
343 proj_file = url_folder+"Jack-Rack_"+ran_check+".xml"
344 os.system("cp "+sys.path[0]+"/../templates/Jack-Rack.xml '"+proj_file+"'")
345 os.system('sed -i "s/X_SR_X-KLAUDIA-X_SR_X/'+sample_rate+'/" "'+proj_file+'"')
346 if (not self.kurl_folder.isEnabled()): proj_file = proj_file.replace(url_folder,"")
347 DBus.appBus.RunCustom(False, "jack-rack '"+proj_file+"'", str(app), 0)
349 elif (app == "Qsampler" or app == "Qsampler (SVN)"):
350 if (app == "Qsampler (SVN)"):
351 level = 1
352 else:
353 level = 0
354 proj_file = url_folder+"Qsampler_"+ran_check+".lscp"
355 os.system("cp "+sys.path[0]+"/../templates/Qsampler.lscp '"+proj_file+"'")
356 if (not self.kurl_folder.isEnabled()): proj_file = proj_file.replace(url_folder,"")
357 DBus.appBus.RunCustom(False, "qsampler '"+proj_file+"'", str(app), level)
358 elif (app == "Yoshimi"):
359 proj_file = url_folder+"Yoshimi_"+ran_check+".state"
360 os.system("cp "+sys.path[0]+"/../templates/Yoshimi.state '"+proj_file+"'")
361 os.system('sed -i "s/X_SR_X-KLAUDIA-X_SR_X/'+sample_rate+'/" "'+proj_file+'"')
362 os.system('sed -i "s/X_FILE_X-KLAUDIA-X_FILE_X/'+proj_file.replace("/","\/")+'/" "'+proj_file+'"')
363 if (not self.kurl_folder.isEnabled()): proj_file = proj_file.replace(url_folder,"")
364 DBus.appBus.RunCustom(False, "yoshimi -j -J --state='"+proj_file+"'", str(app), 1)
366 elif (app == "Jamin"):
367 proj_file = url_folder+"Jamin_"+ran_check+".jam"
368 os.system("cp "+sys.path[0]+"/../templates/Jamin.jam '"+proj_file+"'")
369 if (not self.kurl_folder.isEnabled()): proj_file = proj_file.replace(url_folder,"")
370 DBus.appBus.RunCustom(False, "jamin -f '"+proj_file+"'", str(app), 0)
372 elif (app == "Jack Mixer"):
373 proj_file = url_folder+"Jack-Mixer_"+ran_check+".xml"
374 os.system("cp "+sys.path[0]+"/../templates/Jack-Mixer.xml '"+proj_file+"'")
375 if (not self.kurl_folder.isEnabled()): proj_file = proj_file.replace(url_folder,"")
376 DBus.appBus.RunCustom(False, "jack_mixer -c '"+proj_file+"'", str(app), 1)
377 elif (app == "Non-Mixer"):
378 proj_file = url_folder+"Non-Mixer_"+ran_check
379 os.system("cp -r "+sys.path[0]+"/../templates/Non-Mixer '"+proj_file+"'")
380 if (not self.kurl_folder.isEnabled()): proj_file = proj_file.replace(url_folder,"")
381 DBus.appBus.RunCustom(False, "non-mixer '"+proj_file+"'", str(app), 0)
383 else:
384 DBus.appBus.RunCustom(False, binary, str(app), 0)
386 def clearInfo_DAW(self):
387 self.ico_app_daw.setPixmap(KIcon("start-here-kde").pixmap(48, 48))
388 self.label_name_daw.setText("App Name")
389 self.ico_ladspa_daw.setPixmap(KIcon("dialog-cancel").pixmap(16, 16))
390 self.ico_dssi_daw.setPixmap(KIcon("dialog-cancel").pixmap(16, 16))
391 self.ico_lv2_daw.setPixmap(KIcon("dialog-cancel").pixmap(16, 16))
392 self.ico_vst_daw.setPixmap(KIcon("dialog-cancel").pixmap(16, 16))
393 self.label_vst_mode_daw.setText("")
394 self.ico_jack_transport_daw.setPixmap(KIcon("dialog-cancel").pixmap(16, 16))
395 self.label_midi_mode_daw.setText("---")
396 self.label_ladish_level_daw.setText("0")
397 self.showDoc_DAW(0, 0)
398 self.frame_DAW.setEnabled(False)
400 def clearInfo_Host(self):
401 self.ico_app_host.setPixmap(KIcon("start-here-kde").pixmap(48, 48))
402 self.label_name_host.setText("App Name")
403 self.ico_ladspa_host.setPixmap(KIcon("dialog-cancel").pixmap(16, 16))
404 self.ico_dssi_host.setPixmap(KIcon("dialog-cancel").pixmap(16, 16))
405 self.ico_lv2_host.setPixmap(KIcon("dialog-cancel").pixmap(16, 16))
406 self.ico_vst_host.setPixmap(KIcon("dialog-cancel").pixmap(16, 16))
407 self.label_vst_mode_host.setText("")
408 self.label_midi_mode_host.setText("---")
409 self.label_ladish_level_host.setText("0")
410 self.showDoc_Host(0, 0)
411 self.frame_Host.setEnabled(False)
413 def clearInfo_Intrument(self):
414 self.ico_app_ins.setPixmap(KIcon("start-here-kde").pixmap(48, 48))
415 self.label_name_ins.setText("App Name")
416 self.ico_builtin_fx_ins.setPixmap(KIcon("dialog-cancel").pixmap(16, 16))
417 self.ico_audio_input_ins.setPixmap(KIcon("dialog-cancel").pixmap(16, 16))
418 self.label_midi_mode_ins.setText("---")
419 self.label_ladish_level_ins.setText("0")
420 self.showDoc_Instrument(0, 0)
421 self.frame_Instrument.setEnabled(False)
423 def clearInfo_Effect(self):
424 self.ico_app_effect.setPixmap(KIcon("start-here-kde").pixmap(48, 48))
425 self.label_name_effect.setText("App Name")
426 self.ico_stereo_effect.setPixmap(KIcon("dialog-cancel").pixmap(16, 16))
427 self.label_midi_mode_effect.setText("---")
428 self.label_ladish_level_effect.setText("0")
429 self.showDoc_Effect(0, 0)
430 self.frame_Effect.setEnabled(False)
432 def clearInfo_Tool(self):
433 self.ico_app_tool.setPixmap(KIcon("start-here-kde").pixmap(48, 48))
434 self.label_name_tool.setText("App Name")
435 self.label_midi_mode_tool.setText("---")
436 self.label_ladish_level_tool.setText("0")
437 self.showDoc_Tool(0, 0)
438 self.frame_Tool.setEnabled(False)
440 def checkFolderUrl(self, url):
441 if (os.path.exists(url)):
442 self.test_url = True
443 if (self.kurl_folder.isEnabled()):
444 self.studio_root_folder = QString(url)
445 else:
446 self.test_url = False
447 self.checkButtons()
449 def checkSelectedTab(self, tab):
450 self.test_selected = False
451 if (tab == 0): # DAW
452 if (self.listDAW.selectedItems()):
453 self.test_selected = True
454 elif (tab == 1): # Host
455 if (self.listHost.selectedItems()):
456 self.test_selected = True
457 elif (tab == 2): # Instrument
458 if (self.listInstrument.selectedItems()):
459 self.test_selected = True
460 elif (tab == 3): # Effect
461 if (self.listEffect.selectedItems()):
462 self.test_selected = True
463 elif (tab == 4): # Tool
464 if (self.listTool.selectedItems()):
465 self.test_selected = True
467 self.checkButtons()
469 def checkSelectedDAW(self, row, column, p_row, p_column):
470 if (row >= 0):
471 self.test_selected = True
473 app_name = self.listDAW.item(row, 1).text()
474 app_info = []
475 list_DAW = database.list_DAW
477 for i in range(len(list_DAW)):
478 if (app_name == list_DAW[i][1]):
479 app_info = list_DAW[i]
480 break
482 if (not app_info):
483 print "Error here, cod.001"
484 return
486 self.frame_DAW.setEnabled(True)
487 self.ico_app_daw.setPixmap(KIcon(self.MyIcons.iconPath(app_info[4], KIconLoader.Desktop)).pixmap(48, 48))
488 self.ico_ladspa_daw.setPixmap(KIcon(self.getIconForYesNo(app_info[8][0])).pixmap(16, 16))
489 self.ico_dssi_daw.setPixmap(KIcon(self.getIconForYesNo(app_info[8][1])).pixmap(16, 16))
490 self.ico_lv2_daw.setPixmap(KIcon(self.getIconForYesNo(app_info[8][2])).pixmap(16, 16))
491 self.ico_vst_daw.setPixmap(KIcon(self.getIconForYesNo(app_info[8][3])).pixmap(16, 16))
492 self.ico_jack_transport_daw.setPixmap(KIcon(self.getIconForYesNo(app_info[8][5])).pixmap(16, 16))
493 self.label_name_daw.setText(app_info[1])
494 self.label_vst_mode_daw.setText(app_info[8][4])
495 self.ico_midi_mode_daw.setPixmap(KIcon(self.getIconForYesNo(app_info[8][6])).pixmap(16, 16))
496 self.label_midi_mode_daw.setText(app_info[8][7])
497 self.label_ladish_level_daw.setText(str(app_info[6]))
498 self.showDoc_DAW(app_info[9][0], app_info[9][1])
499 else:
500 self.test_selected = False
501 self.clearInfo_DAW()
502 self.checkButtons()
504 def checkSelectedHost(self, row, column, p_row, p_column):
505 if (row >= 0):
506 self.test_selected = True
508 app_name = self.listHost.item(row, 1).text()
509 app_info = []
510 list_Host = database.list_Host
512 for i in range(len(list_Host)):
513 if (app_name == list_Host[i][1]):
514 app_info = list_Host[i]
515 break
517 if (not app_info):
518 print "Error here, cod.003"
519 return
521 self.frame_Host.setEnabled(True)
522 self.ico_app_host.setPixmap(KIcon(self.MyIcons.iconPath(app_info[5], KIconLoader.Desktop)).pixmap(48, 48))
523 self.ico_internal_host.setPixmap(KIcon(self.getIconForYesNo(app_info[9][0])).pixmap(16, 16))
524 self.ico_ladspa_host.setPixmap(KIcon(self.getIconForYesNo(app_info[9][1])).pixmap(16, 16))
525 self.ico_dssi_host.setPixmap(KIcon(self.getIconForYesNo(app_info[9][2])).pixmap(16, 16))
526 self.ico_lv2_host.setPixmap(KIcon(self.getIconForYesNo(app_info[9][3])).pixmap(16, 16))
527 self.ico_vst_host.setPixmap(KIcon(self.getIconForYesNo(app_info[9][4])).pixmap(16, 16))
528 self.label_name_host.setText(app_info[1])
529 self.label_vst_mode_host.setText(app_info[9][5])
530 self.label_midi_mode_host.setText(app_info[9][6])
531 self.label_ladish_level_host.setText(str(app_info[7]))
532 self.showDoc_Host(app_info[10][0], app_info[10][1])
533 else:
534 self.test_selected = False
535 self.clearInfo_DAW()
536 self.checkButtons()
538 def checkSelectedInstrument(self, row, column, p_row, p_column):
539 if (row >= 0):
540 self.test_selected = True
542 app_name = self.listInstrument.item(row, 1).text()
543 app_info = []
544 list_Instrument = database.list_Instrument
546 for i in range(len(list_Instrument)):
547 if (app_name == list_Instrument[i][1]):
548 app_info = list_Instrument[i]
549 break
551 if (not app_info):
552 print "Error here, cod.004"
553 return
555 self.frame_Instrument.setEnabled(True)
556 self.ico_app_ins.setPixmap(KIcon(self.MyIcons.iconPath(app_info[4], KIconLoader.Desktop)).pixmap(48, 48))
557 self.ico_builtin_fx_ins.setPixmap(KIcon(self.getIconForYesNo(app_info[8][0])).pixmap(16, 16))
558 self.ico_audio_input_ins.setPixmap(KIcon(self.getIconForYesNo(app_info[8][1])).pixmap(16, 16))
559 self.label_name_ins.setText(app_info[1])
560 self.label_midi_mode_ins.setText(app_info[8][2])
561 self.label_ladish_level_ins.setText(str(app_info[6]))
562 self.showDoc_Instrument(app_info[9][0], app_info[9][1])
563 else:
564 self.test_selected = False
565 self.clearInfo_Intrument()
566 self.checkButtons()
568 def checkSelectedEffect(self, row, column, p_row, p_column):
569 if (row >= 0):
570 self.test_selected = True
572 app_name = self.listEffect.item(row, 1).text()
573 app_info = []
574 list_Effect = database.list_Effect
576 for i in range(len(list_Effect)):
577 if (app_name == list_Effect[i][1]):
578 app_info = list_Effect[i]
579 break
581 if (not app_info):
582 print "Error here, cod.005"
583 return
585 self.frame_Effect.setEnabled(True)
586 self.ico_app_effect.setPixmap(KIcon(self.MyIcons.iconPath(app_info[4], KIconLoader.Desktop)).pixmap(48, 48))
587 self.ico_stereo_effect.setPixmap(KIcon(self.getIconForYesNo(app_info[8][0])).pixmap(16, 16))
588 self.label_name_effect.setText(app_info[1])
589 self.label_midi_mode_effect.setText(app_info[8][1])
590 self.label_ladish_level_effect.setText(str(app_info[6]))
591 self.showDoc_Effect(app_info[9][0], app_info[9][1])
592 else:
593 self.test_selected = False
594 self.clearInfo_Effect()
595 self.checkButtons()
597 def checkSelectedTool(self, row, column, p_row, p_column):
598 if (row >= 0):
599 self.test_selected = True
601 app_name = self.listTool.item(row, 1).text()
602 app_info = []
603 list_Tool = database.list_Tool
605 for i in range(len(list_Tool)):
606 if (app_name == list_Tool[i][1]):
607 app_info = list_Tool[i]
608 break
610 if (not app_info):
611 print "Error here, cod.005"
612 return
614 self.frame_Tool.setEnabled(True)
615 self.ico_app_tool.setPixmap(KIcon(self.MyIcons.iconPath(app_info[4], KIconLoader.Desktop)).pixmap(48, 48))
616 self.label_name_tool.setText(app_info[1])
617 self.label_midi_mode_tool.setText(app_info[8][0])
618 self.ico_jack_transport_tool.setPixmap(KIcon(self.getIconForYesNo(app_info[8][1])).pixmap(16, 16))
619 self.label_ladish_level_tool.setText(str(app_info[6]))
620 self.showDoc_Tool(app_info[9][0], app_info[9][1])
621 else:
622 self.test_selected = False
623 self.clearInfo_Tool()
624 self.checkButtons()
626 def showDoc_DAW(self, doc, web):
627 if (doc):
628 self.url_documentation_daw.setVisible(True)
629 self.url_documentation_daw.setUrl(doc)
630 else: self.url_documentation_daw.setVisible(False)
632 if (web):
633 self.url_website_daw.setVisible(True)
634 self.url_website_daw.setUrl(web)
635 else: self.url_website_daw.setVisible(False)
637 if (not doc and not web):
638 self.label_no_help_daw.setVisible(True)
639 else:
640 self.label_no_help_daw.setVisible(False)
642 def showDoc_Host(self, doc, web):
643 if (doc):
644 self.url_documentation_host.setVisible(True)
645 self.url_documentation_host.setUrl(doc)
646 else: self.url_documentation_host.setVisible(False)
648 if (web):
649 self.url_website_host.setVisible(True)
650 self.url_website_host.setUrl(web)
651 else: self.url_website_host.setVisible(False)
653 if (not doc and not web):
654 self.label_no_help_host.setVisible(True)
655 else:
656 self.label_no_help_host.setVisible(False)
658 def showDoc_Instrument(self, doc, web):
659 if (doc):
660 self.url_documentation_ins.setVisible(True)
661 self.url_documentation_ins.setUrl(doc)
662 else: self.url_documentation_ins.setVisible(False)
664 if (web):
665 self.url_website_ins.setVisible(True)
666 self.url_website_ins.setUrl(web)
667 else: self.url_website_ins.setVisible(False)
669 if (not doc and not web):
670 self.label_no_help_ins.setVisible(True)
671 else:
672 self.label_no_help_ins.setVisible(False)
674 def showDoc_Effect(self, doc, web):
675 if (doc):
676 self.url_documentation_effect.setVisible(True)
677 self.url_documentation_effect.setUrl(doc)
678 else: self.url_documentation_effect.setVisible(False)
680 if (web):
681 self.url_website_effect.setVisible(True)
682 self.url_website_effect.setUrl(web)
683 else: self.url_website_effect.setVisible(False)
685 if (not doc and not web):
686 self.label_no_help_effect.setVisible(True)
687 else:
688 self.label_no_help_effect.setVisible(False)
690 def showDoc_Tool(self, doc, web):
691 if (doc):
692 self.url_documentation_tool.setVisible(True)
693 self.url_documentation_tool.setUrl(doc)
694 else: self.url_documentation_tool.setVisible(False)
696 if (web):
697 self.url_website_tool.setVisible(True)
698 self.url_website_tool.setUrl(web)
699 else: self.url_website_tool.setVisible(False)
701 if (not doc and not web):
702 self.label_no_help_tool.setVisible(True)
703 else:
704 self.label_no_help_tool.setVisible(False)
706 def openUrl(self, url):
707 os.system("xdg-open "+str(url)+" &")
709 def checkButtons(self):
710 if (self.test_url and self.test_selected):
711 self.b_add.setEnabled(True)
712 self.b_start.setEnabled(True)
713 else:
714 self.b_add.setEnabled(False)
715 self.b_start.setEnabled(False)
717 def clearAll(self):
718 self.listDAW.clearContents()
719 self.listHost.clearContents()
720 self.listInstrument.clearContents()
721 self.listEffect.clearContents()
722 self.listTool.clearContents()
723 for i in range(self.listDAW.rowCount()):
724 self.listDAW.removeRow(0)
725 for i in range(self.listHost.rowCount()):
726 self.listHost.removeRow(0)
727 for i in range(self.listInstrument.rowCount()):
728 self.listInstrument.removeRow(0)
729 for i in range(self.listEffect.rowCount()):
730 self.listEffect.removeRow(0)
731 for i in range(self.listTool.rowCount()):
732 self.listTool.removeRow(0)
734 def getIconForYesNo(self, yesno):
735 if (yesno):
736 return "dialog-ok-apply"
737 else:
738 return "dialog-cancel"
740 def refreshAll(self):
741 self.clearAll()
743 pkg_out = getoutput("dpkg -l").split("\n")
744 pkglist = []
745 for i in range(len(pkg_out)):
746 if (pkg_out[i][0] == "i" and pkg_out[i][1] == "i"):
747 package = pkg_out[i].split()[1]
748 pkglist.append(package)
750 last_pos = 0
751 list_DAW = database.list_DAW
752 for i in range(len(list_DAW)):
753 if (list_DAW[i][0] in pkglist):
754 AppName = list_DAW[i][1]
755 Type = list_DAW[i][2]
756 Binary = list_DAW[i][3]
757 Icon = list_DAW[i][4]
758 Save = list_DAW[i][5]
759 Level = list_DAW[i][6]
760 Licence = list_DAW[i][7]
761 Features = list_DAW[i][8]
762 Docs = list_DAW[i][9]
764 w_icon = QTableWidgetItem("")
765 w_icon.setIcon(KIcon(self.MyIcons.iconPath(Icon, KIconLoader.Small)))
766 w_name = QTableWidgetItem(AppName)
767 w_type = QTableWidgetItem(Type)
768 w_save = QTableWidgetItem(Save)
769 w_licc = QTableWidgetItem(Licence)
771 self.listDAW.insertRow(last_pos)
772 self.listDAW.setItem(last_pos, 0, w_icon)
773 self.listDAW.setItem(last_pos, 1, w_name)
774 self.listDAW.setItem(last_pos, 2, w_type)
775 self.listDAW.setItem(last_pos, 3, w_save)
776 self.listDAW.setItem(last_pos, 4, w_licc)
778 last_pos += 1
780 last_pos = 0
781 list_Host = database.list_Host
782 for i in range(len(list_Host)):
783 if (list_Host[i][0] in pkglist):
784 AppName = list_Host[i][1]
785 Has_Ins = list_Host[i][2]
786 Has_Eff = list_Host[i][3]
787 Binary = list_Host[i][4]
788 Icon = list_Host[i][5]
789 Save = list_Host[i][6]
790 Level = list_Host[i][7]
791 Licence = list_Host[i][8]
792 Features = list_Host[i][9]
793 Docs = list_Host[i][10]
795 w_icon = QTableWidgetItem("")
796 w_icon.setIcon(KIcon(self.MyIcons.iconPath(Icon, KIconLoader.Small)))
797 w_name = QTableWidgetItem(AppName)
798 w_h_in = QTableWidgetItem(Has_Ins)
799 w_h_ef = QTableWidgetItem(Has_Eff)
800 w_save = QTableWidgetItem(Save)
801 w_licc = QTableWidgetItem(Licence)
803 self.listHost.insertRow(last_pos)
804 self.listHost.setItem(last_pos, 0, w_icon)
805 self.listHost.setItem(last_pos, 1, w_name)
806 self.listHost.setItem(last_pos, 2, w_h_in)
807 self.listHost.setItem(last_pos, 3, w_h_ef)
808 self.listHost.setItem(last_pos, 4, w_save)
809 self.listHost.setItem(last_pos, 5, w_licc)
811 last_pos += 1
813 last_pos = 0
814 list_Instrument = database.list_Instrument
815 for i in range(len(list_Instrument)):
816 if (list_Instrument[i][0] in pkglist):
817 AppName = list_Instrument[i][1]
818 Type = list_Instrument[i][2]
819 Binary = list_Instrument[i][3]
820 Icon = list_Instrument[i][4]
821 Save = list_Instrument[i][5]
822 Level = list_Instrument[i][6]
823 Licence = list_Instrument[i][7]
824 Features = list_Instrument[i][8]
825 Docs = list_Instrument[i][9]
827 w_icon = QTableWidgetItem("")
828 w_icon.setIcon(KIcon(self.MyIcons.iconPath(Icon, KIconLoader.Small)))
829 w_name = QTableWidgetItem(AppName)
830 w_type = QTableWidgetItem(Type)
831 w_save = QTableWidgetItem(Save)
832 w_licc = QTableWidgetItem(Licence)
834 self.listInstrument.insertRow(last_pos)
835 self.listInstrument.setItem(last_pos, 0, w_icon)
836 self.listInstrument.setItem(last_pos, 1, w_name)
837 self.listInstrument.setItem(last_pos, 2, w_type)
838 self.listInstrument.setItem(last_pos, 3, w_save)
839 self.listInstrument.setItem(last_pos, 4, w_licc)
841 last_pos += 1
843 last_pos = 0
844 list_Effect = database.list_Effect
845 for i in range(len(list_Effect)):
846 if (list_Effect[i][0] in pkglist):
847 AppName = list_Effect[i][1]
848 Type = list_Effect[i][2]
849 Binary = list_Effect[i][3]
850 Icon = list_Effect[i][4]
851 Save = list_Effect[i][5]
852 Level = list_Effect[i][6]
853 Licence = list_Effect[i][7]
854 Features = list_Effect[i][8]
855 Docs = list_Effect[i][9]
857 w_icon = QTableWidgetItem("")
858 w_icon.setIcon(KIcon(self.MyIcons.iconPath(Icon, KIconLoader.Small)))
859 w_name = QTableWidgetItem(AppName)
860 w_type = QTableWidgetItem(Type)
861 w_save = QTableWidgetItem(Save)
862 w_licc = QTableWidgetItem(Licence)
864 self.listEffect.insertRow(last_pos)
865 self.listEffect.setItem(last_pos, 0, w_icon)
866 self.listEffect.setItem(last_pos, 1, w_name)
867 self.listEffect.setItem(last_pos, 2, w_type)
868 self.listEffect.setItem(last_pos, 3, w_save)
869 self.listEffect.setItem(last_pos, 4, w_licc)
871 last_pos += 1
873 last_pos = 0
874 list_Tool = database.list_Tool
875 for i in range(len(list_Tool)):
876 if (list_Tool[i][0] in pkglist):
877 AppName = list_Tool[i][1]
878 Type = list_Tool[i][2]
879 Binary = list_Tool[i][3]
880 Icon = list_Tool[i][4]
881 Save = list_Tool[i][5]
882 Level = list_Tool[i][6]
883 Licence = list_Tool[i][7]
884 Features = list_Tool[i][8]
885 Docs = list_Tool[i][9]
887 w_icon = QTableWidgetItem("")
888 w_icon.setIcon(KIcon(self.MyIcons.iconPath(Icon, KIconLoader.Small)))
889 w_name = QTableWidgetItem(AppName)
890 w_type = QTableWidgetItem(Type)
891 w_save = QTableWidgetItem(Save)
892 w_licc = QTableWidgetItem(Licence)
894 self.listTool.insertRow(last_pos)
895 self.listTool.setItem(last_pos, 0, w_icon)
896 self.listTool.setItem(last_pos, 1, w_name)
897 self.listTool.setItem(last_pos, 2, w_type)
898 self.listTool.setItem(last_pos, 3, w_save)
899 self.listTool.setItem(last_pos, 4, w_licc)
901 last_pos += 1
904 self.listDAW.setCurrentCell(-1, -1)
905 self.listHost.setCurrentCell(-1, -1)
906 self.listInstrument.setCurrentCell(-1, -1)
907 self.listEffect.setCurrentCell(-1, -1)
908 self.listTool.setCurrentCell(-1, -1)
910 self.listDAW.sortByColumn(1, Qt.AscendingOrder)
911 self.listHost.sortByColumn(1, Qt.AscendingOrder)
912 self.listInstrument.sortByColumn(1, Qt.AscendingOrder)
913 self.listEffect.sortByColumn(1, Qt.AscendingOrder)
914 self.listTool.sortByColumn(1, Qt.AscendingOrder)