SF.net SVN: fclient:[881] trunk/fclient/fclient/impl
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <jU...@us...> - 2008-08-09 11:22:45
|
Revision: 881
http://fclient.svn.sourceforge.net/fclient/?rev=881&view=rev
Author: jUrner
Date: 2008-08-09 11:22:54 +0000 (Sat, 09 Aug 2008)
Log Message:
-----------
got a nice connection label on the statusBar now
Modified Paths:
--------------
trunk/fclient/fclient/impl/MainWindow.py
trunk/fclient/fclient/impl/res/stylesheets/default.css
Modified: trunk/fclient/fclient/impl/MainWindow.py
===================================================================
--- trunk/fclient/fclient/impl/MainWindow.py 2008-08-09 11:22:16 UTC (rev 880)
+++ trunk/fclient/fclient/impl/MainWindow.py 2008-08-09 11:22:54 UTC (rev 881)
@@ -21,6 +21,7 @@
_key_ = config.IdMainWindow
_settings_ = (
('Geometry', 'ByteArray', QtCore.QByteArray()),
+ ('ConnectionLabelFlashRate', 'UInt', 800),
)
@@ -78,12 +79,78 @@
class StatusBar(QtGui.QStatusBar):
- def __init__(self, parent):
- QtGui.QStatusBar.__init__(self, parent)
+
+ class DisconnectTimer(QtCore.QTimer):
+
+ def __init__(self,statusBar):
+ QtCore.QTimer.__init__(self, statusBar)
+ self.connect(self, QtCore.SIGNAL('timeout()'), self.onNext)
+
+ def start(self, n):
+ QtCore.QTimer.start(self, n)
+
+ def onNext(self):
+ statusBar = self.parent()
+ if statusBar.connectionLabels['LabelConnectionConnected'].isVisible():
+ self.stop()
+ else:
+ statusBar.connectionLabels['LabelConnectionDisonnectedOn'].setVisible(
+ not statusBar.connectionLabels['LabelConnectionDisonnectedOn'].isVisible()
+ )
+ statusBar.connectionLabels['LabelConnectionDisonnectedOff'].setVisible(
+ not statusBar.connectionLabels['LabelConnectionDisonnectedOff'].isVisible()
+ )
+
+ def __init__(self, mainWindow):
+ QtGui.QStatusBar.__init__(self, mainWindow)
self.setObjectName('StatusBar')
#config.ObjectRegistry.register(self)
- parent.setStatusBar(self)
+ mainWindow.setStatusBar(self)
+
+ self._disconnectTimer = self.DisconnectTimer(self)
+
+ # setup connection labels
+ self.fcpEvents = (
+ (config.fcpClient.events.ClientConnected, self.onFcpClientConnected),
+ (config.fcpClient.events.ClientDisconnected, self.onFcpClientDisconnected),
+ )
+ config.fcpClient.events += self.fcpEvents
+ self.connectionLabels = {
+ 'LabelConnectionConnected': QtGui.QLabel(self),
+ 'LabelConnectionDisonnectedOn': QtGui.QLabel(self),
+ 'LabelConnectionDisonnectedOff': QtGui.QLabel(self),
+ }
+ for objectName, label in self.connectionLabels.items():
+ label.setObjectName(objectName)
+ label.setVisible(False)
+ self.addWidget(label, 0)
+ if config.fcpClient.isConnected():
+ self.connectionLabels['LabelConnectionConnected'].show()
+ else :
+ self.connectionLabels['LabelConnectionDisonnectedOn'].show()
+
+ self.retranslateUi(self)
+
+
+ def retranslateUi(self, this):
+ self.connectionLabels['LabelConnectionConnected'].setText(self.trUtf8('CONNECTED'))
+ self.connectionLabels['LabelConnectionDisonnectedOn'].setText(self.trUtf8('DISCONNECTED'))
+ self.connectionLabels['LabelConnectionDisonnectedOff'].setText(self.trUtf8('DISCONNECTED'))
+
+ def onFcpClientConnected(self, event, msg):
+ self._disconnectTimer.stop()
+ for label in self.connectionLabels.values():
+ label.hide()
+ self.connectionLabels['LabelConnectionConnected'].show()
+
+ def onFcpClientDisconnected(self, event, msg):
+ for label in self.connectionLabels.values():
+ label.hide()
+ self.connectionLabels['LabelConnectionDisonnectedOn'].show()
+ self._disconnectTimer.start(self.parent().fcSettings.value('ConnectionLabelFlashRate'))
+
+
class TitleBar(QtCore.QObject):
def __init__(self, parent):
Modified: trunk/fclient/fclient/impl/res/stylesheets/default.css
===================================================================
--- trunk/fclient/fclient/impl/res/stylesheets/default.css 2008-08-09 11:22:16 UTC (rev 880)
+++ trunk/fclient/fclient/impl/res/stylesheets/default.css 2008-08-09 11:22:54 UTC (rev 881)
@@ -95,3 +95,21 @@
background:red;
}
*/
+
+
+QLabel#LabelConnectionConnected{
+ color: green;
+ font: bold;
+ background: white;
+ }
+QLabel#LabelConnectionDisonnectedOn{
+ color: red;
+ font: bold;
+ background: white;
+ }
+QLabel#LabelConnectionDisonnectedOff{
+ color: lightsalmon;
+ font: bold;
+ background: white;
+ }
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|