Network Status tab translations update

- remembers startup time
- kB instead of KB
- stream table and status texts scale and aren't cut if they translated
text doesn't fit
This commit is contained in:
Peter Šurda 2016-04-25 18:17:02 +02:00
parent af098e4805
commit 38700a1721
2 changed files with 249 additions and 210 deletions

View File

@ -1,4 +1,5 @@
from PyQt4 import QtCore, QtGui
import time
import shared
from tr import _translate
import l10n
@ -12,8 +13,9 @@ class NetworkStatus(QtGui.QWidget, RetranslateMixin):
super(NetworkStatus, self).__init__(parent)
widgets.load('networkstatus.ui', self)
self.startup = time.localtime()
self.labelStartupTime.setText(_translate("networkstatus", "Since startup on %1").arg(
l10n.formatTimestamp()))
l10n.formatTimestamp(self.startup)))
self.UISignalThread = UISignaler.get()
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
@ -33,7 +35,7 @@ class NetworkStatus(QtGui.QWidget, RetranslateMixin):
QtCore.QObject.connect(self.timer, QtCore.SIGNAL("timeout()"), self.runEveryTwoSeconds)
def formatBytes(self, num):
for x in ['bytes','KB','MB','GB']:
for x in [_translate("networkstatus", "byte(s)"), "kB", "MB", "GB"]:
if num < 1000.0:
return "%3.0f %s" % (num, x)
num /= 1000.0
@ -41,7 +43,7 @@ class NetworkStatus(QtGui.QWidget, RetranslateMixin):
def formatByteRate(self, num):
num /= 1000
return "%4.0f KB" % num
return "%4.0f kB" % num
def updateNumberOfMessagesProcessed(self):
self.labelSyncStatus.setText(_translate("networkstatus", "Objects to be synced: %1").arg(str(sum(shared.numberOfObjectsThatWeHaveYetToGetPerPeer.itervalues()))))
@ -125,3 +127,8 @@ class NetworkStatus(QtGui.QWidget, RetranslateMixin):
"networkstatus", "Inventory lookups per second: %1").arg(str(shared.numberOfInventoryLookupsPerformed/2)))
shared.numberOfInventoryLookupsPerformed = 0
self.updateNumberOfBytes()
def retranslateUi(self):
super(QtGui.QWidget, self).retranslateUi()
self.labelStartupTime.setText(_translate("networkstatus", "Since startup on %1").arg(
l10n.formatTimestamp(self.startup)))

View File

@ -6,137 +6,40 @@
<rect>
<x>0</x>
<y>0</y>
<width>731</width>
<height>493</height>
<width>602</width>
<height>252</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,1">
<property name="spacing">
<number>20</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="spacing">
<number>20</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum>
</property>
<item>
<widget class="QLabel" name="labelTotalConnections">
<property name="geometry">
<rect>
<x>20</x>
<y>30</y>
<width>401</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Total connections:</string>
</property>
</widget>
<widget class="QLabel" name="labelStartupTime">
<property name="geometry">
<rect>
<x>320</x>
<y>110</y>
<width>331</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Since startup:</string>
</property>
</widget>
<widget class="QLabel" name="labelMessageCount">
<property name="geometry">
<rect>
<x>350</x>
<y>130</y>
<width>361</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Processed 0 person-to-person messages.</string>
</property>
</widget>
<widget class="QLabel" name="labelPubkeyCount">
<property name="geometry">
<rect>
<x>350</x>
<y>170</y>
<width>331</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Processed 0 public keys.</string>
</property>
</widget>
<widget class="QLabel" name="labelBroadcastCount">
<property name="geometry">
<rect>
<x>350</x>
<y>150</y>
<width>351</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Processed 0 broadcasts.</string>
</property>
</widget>
<widget class="QLabel" name="labelLookupsPerSecond">
<property name="geometry">
<rect>
<x>320</x>
<y>270</y>
<width>291</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Inventory lookups per second: 0</string>
</property>
</widget>
<widget class="QLabel" name="labelBytesRecvCount">
<property name="geometry">
<rect>
<x>350</x>
<y>220</y>
<width>251</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Down: 0 KB/s</string>
</property>
</widget>
<widget class="QLabel" name="labelBytesSentCount">
<property name="geometry">
<rect>
<x>350</x>
<y>240</y>
<width>251</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Up: 0 KB/s</string>
</property>
</widget>
<widget class="QLabel" name="labelSyncStatus">
<property name="geometry">
<rect>
<x>350</x>
<y>190</y>
<width>331</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Objects to be synced:</string>
</property>
</widget>
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>20</x>
<y>70</y>
<width>241</width>
<height>241</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
</item>
<item>
<widget class="STableWidget" name="tableWidgetConnectionCount">
<property name="palette">
@ -192,7 +95,7 @@
<enum>QAbstractItemView::NoSelection</enum>
</property>
<attribute name="horizontalHeaderCascadingSectionResizes">
<bool>true</bool>
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderHighlightSections">
<bool>false</bool>
@ -216,7 +119,136 @@
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_6">
<property name="spacing">
<number>4</number>
</property>
<item>
<widget class="QLabel" name="labelStartupTime">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>9</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
<property name="text">
<string>Since startup:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelMessageCount">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Processed 0 person-to-person messages.</string>
</property>
<property name="margin">
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelBroadcastCount">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Processed 0 broadcasts.</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelPubkeyCount">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Processed 0 public keys.</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelSyncStatus">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Objects to be synced:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelBytesSentCount">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Up: 0 kB/s</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelBytesRecvCount">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Down: 0 kB/s</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelLookupsPerSecond">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Inventory lookups per second: 0</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>