root/trunk/libffado/support/mixer-qt4/ffado-mixer.in

Revision 1707, 7.1 kB (checked in by arnonym, 14 years ago)

Use QSettings to store the state of the VU-switch.

And do some playing with deleting panels when the devices are removed from the bus. Otherwise the timer checking the VU-values will run forever and complain about missing dbus-objects.

  • Property svn:executable set to *
Line 
1 #!/usr/bin/python
2 #
3 # Copyright (C) 2005-2008 by Pieter Palmers
4 #               2007-2008 by Arnold Krille
5 #
6 # This file is part of FFADO
7 # FFADO = Free Firewire (pro-)audio drivers for linux
8 #
9 # FFADO is based upon FreeBoB.
10 #
11 # This program is free software: you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation, either version 3 of the License, or
14 # (at your option) any later version.
15 #
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
23 #
24
25 #
26 # QT 4 version
27 #
28
29 import sys, os
30
31 # Add the path of the installed ffado-modules
32 # for path in sys.path:
33 sys.path.append( "$PYPKGDIR" )
34
35 from ffado.config import * #POLL_SLEEP_TIME_MSEC, FFADO_DBUS_SERVER, FFADO_DBUS_BASEPATH
36
37 import os
38 import time
39
40 from PyQt4.QtCore import SIGNAL, SLOT, QObject, QTimer, Qt
41 from PyQt4.QtGui import * #QApplication, QMessageBox, QIcon
42
43 from ffado.dbus_util import *
44
45 from ffado.panelmanager import PanelManager
46
47 from ffado.logginghandler import *
48
49 """Just a small helper to ask the retry-question without a blocking messagebox"""
50 class StartDialog(QWidget):
51     def __init__(self, parent):
52         QWidget.__init__(self, parent)
53         self.setObjectName("Restart Dialog")
54         self.label = QLabel("Somehow the connection to the dbus-service of FFADO couldn't be established.\nShall we take another try?",self)
55         self.button = QPushButton("Retry", self)
56         self.layout = QGridLayout(self)
57         self.layout.addWidget(self.label, 0, 0, Qt.AlignCenter)
58         self.layout.addWidget(self.button, 1, 0, Qt.AlignCenter)
59
60 class FFADOWindow(QMainWindow):
61     def __init__(self, parent):
62         QMainWindow.__init__(self, parent)
63
64         self.textlogger = QTextLogger(self)
65         dock = QDockWidget("Log Messages",self)
66         dock.setWidget(self.textlogger.textedit)
67         logging.getLogger('').addHandler(self.textlogger)
68         self.addDockWidget(Qt.BottomDockWidgetArea, dock)
69
70         self.statuslogger = QStatusLogger(self, self.statusBar(), 20)
71         logging.getLogger('').addHandler(self.statuslogger)
72
73         self.manager = PanelManager(self)
74
75         filemenu = self.menuBar().addMenu("File")
76         quitaction = QAction("Quit", self)
77         quitaction.setShortcut(self.tr("Ctrl+q"))
78         self.connect(quitaction, SIGNAL("triggered()"), self, SLOT("close()"))
79         filemenu.addAction(quitaction)
80
81         editmenu = self.menuBar().addMenu("Edit")
82         self.updateaction = QAction("Update Mixer Panels", self)
83         self.updateaction.setEnabled(False)
84         self.connect(self.updateaction, SIGNAL("triggered()"), self.manager.updatePanels)
85         editmenu.addAction(self.updateaction)
86
87         helpmenu = self.menuBar().addMenu( "Help" )
88         aboutaction = QAction( "About FFADO", self )
89         self.connect( aboutaction, SIGNAL( "triggered()" ), self.aboutFFADO )
90         helpmenu.addAction( aboutaction )
91         aboutqtaction = QAction( "About Qt", self )
92         self.connect( aboutqtaction, SIGNAL( "triggered()" ), qApp, SLOT( "aboutQt()" ) )
93         helpmenu.addAction( aboutqtaction )
94
95         log.info( "Starting up" )
96
97         QTimer.singleShot( 1, self.connectToDBUS )
98
99     def __del__(self):
100         log.info("__del__")
101         del self.manager
102         #delattr(self, "manager")
103         log.info("__del__ finished")
104
105     def closeEvent(self, event):
106         log.info("closeEvent()")
107         self.manager.deleteLater()
108         event.accept()
109
110     def connectToDBUS(self):
111         try:
112             self.setupDeviceManager()
113         except dbus.DBusException, ex:
114             log.error("Could not communicate with the FFADO DBus service...")
115             if not hasattr(self,"retry"):
116                 self.retry = StartDialog(self)
117                 self.setCentralWidget(self.retry)
118                 self.connect(self.retry.button, SIGNAL("clicked()"), self.tryStartDBUSServer)
119             self.retry.setEnabled(True)
120
121     def tryStartDBUSServer(self):
122         try:
123             self.setupDeviceManager()
124         except dbus.DBusException, ex:
125             self.retry.setEnabled(False)
126             os.spawnlp( os.P_NOWAIT, "ffado-dbus-server" )
127             QTimer.singleShot(2000, self.connectToDBUS)
128
129     def setupDeviceManager(self):
130         devmgr = DeviceManagerInterface(FFADO_DBUS_SERVER, FFADO_DBUS_BASEPATH)
131         #nbDevices = devmgr.getNbDevices()
132         self.manager.setManager(devmgr)
133         self.setCentralWidget(self.manager)
134         self.updateaction.setEnabled(True)
135
136     def aboutFFADO(self):
137         QMessageBox.about( self, "About FFADO", """
138 <h1>ffado.org</h1>
139
140 <p>FFADO is the new approach to have firewire audio on linux.</p>
141
142 <p>&copy; 2006-2008 by the FFADO developers<br />ffado is licensed under the GPLv3, for the full license text see <a href="http://www.gnu.org/licenses/">www.gnu.org/licenses</a> or the LICENSE.* files shipped with ffado.</p>
143
144 <p>FFADO developers are:<ul>
145 <li>Pieter Palmers
146 <li>Daniel Wagner
147 <li>Jonathan Woithe
148 <li>Arnold Krille
149 </ul>
150 """ )
151
152
153 if __name__ == "__main__":
154     #set up logging
155     import logging
156     logging.basicConfig( datefmt="%H:%M:%S", format="%(asctime)s %(name)-16s %(levelname)-8s %(message)s" )
157
158     if DEBUG:
159         debug_level = logging.DEBUG
160     else:
161         debug_level = logging.INFO
162
163     # main loggers:
164     logging.getLogger('main').setLevel(debug_level)
165     logging.getLogger('dbus').setLevel(debug_level)
166     logging.getLogger('registration').setLevel(debug_level)
167     logging.getLogger('panelmanager').setLevel(debug_level)
168     logging.getLogger('configparser').setLevel(logging.INFO)
169
170     # widgets:
171     logging.getLogger('matrixmixer').setLevel(debug_level)
172     logging.getLogger('crossbarrouter').setLevel(debug_level)
173
174     # mixers:
175     logging.getLogger('audiofire').setLevel(debug_level)
176     logging.getLogger('bridgeco').setLevel(debug_level)
177     logging.getLogger('edirolfa101').setLevel(debug_level)
178     logging.getLogger('edirolfa66').setLevel(debug_level)
179     logging.getLogger('motu').setLevel(debug_level)
180     logging.getLogger('rme').setLevel(debug_level)
181     logging.getLogger('phase24').setLevel(debug_level)
182     logging.getLogger('phase88').setLevel(debug_level)
183     logging.getLogger('quatafire').setLevel(debug_level)
184     logging.getLogger('saffirebase').setLevel(debug_level)
185     logging.getLogger('saffire').setLevel(debug_level)
186     logging.getLogger('saffirepro').setLevel(debug_level)
187
188     logging.getLogger('global').setLevel(debug_level)
189
190     log = logging.getLogger('main')
191
192     app = QApplication(sys.argv)
193     app.setWindowIcon( QIcon( SHAREDIR + "/icons/hi64-apps-ffado.png" ) )
194
195     app.setOrganizationName("FFADO")
196     app.setOrganizationDomain("ffado.org")
197     app.setApplicationName("ffado-mixer")
198
199     mainwindow = FFADOWindow(None)
200
201
202     # rock & roll
203     mainwindow.show()
204     #QObject.connect(app,SIGNAL("lastWindowClosed()"),app,SLOT("quit()"))
205     app.exec_()
206
207 #
208 # vim: ts=4 sw=4 et
Note: See TracBrowser for help on using the browser.