root/trunk/libffado/support/mixer-qt4/mixer_global.py

Revision 1435, 4.6 kB (checked in by arnonym, 12 years ago)

forward port the mixer-changes from 2.0-branch r1361:HEAD

Line 
1 #
2 # Copyright (C) 2008 by Arnold Krille
3 #
4 # This file is part of FFADO
5 # FFADO = Free Firewire (pro-)audio drivers for linux
6 #
7 # FFADO is based upon FreeBoB.
8 #
9 # This program is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 2 of the License, or
12 # (at your option) version 3 of the License.
13 #
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
21 #
22
23 from PyQt4.QtCore import QObject, pyqtSignature
24 from PyQt4.QtGui import QWidget, QMessageBox
25 from mixer_globalui import Ui_GlobalMixerUi
26
27 import logging
28 log = logging.getLogger('global')
29
30 class GlobalMixer( QWidget, Ui_GlobalMixerUi ):
31     def __init__( self, parent, name=None ):
32         QWidget.__init__( self, parent )
33         self.setupUi(self)
34         self.setName(name)
35
36     def setName(self,name):
37         if name is not None:
38             self.lblName.setText(name)
39             self.lblName.show()
40         else:
41             self.lblName.hide()
42
43     @pyqtSignature("int")
44     def on_clocksource_activated( self, clock ):
45         #log.debug("updateClockSource( " + str(clock) + " )")
46         if self.clockselect.canChangeValue():
47             self.clockselect.select( clock )
48         else:
49             msg = QMessageBox()
50             msg.question( msg, "Error", \
51                 "<qt>Clock source change not permitted. Is streaming active?</qt>", \
52                 QMessageBox.Ok )
53             self.clocksource.setEnabled(False)
54             return
55
56         selected = self.clockselect.selected()
57         if selected != clock:
58             clockname = self.clockselect.getEnumLabel( clock )
59             msg = QMessageBox()
60             msg.question( msg, "Failed to select clock source", \
61                 "<qt>Could not select %s as clock source.</qt>" % clockname, \
62                 QMessageBox.Ok )
63             self.clocksource.setCurrentIndex( selected )
64
65     @pyqtSignature("int")
66     def on_samplerate_activated( self, sr ):
67         log.debug("on_samplerate_activated( " + str(sr) + " )")
68         if self.samplerateselect.canChangeValue():
69             self.samplerateselect.select( sr )
70         else:
71             msg = QMessageBox()
72             msg.question( msg, "Error", \
73                 "<qt>Sample rate change not permitted. Is streaming active?</qt>", \
74                 QMessageBox.Ok )
75             self.samplerate.setEnabled(False)
76             return
77
78         selected = self.samplerateselect.selected()
79         if selected != sr:
80             srname = self.samplerateselect.getEnumLabel( sr )
81             msg = QMessageBox()
82             msg.question( msg, "Failed to select sample rate", \
83                 "<qt>Could not select %s as samplerate.</qt>" % srname, \
84                 QMessageBox.Ok )
85             self.samplerate.setCurrentIndex( selected )
86
87     @pyqtSignature("QString")
88     def on_nickname_activated( self, name ):
89         #log.debug("on_nickname_activated( %s )" % name)
90         if self.nickname.canChangeValue():
91             asciiData = name.toAscii()
92             self.nickname.setText( asciiData.data() )
93         else:
94             self.txtNickname.setText( self.nickname.text() )
95
96     def initValues( self ):
97         #print "GlobalMixer::initValues()"
98         nb_clocks = self.clockselect.count()
99         for i in range( nb_clocks ):
100             self.clocksource.insertItem( nb_clocks, self.clockselect.getEnumLabel( i ) )
101         self.clocksource.setCurrentIndex( self.clockselect.selected() )
102
103         nb_rates = self.samplerateselect.count()
104         for i in range( nb_rates ):
105             self.samplerate.insertItem( nb_rates, self.samplerateselect.getEnumLabel( i ) )
106         self.samplerate.setCurrentIndex( self.samplerateselect.selected() )
107
108         self.txtNickname.setText( self.nickname.text() )
109
110         self.samplerate.setEnabled(self.samplerateselect.canChangeValue())
111         self.clocksource.setEnabled(self.clockselect.canChangeValue())
112         if self.nickname.canChangeValue():
113             self.txtNickname.setEnabled(True)
114         else:
115             self.txtNickname.setEnabled(False)
116
117     def polledUpdate(self):
118         self.samplerate.setEnabled(self.samplerateselect.canChangeValue())
119         self.clocksource.setEnabled(self.clockselect.canChangeValue())
120         self.txtNickname.setEnabled(self.nickname.canChangeValue())
Note: See TracBrowser for help on using the browser.