root/trunk/libffado/support/mixer-qt4/ffado/ffadowindow.py

Revision 2110, 7.4 kB (checked in by jwoithe, 9 years ago)

Patch from Philippe Carriere. refreshPanels is the 'orthogonal' function to updatePanels; it permits the reconfiguration and redrawing of the current mixer panels under user request. This may be useful when some hardware settings have been changed that ffado-mixer is unaware of but which can affect the options offered by the mixer.

  • Property svn:executable set to *
Line 
1 #!/usr/bin/python
2 #
3 # Copyright (C) 2005-2008 by Pieter Palmers
4 #               2007-2009 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 import os
26
27 from ffado.config import *
28
29 import subprocess
30
31 from PyQt4.QtCore import SIGNAL, SLOT, QObject, QTimer, Qt
32 from PyQt4.QtGui import *
33
34 from ffado.dbus_util import *
35
36 from ffado.panelmanager import PanelManager
37
38 from ffado.logginghandler import *
39
40 """Just a small helper to ask the retry-question without a blocking messagebox"""
41 class StartDialog(QWidget):
42     def __init__(self, parent):
43         QWidget.__init__(self, parent)
44         self.setObjectName("Restart Dialog")
45         self.label = QLabel("<qt>Somehow the connection to the dbus-service of FFADO couldn't be established.<p>\nShall we take another try?</qt>",self)
46         self.button = QPushButton("Retry", self)
47         self.layout = QGridLayout(self)
48         self.layout.setContentsMargins( 50, 10, 50, 10 )
49         self.layout.addWidget(self.label, 0, 0, Qt.AlignHCenter|Qt.AlignBottom)
50         self.layout.addWidget(self.button, 1, 0, Qt.AlignHCenter|Qt.AlignTop)
51
52 class FFADOWindow(QMainWindow):
53     def __init__(self, parent):
54         QMainWindow.__init__(self, parent)
55
56         self.textlogger = QTextLogger(self)
57         dock = QDockWidget("Log Messages",self)
58         dock.setWidget(self.textlogger.textedit)
59         logging.getLogger('').addHandler(self.textlogger)
60         self.addDockWidget(Qt.BottomDockWidgetArea, dock)
61
62         self.statuslogger = QStatusLogger(self, self.statusBar(), 20)
63         logging.getLogger('').addHandler(self.statuslogger)
64
65         self.manager = PanelManager(self)
66         self.connect(self.manager, SIGNAL("connectionLost"), self.connectToDBUS)
67
68         filemenu = self.menuBar().addMenu("File")
69         quitaction = QAction("Quit", self)
70         quitaction.setShortcut(self.tr("Ctrl+q"))
71         self.connect(quitaction, SIGNAL("triggered()"), self, SLOT("close()"))
72         filemenu.addAction(quitaction)
73
74         editmenu = self.menuBar().addMenu("Edit")
75         self.updateaction = QAction("Update Mixer Panels", self)
76         self.updateaction.setEnabled(False)
77         self.connect(self.updateaction, SIGNAL("triggered()"), self.manager.updatePanels)
78         editmenu.addAction(self.updateaction)
79         refreshaction = QAction("Refresh Current Panels", self)
80         self.connect(refreshaction, SIGNAL("triggered()"), self.manager.refreshPanels)
81         editmenu.addAction(refreshaction)
82
83         helpmenu = self.menuBar().addMenu( "Help" )
84         aboutaction = QAction( "About FFADO", self )
85         self.connect( aboutaction, SIGNAL( "triggered()" ), self.aboutFFADO )
86         helpmenu.addAction( aboutaction )
87         aboutqtaction = QAction( "About Qt", self )
88         self.connect( aboutqtaction, SIGNAL( "triggered()" ), qApp, SLOT( "aboutQt()" ) )
89         helpmenu.addAction( aboutqtaction )
90
91         log.info( "Starting up" )
92
93         QTimer.singleShot( 1, self.tryStartDBUSServer )
94
95     def __del__(self):
96         log.info("__del__")
97         del self.manager
98         log.info("__del__ finished")
99
100     def closeEvent(self, event):
101         log.info("closeEvent()")
102         event.accept()
103
104     def connectToDBUS(self):
105         log.info("connectToDBUS")
106         try:
107             self.setupDeviceManager()
108         except dbus.DBusException, ex:
109             log.error("Could not communicate with the FFADO DBus service...")
110             if not hasattr(self,"retry"):
111                 self.retry = StartDialog(self)
112                 self.connect(self.retry.button, SIGNAL("clicked()"), self.tryStartDBUSServer)
113             if hasattr(self, "retry"):
114                 self.manager.setParent(None)
115                 self.setCentralWidget(self.retry)
116                 self.retry.setEnabled(True)
117
118     def tryStartDBUSServer(self):
119         try:
120             self.setupDeviceManager()
121         except dbus.DBusException, ex:
122             if hasattr(self, "retry"):
123                 self.retry.setEnabled(False)
124             subprocess.Popen(['ffado-dbus-server', '-v3']).pid
125             QTimer.singleShot(5000, self.connectToDBUS)
126
127     def setupDeviceManager(self):
128         devmgr = DeviceManagerInterface(FFADO_DBUS_SERVER, FFADO_DBUS_BASEPATH)
129         self.manager.setManager(devmgr)
130         if hasattr(self, "retry"):
131             self.retry.setParent(None)
132         self.setCentralWidget(self.manager)
133         self.updateaction.setEnabled(True)
134
135     def aboutFFADO(self):
136         QMessageBox.about( self, "About FFADO", """
137 <h1>ffado.org</h1>
138
139 <p>FFADO is the new approach to have firewire audio on linux.</p>
140
141 <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>
142
143 <p>FFADO developers are:<ul>
144 <li>Pieter Palmers
145 <li>Daniel Wagner
146 <li>Jonathan Woithe
147 <li>Arnold Krille
148 </ul>
149 """ )
150
151
152 def ffadomain(args):
153     #set up logging
154     import logging
155     logging.basicConfig( datefmt="%H:%M:%S", format="%(asctime)s %(name)-16s %(levelname)-8s %(message)s" )
156
157     if DEBUG:
158         debug_level = logging.DEBUG
159     else:
160         debug_level = logging.INFO
161
162     # main loggers:
163     logging.getLogger('main').setLevel(debug_level)
164     logging.getLogger('dbus').setLevel(debug_level)
165     logging.getLogger('registration').setLevel(debug_level)
166     logging.getLogger('panelmanager').setLevel(debug_level)
167     logging.getLogger('configparser').setLevel(logging.INFO)
168
169     # widgets:
170     logging.getLogger('matrixmixer').setLevel(debug_level)
171     logging.getLogger('crossbarrouter').setLevel(debug_level)
172
173     # mixers:
174     logging.getLogger('audiofire').setLevel(debug_level)
175     logging.getLogger('bridgeco').setLevel(debug_level)
176     logging.getLogger('edirolfa101').setLevel(debug_level)
177     logging.getLogger('edirolfa66').setLevel(debug_level)
178     logging.getLogger('motu').setLevel(debug_level)
179     logging.getLogger('rme').setLevel(debug_level)
180     logging.getLogger('phase24').setLevel(debug_level)
181     logging.getLogger('phase88').setLevel(debug_level)
182     logging.getLogger('quatafire').setLevel(debug_level)
183     logging.getLogger('saffirebase').setLevel(debug_level)
184     logging.getLogger('saffire').setLevel(debug_level)
185     logging.getLogger('saffirepro').setLevel(debug_level)
186
187     logging.getLogger('global').setLevel(debug_level)
188
189     log = logging.getLogger('main')
190
191     app = QApplication(args)
192     app.setWindowIcon( QIcon( SHAREDIR + "/icons/hi64-apps-ffado.png" ) )
193
194     app.setOrganizationName("FFADO")
195     app.setOrganizationDomain("ffado.org")
196     app.setApplicationName("ffado-mixer")
197
198     mainwindow = FFADOWindow(None)
199
200
201     # rock & roll
202     mainwindow.show()
203     return app.exec_()
204
205 if __name__ == "__main__":
206     import sys
207     sys.exit(ffadomain(sys.argv))
208
209 #
210 # vim: ts=4 sw=4 et
Note: See TracBrowser for help on using the browser.