2 # -*- coding: utf-8 -*-
7 from commands
import getoutput
8 from random
import randint
9 from PyQt4
.QtCore
import Qt
, SIGNAL
10 from PyQt4
.QtGui
import QTableWidgetItem
, QWidget
11 from PyKDE4
.kdeui
import KIcon
12 import shared
, tb_main
, ui_tb_apps
, find_plugins
16 class AppsW(QWidget
, ui_tb_apps
.Ui_AppsW
):
17 def __init__(self
, *args
):
18 QWidget
.__init
__(self
, *args
)
21 self
.b_add
.setEnabled(False)
22 self
.b_add
.setIcon(KIcon("list-add"))
23 #self.b_addc.setEnabled(False)
24 self
.b_addc
.setIcon(KIcon("list-add"))
25 self
.b_refresh
.setIcon(KIcon("view-refresh"))
27 self
.listDAW
.setColumnWidth(0, 32)
28 self
.listDAW
.setColumnWidth(1, 400)
29 self
.listDAW
.setColumnWidth(2, 100)
30 self
.listDAW
.setColumnWidth(3, 75)
31 self
.listDAW
.setColumnWidth(4, 75)
33 self
.connect(self
.b_refresh
, SIGNAL("clicked()"), self
.refreshFull
)
34 self
.connect(self
.b_add
, SIGNAL("clicked()"), self
.addApplication
)
35 self
.connect(self
.b_addc
, SIGNAL("clicked()"), self
.addCustom
)
36 self
.connect(self
.listDAW
, SIGNAL("currentCellChanged(int, int, int, int)"), self
.updateButtons
)
41 def addApplication(self
):
42 tab
= self
.tabWidget
.currentIndex()
44 listSel
= self
.listDAW
46 listSel
= self
.listHosts
48 listSel
= self
.listSynths
50 listSel
= self
.listEffects
52 listSel
= self
.listTools
54 listSel
= self
.listBristol
56 listSel
= self
.listVSTs
58 app
= listSel
.item(listSel
.currentRow(), 1).text()
60 if (app
== "Renoise"):
61 ran_check
= str(randint(1, 99999))
62 os
.mkdir(shared
.p_folder
+"/tmp_bu")
63 os
.system("cp "+shared
.Path
+"/../templates/Renoise.xml "+shared
.p_folder
+"/tmp_bu")
64 os
.system('sed -i "s/X_BPM_X-KLAUDIA-X_BPM_X/'+str(shared
.p_bpm
)+'/" '+str(shared
.p_folder
)+'/tmp_bu/Renoise.xml')
65 os
.system("cd "+str(shared
.p_folder
)+"/tmp_bu && mv Renoise.xml Song.xml && zip ../Renoise_"+ran_check
+".xrns Song.xml")
66 os
.system("rm -rf "+str(shared
.p_folder
)+"/tmp_bu")
67 shared
.appBus
.RunCustom(False, "renoise "+str(shared
.p_folder
)+"/Renoise_"+ran_check
+".xrns", "Renoise", 0)
70 tb_main
.NewAppW().exec_()
72 def refreshFull(self
):
73 self
.listDAW
.clearContents()
74 for i
in range(self
.listDAW
.rowCount()):
75 self
.listDAW
.removeRow(i
)
77 plugins
= find_plugins
.findAll()
80 for h
in range(len(plugins
)):
81 if (plugins
[h
][5] == "DAW"):
82 name
= QTableWidgetItem(plugins
[h
][0])
83 binary
= QTableWidgetItem(plugins
[h
][1])
84 icon
= QTableWidgetItem("")
85 icon
.setIcon(KIcon(plugins
[h
][2]))
86 version
= QTableWidgetItem(plugins
[h
][3])
87 level
= QTableWidgetItem(plugins
[h
][4])
88 path
= QTableWidgetItem(plugins
[h
][6])
89 self
.listDAW
.insertRow(h
)
90 self
.listDAW
.setItem(h
, 0, icon
)
91 self
.listDAW
.setItem(h
, 1, name
)
92 self
.listDAW
.setItem(h
, 2, path
)
93 self
.listDAW
.setItem(h
, 3, binary
)
94 self
.listDAW
.setItem(h
, 4, version
)
95 self
.listDAW
.setItem(h
, 5, level
)
97 for g
in range(self
.listDAW
.rowCount()):
98 if (self
.listDAW
.item(g
, 0) == None):
99 self
.listDAW
.removeRow(g
)
101 self
.listDAW
.sortByColumn(1, Qt
.AscendingOrder
)
104 def updateButtons(self
, a
, b
, c
, d
):
106 self
.b_add
.setEnabled(True)
108 self
.b_add
.setEnabled(False)