diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index dd67d211..47870046 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -482,6 +482,10 @@ class MyForm(QtGui.QMainWindow): # startup for linux pass + + self.totalNumberOfBytesReceived = 0 + self.totalNumberOfBytesSent = 0 + self.ui.labelSendBroadcastWarning.setVisible(False) self.timer = QtCore.QTimer() @@ -1468,6 +1472,31 @@ class MyForm(QtGui.QMainWindow): self.ui.labelPubkeyCount.setText(_translate( "MainWindow", "Processed %1 public keys.").arg(str(shared.numberOfPubkeysProcessed))) + def formatBytes(self, num): + for x in ['bytes','KB','MB','GB']: + if num < 1000.0: + return "%3.0f %s" % (num, x) + num /= 1000.0 + return "%3.0f %s" % (num, 'TB') + + def formatByteRate(self, num): + num /= 1000 + return "%4.0f KB" % num + + def updateNumberOfBytes(self): + """ + This function is run every two seconds, so we divide the rate of bytes + sent and received by 2. + """ + self.ui.labelBytesRecvCount.setText(_translate( + "MainWindow", "Down: %1/s Total: %2").arg(self.formatByteRate(shared.numberOfBytesReceived/2), self.formatBytes(self.totalNumberOfBytesReceived))) + self.ui.labelBytesSentCount.setText(_translate( + "MainWindow", "Up: %1/s Total: %2").arg(self.formatByteRate(shared.numberOfBytesSent/2), self.formatBytes(self.totalNumberOfBytesSent))) + self.totalNumberOfBytesReceived += shared.numberOfBytesReceived + self.totalNumberOfBytesSent += shared.numberOfBytesSent + shared.numberOfBytesReceived = 0 + shared.numberOfBytesSent = 0 + def updateNetworkStatusTab(self): # print 'updating network status tab' totalNumberOfConnectionsFromAllStreams = 0 # One would think we could use len(sendDataQueues) for this but the number doesn't always match: just because we have a sendDataThread running doesn't mean that the connection has been fully established (with the exchange of version messages). @@ -1521,6 +1550,7 @@ class MyForm(QtGui.QMainWindow): self.ui.labelLookupsPerSecond.setText(_translate( "MainWindow", "Inventory lookups per second: %1").arg(str(shared.numberOfInventoryLookupsPerformed/2))) shared.numberOfInventoryLookupsPerformed = 0 + self.updateNumberOfBytes() # Indicates whether or not there is a connection to the Bitmessage network connected = False diff --git a/src/bitmessageqt/bitmessageui.py b/src/bitmessageqt/bitmessageui.py index b80367dd..fb0056aa 100644 --- a/src/bitmessageqt/bitmessageui.py +++ b/src/bitmessageqt/bitmessageui.py @@ -2,8 +2,8 @@ # Form implementation generated from reading ui file 'bitmessageui.ui' # -# Created: Sat Nov 2 18:01:09 2013 -# by: PyQt4 UI code generator 4.10 +# Created: Fri Aug 01 15:30:14 2014 +# by: PyQt4 UI code generator 4.10.3 # # WARNING! All changes made in this file will be lost! @@ -431,15 +431,21 @@ class Ui_MainWindow(object): self.labelBroadcastCount.setGeometry(QtCore.QRect(350, 150, 351, 16)) self.labelBroadcastCount.setObjectName(_fromUtf8("labelBroadcastCount")) self.labelLookupsPerSecond = QtGui.QLabel(self.networkstatus) - self.labelLookupsPerSecond.setGeometry(QtCore.QRect(320, 210, 291, 16)) + self.labelLookupsPerSecond.setGeometry(QtCore.QRect(320, 250, 291, 16)) self.labelLookupsPerSecond.setObjectName(_fromUtf8("labelLookupsPerSecond")) + self.labelBytesRecvCount = QtGui.QLabel(self.networkstatus) + self.labelBytesRecvCount.setGeometry(QtCore.QRect(350, 210, 251, 16)) + self.labelBytesRecvCount.setObjectName(_fromUtf8("labelBytesRecvCount")) + self.labelBytesSentCount = QtGui.QLabel(self.networkstatus) + self.labelBytesSentCount.setGeometry(QtCore.QRect(350, 230, 251, 16)) + self.labelBytesSentCount.setObjectName(_fromUtf8("labelBytesSentCount")) icon9 = QtGui.QIcon() icon9.addPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/networkstatus.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.tabWidget.addTab(self.networkstatus, icon9, _fromUtf8("")) self.gridLayout.addWidget(self.tabWidget, 0, 0, 1, 1) MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(MainWindow) - self.menubar.setGeometry(QtCore.QRect(0, 0, 885, 27)) + self.menubar.setGeometry(QtCore.QRect(0, 0, 885, 21)) self.menubar.setObjectName(_fromUtf8("menubar")) self.menuFile = QtGui.QMenu(self.menubar) self.menuFile.setObjectName(_fromUtf8("menuFile")) @@ -557,8 +563,8 @@ class Ui_MainWindow(object): self.textEditMessage.setHtml(_translate("MainWindow", "\n" "
\n" -"