| 23 | |
---|
| 24 | class OutputSwitcher(QtGui.QFrame): |
---|
| 25 | """ |
---|
| 26 | The name is a bit misleading. This widget selectes sources for a specified |
---|
| 27 | destination. |
---|
| 28 | |
---|
| 29 | In mixer-usage this widget is at the top of the input-channel. Because the input |
---|
| 30 | of the mixer is an available output from the routers point. |
---|
| 31 | """ |
---|
| 32 | def __init__(self, interface, outname, parent): |
---|
| 33 | QtGui.QFrame.__init__(self, parent) |
---|
| 34 | self.interface = interface |
---|
| 35 | self.outname = outname |
---|
| 36 | |
---|
| 37 | self.setLineWidth(1) |
---|
| 38 | |
---|
| 39 | self.layout = QtGui.QGridLayout(self) |
---|
| 40 | self.setLayout(self.layout) |
---|
| 41 | |
---|
| 42 | self.lbl = QtGui.QLabel(self.outname, self) |
---|
| 43 | self.layout.addWidget(self.lbl, 0, 0, 1, 2) |
---|
| 44 | |
---|
| 45 | self.btn = QtGui.QPushButton("Sel.", self) |
---|
| 46 | self.layout.addWidget(self.btn, 1, 0) |
---|
| 47 | |
---|
| 48 | self.exclusiveGroup = QtGui.QActionGroup(self) |
---|
| 49 | |
---|
| 50 | sources = self.interface.getSourceNames() |
---|
| 51 | self.ingroups = {} |
---|
| 52 | for ch in sources: |
---|
| 53 | tmp = str(ch).split(":")[0] |
---|
| 54 | if tmp not in self.ingroups: |
---|
| 55 | self.ingroups[tmp] = 0 |
---|
| 56 | self.ingroups[tmp] += 1 |
---|
| 57 | #print "Detected ingroups: %s" % str(self.ingroups) |
---|
| 58 | |
---|
| 59 | self.menu = QtGui.QMenu(self) |
---|
| 60 | self.btn.setMenu(self.menu) |
---|
| 61 | |
---|
| 62 | for group in self.ingroups: |
---|
| 63 | submenu = InGroupMenu(self.interface, self.outname, group, self.ingroups[group], self, self.exclusiveGroup) |
---|
| 64 | self.menu.addMenu(submenu) |
---|
78 | | self.destinations = [] |
---|
79 | | for dest in destinations: |
---|
80 | | self.destinations.append(str(dest)) |
---|
81 | | |
---|
82 | | print "Available sources (%i=?%i) %s" % (self.interface.getNbSources(), len(self.sources), str(self.sources)) |
---|
83 | | print "Available destinations (%i=?%i) %s" % (self.interface.getNbDestinations(), len(self.destinations), str(self.destinations)) |
---|
84 | | |
---|
85 | | self.innames = [] |
---|
86 | | self.ingroups = {} |
---|
87 | | for ch in self.sources: |
---|
88 | | tmp = ch.split(":")[0] |
---|
89 | | if True: #tmp[0] == "M" or tmp[0] == "I": |
---|
90 | | if not tmp in self.ingroups: |
---|
91 | | self.ingroups[tmp] = 0 |
---|
92 | | self.innames.append(tmp) |
---|
93 | | self.ingroups[tmp] = self.ingroups[tmp] + 1 |
---|
94 | | print self.ingroups |
---|
95 | | self.outnames = [] |
---|
96 | | self.outgroups = {} |
---|
97 | | for ch in self.destinations: |
---|
98 | | tmp = ch.split(":")[0] |
---|
99 | | if True: #tmp == "MixerIn": |
---|
100 | | if not tmp in self.outgroups: |
---|
101 | | self.outgroups[tmp] = 0 |
---|
102 | | self.outnames.append(tmp) |
---|
103 | | self.outgroups[tmp] = self.outgroups[tmp] + 1 |
---|
104 | | print self.outgroups |
---|
| 116 | self.outgroups = [] |
---|
| 117 | for ch in destinations: |
---|
| 118 | tmp = str(ch).split(":")[0] |
---|
| 119 | if not tmp in self.outgroups: |
---|
| 120 | self.outgroups.append(tmp) |
---|
109 | | for group in self.outgroups.keys(): |
---|
110 | | for i in range(self.outgroups[group]): |
---|
111 | | outname = "%s:%02i" % (group,i) |
---|
112 | | #print "Creating buttons for %s" % outname |
---|
113 | | btn = QtGui.QPushButton("%s" % outname, self) |
---|
114 | | outidx = self.destinations.index(outname) |
---|
115 | | self.layout.addWidget(btn, i, self.outnames.index(group)) |
---|
116 | | menu = QtGui.QMenu(self) |
---|
117 | | btn.setMenu(menu) |
---|
118 | | exclusiveGroup = QtGui.QActionGroup(btn) |
---|
119 | | for x in self.ingroups: |
---|
120 | | submenu = InGroupMenu(self.interface, outname, x, self.ingroups[x], self, exclusiveGroup) |
---|
121 | | menu.addMenu(submenu) |
---|
| 125 | for out in destinations: |
---|
| 126 | btn = OutputSwitcher(self.interface, out, self) |
---|
| 127 | self.layout.addWidget(btn, int(out.split(":")[-1]), self.outgroups.index(out.split(":")[0])) |
---|