SF.net SVN: fclient:[960] trunk/fclient/fclient/impl
Status: Pre-Alpha
Brought to you by:
jurner
From: <jU...@us...> - 2008-08-22 13:03:21
|
Revision: 960 http://fclient.svn.sourceforge.net/fclient/?rev=960&view=rev Author: jUrner Date: 2008-08-22 13:03:28 +0000 (Fri, 22 Aug 2008) Log Message: ----------- add a context menu to connection label on statusbar to easily connect/disconnect to the node Modified Paths: -------------- trunk/fclient/fclient/impl/MainWindow/StatusBar.py trunk/fclient/fclient/impl/ViewConnection/Actions.py trunk/fclient/fclient/impl/ViewConnection/ViewConnection.py Modified: trunk/fclient/fclient/impl/MainWindow/StatusBar.py =================================================================== --- trunk/fclient/fclient/impl/MainWindow/StatusBar.py 2008-08-22 13:01:31 UTC (rev 959) +++ trunk/fclient/fclient/impl/MainWindow/StatusBar.py 2008-08-22 13:03:28 UTC (rev 960) @@ -1,4 +1,9 @@ - +#*************************************************************************************************** +#TODO +# +# x. maybe move connection labels to ViewConnection +# +#*************************************************************************************************** # some fixes for relative imports # see --> [http://bugs.python.org/issue1510172] absolute/rellative import not working (works only current dir and below) # see --> [http://mail.python.org/pipermail/python-ideas/2007-February/000232.html] PEP for executing a module in a @@ -63,6 +68,9 @@ for objectName, label in self.connectionLabels.items(): label.setObjectName(objectName) label.setVisible(False) + label.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + self.connect(label, QtCore.SIGNAL('customContextMenuRequested( const QPoint &)'), self.onConnectionLabelConextMenuRequested) + self.addWidget(label, 0) if config.fcpClient.isConnected(): self.connectionLabels['LabelConnectionConnected'].show() @@ -77,6 +85,18 @@ self.connectionLabels['LabelConnectionDisonnectedOn'].setText(self.trUtf8('DISCONNECTED')) self.connectionLabels['LabelConnectionDisonnectedOff'].setText(self.trUtf8('DISCONNECTED')) + + def onConnectionLabelConextMenuRequested(self, pt): + label = self.sender() + pt = label.mapToGlobal(pt) + voConnection = config.ObjectRegistry.get(config.IdViewObjectConnection, None) + if voConnection is not None: + actions = voConnection.widget().fcActions + menu = QtGui.QMenu(self) + menu.addAction(actions['ActionConnect']) + menu.addAction(actions['ActionDisconnect']) + menu.exec_(pt) + def onFcpClientConnected(self, event, msg): self._disconnectTimer.stop() for label in self.connectionLabels.values(): @@ -88,3 +108,5 @@ label.hide() self.connectionLabels['LabelConnectionDisonnectedOn'].show() self._disconnectTimer.start(self.parent().fcSettings.value('ConnectionLabelFlashRate')) + + Modified: trunk/fclient/fclient/impl/ViewConnection/Actions.py =================================================================== --- trunk/fclient/fclient/impl/ViewConnection/Actions.py 2008-08-22 13:01:31 UTC (rev 959) +++ trunk/fclient/fclient/impl/ViewConnection/Actions.py 2008-08-22 13:03:28 UTC (rev 960) @@ -17,4 +17,35 @@ # #********************************************************************************** class Actions(config.ActionsBase): - pass + + def __init__(self, parent): + config.ActionsBase.__init__(self, parent) + + group = self.group( + name='GroupConnection', + isExclusive=True, + trigger=parent.onGroupConnection, + ) + self.action( + name='ActionConnect', + group=group, + isEnabled=True, + isCheckable=True, + isChecked=False, + ) + self.action( + name='ActionDisconnect', + group=group, + isEnabled=True, + isCheckable=True, + isChecked=True, + ) + + + def retranslateUi(self, parent): + self['ActionConnect'].setText(self.trUtf8('Connect')) + self['ActionDisconnect'].setText(self.trUtf8('Disconnect')) + + + + Modified: trunk/fclient/fclient/impl/ViewConnection/ViewConnection.py =================================================================== --- trunk/fclient/fclient/impl/ViewConnection/ViewConnection.py 2008-08-22 13:01:31 UTC (rev 959) +++ trunk/fclient/fclient/impl/ViewConnection/ViewConnection.py 2008-08-22 13:03:28 UTC (rev 960) @@ -86,6 +86,7 @@ def __init__(self, parent, idGlobalFeedback=config.IdViewObjectMainWindow): QtGui.QWidget.__init__(self, parent) + self.fcActions = Actions.Actions(self) self.setupUi(self) # adjust spin box ranges @@ -96,7 +97,6 @@ self._isCreated = False self.fcSettings = Settings.Settings(self).restore() - self.fcActions = Actions.Actions(self) self.fcGlobalFeedback = GlobalFeedback.GlobalFeedback(self,idGlobalFeedback) self._connectionTimer = ConnectionTimer(self) @@ -175,10 +175,11 @@ Ui_ViewConnectionWidget.retranslateUi(self, w) bt = self.controlById(self.IdBtConnect) bt.setText(self.trUtf8('Disconnect') if self.connected() else self.trUtf8('Connect')) + self.fcActions.retranslateUi(self) ######################################### - ## event onrs + ## event handlers ######################################### def onBtConnectClicked(self, isChecked): bt = self.controlById(self.IdBtConnect) @@ -192,8 +193,10 @@ if config.fcpClient.isConnected(): self._pollTimer.stop() config.fcpClient.close() - + def onGroupConnection(self, action): + self.setConnected(action == self.fcActions['ActionConnect']) + def onCkFcpAutoConnectStateChanged(self, state): self.fcSettings.setValues(FcpAutoConnect=state == QtCore.Qt.Checked) @@ -216,9 +219,12 @@ bt = self.controlById(self.IdBtConnect) if bt.isChecked(): bt.click() + self.fcActions['ActionDisconnect'].setChecked(True) + def onFcpClientConected(self, event, msg): self._pollTimer.start(self.fcSettings) + self.fcActions['ActionConnect'].setChecked(True) #********************************************************************************** # This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |