Update "Network Status" information only when the tab selected

This commit is contained in:
Dmitri Bogomolov 2018-02-05 14:39:32 +02:00
parent 03f08b3cfd
commit 85cce42de0
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13
2 changed files with 21 additions and 3 deletions

View File

@ -686,6 +686,10 @@ class MyForm(settingsmixin.SMainWindow):
"itemSelectionChanged ()"), self.treeWidgetItemClicked) "itemSelectionChanged ()"), self.treeWidgetItemClicked)
QtCore.QObject.connect(self.ui.treeWidgetChans, QtCore.SIGNAL( QtCore.QObject.connect(self.ui.treeWidgetChans, QtCore.SIGNAL(
"itemChanged (QTreeWidgetItem *, int)"), self.treeWidgetItemChanged) "itemChanged (QTreeWidgetItem *, int)"), self.treeWidgetItemChanged)
QtCore.QObject.connect(
self.ui.tabWidget, QtCore.SIGNAL("currentChanged(int)"),
self.tabWidgetCurrentChanged
)
# Put the colored icon on the status bar # Put the colored icon on the status bar
# self.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/yellowicon.png")) # self.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/yellowicon.png"))
@ -4012,6 +4016,12 @@ class MyForm(settingsmixin.SMainWindow):
completerList[i] = item.label + " <" + item.address + ">" completerList[i] = item.label + " <" + item.address + ">"
self.ui.lineEditTo.completer().model().setStringList(completerList) self.ui.lineEditTo.completer().model().setStringList(completerList)
def tabWidgetCurrentChanged(self, n):
if n == self.ui.tabWidget.indexOf(self.ui.networkstatus):
self.ui.networkstatus.startUpdate()
else:
self.ui.networkstatus.stopUpdate()
def writeNewAddressToTable(self, label, address, streamNumber): def writeNewAddressToTable(self, label, address, streamNumber):
self.rerenderTabTreeMessages() self.rerenderTabTreeMessages()
self.rerenderTabTreeSubscriptions() self.rerenderTabTreeSubscriptions()

View File

@ -41,8 +41,16 @@ class NetworkStatus(QtGui.QWidget, RetranslateMixin):
"updateNetworkStatusTab(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.updateNetworkStatusTab) "updateNetworkStatusTab(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.updateNetworkStatusTab)
self.timer = QtCore.QTimer() self.timer = QtCore.QTimer()
self.timer.start(2000) # milliseconds
QtCore.QObject.connect(self.timer, QtCore.SIGNAL("timeout()"), self.runEveryTwoSeconds) QtCore.QObject.connect(
self.timer, QtCore.SIGNAL("timeout()"), self.runEveryTwoSeconds)
def startUpdate(self):
self.runEveryTwoSeconds()
self.timer.start(2000) # milliseconds
def stopUpdate(self):
self.timer.stop()
def formatBytes(self, num): def formatBytes(self, num):
for x in [_translate("networkstatus", "byte(s)", None, QtCore.QCoreApplication.CodecForTr, num), "kB", "MB", "GB"]: for x in [_translate("networkstatus", "byte(s)", None, QtCore.QCoreApplication.CodecForTr, num), "kB", "MB", "GB"]: