Changeset 1434
- Timestamp:
- 11/16/08 13:09:22 (15 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/libffado-2.0/support/mixer-qt4/ffado-mixer.in
r1415 r1434 37 37 import time 38 38 39 from PyQt4.QtCore import SIGNAL, SLOT, QObject, QTimer 40 from PyQt4.QtGui import QApplication, QMessageBox, QIcon39 from PyQt4.QtCore import SIGNAL, SLOT, QObject, QTimer, Qt 40 from PyQt4.QtGui import * #QApplication, QMessageBox, QIcon 41 41 42 42 from ffado_dbus_util import * 43 43 44 44 from ffado_panelmanager import PanelManager 45 46 """Just a small helper to ask the retry-question without a blocking messagebox""" 47 class StartDialog(QWidget): 48 def __init__(self, parent): 49 QWidget.__init__(self, parent) 50 self.setObjectName("Restart Dialog") 51 self.label = QLabel("Somehow the connection to the dbus-service of FFADO couldn't be established.\nShall we take another try?",self) 52 self.button = QPushButton("Retry", self) 53 self.layout = QGridLayout(self) 54 self.layout.addWidget(self.label, 0, 0, Qt.AlignCenter) 55 self.layout.addWidget(self.button, 1, 0, Qt.AlignCenter) 56 57 58 class FFADOWindow(QMainWindow): 59 def __init__(self, parent): 60 QMainWindow.__init__(self, parent) 61 62 self.manager = PanelManager(self) 63 64 filemenu = self.menuBar().addMenu("File") 65 quitaction = QAction("Quit", self) 66 quitaction.setShortcut(self.tr("Ctrl+q")) 67 self.connect(quitaction, SIGNAL("triggered()"), self, SLOT("close()")) 68 filemenu.addAction(quitaction) 69 70 editmenu = self.menuBar().addMenu("Edit") 71 self.updateaction = QAction("Update Mixer Panels", self) 72 self.updateaction.setEnabled(False) 73 self.connect(self.updateaction, SIGNAL("triggered()"), self.manager.updatePanels) 74 editmenu.addAction(self.updateaction) 75 self.resetaction = QAction("Trigger Bus Reset", self) 76 self.connect(self.resetaction, SIGNAL("triggered()"), self.manager.busreset) 77 editmenu.addAction(self.resetaction) 78 self.resetaction.setEnabled(False) 79 80 helpmenu = self.menuBar().addMenu( "Help" ) 81 aboutaction = QAction( "About FFADO", self ) 82 self.connect( aboutaction, SIGNAL( "triggered()" ), self.aboutFFADO ) 83 helpmenu.addAction( aboutaction ) 84 aboutqtaction = QAction( "About Qt", self ) 85 self.connect( aboutqtaction, SIGNAL( "triggered()" ), qApp, SLOT( "aboutQt()" ) ) 86 helpmenu.addAction( aboutqtaction ) 87 88 self.statusBar().showMessage( "Initializing...", 5000 ) 89 90 QTimer.singleShot( 1, self.connectToDBUS ) 91 92 def connectToDBUS(self): 93 try: 94 self.setupDeviceManager() 95 except dbus.DBusException, ex: 96 log.error("") 97 log.error("") 98 log.error("===========================================================") 99 log.error("ERROR: Could not communicate with the FFADO DBus service...") 100 log.error("===========================================================") 101 log.error("") 102 log.error("") 103 if not hasattr(self,"retry"): 104 self.retry = StartDialog(self) 105 self.setCentralWidget(self.retry) 106 self.connect(self.retry.button, SIGNAL("clicked()"), self.tryStartDBUSServer) 107 self.retry.setEnabled(True) 108 109 def tryStartDBUSServer(self): 110 try: 111 self.setupDeviceManager() 112 except dbus.DBusException, ex: 113 self.retry.setEnabled(False) 114 os.spawnlp( os.P_NOWAIT, "ffado-dbus-server" ) 115 QTimer.singleShot(2000, self.connectToDBUS) 116 117 def setupDeviceManager(self): 118 devmgr = DeviceManagerInterface(FFADO_DBUS_SERVER, FFADO_DBUS_BASEPATH) 119 nbDevices = devmgr.getNbDevices() 120 self.manager.setManager(devmgr) 121 self.setCentralWidget(self.manager) 122 self.updateaction.setEnabled(True) 123 self.resetaction.setEnabled(True) 124 125 def aboutFFADO(self): 126 QMessageBox.about( self, "About FFADO", """ 127 <h1>ffado.org</h1> 128 129 <p>FFADO is the new approach to have firewire audio on linux.</p> 130 131 <p>© 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> 132 133 <p>FFADO developers are:<ul> 134 <li>Pieter Palmers 135 <li>Daniel Wagner 136 <li>Jonathan Woithe 137 <li>Arnold Krille 138 </ul> 139 """ ) 140 45 141 46 142 if __name__ == "__main__": … … 78 174 app.setWindowIcon( QIcon( SHAREDIR + "/icons/hi64-apps-ffado.png" ) ) 79 175 80 msg = QMessageBox()81 176 82 repeat = 1 83 while repeat > 0: 84 try: 85 devmgr = DeviceManagerInterface(FFADO_DBUS_SERVER, FFADO_DBUS_BASEPATH) 86 nbDevices = devmgr.getNbDevices() 87 repeat -= 1 88 except dbus.DBusException, ex: 89 log.error("") 90 log.error("") 91 log.error("===========================================================") 92 log.error("ERROR: Could not communicate with the FFADO DBus service...") 93 log.error("===========================================================") 94 log.error("") 95 log.error("") 96 tmp = msg.question( msg, "FFADO-DBus not found", "<qt><b>The connection to FFADOs DBus service could not be established.</b><p>Probably you didn't start the ffado-dbus-server. Should I try this now?</qt>", QMessageBox.Yes, QMessageBox.No ) 97 if tmp == QMessageBox.No: 98 sys.exit(-1) 99 else: 100 os.spawnlp( os.P_NOWAIT, "ffado-dbus-server" ) 101 nb_checks = 20 102 while nb_checks > 0: 103 nb_checks = nb_checks - 1 104 try: 105 devmgr = DeviceManagerInterface(FFADO_DBUS_SERVER, FFADO_DBUS_BASEPATH) 106 nbDevices = devmgr.getNbDevices() 107 nb_checks = 0 108 repeat = 0 109 except dbus.DBusException, ex: 110 time.sleep( 1 ) 177 mainwindow = FFADOWindow(None) 111 178 112 manager = PanelManager(None, devmgr)113 114 # create a timer to poll the panels115 polltimer = QTimer()116 QObject.connect( polltimer, SIGNAL('timeout()'), manager.pollPanels )117 polltimer.start( POLL_SLEEP_TIME_MSEC )118 119 # create a timer to initialize the panel after the main form is shown120 # since initialization can take a while121 showtimer = QTimer()122 QObject.connect( showtimer, SIGNAL('timeout()'), manager.updatePanels )123 showtimer.setSingleShot(True)124 showtimer.start( POLL_SLEEP_TIME_MSEC )125 179 126 180 # rock & roll 127 ma nager.show()181 mainwindow.show() 128 182 QObject.connect(app,SIGNAL("lastWindowClosed()"),app,SLOT("quit()")) 129 183 app.exec_() 184 185 # 186 # vim: ts=4 sw=4 et branches/libffado-2.0/support/mixer-qt4/ffado_panelmanager.py
r1427 r1434 25 25 from ffadomixer_config import * #FFADO_VERSION, FFADO_DBUS_SERVER, FFADO_DBUS_BASEPATH 26 26 27 from PyQt4.QtGui import QFrame, QWidget, QTabWidget, QVBoxLayout, QMainWindow, QIcon, QAction, qApp 27 from PyQt4.QtGui import QFrame, QWidget, QTabWidget, QVBoxLayout, QMainWindow, QIcon, QAction, qApp, QStyleOptionTabWidgetFrame 28 28 from PyQt4.QtCore import QTimer 29 29 … … 79 79 self.setupUi(self) 80 80 81 class PanelManager(QMainWindow): 82 def __init__(self, parent, devmgr): 81 class OwnTabWidget(QTabWidget): 82 def __init__(self,parent): 83 QTabWidget.__init__(self,parent) 84 85 def tabInserted(self,index): 86 self.checkTabBar() 87 88 def tabRemoved(self,index): 89 self.checkTabBar() 90 91 def checkTabBar(self): 92 if self.count()<2: 93 self.tabBar().hide() 94 else: 95 self.tabBar().show() 96 97 class PanelManager(QWidget): 98 def __init__(self, parent, devmgr=None): 83 99 QMainWindow.__init__(self, parent) 100 self.setObjectName("PanelManager") 101 102 # maps a device GUID to a QT panel 103 self.panels = {} 104 105 # a layout for ourselves 106 self.layout = QVBoxLayout(self) 107 108 # the tabs 109 self.tabs = OwnTabWidget(self) 110 self.tabs.hide() 111 self.layout.addWidget(self.tabs) 112 113 # a dialog that is shown during update 114 self.status = PanelManagerStatus(self) 115 self.layout.addWidget(self.status) 116 self.status.show() 117 118 self.devices = DeviceList( SYSTEM_CONFIG_FILE ) 119 self.devices.updateFromFile( USER_CONFIG_FILE ) 120 121 if devmgr is not None: 122 self.setManager(devmgr) 123 124 def setManager(self,devmgr): 84 125 self.devmgr = devmgr 85 126 self.devmgr.registerPreUpdateCallback(self.devlistPreUpdate) … … 87 128 self.devmgr.registerUpdateCallback(self.devlistUpdate) 88 129 self.devmgr.registerDestroyedCallback(self.devmgrDestroyed) 89 90 filemenu = self.menuBar().addMenu( "File" ) 91 quitaction = QAction( "Quit", self ) 92 quitaction.setShortcut( self.tr("Ctrl+q") ) 93 self.connect( quitaction, SIGNAL( "triggered()" ), self, SLOT( "close()" ) ) 94 filemenu.addAction( quitaction ) 95 96 editmenu = self.menuBar().addMenu( "Edit" ) 97 updateaction = QAction( "Update Mixer Panels", self ) 98 self.connect( updateaction, SIGNAL( "triggered()" ), self.updatePanels ) 99 editmenu.addAction( updateaction ) 100 resetaction = QAction( "Trigger Bus Reset", self ) 101 self.connect( resetaction, SIGNAL( "triggered()" ), self.busreset ) 102 editmenu.addAction( resetaction ) 103 104 helpmenu = self.menuBar().addMenu( "Help" ) 105 aboutaction = QAction( "About FFADO", self ) 106 self.connect( aboutaction, SIGNAL( "triggered()" ), self.aboutFFADO ) 107 helpmenu.addAction( aboutaction ) 108 aboutqtaction = QAction( "About Qt", self ) 109 self.connect( aboutqtaction, SIGNAL( "triggered()" ), qApp, SLOT( "aboutQt()" ) ) 110 helpmenu.addAction( aboutqtaction ) 111 112 self.statusBar().showMessage( "Initializing...", 5000 ) 113 114 # maps a device GUID to a QT panel 115 self.panels = {} 116 117 # a layout for ourselves 118 mw = QWidget( self ) 119 self.layout = QVBoxLayout( mw ) 120 self.setCentralWidget( mw ) 121 122 # the tabs 123 self.tabs = QTabWidget(mw) 124 self.tabs.hide() 125 self.layout.addWidget(self.tabs) 126 127 # a dialog that is shown during update 128 self.status = PanelManagerStatus(mw) 129 self.status.lblMessage.setText("Initializing...") 130 self.layout.addWidget(self.status) 131 self.status.show() 130 # create a timer to poll the panels 131 self.polltimer = QTimer() 132 self.connect( self.polltimer, SIGNAL('timeout()'), self.pollPanels ) 133 self.polltimer.start( POLL_SLEEP_TIME_MSEC ) 134 135 # create a timer to initialize the panel after the main form is shown 136 # since initialization can take a while 137 QTimer.singleShot( POLL_SLEEP_TIME_MSEC, self.updatePanels ) 132 138 133 139 # live check timer … … 135 141 QObject.connect( self.alivetimer, SIGNAL('timeout()'), self.commCheck ) 136 142 self.alivetimer.start( 2000 ) 137 138 self.devices = DeviceList( SYSTEM_CONFIG_FILE )139 self.devices.updateFromFile( USER_CONFIG_FILE )140 143 141 144 def count(self): … … 163 166 self.status.lblMessage.setText("Bus reconfiguration in progress, please wait...") 164 167 self.status.show() 165 self.statusBar().showMessage("bus reconfiguration in progress...", 5000)168 #self.statusBar().showMessage("bus reconfiguration in progress...", 5000) 166 169 167 170 def devlistPostUpdate(self): … … 217 220 log.debug("PanelManager::updatePanels()") 218 221 nbDevices = self.devmgr.getNbDevices() 219 self.statusBar().showMessage("Reconfiguring the mixer panels...")222 #self.statusBar().showMessage("Reconfiguring the mixer panels...") 220 223 221 224 # list of panels present … … 300 303 # Generic elements for all mixers follow here: 301 304 # 302 tmp= GlobalMixer( w )303 tmp.configrom = cfgrom304 tmp.clockselect = clockselect305 tmp.samplerateselect = samplerateselect306 tmp.nickname = nickname307 tmp.hw = hw308 tmp.initValues()309 l.addWidget( tmp, 1 )305 globalmixer = GlobalMixer( w ) 306 globalmixer.configrom = cfgrom 307 globalmixer.clockselect = clockselect 308 globalmixer.samplerateselect = samplerateselect 309 globalmixer.nickname = nickname 310 globalmixer.hw = hw 311 globalmixer.initValues() 312 l.addWidget( globalmixer, 1 ) 310 313 311 314 # … … 342 345 title = mixerapp 343 346 347 globalmixer.setName(title) 344 348 self.tabs.addTab( w, title ) 345 349 self.panels[guid] = w … … 352 356 self.status.lblMessage.setText("No supported device found.") 353 357 self.status.show() 354 self.statusBar().showMessage("No supported device found.", 5000)358 #self.statusBar().showMessage("No supported device found.", 5000) 355 359 else: 356 360 self.tabs.show() 357 361 self.tabs.setEnabled(True) 358 362 self.status.hide() 359 self.statusBar().showMessage("Configured the mixer for %i devices." % self.tabs.count())363 #self.statusBar().showMessage("Configured the mixer for %i devices." % self.tabs.count()) 360 364 if use_generic: 361 365 # … … 369 373 QMessageBox.information( self, "Not supported", "Triggering bus resets from the mixer (via dbus) isn't yet supported." ) 370 374 371 def aboutFFADO(self): 372 QMessageBox.about( self, "About FFADO", """ 373 <h1>ffado.org</h1> 374 375 <p>FFADO is the new approach to have firewire audio on linux.</p> 376 377 <p>© 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> 378 379 <p>FFADO developers are:<ul> 380 <li>Pieter Palmers 381 <li>Daniel Wagner 382 <li>Jonathan Woithe 383 <li>Arnold Krille 384 </ul> 385 """ ) 375 # vim: et