Thread: SF.net SVN: fclient: [546] trunk/fclient/src/fclient/Ui_ViewConnection.py
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <jU...@us...> - 2008-07-08 10:47:40
|
Revision: 546
http://fclient.svn.sourceforge.net/fclient/?rev=546&view=rev
Author: jUrner
Date: 2008-07-08 03:47:10 -0700 (Tue, 08 Jul 2008)
Log Message:
-----------
starterd implementing connection interface
Added Paths:
-----------
trunk/fclient/src/fclient/Ui_ViewConnection.py
Added: trunk/fclient/src/fclient/Ui_ViewConnection.py
===================================================================
--- trunk/fclient/src/fclient/Ui_ViewConnection.py (rev 0)
+++ trunk/fclient/src/fclient/Ui_ViewConnection.py 2008-07-08 10:47:10 UTC (rev 546)
@@ -0,0 +1,117 @@
+from __future__ import absolute_import
+if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below
+ import os; __path__ = [os.path.dirname(__file__)]
+
+
+from PyQt4 import QtCore, QtGui
+
+
+from . import config
+from .lib import fcp2
+from .lib.qt4ex import settingsbase
+from .tpls.Ui_ViewConnectionTpl import Ui_ViewConnectionTpl
+
+#**********************************************************************************
+#
+#**********************************************************************************
+class UserSettings(settingsbase.SettingsBase):
+
+ KEY_SETTINGS = 'UserSettingsConnection'
+ SETTINGS = [
+ ('AutoConnect', ['toBool', False]),
+ ('ConnectionHost', ['toString', fcp2.Client.DefaultFcpHost]),
+ ('ConnectionPort', ['toUInt', fcp2.Client.DefaultFcpPort]),
+ ]
+
+#***********************************************************************
+#
+#***********************************************************************
+class ViewWidgetConnection(QtGui.QWidget, Ui_ViewConnectionTpl):
+
+ IdBtConnect = 'btConnect'
+ IdEdConnectionHost = 'edConnectionHost'
+ IdSpinConnectionPort = 'spinConnectionPort'
+
+
+
+ def __init__(self, parent, cfg=None):
+ QtGui.QWidget.__init__(self, parent)
+
+ self._isCreated = False
+
+
+ self.cfg = config.Config(self) if cfg is None else cfg
+ self.userSettings = UserSettings()
+
+ self.setupUi(self)
+
+
+ def showEvent(self, event):
+ QtGui.QWidget.showEvent(self, event)
+ if self._isCreated:
+ return
+
+ self._isCreated = True
+ self.connect(
+ self.controlById(self.IdBtConnect),
+ QtCore.SIGNAL('clicked(bool)'),
+ self.onBtConnectClicked
+ )
+
+ # setup host / port boxes
+ edHost = self.controlById(self.IdEdConnectionHost)
+ edHost.setText(self.userSettings['ConnectionHost'])
+
+ spinPort = self.controlById(self.IdSpinConnectionPort)
+ #TODO: no idea if port range (0, 0xFFFF) this is reasonable
+ spinPort.setRange(0, 0xFFFF)
+ spinPort.setValue(self.userSettings['ConnectionPort'])
+
+
+ # autoconnect if desired
+ self.cfg.settings.readSettings(self, self.userSettings)
+ if self.userSettings['AutoConnect']:
+ self.controlById(self.IdBtConnect).setChecked(True)
+ self.onBtConnectClicked(True)
+
+
+
+
+ def controlById(self, idControl):
+ return getattr(self, idControl)
+
+
+ def retranslateUi(self, w):
+ Ui_ViewConnectionTpl.retranslateUi(self, w)
+ bt = self.controlById(self.IdBtConnect)
+ if bt.isChecked():
+ bt.setText()
+
+
+ #########################################
+ ##
+ #########################################
+ def onBtConnectClicked(self, checked):
+ bt = self.controlById(self.IdBtConnect)
+ if checked:
+ bt.setText(QtGui.QApplication.translate("ViewWidgetConnection", "Disconnect", None, QtGui.QApplication.UnicodeUTF8))
+ else:
+ bt.setText(QtGui.QApplication.translate("ViewWidgetConnection", "Connect", None, QtGui.QApplication.UnicodeUTF8))
+
+
+
+
+#**********************************************************************************
+#
+#**********************************************************************************
+if __name__ == '__main__':
+ import sys
+
+ app = QtGui.QApplication(sys.argv)
+ w = ViewWidgetConnection(None)
+ w.show()
+ res = app.exec_()
+ sys.exit(res)
+
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-07-08 15:43:50
|
Revision: 556
http://fclient.svn.sourceforge.net/fclient/?rev=556&view=rev
Author: jUrner
Date: 2008-07-08 08:43:13 -0700 (Tue, 08 Jul 2008)
Log Message:
-----------
...
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-08 15:42:31 UTC (rev 555)
+++ trunk/fclient/src/fclient/Ui_ViewConnection.py 2008-07-08 15:43:13 UTC (rev 556)
@@ -9,7 +9,7 @@
from . import config
from .lib import fcp2
from .lib.qt4ex import settingsbase
-from .tpls.Ui_ViewConnectionTpl import Ui_ViewConnectionTpl
+from .tpls.Ui_ViewConnectionWidgetTpl import Ui_ViewConnectionWidget
#**********************************************************************************
#
@@ -26,8 +26,11 @@
#***********************************************************************
#
#***********************************************************************
-class ViewWidgetConnection(QtGui.QWidget, Ui_ViewConnectionTpl):
+class ViewConnectionWidget(QtGui.QWidget, Ui_ViewConnectionWidget):
+ UUID = '{2339cfb0-5e84-44eb-9c8d-00965b5bb460}'
+
+
IdBtConnect = 'btConnect'
IdEdConnectionHost = 'edConnectionHost'
IdSpinConnectionPort = 'spinConnectionPort'
@@ -82,7 +85,7 @@
def retranslateUi(self, w):
- Ui_ViewConnectionTpl.retranslateUi(self, w)
+ Ui_ViewConnectionWidget.retranslateUi(self, w)
bt = self.controlById(self.IdBtConnect)
if bt.isChecked():
bt.setText()
@@ -94,9 +97,9 @@
def onBtConnectClicked(self, checked):
bt = self.controlById(self.IdBtConnect)
if checked:
- bt.setText(QtGui.QApplication.translate("ViewWidgetConnection", "Disconnect", None, QtGui.QApplication.UnicodeUTF8))
+ bt.setText(QtGui.QApplication.translate("ViewConnectionWidget", "Disconnect", None, QtGui.QApplication.UnicodeUTF8))
else:
- bt.setText(QtGui.QApplication.translate("ViewWidgetConnection", "Connect", None, QtGui.QApplication.UnicodeUTF8))
+ bt.setText(QtGui.QApplication.translate("ViewConnectionWidget", "Connect", None, QtGui.QApplication.UnicodeUTF8))
@@ -108,7 +111,7 @@
import sys
app = QtGui.QApplication(sys.argv)
- w = ViewWidgetConnection(None)
+ w = ViewConnectionWidget(None)
w.show()
res = app.exec_()
sys.exit(res)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-07-09 08:38:57
|
Revision: 570
http://fclient.svn.sourceforge.net/fclient/?rev=570&view=rev
Author: jUrner
Date: 2008-07-09 01:39:05 -0700 (Wed, 09 Jul 2008)
Log Message:
-----------
dump settings on close
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-09 08:38:38 UTC (rev 569)
+++ trunk/fclient/src/fclient/Ui_ViewConnection.py 2008-07-09 08:39:05 UTC (rev 570)
@@ -89,14 +89,10 @@
bt.setText()
#########################################
- ## view methods
+ ## events
#########################################
- def displayName(self):
- return QtGui.QApplication.translate("ViewConnectionWidget", "Connection", None, QtGui.QApplication.UnicodeUTF8)
-
-
- def icon(self):
- return QtGui.QIcon()
+ def closeEvent(self, event):
+ self.cfg.settings.dumpSettings(self, self.userSettings)
#########################################
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-07-11 16:33:20
|
Revision: 574
http://fclient.svn.sourceforge.net/fclient/?rev=574&view=rev
Author: jUrner
Date: 2008-07-11 09:33:29 -0700 (Fri, 11 Jul 2008)
Log Message:
-----------
too many changes to list
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-11 16:33:24 UTC (rev 573)
+++ trunk/fclient/src/fclient/Ui_ViewConnection.py 2008-07-11 16:33:29 UTC (rev 574)
@@ -10,20 +10,18 @@
from . import Ui_View
from .lib import fcp2
-from .lib.qt4ex import settingsbase
-
from .tpls.Ui_ViewConnectionWidgetTpl import Ui_ViewConnectionWidget
#**********************************************************************************
#
#**********************************************************************************
-class UserSettings(settingsbase.SettingsBase):
-
- KEY_SETTINGS = 'UserSettingsConnection'
- SETTINGS = [
- ('AutoConnect', ['toBool', False]),
- ('ConnectionHost', ['toString', fcp2.Client.DefaultFcpHost]),
- ('ConnectionPort', ['toUInt', fcp2.Client.DefaultFcpPort]),
- ]
+class Settings(config.SettingsBase):
+ _key_ = config.IdViewConnectionWidget
+ _settings_ = (
+ ('AutoConnect', 'Bool', False),
+ ('ConnectionHost', 'String', fcp2.Client.DefaultFcpHost),
+ ('ConnectionName', 'String', ''), #TODO: we need a python ansi string
+ ('ConnectionPort', 'UInt', fcp2.Client.DefaultFcpPort),
+ )
#***********************************************************************
#
@@ -39,16 +37,27 @@
QtGui.QWidget.__init__(self, parent)
self._isCreated = False
+ self.settings = Settings()
-
- self.cfg = config.Config(self) if cfg is None else cfg
- self.userSettings = UserSettings()
-
-
self.setupUi(self)
+
+ self.settings.restore()
config.ObjectRegistry.register(self)
+ def controlById(self, idControl):
+ return getattr(self, idControl)
+
+
+ def retranslateUi(self, w):
+ Ui_ViewConnectionWidget.retranslateUi(self, w)
+ bt = self.controlById(self.IdBtConnect)
+ if bt.isChecked():
+ bt.setText()
+
+ #########################################
+ ## events
+ #########################################
def showEvent(self, event):
QtGui.QWidget.showEvent(self, event)
if self._isCreated:
@@ -63,39 +72,24 @@
# setup host / port boxes
edHost = self.controlById(self.IdEdConnectionHost)
- edHost.setText(self.userSettings['ConnectionHost'])
+ edHost.setText(self.settings.value('ConnectionHost'))
spinPort = self.controlById(self.IdSpinConnectionPort)
#TODO: no idea if port range (0, 0xFFFF) this is reasonable
spinPort.setRange(0, 0xFFFF)
- spinPort.setValue(self.userSettings['ConnectionPort'])
+ spinPort.setValue(self.settings.value('ConnectionPort'))
# autoconnect if desired
- self.cfg.settings.readSettings(self, self.userSettings)
- if self.userSettings['AutoConnect']:
+ self.settings.restore()
+ if self.settings.value('AutoConnect'):
self.controlById(self.IdBtConnect).setChecked(True)
self.onBtConnectClicked(True)
+ #XXX
+ self.settings.setValues(ConnectionName='abc')
- def controlById(self, idControl):
- return getattr(self, idControl)
-
-
- def retranslateUi(self, w):
- Ui_ViewConnectionWidget.retranslateUi(self, w)
- bt = self.controlById(self.IdBtConnect)
- if bt.isChecked():
- bt.setText()
-
#########################################
- ## events
- #########################################
- def closeEvent(self, event):
- self.cfg.settings.dumpSettings(self, self.userSettings)
-
-
- #########################################
##
#########################################
def onBtConnectClicked(self, checked):
@@ -113,7 +107,7 @@
def __init__(self):
self._widget = None
-
+
def displayName(self):
return QtGui.QApplication.translate("ViewConnectionWidget", "Connection", None, QtGui.QApplication.UnicodeUTF8)
@@ -129,17 +123,18 @@
self._widget = ViewConnectionWidget(parent)
return self._widget
-
+ def close(self):
+ pass
+
#**********************************************************************************
#
#**********************************************************************************
if __name__ == '__main__':
import sys
- app = QtGui.QApplication(sys.argv)
-
-
from . import Ui_ViewLogger
+ app = QtGui.QApplication(sys.argv)
+
w = Ui_View.ViewWidget(None)
w.addViews(True, ViewConnection())
w.addViews(False, Ui_ViewLogger.ViewLogger())
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-07-11 19:42:16
|
Revision: 582
http://fclient.svn.sourceforge.net/fclient/?rev=582&view=rev
Author: jUrner
Date: 2008-07-11 12:42:24 -0700 (Fri, 11 Jul 2008)
Log Message:
-----------
after 4 months of work. celebrate. the node is alive /houston
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-11 19:37:10 UTC (rev 581)
+++ trunk/fclient/src/fclient/Ui_ViewConnection.py 2008-07-11 19:42:24 UTC (rev 582)
@@ -96,10 +96,47 @@
bt = self.controlById(self.IdBtConnect)
if checked:
bt.setText(QtGui.QApplication.translate("ViewConnectionWidget", "Disconnect", None, QtGui.QApplication.UnicodeUTF8))
+
+ if config.fcpClient.isConnected():
+ config.fcpClient.close()
+ t = self.ConnectTimer(self)
+
else:
bt.setText(QtGui.QApplication.translate("ViewConnectionWidget", "Connect", None, QtGui.QApplication.UnicodeUTF8))
-
-
+ config.fcpClient.close()
+
+ #TODO: under construction!
+ class ConnectTimer(QtCore.QTimer):
+
+ def __init__(self,parent):
+ QtCore.QTimer.__init__(self, parent)
+ #self.setInterval(10)
+ self.connect(self, QtCore.SIGNAL('timeout()'), self.handleNext)
+
+ self.iterConnect = config.fcpClient.iterConnect() # ...more args
+ self.start(10)
+
+ def handleNext(self):
+ try:
+ result = self.iterConnect.next()
+ except StopIteration:
+ self.stop()
+ else:
+ if result is not None:
+ self.stop()
+
+
+
+
+
+
+
+
+ def handleFoo(self):
+ pass
+
+
+
#**********************************************************************************
#
#**********************************************************************************
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-07-12 11:07:25
|
Revision: 584
http://fclient.svn.sourceforge.net/fclient/?rev=584&view=rev
Author: jUrner
Date: 2008-07-12 04:07:35 -0700 (Sat, 12 Jul 2008)
Log Message:
-----------
continued working on 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-12 11:06:56 UTC (rev 583)
+++ trunk/fclient/src/fclient/Ui_ViewConnection.py 2008-07-12 11:07:35 UTC (rev 584)
@@ -5,11 +5,9 @@
from PyQt4 import QtCore, QtGui
-
from . import config
-from . import Ui_View
-
from .lib import fcp2
+from . import Ui_View
from .tpls.Ui_ViewConnectionWidgetTpl import Ui_ViewConnectionWidget
#**********************************************************************************
#
@@ -17,126 +15,126 @@
class Settings(config.SettingsBase):
_key_ = config.IdViewConnectionWidget
_settings_ = (
- ('AutoConnect', 'Bool', False),
- ('ConnectionHost', 'String', fcp2.Client.DefaultFcpHost),
- ('ConnectionName', 'String', ''), #TODO: we need a python ansi string
- ('ConnectionPort', 'UInt', fcp2.Client.DefaultFcpPort),
+ ('ConnectionTimerTimeout', 'UInt', 100, config.SettingScopeExpert),
+
+ ('AutoConnect', 'Bool', False, config.SettingScopeUser),
+ ('ConnectionName', 'String', '', config.SettingScopeUser), #TODO: we need a python ansi string
+ ('ConnectionHost', 'String', fcp2.Client.DefaultFcpHost, config.SettingScopeUser),
+ ('ConnectionPort', 'UInt', fcp2.Client.DefaultFcpPort, config.SettingScopeUser),
)
+#**********************************************************************************
+#
+#**********************************************************************************
+class ConnectionTimer(QtCore.QTimer):
+
+ def __init__(self,parent):
+ QtCore.QTimer.__init__(self, parent)
+ self.iterConnect = None
+ self.nodeHello = None
+ self.connect(self, QtCore.SIGNAL('timeout()'), self.handleNext)
+
+ def start(self, settings):
+ self.iterConnect = config.fcpClient.iterConnect() #TODO: ...more args
+ QtCore.QTimer.start(self, settings.value('ConnectionTimerTimeout'))
+
+ def handleNext(self):
+ try:
+ result = self.iterConnect.next()
+ except StopIteration:
+ self.stop()
+ else:
+ if result is not None:
+ self.stop()
+ self.nodeHello = result
+
#***********************************************************************
#
#***********************************************************************
class ViewConnectionWidget(QtGui.QWidget, Ui_ViewConnectionWidget):
IdBtConnect = 'btConnect'
- IdEdConnectionHost = 'edConnectionHost'
+ IdEdConnectionHost = 'edConnectionHost' #TODO: combobox? validate input.
IdSpinConnectionPort = 'spinConnectionPort'
-
def __init__(self, parent, cfg=None):
QtGui.QWidget.__init__(self, parent)
self._isCreated = False
- self.settings = Settings()
+ self._connectionTimer = ConnectionTimer(self)
+ self.settings = Settings()
self.setupUi(self)
-
- self.settings.restore()
config.ObjectRegistry.register(self)
-
+ #########################################
+ ##
+ #########################################
def controlById(self, idControl):
return getattr(self, idControl)
-
- def retranslateUi(self, w):
- Ui_ViewConnectionWidget.retranslateUi(self, w)
- bt = self.controlById(self.IdBtConnect)
- if bt.isChecked():
- bt.setText()
-
#########################################
- ## events
+ ## overwritten events
#########################################
def showEvent(self, event):
QtGui.QWidget.showEvent(self, event)
- if self._isCreated:
+ if self._isCreated:
return
-
self._isCreated = True
+
self.connect(
self.controlById(self.IdBtConnect),
QtCore.SIGNAL('clicked(bool)'),
- self.onBtConnectClicked
+ self.handleBtConnectClicked
)
+ self.settings.restore()
+
# setup host / port boxes
edHost = self.controlById(self.IdEdConnectionHost)
edHost.setText(self.settings.value('ConnectionHost'))
spinPort = self.controlById(self.IdSpinConnectionPort)
- #TODO: no idea if port range (0, 0xFFFF) this is reasonable
- spinPort.setRange(0, 0xFFFF)
+ spinPort.setRange(0, 0xFFFF) #TODO: no idea if port range (0, 0xFFFF) this is reasonable
spinPort.setValue(self.settings.value('ConnectionPort'))
-
# autoconnect if desired
- self.settings.restore()
if self.settings.value('AutoConnect'):
self.controlById(self.IdBtConnect).setChecked(True)
self.onBtConnectClicked(True)
- #XXX
- self.settings.setValues(ConnectionName='abc')
-
-
+
#########################################
- ##
+ ## overwritten methods
#########################################
- def onBtConnectClicked(self, checked):
+ def retranslateUi(self, w):
+ Ui_ViewConnectionWidget.retranslateUi(self, w)
bt = self.controlById(self.IdBtConnect)
+ if bt.isChecked():
+ bt.setText()
+
+ #########################################
+ ## event handlers
+ #########################################
+ def handleBtConnectClicked(self, checked):
+ bt = self.controlById(self.IdBtConnect)
if checked:
- bt.setText(QtGui.QApplication.translate("ViewConnectionWidget", "Disconnect", None, QtGui.QApplication.UnicodeUTF8))
+ bt.setText(QtGui.QApplication.translate(config.IdViewConnectionWidget, "Disconnect", None, QtGui.QApplication.UnicodeUTF8))
if config.fcpClient.isConnected():
config.fcpClient.close()
- t = self.ConnectTimer(self)
+ self._connectionTimer.start(self.settings)
else:
- bt.setText(QtGui.QApplication.translate("ViewConnectionWidget", "Connect", None, QtGui.QApplication.UnicodeUTF8))
+ bt.setText(QtGui.QApplication.translate(config.IdViewConnectionWidget, "Connect", None, QtGui.QApplication.UnicodeUTF8))
config.fcpClient.close()
-
- #TODO: under construction!
- class ConnectTimer(QtCore.QTimer):
-
- def __init__(self,parent):
- QtCore.QTimer.__init__(self, parent)
- #self.setInterval(10)
- self.connect(self, QtCore.SIGNAL('timeout()'), self.handleNext)
+ self._connectionTimer.stop()
- self.iterConnect = config.fcpClient.iterConnect() # ...more args
- self.start(10)
-
- def handleNext(self):
- try:
- result = self.iterConnect.next()
- except StopIteration:
- self.stop()
- else:
- if result is not None:
- self.stop()
-
-
-
-
-
-
-
-
- def handleFoo(self):
+ #########################################
+ ## fcp event handlers
+ #########################################
+ def handleFcpClientDisconected(self, event):
pass
-
-
-
+
#**********************************************************************************
#
#**********************************************************************************
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-07-12 13:40:30
|
Revision: 595
http://fclient.svn.sourceforge.net/fclient/?rev=595&view=rev
Author: jUrner
Date: 2008-07-12 06:40:27 -0700 (Sat, 12 Jul 2008)
Log Message:
-----------
more work on 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-12 13:40:07 UTC (rev 594)
+++ trunk/fclient/src/fclient/Ui_ViewConnection.py 2008-07-12 13:40:27 UTC (rev 595)
@@ -15,7 +15,9 @@
class Settings(config.SettingsBase):
_key_ = config.IdViewConnectionWidget
_settings_ = (
- ('ConnectionTimerTimeout', 'UInt', 100, config.SettingScopeExpert),
+ #TODO: time secs vsmilis. should be either secs or milis. fix in fcp2.Client.connect
+ ('ConnectionTimerTimeout', 'UInt', 800, config.SettingScopeExpert),
+ ('ConnectionTimerMaxDuration', 'UInt', 20, config.SettingScopeExpert),
('AutoConnect', 'Bool', False, config.SettingScopeUser),
('ConnectionName', 'String', '', config.SettingScopeUser), #TODO: we need a python ansi string
@@ -35,7 +37,10 @@
self.connect(self, QtCore.SIGNAL('timeout()'), self.handleNext)
def start(self, settings):
- self.iterConnect = config.fcpClient.iterConnect() #TODO: ...more args
+ self.iterConnect = config.fcpClient.iterConnect(
+ duration=settings.value('ConnectionTimerMaxDuration'),
+ timeout=0
+ )
QtCore.QTimer.start(self, settings.value('ConnectionTimerTimeout'))
def handleNext(self):
@@ -54,6 +59,7 @@
class ViewConnectionWidget(QtGui.QWidget, Ui_ViewConnectionWidget):
IdBtConnect = 'btConnect'
+ IdckAutoConnect = 'ckAutoConnect'
IdEdConnectionHost = 'edConnectionHost' #TODO: combobox? validate input.
IdSpinConnectionPort = 'spinConnectionPort'
@@ -82,14 +88,15 @@
return
self._isCreated = True
- self.connect(
- self.controlById(self.IdBtConnect),
- QtCore.SIGNAL('clicked(bool)'),
- self.handleBtConnectClicked
+
+ self.settings.restore()
+
+ #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),
)
- self.settings.restore()
-
# setup host / port boxes
edHost = self.controlById(self.IdEdConnectionHost)
edHost.setText(self.settings.value('ConnectionHost'))
@@ -98,11 +105,17 @@
spinPort.setRange(0, 0xFFFF) #TODO: no idea if port range (0, 0xFFFF) this is reasonable
spinPort.setValue(self.settings.value('ConnectionPort'))
- # autoconnect if desired
- if self.settings.value('AutoConnect'):
- self.controlById(self.IdBtConnect).setChecked(True)
- self.onBtConnectClicked(True)
-
+ # setup Connect button and AutoConnect checkbox
+ doAutoConnect = self.settings.value('AutoConnect')
+ ck = self.controlById(self.IdckAutoConnect)
+ ck.setChecked(doAutoConnect)
+ self.connect(ck, QtCore.SIGNAL('stateChanged(int)'), self.handleCkAutoConnectStateChanged)
+
+ bt = self.controlById(self.IdBtConnect)
+ self.connect(bt, QtCore.SIGNAL('clicked(bool)'), self.handleBtConnectClicked)
+ if doAutoConnect:
+ self.controlById(self.IdBtConnect).click()
+
#########################################
## overwritten methods
#########################################
@@ -110,7 +123,9 @@
Ui_ViewConnectionWidget.retranslateUi(self, w)
bt = self.controlById(self.IdBtConnect)
if bt.isChecked():
- bt.setText()
+ bt.setText(QtGui.QApplication.translate("ViewConnectionWidget", "Connect", None, QtGui.QApplication.UnicodeUTF8))
+ else:
+ bt.setText(QtGui.QApplication.translate("ViewConnectionWidget", "Disconnect", None, QtGui.QApplication.UnicodeUTF8))
#########################################
## event handlers
@@ -118,22 +133,27 @@
def handleBtConnectClicked(self, checked):
bt = self.controlById(self.IdBtConnect)
if checked:
- bt.setText(QtGui.QApplication.translate(config.IdViewConnectionWidget, "Disconnect", None, QtGui.QApplication.UnicodeUTF8))
-
+ bt.setText(QtGui.QApplication.translate("ViewConnectionWidget", "Disconnect", None, QtGui.QApplication.UnicodeUTF8))
if config.fcpClient.isConnected():
config.fcpClient.close()
self._connectionTimer.start(self.settings)
-
else:
- bt.setText(QtGui.QApplication.translate(config.IdViewConnectionWidget, "Connect", None, QtGui.QApplication.UnicodeUTF8))
- config.fcpClient.close()
+ bt.setText(QtGui.QApplication.translate("ViewConnectionWidget", "Connect", None, QtGui.QApplication.UnicodeUTF8))
self._connectionTimer.stop()
+ if config.fcpClient.isConnected():
+ config.fcpClient.close()
+
+
+ def handleCkAutoConnectStateChanged(self, state):
+ self.settings.setValues(AutoConnect=state == QtCore.Qt.Checked)
#########################################
## fcp event handlers
#########################################
- def handleFcpClientDisconected(self, event):
- pass
+ def handleFcpClientDisconected(self, event, msg):
+ bt = self.controlById(self.IdBtConnect)
+ if bt.isChecked():
+ bt.click()
#**********************************************************************************
#
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-07-12 19:59:18
|
Revision: 600
http://fclient.svn.sourceforge.net/fclient/?rev=600&view=rev
Author: jUrner
Date: 2008-07-12 12:59:24 -0700 (Sat, 12 Jul 2008)
Log Message:
-----------
beautify
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-12 19:58:48 UTC (rev 599)
+++ trunk/fclient/src/fclient/Ui_ViewConnection.py 2008-07-12 19:59:24 UTC (rev 600)
@@ -15,7 +15,6 @@
class Settings(config.SettingsBase):
_key_ = config.IdViewConnectionWidget
_settings_ = (
- #TODO: time secs vsmilis. should be either secs or milis. fix in fcp2.Client.connect
('ConnectionTimerTimeout', 'UInt', 800, config.SettingScopeExpert),
('ConnectionTimerMaxDuration', 'UInt', 20, config.SettingScopeExpert),
@@ -122,23 +121,20 @@
def retranslateUi(self, w):
Ui_ViewConnectionWidget.retranslateUi(self, w)
bt = self.controlById(self.IdBtConnect)
- if bt.isChecked():
- bt.setText(QtGui.QApplication.translate("ViewConnectionWidget", "Connect", None, QtGui.QApplication.UnicodeUTF8))
- else:
- bt.setText(QtGui.QApplication.translate("ViewConnectionWidget", "Disconnect", None, QtGui.QApplication.UnicodeUTF8))
+ bt.setText(self.trUtf8('Disconnect') if bt.isChecked() else self.trUtf8('Connect'))
+
#########################################
## event handlers
#########################################
- def handleBtConnectClicked(self, checked):
+ def handleBtConnectClicked(self, isChecked):
bt = self.controlById(self.IdBtConnect)
- if checked:
- bt.setText(QtGui.QApplication.translate("ViewConnectionWidget", "Disconnect", None, QtGui.QApplication.UnicodeUTF8))
+ bt.setText(self.trUtf8('Disconnect') if isChecked else self.trUtf8('Connect'))
+ if isChecked:
if config.fcpClient.isConnected():
config.fcpClient.close()
self._connectionTimer.start(self.settings)
else:
- bt.setText(QtGui.QApplication.translate("ViewConnectionWidget", "Connect", None, QtGui.QApplication.UnicodeUTF8))
self._connectionTimer.stop()
if config.fcpClient.isConnected():
config.fcpClient.close()
@@ -172,7 +168,6 @@
def objectName(self):
return 'ViewConnection'
-
def widget(self, parent):
if self._widget is None:
self._widget = ViewConnectionWidget(parent)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
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.
|
|
From: <jU...@us...> - 2008-07-15 23:57:33
|
Revision: 647
http://fclient.svn.sourceforge.net/fclient/?rev=647&view=rev
Author: jUrner
Date: 2008-07-15 16:57:40 -0700 (Tue, 15 Jul 2008)
Log Message:
-----------
what a diff
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-15 23:57:01 UTC (rev 646)
+++ trunk/fclient/src/fclient/Ui_ViewConnection.py 2008-07-15 23:57:40 UTC (rev 647)
@@ -17,6 +17,7 @@
_settings_ = (
('ConnectionTimerTimeout', 'UInt', 800, config.SettingScopeExpert),
('ConnectionTimerMaxDuration', 'UInt', 20, config.SettingScopeExpert),
+ ('PollTimerTimeout', 'UInt', 200, config.SettingScopeExpert),
('AutoConnect', 'Bool', False, config.SettingScopeUser),
('ConnectionName', 'String', '', config.SettingScopeUser), #TODO: we need a python ansi string
@@ -31,27 +32,46 @@
def __init__(self,parent):
QtCore.QTimer.__init__(self, parent)
- self.iterConnect = None
- self.nodeHello = None
+ self.fcpIterConnect = None
self.connect(self, QtCore.SIGNAL('timeout()'), self.handleNext)
def start(self, settings):
- self.iterConnect = config.fcpClient.iterConnect(
+ self.fcpIterConnect = config.fcpClient.iterConnect(
duration=settings.value('ConnectionTimerMaxDuration'),
timeout=0
)
- QtCore.QTimer.start(self, settings.value('ConnectionTimerTimeout'))
+ if not self.handleNext():
+ QtCore.QTimer.start(self, settings.value('ConnectionTimerTimeout'))
def handleNext(self):
try:
- result = self.iterConnect.next()
+ result = self.fcpIterConnect.next()
except StopIteration:
self.stop()
else:
if result is not None:
self.stop()
- self.nodeHello = result
+ # 1st thing todo after connect is to query the config from the node so all
+ # listeners right away so not everyone has to query it so. needs more details
+ # or joins the gui later.. feel free to query again
+ config.fcpClient.getConfig()
+ return True
+ return False
+
+
+class PollTimer(QtCore.QTimer):
+
+ def __init__(self,parent):
+ QtCore.QTimer.__init__(self, parent)
+ self.connect(self, QtCore.SIGNAL('timeout()'), self.handleNext)
+ def start(self, settings):
+ QtCore.QTimer.start(self, settings.value('PollTimerTimeout'))
+
+ def handleNext(self):
+ if config.fcpClient.isConnected():
+ result = config.fcpClient.next()
+
#***********************************************************************
#
#***********************************************************************
@@ -65,24 +85,25 @@
def __init__(self, parent, cfg=None):
QtGui.QWidget.__init__(self, parent)
- self._acts = []
self._isCreated = False
self._connectionTimer = ConnectionTimer(self)
- self._eventHandlers = (
+ self._pollTimer = PollTimer(self)
+ self._fcpEventHandlers = (
+ (config.fcpClient.events.ClientConnected, self.handleFcpClientConected),
(config.fcpClient.events.ClientDisconnected, self.handleFcpClientDisconected),
)
+ config.fcpClient.events += self._fcpEventHandlers
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.populateMenu(menu)
self._mainWindowMenus = (
menuBarWrap.addViewMenu(menu),
)
@@ -90,26 +111,18 @@
#########################################
## 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 populateMenu(self, menu):
+ return menu
- def acts(self):
- if not self._acts:
- self._acts = (
- )
- return self._acts
-
#########################################
## view methods
#########################################
def viewClose(self):
- self.close()
+ config.fcpClient.events -= self._fcpEventHandlers
def viewDisplayName(self):
return self.trUtf8('Connection')
@@ -128,7 +141,7 @@
## overwritten events
#########################################
def closeEvent(self, event):
- self.close()
+ self.viewClose()
def showEvent(self, event):
if self._isCreated:
@@ -137,8 +150,7 @@
self.settings.restore()
- config.fcpClient.events += self._eventHandlers
-
+
# setup host / port boxes
edHost = self.controlById(self.IdEdConnectionHost)
edHost.setText(self.settings.value('ConnectionHost'))
@@ -157,10 +169,7 @@
self.connect(bt, QtCore.SIGNAL('clicked(bool)'), self.handleBtConnectClicked)
if doAutoConnect:
self.controlById(self.IdBtConnect).click()
-
-
-
-
+
########################################
## overwritten methods
#########################################
@@ -183,6 +192,7 @@
else:
self._connectionTimer.stop()
if config.fcpClient.isConnected():
+ self._pollTimer.stop()
config.fcpClient.close()
@@ -197,6 +207,9 @@
if bt.isChecked():
bt.click()
+ def handleFcpClientConected(self, event, msg):
+ self._pollTimer.start(self.settings)
+
#**********************************************************************************
#
#**********************************************************************************
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|