From 85cce42de08034b426954b02b516d817f35e1707 Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Mon, 5 Feb 2018 14:39:32 +0200 Subject: [PATCH] Update "Network Status" information only when the tab selected --- src/bitmessageqt/__init__.py | 10 ++++++++++ src/bitmessageqt/networkstatus.py | 14 +++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index 3422664b..f370f3b8 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -686,6 +686,10 @@ class MyForm(settingsmixin.SMainWindow): "itemSelectionChanged ()"), self.treeWidgetItemClicked) QtCore.QObject.connect(self.ui.treeWidgetChans, QtCore.SIGNAL( "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 # self.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/yellowicon.png")) @@ -4012,6 +4016,12 @@ class MyForm(settingsmixin.SMainWindow): completerList[i] = item.label + " <" + item.address + ">" 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): self.rerenderTabTreeMessages() self.rerenderTabTreeSubscriptions() diff --git a/src/bitmessageqt/networkstatus.py b/src/bitmessageqt/networkstatus.py index 67284495..02c0deaf 100644 --- a/src/bitmessageqt/networkstatus.py +++ b/src/bitmessageqt/networkstatus.py @@ -39,10 +39,18 @@ class NetworkStatus(QtGui.QWidget, RetranslateMixin): "updateNumberOfBroadcastsProcessed()"), self.updateNumberOfBroadcastsProcessed) QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL( "updateNetworkStatusTab(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.updateNetworkStatusTab) - + 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): for x in [_translate("networkstatus", "byte(s)", None, QtCore.QCoreApplication.CodecForTr, num), "kB", "MB", "GB"]: