More apps and fixes, disable ingen template for now
[klaudia.git] / src / w_klaudia.py
blob6f4b626853a6d61415770817393c455ec140c92b
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, 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.kurl_folder.setText(os.getenv("HOME"))
81 self.test_url = True
82 self.test_selected = False
84 self.clearInfo_DAW()
85 self.clearInfo_Host()
86 self.clearInfo_Intrument()
87 self.clearInfo_Effect()
88 self.clearInfo_Tool()
90 self.refreshAll()
91 self.refreshStudioList()
94 self.connect(self.b_start, SIGNAL("clicked()"), self.startApp)
95 self.connect(self.b_add, SIGNAL("clicked()"), self.addApp)
96 self.connect(self.b_refresh, SIGNAL("clicked()"), self.refreshStudioList)
98 self.connect(self.co_ladi_room, SIGNAL("currentIndexChanged(int)"), self.checkSelectedRoom)
100 self.connect(self.kurl_folder, SIGNAL("textChanged(QString)"), self.checkFolderUrl)
101 self.connect(self.tabWidget, SIGNAL("currentChanged(int)"), self.checkSelectedTab)
103 self.connect(self.listDAW, SIGNAL("currentCellChanged(int, int, int, int)"), self.checkSelectedDAW)
104 self.connect(self.listHost, SIGNAL("currentCellChanged(int, int, int, int)"), self.checkSelectedHost)
105 self.connect(self.listInstrument, SIGNAL("currentCellChanged(int, int, int, int)"), self.checkSelectedInstrument)
106 self.connect(self.listEffect, SIGNAL("currentCellChanged(int, int, int, int)"), self.checkSelectedEffect)
107 self.connect(self.listTool, SIGNAL("currentCellChanged(int, int, int, int)"), self.checkSelectedTool)
108 self.connect(self.listDAW, SIGNAL("cellDoubleClicked(int, int)"), self.doubleClickedListDAW)
109 self.connect(self.listHost, SIGNAL("cellDoubleClicked(int, int)"), self.doubleClickedListHost)
110 self.connect(self.listInstrument, SIGNAL("cellDoubleClicked(int, int)"), self.doubleClickedListInstrument)
111 self.connect(self.listEffect, SIGNAL("cellDoubleClicked(int, int)"), self.doubleClickedListEffect)
112 self.connect(self.listTool, SIGNAL("cellDoubleClicked(int, int)"), self.doubleClickedListTool)
114 self.connect(self.url_documentation_daw, SIGNAL("leftClickedUrl(QString)"), self.openUrl)
115 self.connect(self.url_website_daw, SIGNAL("leftClickedUrl(QString)"), self.openUrl)
116 self.connect(self.url_documentation_host, SIGNAL("leftClickedUrl(QString)"), self.openUrl)
117 self.connect(self.url_website_host, SIGNAL("leftClickedUrl(QString)"), self.openUrl)
118 self.connect(self.url_documentation_ins, SIGNAL("leftClickedUrl(QString)"), self.openUrl)
119 self.connect(self.url_website_ins, SIGNAL("leftClickedUrl(QString)"), self.openUrl)
120 self.connect(self.url_documentation_effect, SIGNAL("leftClickedUrl(QString)"), self.openUrl)
121 self.connect(self.url_website_effect, SIGNAL("leftClickedUrl(QString)"), self.openUrl)
122 self.connect(self.url_documentation_tool, SIGNAL("leftClickedUrl(QString)"), self.openUrl)
123 self.connect(self.url_website_tool, SIGNAL("leftClickedUrl(QString)"), self.openUrl)
126 def refreshStudioList(self):
127 self.co_ladi_room.clear()
128 self.co_ladi_room.addItem("<Studio Root>")
129 studio_bus = DBus.loopBus.get_object("org.ladish", "/org/ladish/Studio")
130 studio_list_dump = studio_bus.GetRoomList()
131 for i in range(len(studio_list_dump)):
132 self.co_ladi_room.addItem(str(studio_list_dump[i][0]).replace("/org/ladish/Room","")+" - "+studio_list_dump[i][1]['name'])
134 def checkSelectedRoom(self, co_n):
135 if (co_n == -1):
136 print "going -1"
137 elif (co_n == 0):
138 print "selected studio room"
139 DBus.studioBus = DBus.loopBus.get_object("org.ladish", "/org/ladish/Studio")
140 DBus.appBus = dbus.Interface(DBus.studioBus, 'org.ladish.AppSupervisor')
141 else:
142 print "selected a room", co_n
143 room_name = "/org/ladish/Room"+str(self.co_ladi_room.currentText()).split()[0]
144 DBus.studioBus = DBus.loopBus.get_object("org.ladish", room_name)
145 DBus.appBus = dbus.Interface(DBus.studioBus, 'org.ladish.AppSupervisor')
147 def getSelectedApp(self):
148 tab = self.tabWidget.currentIndex()
149 if (tab == 0):
150 listSel = self.listDAW
151 elif (tab == 1):
152 listSel = self.listHost
153 elif (tab == 2):
154 listSel = self.listInstrument
155 elif (tab == 3):
156 listSel = self.listEffect
157 elif (tab == 4):
158 listSel = self.listTool
159 else:
160 return ""
162 return listSel.item(listSel.currentRow(), 1).text()
164 def getBinaryFromAppName(self, appname):
165 list_DAW = database.list_DAW
166 for i in range(len(list_DAW)):
167 if (appname == list_DAW[i][1]):
168 binary = list_DAW[i][3]
169 break
171 list_Host = database.list_Host
172 for i in range(len(list_Host)):
173 if (appname == list_Host[i][1]):
174 binary = list_Host[i][4]
175 break
177 list_Instrument = database.list_Instrument
178 for i in range(len(list_Instrument)):
179 if (appname == list_Instrument[i][1]):
180 binary = list_Instrument[i][3]
181 break
183 list_Effect = database.list_Effect
184 for i in range(len(list_Effect)):
185 if (appname == list_Effect[i][1]):
186 binary = list_Effect[i][3]
187 break
189 list_Tool = database.list_Tool
190 for i in range(len(list_Tool)):
191 if (appname == list_Tool[i][1]):
192 binary = list_Tool[i][3]
193 break
195 if (binary):
196 return binary
197 else:
198 print "Error here, cod.002"
199 return ""
201 def doubleClickedListDAW(self, row, column):
202 app = self.listDAW.item(row, 1).text()
203 self.startApp(app)
205 def doubleClickedListHost(self, row, column):
206 app = self.listHost.item(row, 1).text()
207 self.startApp(app)
209 def doubleClickedListInstrument(self, row, column):
210 app = self.listInstrument.item(row, 1).text()
211 self.startApp(app)
213 def doubleClickedListEffect(self, row, column):
214 app = self.listEffect.item(row, 1).text()
215 self.startApp(app)
217 def doubleClickedListTool(self, row, column):
218 app = self.listTool.item(row, 1).text()
219 self.startApp(app)
221 def startApp(self, app=None):
222 if (not app):
223 app = self.getSelectedApp()
224 binary = self.getBinaryFromAppName(app)
225 os.system("cd "+str(self.kurl_folder.text())+" && "+binary+" &")
227 def addApp(self):
228 app = self.getSelectedApp()
229 binary = self.getBinaryFromAppName(app)
231 ran_check = str(randint(1, 99999))
232 sample_rate = int(self.co_sample_rate.currentText())
233 url_folder = str(self.kurl_folder.text())
234 proj_bpm = str(self.sb_bpm.text())
236 if (app == "Ardour" or app == "ArdourVST" or app == "ArdourVST (32bit)"):
237 proj_folder = url_folder+"/Ardour2_"+ran_check
238 os.mkdir(proj_folder)
239 os.system("cp "+sys.path[0]+"/../templates/Ardour2/* '"+proj_folder+"'")
240 os.system('sed -i "s/X_BPM_X-KLAUDIA-X_BPM_X/'+str(proj_bpm)+'/" "'+proj_folder+'/Ardour2.ardour"')
241 os.system('sed -i "s/X_SR_X-KLAUDIA-X_SR_X/'+str(sample_rate)+'/" "'+proj_folder+'/Ardour2.ardour"')
242 os.system("cd '"+proj_folder+"' && mv Ardour2.ardour Ardour2_"+ran_check+".ardour")
243 os.mkdir(proj_folder+"/analysis")
244 os.mkdir(proj_folder+"/dead_sounds")
245 os.mkdir(proj_folder+"/export")
246 os.mkdir(proj_folder+"/interchange")
247 os.mkdir(proj_folder+"/interchange/Ardour")
248 os.mkdir(proj_folder+"/interchange/Ardour/audiofiles")
249 os.mkdir(proj_folder+"/peaks")
250 DBus.appBus.RunCustom(False, binary+" '"+proj_folder+"'", str(app), 1)
251 elif (app == "Hydrogen" or app == "Hydrogen (SVN)"):
252 if (app == "Hydrogen (SVN)"):
253 level = 1
254 else:
255 level = 0
256 proj_file = url_folder+"/"+"Hydrogen_"+ran_check+".h2song"
257 os.system("cp "+sys.path[0]+"/../templates/Hydrogen.h2song '"+proj_file+"'")
258 os.system('sed -i "s/X_BPM_X-KLAUDIA-X_BPM_X/'+str(proj_bpm)+'/" "'+proj_file+'"')
259 DBus.appBus.RunCustom(False, "hydrogen -s '"+proj_file+"'", str(app), level)
260 elif (app == "MusE" or app == "MusE (SVN)"):
261 proj_file = url_folder+"/"+"MusE_"+ran_check+".med"
262 os.system("cp "+sys.path[0]+"/../templates/MusE.med '"+proj_file+"'")
263 DBus.appBus.RunCustom(False, "muse '"+proj_file+"'", str(app), 0)
264 elif (app == "Non-DAW"):
265 proj_file = url_folder+"/"+"Non-DAW_"+ran_check
266 os.system("cp -r "+sys.path[0]+"/../templates/Non-DAW '"+proj_file+"'")
267 os.system('sed -i "s/X_BPM_X-KLAUDIA-X_BPM_X/'+str(proj_bpm)+'/" "'+proj_file+'/history"')
268 os.system('sed -i "s/X_SR_X-KLAUDIA-X_SR_X/'+str(sample_rate)+'/" "'+proj_file+'/info"')
269 DBus.appBus.RunCustom(False, "non-daw '"+proj_file+"'", str(app), 0)
270 elif (app == "Non-Sequencer"):
271 proj_file = url_folder+"/"+"Non-Sequencer_"+ran_check+".non"
272 os.system("cp "+sys.path[0]+"/../templates/Non-Sequencer.non '"+proj_file+"'")
273 DBus.appBus.RunCustom(False, "non-sequencer '"+proj_file+"'", str(app), 0)
274 elif (app == "Qtractor" or app == "QtractorVST" or app == "QtractorVST (32bit)"):
275 proj_file = url_folder+"/"+"Qtractor_"+ran_check+".qtr"
276 os.system("cp "+sys.path[0]+"/../templates/Qtractor.qtr '"+proj_file+"'")
277 os.system('sed -i "s/X_BPM_X-KLAUDIA-X_BPM_X/'+str(proj_bpm)+'/" "'+proj_file+'"')
278 os.system('sed -i "s/X_SR_X-KLAUDIA-X_SR_X/'+str(sample_rate)+'/" "'+proj_file+'"')
279 os.system('sed -i "s/X_FOLDER_X-KLAUDIA-X_FOLDER_X/'+str(url_folder).replace("/","\/")+'/" "'+proj_file+'"')
280 DBus.appBus.RunCustom(False, binary+" '"+proj_file+"'", str(app), 1)
281 elif (app == "Renoise" or app == "Renoise (64bit)"):
282 os.mkdir(url_folder+"/tmp_bu")
283 os.system("cp "+sys.path[0]+"/../templates/Renoise.xml "+url_folder+"/tmp_bu")
284 os.system('sed -i "s/X_BPM_X-KLAUDIA-X_BPM_X/'+str(proj_bpm)+'/" "'+str(url_folder)+'/tmp_bu/Renoise.xml"')
285 os.system("cd '"+str(url_folder)+"/tmp_bu' && mv Renoise.xml Song.xml && zip ../Renoise_"+ran_check+".xrns Song.xml")
286 os.system("rm -rf '"+str(url_folder)+"/tmp_bu'")
287 DBus.appBus.RunCustom(False, binary+" '"+str(url_folder)+"/Renoise_"+ran_check+".xrns'", str(app), 0)
288 elif (app == "Rosegarden"):
289 proj_file = url_folder+"/"+"Rosegarden_"+ran_check+".rg"
290 os.system("cp "+sys.path[0]+"/../templates/Rosegarden.rg '"+proj_file+"'")
291 os.system('sed -i "s/X_BPM_X-KLAUDIA-X_BPM_X/'+str(proj_bpm)+'/" "'+proj_file+'"')
292 DBus.appBus.RunCustom(False, "rosegarden '"+proj_file+"'", str(app), 1)
293 elif (app == "Seq24" or app == "Seq24 (BZR)"):
294 proj_file = url_folder+"/"+"Seq24_"+ran_check+".midi"
295 os.system("cp "+sys.path[0]+"/../templates/Seq24.midi '"+proj_file+"'")
296 DBus.appBus.RunCustom(False, "seq24 --file '"+proj_file+"'", str(app), 0)
298 elif (app == "Calf Jack Host" or app == "Calf Jack Host (GIT)"):
299 if (app == "Calf Jack Host (GIT)"):
300 level = 1
301 else:
302 level = 0
303 proj_file = url_folder+"/"+"CalfJackHost_"+ran_check
304 os.system("cp "+sys.path[0]+"/../templates/CalfJackHost '"+proj_file+"'")
305 DBus.appBus.RunCustom(False, "calfjackhost --load '"+proj_file+"'", str(app), level)
306 elif (app == "FeSTige"):
307 room_name = "" if (self.co_ladi_room.currentIndex() <= 0) else "\""+str(self.co_ladi_room.currentText()).split(" - ")[1]+"\""
308 DBus.appBus.RunCustom(False, "festige "+url_folder+" "+room_name, str(app), 0)
309 #elif (app == "Ingen" or app == "Ingen (SVN)"):
310 #if (app == "Ingen (SVN)"):
311 #binary = "ingen-svn"
312 #else:
313 #binary = "ingen"
314 #proj_file = url_folder+"/"+"ingen_"+ran_check+".ing.lv2"
315 #os.system("cp -r "+sys.path[0]+"/../templates/ingen.ing.lv2 '"+proj_file+"'")
316 #DBus.appBus.RunCustom(False, binary+" -egl '"+proj_file+"'", str(app), 0)
317 elif (app == "Jack Rack"):
318 proj_file = url_folder+"/"+"Jack-Rack_"+ran_check+".xml"
319 os.system("cp "+sys.path[0]+"/../templates/Jack-Rack.xml '"+proj_file+"'")
320 os.system('sed -i "s/X_SR_X-KLAUDIA-X_SR_X/'+str(sample_rate)+'/" "'+proj_file+'"')
321 DBus.appBus.RunCustom(False, "jack-rack '"+proj_file+"'", str(app), 0)
323 elif (app == "Qsampler" or app == "Qsampler (SVN)"):
324 if (app == "Qsampler (SVN)"):
325 level = 1
326 else:
327 level = 0
328 proj_file = url_folder+"/"+"Qsampler_"+ran_check+".lscp"
329 os.system("cp "+sys.path[0]+"/../templates/Qsampler.lscp '"+proj_file+"'")
330 DBus.appBus.RunCustom(False, "qsampler '"+proj_file+"'", str(app), level)
331 elif (app == "Yoshimi"):
332 proj_file = url_folder+"/"+"Yoshimi_"+ran_check+".state"
333 os.system("cp "+sys.path[0]+"/../templates/Yoshimi.state '"+proj_file+"'")
334 os.system('sed -i "s/X_SR_X-KLAUDIA-X_SR_X/'+str(sample_rate)+'/" "'+proj_file+'"')
335 os.system('sed -i "s/X_FILE_X-KLAUDIA-X_FILE_X/'+proj_file.replace(" ","\ ").replace("/","\/")+'/" "'+proj_file+'"')
336 DBus.appBus.RunCustom(False, "yoshimi -j -J --state='"+proj_file+"'", str(app), 1)
338 elif (app == "Jamin"):
339 proj_file = url_folder+"/"+"Jamin_"+ran_check+".jam"
340 os.system("cp "+sys.path[0]+"/../templates/Jamin.jam '"+proj_file+"'")
341 DBus.appBus.RunCustom(False, "jamin -f '"+proj_file+"'", str(app), 0)
343 elif (app == "Jack Mixer"):
344 proj_file = url_folder+"/"+"Jack-Mixer_"+ran_check+".xml"
345 os.system("cp "+sys.path[0]+"/../templates/Jack-Mixer.xml '"+proj_file+"'")
346 DBus.appBus.RunCustom(False, "jack_mixer -c '"+proj_file+"'", str(app), 1)
347 elif (app == "Non-Mixer"):
348 proj_file = url_folder+"/"+"Non-Mixer_"+ran_check
349 os.system("cp -r "+sys.path[0]+"/../templates/Non-Mixer '"+proj_file+"'")
350 DBus.appBus.RunCustom(False, "non-mixer '"+proj_file+"'", str(app), 0)
352 else:
353 DBus.appBus.RunCustom(False, binary, str(app), 0)
355 def clearInfo_DAW(self):
356 self.ico_app_daw.setPixmap(KIcon("start-here-kde").pixmap(48, 48))
357 self.label_name_daw.setText("App Name")
358 self.ico_ladspa_daw.setPixmap(KIcon("dialog-cancel").pixmap(16, 16))
359 self.ico_dssi_daw.setPixmap(KIcon("dialog-cancel").pixmap(16, 16))
360 self.ico_lv2_daw.setPixmap(KIcon("dialog-cancel").pixmap(16, 16))
361 self.ico_vst_daw.setPixmap(KIcon("dialog-cancel").pixmap(16, 16))
362 self.label_vst_mode_daw.setText("")
363 self.ico_jack_transport_daw.setPixmap(KIcon("dialog-cancel").pixmap(16, 16))
364 self.label_midi_mode_daw.setText("---")
365 self.label_ladish_level_daw.setText("0")
366 self.showDoc_DAW(0, 0)
367 self.frame_DAW.setEnabled(False)
369 def clearInfo_Host(self):
370 self.ico_app_host.setPixmap(KIcon("start-here-kde").pixmap(48, 48))
371 self.label_name_host.setText("App Name")
372 self.ico_ladspa_host.setPixmap(KIcon("dialog-cancel").pixmap(16, 16))
373 self.ico_dssi_host.setPixmap(KIcon("dialog-cancel").pixmap(16, 16))
374 self.ico_lv2_host.setPixmap(KIcon("dialog-cancel").pixmap(16, 16))
375 self.ico_vst_host.setPixmap(KIcon("dialog-cancel").pixmap(16, 16))
376 self.label_vst_mode_host.setText("")
377 self.label_midi_mode_host.setText("---")
378 self.label_ladish_level_host.setText("0")
379 self.showDoc_Host(0, 0)
380 self.frame_Host.setEnabled(False)
382 def clearInfo_Intrument(self):
383 self.ico_app_ins.setPixmap(KIcon("start-here-kde").pixmap(48, 48))
384 self.label_name_ins.setText("App Name")
385 self.ico_builtin_fx_ins.setPixmap(KIcon("dialog-cancel").pixmap(16, 16))
386 self.ico_audio_input_ins.setPixmap(KIcon("dialog-cancel").pixmap(16, 16))
387 self.label_midi_mode_ins.setText("---")
388 self.label_ladish_level_ins.setText("0")
389 self.showDoc_Instrument(0, 0)
390 self.frame_Instrument.setEnabled(False)
392 def clearInfo_Effect(self):
393 self.ico_app_effect.setPixmap(KIcon("start-here-kde").pixmap(48, 48))
394 self.label_name_effect.setText("App Name")
395 self.ico_stereo_effect.setPixmap(KIcon("dialog-cancel").pixmap(16, 16))
396 self.label_midi_mode_effect.setText("---")
397 self.label_ladish_level_effect.setText("0")
398 self.showDoc_Effect(0, 0)
399 self.frame_Effect.setEnabled(False)
401 def clearInfo_Tool(self):
402 self.ico_app_tool.setPixmap(KIcon("start-here-kde").pixmap(48, 48))
403 self.label_name_tool.setText("App Name")
404 self.label_midi_mode_tool.setText("---")
405 self.label_ladish_level_tool.setText("0")
406 self.showDoc_Tool(0, 0)
407 self.frame_Tool.setEnabled(False)
409 def checkFolderUrl(self, url):
410 if (os.path.exists(url)):
411 self.test_url = True
412 else:
413 self.test_url = False
414 self.checkButtons()
416 def checkSelectedTab(self, tab):
417 self.test_selected = False
418 if (tab == 0): # DAW
419 if (self.listDAW.selectedItems()):
420 self.test_selected = True
421 elif (tab == 1): # Host
422 if (self.listHost.selectedItems()):
423 self.test_selected = True
424 elif (tab == 2): # Instrument
425 if (self.listInstrument.selectedItems()):
426 self.test_selected = True
427 elif (tab == 3): # Effect
428 if (self.listEffect.selectedItems()):
429 self.test_selected = True
430 elif (tab == 4): # Tool
431 if (self.listTool.selectedItems()):
432 self.test_selected = True
434 self.checkButtons()
436 def checkSelectedDAW(self, row, column, p_row, p_column):
437 if (row >= 0):
438 self.test_selected = True
440 app_name = self.listDAW.item(row, 1).text()
441 app_info = []
442 list_DAW = database.list_DAW
444 for i in range(len(list_DAW)):
445 if (app_name == list_DAW[i][1]):
446 app_info = list_DAW[i]
447 break
449 if (not app_info):
450 print "Error here, cod.001"
451 return
453 self.frame_DAW.setEnabled(True)
454 self.ico_app_daw.setPixmap(KIcon(self.MyIcons.iconPath(app_info[4], KIconLoader.Desktop)).pixmap(48, 48))
455 self.ico_ladspa_daw.setPixmap(KIcon(self.getIconForYesNo(app_info[8][0])).pixmap(16, 16))
456 self.ico_dssi_daw.setPixmap(KIcon(self.getIconForYesNo(app_info[8][1])).pixmap(16, 16))
457 self.ico_lv2_daw.setPixmap(KIcon(self.getIconForYesNo(app_info[8][2])).pixmap(16, 16))
458 self.ico_vst_daw.setPixmap(KIcon(self.getIconForYesNo(app_info[8][3])).pixmap(16, 16))
459 self.ico_jack_transport_daw.setPixmap(KIcon(self.getIconForYesNo(app_info[8][5])).pixmap(16, 16))
460 self.label_name_daw.setText(app_info[1])
461 self.label_vst_mode_daw.setText(app_info[8][4])
462 self.ico_midi_mode_daw.setPixmap(KIcon(self.getIconForYesNo(app_info[8][6])).pixmap(16, 16))
463 self.label_midi_mode_daw.setText(app_info[8][7])
464 self.label_ladish_level_daw.setText(str(app_info[6]))
465 self.showDoc_DAW(app_info[9][0], app_info[9][1])
466 else:
467 self.test_selected = False
468 self.clearInfo_DAW()
469 self.checkButtons()
471 def checkSelectedHost(self, row, column, p_row, p_column):
472 if (row >= 0):
473 self.test_selected = True
475 app_name = self.listHost.item(row, 1).text()
476 app_info = []
477 list_Host = database.list_Host
479 for i in range(len(list_Host)):
480 if (app_name == list_Host[i][1]):
481 app_info = list_Host[i]
482 break
484 if (not app_info):
485 print "Error here, cod.003"
486 return
488 self.frame_Host.setEnabled(True)
489 self.ico_app_host.setPixmap(KIcon(self.MyIcons.iconPath(app_info[5], KIconLoader.Desktop)).pixmap(48, 48))
490 self.ico_internal_host.setPixmap(KIcon(self.getIconForYesNo(app_info[9][0])).pixmap(16, 16))
491 self.ico_ladspa_host.setPixmap(KIcon(self.getIconForYesNo(app_info[9][1])).pixmap(16, 16))
492 self.ico_dssi_host.setPixmap(KIcon(self.getIconForYesNo(app_info[9][2])).pixmap(16, 16))
493 self.ico_lv2_host.setPixmap(KIcon(self.getIconForYesNo(app_info[9][3])).pixmap(16, 16))
494 self.ico_vst_host.setPixmap(KIcon(self.getIconForYesNo(app_info[9][4])).pixmap(16, 16))
495 self.label_name_host.setText(app_info[1])
496 self.label_vst_mode_host.setText(app_info[9][5])
497 self.label_midi_mode_host.setText(app_info[9][6])
498 self.label_ladish_level_host.setText(str(app_info[7]))
499 self.showDoc_Host(app_info[10][0], app_info[10][1])
500 else:
501 self.test_selected = False
502 self.clearInfo_DAW()
503 self.checkButtons()
505 def checkSelectedInstrument(self, row, column, p_row, p_column):
506 if (row >= 0):
507 self.test_selected = True
509 app_name = self.listInstrument.item(row, 1).text()
510 app_info = []
511 list_Instrument = database.list_Instrument
513 for i in range(len(list_Instrument)):
514 if (app_name == list_Instrument[i][1]):
515 app_info = list_Instrument[i]
516 break
518 if (not app_info):
519 print "Error here, cod.004"
520 return
522 self.frame_Instrument.setEnabled(True)
523 self.ico_app_ins.setPixmap(KIcon(self.MyIcons.iconPath(app_info[4], KIconLoader.Desktop)).pixmap(48, 48))
524 self.ico_builtin_fx_ins.setPixmap(KIcon(self.getIconForYesNo(app_info[8][0])).pixmap(16, 16))
525 self.ico_audio_input_ins.setPixmap(KIcon(self.getIconForYesNo(app_info[8][1])).pixmap(16, 16))
526 self.label_name_ins.setText(app_info[1])
527 self.label_midi_mode_ins.setText(app_info[8][2])
528 self.label_ladish_level_ins.setText(str(app_info[6]))
529 self.showDoc_Instrument(app_info[9][0], app_info[9][1])
530 else:
531 self.test_selected = False
532 self.clearInfo_Intrument()
533 self.checkButtons()
535 def checkSelectedEffect(self, row, column, p_row, p_column):
536 if (row >= 0):
537 self.test_selected = True
539 app_name = self.listEffect.item(row, 1).text()
540 app_info = []
541 list_Effect = database.list_Effect
543 for i in range(len(list_Effect)):
544 if (app_name == list_Effect[i][1]):
545 app_info = list_Effect[i]
546 break
548 if (not app_info):
549 print "Error here, cod.005"
550 return
552 self.frame_Effect.setEnabled(True)
553 self.ico_app_effect.setPixmap(KIcon(self.MyIcons.iconPath(app_info[4], KIconLoader.Desktop)).pixmap(48, 48))
554 self.ico_stereo_effect.setPixmap(KIcon(self.getIconForYesNo(app_info[8][0])).pixmap(16, 16))
555 self.label_name_effect.setText(app_info[1])
556 self.label_midi_mode_effect.setText(app_info[8][1])
557 self.label_ladish_level_effect.setText(str(app_info[6]))
558 self.showDoc_Effect(app_info[9][0], app_info[9][1])
559 else:
560 self.test_selected = False
561 self.clearInfo_Effect()
562 self.checkButtons()
564 def checkSelectedTool(self, row, column, p_row, p_column):
565 if (row >= 0):
566 self.test_selected = True
568 app_name = self.listTool.item(row, 1).text()
569 app_info = []
570 list_Tool = database.list_Tool
572 for i in range(len(list_Tool)):
573 if (app_name == list_Tool[i][1]):
574 app_info = list_Tool[i]
575 break
577 if (not app_info):
578 print "Error here, cod.005"
579 return
581 self.frame_Tool.setEnabled(True)
582 self.ico_app_tool.setPixmap(KIcon(self.MyIcons.iconPath(app_info[4], KIconLoader.Desktop)).pixmap(48, 48))
583 self.label_name_tool.setText(app_info[1])
584 self.label_midi_mode_tool.setText(app_info[8][0])
585 self.ico_jack_transport_tool.setPixmap(KIcon(self.getIconForYesNo(app_info[8][1])).pixmap(16, 16))
586 self.label_ladish_level_tool.setText(str(app_info[6]))
587 self.showDoc_Tool(app_info[9][0], app_info[9][1])
588 else:
589 self.test_selected = False
590 self.clearInfo_Tool()
591 self.checkButtons()
593 def showDoc_DAW(self, doc, web):
594 if (doc):
595 self.url_documentation_daw.setVisible(True)
596 self.url_documentation_daw.setUrl(doc)
597 else: self.url_documentation_daw.setVisible(False)
599 if (web):
600 self.url_website_daw.setVisible(True)
601 self.url_website_daw.setUrl(web)
602 else: self.url_website_daw.setVisible(False)
604 if (not doc and not web):
605 self.label_no_help_daw.setVisible(True)
606 else:
607 self.label_no_help_daw.setVisible(False)
609 def showDoc_Host(self, doc, web):
610 if (doc):
611 self.url_documentation_host.setVisible(True)
612 self.url_documentation_host.setUrl(doc)
613 else: self.url_documentation_host.setVisible(False)
615 if (web):
616 self.url_website_host.setVisible(True)
617 self.url_website_host.setUrl(web)
618 else: self.url_website_host.setVisible(False)
620 if (not doc and not web):
621 self.label_no_help_host.setVisible(True)
622 else:
623 self.label_no_help_host.setVisible(False)
625 def showDoc_Instrument(self, doc, web):
626 if (doc):
627 self.url_documentation_ins.setVisible(True)
628 self.url_documentation_ins.setUrl(doc)
629 else: self.url_documentation_ins.setVisible(False)
631 if (web):
632 self.url_website_ins.setVisible(True)
633 self.url_website_ins.setUrl(web)
634 else: self.url_website_ins.setVisible(False)
636 if (not doc and not web):
637 self.label_no_help_ins.setVisible(True)
638 else:
639 self.label_no_help_ins.setVisible(False)
641 def showDoc_Effect(self, doc, web):
642 if (doc):
643 self.url_documentation_effect.setVisible(True)
644 self.url_documentation_effect.setUrl(doc)
645 else: self.url_documentation_effect.setVisible(False)
647 if (web):
648 self.url_website_effect.setVisible(True)
649 self.url_website_effect.setUrl(web)
650 else: self.url_website_effect.setVisible(False)
652 if (not doc and not web):
653 self.label_no_help_effect.setVisible(True)
654 else:
655 self.label_no_help_effect.setVisible(False)
657 def showDoc_Tool(self, doc, web):
658 if (doc):
659 self.url_documentation_tool.setVisible(True)
660 self.url_documentation_tool.setUrl(doc)
661 else: self.url_documentation_tool.setVisible(False)
663 if (web):
664 self.url_website_tool.setVisible(True)
665 self.url_website_tool.setUrl(web)
666 else: self.url_website_tool.setVisible(False)
668 if (not doc and not web):
669 self.label_no_help_tool.setVisible(True)
670 else:
671 self.label_no_help_tool.setVisible(False)
673 def openUrl(self, url):
674 os.system("xdg-open "+str(url))
676 def checkButtons(self):
677 if (self.test_url and self.test_selected):
678 self.b_add.setEnabled(True)
679 self.b_start.setEnabled(True)
680 else:
681 self.b_add.setEnabled(False)
682 self.b_start.setEnabled(False)
684 def clearAll(self):
685 self.listDAW.clearContents()
686 self.listHost.clearContents()
687 self.listInstrument.clearContents()
688 self.listEffect.clearContents()
689 self.listTool.clearContents()
690 for i in range(self.listDAW.rowCount()):
691 self.listDAW.removeRow(0)
692 for i in range(self.listHost.rowCount()):
693 self.listHost.removeRow(0)
694 for i in range(self.listInstrument.rowCount()):
695 self.listInstrument.removeRow(0)
696 for i in range(self.listEffect.rowCount()):
697 self.listEffect.removeRow(0)
698 for i in range(self.listTool.rowCount()):
699 self.listTool.removeRow(0)
701 def getIconForYesNo(self, yesno):
702 if (yesno):
703 return "dialog-ok-apply"
704 else:
705 return "dialog-cancel"
707 def refreshAll(self):
708 self.clearAll()
710 pkg_out = getoutput("dpkg -l").split("\n")
711 pkglist = []
712 for i in range(len(pkg_out)):
713 if (pkg_out[i][0] == "i" and pkg_out[i][1] == "i"):
714 package = pkg_out[i].split()[1]
715 pkglist.append(package)
717 last_pos = 0
718 list_DAW = database.list_DAW
719 for i in range(len(list_DAW)):
720 if (list_DAW[i][0] in pkglist):
721 AppName = list_DAW[i][1]
722 Type = list_DAW[i][2]
723 Binary = list_DAW[i][3]
724 Icon = list_DAW[i][4]
725 Save = list_DAW[i][5]
726 Level = list_DAW[i][6]
727 Licence = list_DAW[i][7]
728 Features = list_DAW[i][8]
729 Docs = list_DAW[i][9]
731 w_icon = QTableWidgetItem("")
732 w_icon.setIcon(KIcon(self.MyIcons.iconPath(Icon, KIconLoader.Small)))
733 w_name = QTableWidgetItem(AppName)
734 w_type = QTableWidgetItem(Type)
735 w_save = QTableWidgetItem(Save)
736 w_licc = QTableWidgetItem(Licence)
738 self.listDAW.insertRow(last_pos)
739 self.listDAW.setItem(last_pos, 0, w_icon)
740 self.listDAW.setItem(last_pos, 1, w_name)
741 self.listDAW.setItem(last_pos, 2, w_type)
742 self.listDAW.setItem(last_pos, 3, w_save)
743 self.listDAW.setItem(last_pos, 4, w_licc)
745 last_pos += 1
747 last_pos = 0
748 list_Host = database.list_Host
749 for i in range(len(list_Host)):
750 if (list_Host[i][0] in pkglist):
751 AppName = list_Host[i][1]
752 Has_Ins = list_Host[i][2]
753 Has_Eff = list_Host[i][3]
754 Binary = list_Host[i][4]
755 Icon = list_Host[i][5]
756 Save = list_Host[i][6]
757 Level = list_Host[i][7]
758 Licence = list_Host[i][8]
759 Features = list_Host[i][9]
760 Docs = list_Host[i][10]
762 w_icon = QTableWidgetItem("")
763 w_icon.setIcon(KIcon(self.MyIcons.iconPath(Icon, KIconLoader.Small)))
764 w_name = QTableWidgetItem(AppName)
765 w_h_in = QTableWidgetItem(Has_Ins)
766 w_h_ef = QTableWidgetItem(Has_Eff)
767 w_save = QTableWidgetItem(Save)
768 w_licc = QTableWidgetItem(Licence)
770 self.listHost.insertRow(last_pos)
771 self.listHost.setItem(last_pos, 0, w_icon)
772 self.listHost.setItem(last_pos, 1, w_name)
773 self.listHost.setItem(last_pos, 2, w_h_in)
774 self.listHost.setItem(last_pos, 3, w_h_ef)
775 self.listHost.setItem(last_pos, 4, w_save)
776 self.listHost.setItem(last_pos, 5, w_licc)
778 last_pos += 1
780 last_pos = 0
781 list_Instrument = database.list_Instrument
782 for i in range(len(list_Instrument)):
783 if (list_Instrument[i][0] in pkglist):
784 AppName = list_Instrument[i][1]
785 Type = list_Instrument[i][2]
786 Binary = list_Instrument[i][3]
787 Icon = list_Instrument[i][4]
788 Save = list_Instrument[i][5]
789 Level = list_Instrument[i][6]
790 Licence = list_Instrument[i][7]
791 Features = list_Instrument[i][8]
792 Docs = list_Instrument[i][9]
794 w_icon = QTableWidgetItem("")
795 w_icon.setIcon(KIcon(self.MyIcons.iconPath(Icon, KIconLoader.Small)))
796 w_name = QTableWidgetItem(AppName)
797 w_type = QTableWidgetItem(Type)
798 w_save = QTableWidgetItem(Save)
799 w_licc = QTableWidgetItem(Licence)
801 self.listInstrument.insertRow(last_pos)
802 self.listInstrument.setItem(last_pos, 0, w_icon)
803 self.listInstrument.setItem(last_pos, 1, w_name)
804 self.listInstrument.setItem(last_pos, 2, w_type)
805 self.listInstrument.setItem(last_pos, 3, w_save)
806 self.listInstrument.setItem(last_pos, 4, w_licc)
808 last_pos += 1
810 last_pos = 0
811 list_Effect = database.list_Effect
812 for i in range(len(list_Effect)):
813 if (list_Effect[i][0] in pkglist):
814 AppName = list_Effect[i][1]
815 Type = list_Effect[i][2]
816 Binary = list_Effect[i][3]
817 Icon = list_Effect[i][4]
818 Save = list_Effect[i][5]
819 Level = list_Effect[i][6]
820 Licence = list_Effect[i][7]
821 Features = list_Effect[i][8]
822 Docs = list_Effect[i][9]
824 w_icon = QTableWidgetItem("")
825 w_icon.setIcon(KIcon(self.MyIcons.iconPath(Icon, KIconLoader.Small)))
826 w_name = QTableWidgetItem(AppName)
827 w_type = QTableWidgetItem(Type)
828 w_save = QTableWidgetItem(Save)
829 w_licc = QTableWidgetItem(Licence)
831 self.listEffect.insertRow(last_pos)
832 self.listEffect.setItem(last_pos, 0, w_icon)
833 self.listEffect.setItem(last_pos, 1, w_name)
834 self.listEffect.setItem(last_pos, 2, w_type)
835 self.listEffect.setItem(last_pos, 3, w_save)
836 self.listEffect.setItem(last_pos, 4, w_licc)
838 last_pos += 1
840 last_pos = 0
841 list_Tool = database.list_Tool
842 for i in range(len(list_Tool)):
843 if (list_Tool[i][0] in pkglist):
844 AppName = list_Tool[i][1]
845 Type = list_Tool[i][2]
846 Binary = list_Tool[i][3]
847 Icon = list_Tool[i][4]
848 Save = list_Tool[i][5]
849 Level = list_Tool[i][6]
850 Licence = list_Tool[i][7]
851 Features = list_Tool[i][8]
852 Docs = list_Tool[i][9]
854 w_icon = QTableWidgetItem("")
855 w_icon.setIcon(KIcon(self.MyIcons.iconPath(Icon, KIconLoader.Small)))
856 w_name = QTableWidgetItem(AppName)
857 w_type = QTableWidgetItem(Type)
858 w_save = QTableWidgetItem(Save)
859 w_licc = QTableWidgetItem(Licence)
861 self.listTool.insertRow(last_pos)
862 self.listTool.setItem(last_pos, 0, w_icon)
863 self.listTool.setItem(last_pos, 1, w_name)
864 self.listTool.setItem(last_pos, 2, w_type)
865 self.listTool.setItem(last_pos, 3, w_save)
866 self.listTool.setItem(last_pos, 4, w_licc)
868 last_pos += 1
871 self.listDAW.setCurrentCell(-1, -1)
872 self.listHost.setCurrentCell(-1, -1)
873 self.listInstrument.setCurrentCell(-1, -1)
874 self.listEffect.setCurrentCell(-1, -1)
875 self.listTool.setCurrentCell(-1, -1)
877 self.listDAW.sortByColumn(1, Qt.AscendingOrder)
878 self.listHost.sortByColumn(1, Qt.AscendingOrder)
879 self.listInstrument.sortByColumn(1, Qt.AscendingOrder)
880 self.listEffect.sortByColumn(1, Qt.AscendingOrder)
881 self.listTool.sortByColumn(1, Qt.AscendingOrder)