SF.net SVN: fclient: [625] trunk/fclient/src/fclient/Ui_ViewConnection.py
Status: Pre-Alpha
Brought to you by:
jurner
From: <jU...@us...> - 2008-07-13 14:20:18
|
Revision: 625 http://fclient.svn.sourceforge.net/fclient/?rev=625&view=rev Author: jUrner Date: 2008-07-13 07:20:28 -0700 (Sun, 13 Jul 2008) Log Message: ----------- continued impl widget Modified Paths: -------------- trunk/fclient/src/fclient/Ui_ViewConnection.py Modified: trunk/fclient/src/fclient/Ui_ViewConnection.py =================================================================== --- trunk/fclient/src/fclient/Ui_ViewConnection.py 2008-07-13 14:20:18 UTC (rev 624) +++ trunk/fclient/src/fclient/Ui_ViewConnection.py 2008-07-13 14:20:28 UTC (rev 625) @@ -65,37 +65,80 @@ def __init__(self, parent, cfg=None): QtGui.QWidget.__init__(self, parent) + self._acts = [] self._isCreated = False self._connectionTimer = ConnectionTimer(self) + self._eventHandlers = ( + (config.fcpClient.events.ClientDisconnected, self.handleFcpClientDisconected), + ) + self._mainWindowMenus = () self.settings = Settings() self.setupUi(self) config.ObjectRegistry.register(self) + # atatch menus to main window if present. have to do it in __init__ to reserve order + menuBarWrap = config.ObjectRegistry.get(config.IdMainWindowMenuBarWrap, None) + if menuBarWrap is not None: + menu = QtGui.QMenu(self.viewDisplayName(), menuBarWrap.menuBar()) + for act in self.acts(): + menu.addAction(act) + self._mainWindowMenus = ( + menuBarWrap.addViewMenu(menu), + ) + ######################################### - ## + ## methods ######################################### + def close(self): + config.fcpClient.events -= self._eventHandlers + def controlById(self, idControl): return getattr(self, idControl) + def displayName(self): + return self.trUft8('Connection') + + def acts(self): + if not self._acts: + self._acts = ( + ) + return self._acts + ######################################### + ## view methods + ######################################### + def viewClose(self): + self.close() + + def viewDisplayName(self): + return self.trUtf8('Connection') + + def viewHandleCurrentChanged(self, isCurrent): + for menu in self._mainWindowMenus: + menu.children()[0].setVisible(isCurrent) + + def viewIcon(self): + return QtGui.QIcon() + + def viewName(self): + return self.objectName() + + ######################################### ## overwritten events ######################################### + def closeEvent(self, event): + self.close() + def showEvent(self, event): - QtGui.QWidget.showEvent(self, event) if self._isCreated: return self._isCreated = True self.settings.restore() + config.fcpClient.events += self._eventHandlers - #TODO: when on a tab closeEvent() is never called. how to disconnect on close? - # maybe fcp2.events should use weakrefs? - config.fcpClient.events += ( - (config.fcpClient.events.ClientDisconnected, self.handleFcpClientDisconected), - ) - # setup host / port boxes edHost = self.controlById(self.IdEdConnectionHost) edHost.setText(self.settings.value('ConnectionHost')) @@ -114,8 +157,11 @@ self.connect(bt, QtCore.SIGNAL('clicked(bool)'), self.handleBtConnectClicked) if doAutoConnect: self.controlById(self.IdBtConnect).click() - - ######################################### + + + + + ######################################## ## overwritten methods ######################################### def retranslateUi(self, w): @@ -154,40 +200,14 @@ #********************************************************************************** # #********************************************************************************** -class ViewConnection(Ui_View.View): - - def __init__(self): - self._widget = None - - def displayName(self): - return QtGui.QApplication.translate("ViewConnectionWidget", "Connection", None, QtGui.QApplication.UnicodeUTF8) - - def icon(self): - return QtGui.QIcon() - - def objectName(self): - return 'ViewConnection' - - def widget(self, parent): - if self._widget is None: - self._widget = ViewConnectionWidget(parent) - return self._widget - - def close(self): - pass - -#********************************************************************************** -# -#********************************************************************************** if __name__ == '__main__': import sys from . import Ui_ViewLogger app = QtGui.QApplication(sys.argv) - w = Ui_View.ViewWidget(None) - w.addViews(True, ViewConnection()) - w.addViews(False, Ui_ViewLogger.ViewLogger()) + w.addTopViews(ViewConnectionWidget(None)) + w.addBottomViews(Ui_ViewLogger.ViewLoggerWidget(None)) w.show() res = app.exec_() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |