Skip to content

Commit 16d8327

Browse files
committed
fix signal-slot connections
1 parent 85d246b commit 16d8327

File tree

13 files changed

+131
-137
lines changed

13 files changed

+131
-137
lines changed

src/mainWindow.py

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import threading
77
import sys
88

9-
from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QThread, QSettings
9+
from PyQt5.QtCore import pyqtSignal, Qt, QThread, QSettings
1010
from PyQt5.QtGui import QPixmap, QColor, QPalette, QTextCursor, QIcon, QFont
1111
from PyQt5.QtWidgets import QWidget, QPushButton, QHBoxLayout, QGroupBox, QVBoxLayout, \
1212
QFileDialog, QMessageBox, QTextEdit, QTabWidget, QLabel, QSplitter
@@ -135,8 +135,10 @@ def __init__(self, parent, masternode_list, imgDir):
135135

136136
###-- Set Layout
137137
self.setLayout(self.layout)
138+
138139
###-- Init Settings
139140
self.initSettings()
141+
140142
###-- Connect buttons/signals
141143
self.connButtons()
142144

@@ -155,15 +157,13 @@ def __init__(self, parent, masternode_list, imgDir):
155157

156158

157159

158-
159-
@pyqtSlot(str)
160+
160161
def append_to_console(self, text):
161162
self.consoleArea.moveCursor(QTextCursor.End)
162163
self.consoleArea.insertHtml(text)
163164

164165

165166

166-
@pyqtSlot(str)
167167
def clearHWstatus(self, message):
168168
self.hwStatus = 1
169169
self.hwStatusMess = 'Unable to connect to the device. Please check that the PIVX app on the device is open, and try again.'
@@ -173,7 +173,7 @@ def clearHWstatus(self, message):
173173

174174

175175

176-
@pyqtSlot()
176+
177177
def clearRPCstatus(self):
178178
self.rpcConnected = False
179179
self.header.lastPingBox.setHidden(False)
@@ -194,13 +194,9 @@ def connButtons(self):
194194
self.sig_clearRPCstatus.connect(self.clearRPCstatus)
195195
self.sig_RPCstatusUpdated.connect(self.showRPCstatus)
196196
self.parent.sig_changed_rpcServers.connect(self.updateRPClist)
197-
self.hwdevice.sig_ledger_disconnected.connect(self.clearHWstatus)
198-
self.hwdevice.sigTxdone.connect(self.t_rewards.FinishSend)
199-
self.hwdevice.sigTxabort.connect(self.t_rewards.onCancel)
200-
self.hwdevice.tx_progress.connect(self.t_rewards.updateProgressPercent)
197+
self.hwdevice.sig_ledger_disconnected.connect(self.clearHWstatus)
201198
self.tabMain.myList.model().rowsMoved.connect(self.saveMNListOrder)
202-
self.sig_UTXOsLoaded.connect(self.t_rewards.display_mn_utxos)
203-
self.sig_ProposalsLoaded.connect(self.t_governance.displayProposals)
199+
204200

205201

206202

@@ -326,8 +322,7 @@ def loadMNConf(self, fileName):
326322

327323

328324

329-
330-
@pyqtSlot()
325+
331326
def onCheckHw(self):
332327
printDbg("Checking for HW device...")
333328
self.updateHWstatus(None)
@@ -336,13 +331,12 @@ def onCheckHw(self):
336331

337332

338333

339-
@pyqtSlot()
340334
def onCheckRpc(self):
341335
self.runInThread(self.updateRPCstatus, (True,),)
342336

343337

344338

345-
@pyqtSlot()
339+
346340
def onCheckVersion(self):
347341
printDbg("Checking SPMT version...")
348342
self.versionLabel.setText("--")
@@ -370,7 +364,7 @@ def updateVersion(self):
370364

371365

372366

373-
@pyqtSlot(int)
367+
374368
def onChangeSelectedRPC(self, i):
375369
# Don't update when we are clearing the box
376370
if not self.updatingRPCbox:
@@ -382,14 +376,14 @@ def onChangeSelectedRPC(self, i):
382376

383377

384378

385-
@pyqtSlot()
379+
386380
def onCleanConsole(self):
387381
self.consoleArea.clear()
388382

389383

390384

391385

392-
@pyqtSlot()
386+
393387
def onSaveConsole(self):
394388
timestamp = strftime('%Y-%m-%d_%H-%M-%S', gmtime(now()))
395389
options = QFileDialog.Options()
@@ -410,22 +404,26 @@ def onSaveConsole(self):
410404

411405

412406

413-
@pyqtSlot()
407+
414408
def onTabChange(self):
415409
# tabRewards
416410
if self.tabs.currentWidget() == self.tabRewards:
417411
# reload last used address
418-
self.tabRewards.destinationLine.setText(self.parent.cache.get("lastAddress"))
412+
self.tabRewards.destinationLine.setText(self.parent.cache.get("lastAddress"))
413+
# show UTXOs from DB
414+
self.t_rewards.display_mn_utxos()
419415

420416
# tabGovernace
421417
if self.tabs.currentWidget() == self.tabGovernance:
422418
# update selectedMNlabel (since we might have edited them)
423419
self.t_governance.updateSelectedMNlabel()
420+
# show proposals from DB
421+
self.t_governance.displayProposals()
424422

425423

426424

427425

428-
@pyqtSlot()
426+
429427
def onToggleConsole(self):
430428
if self.btn_consoleToggle.text() == 'Hide':
431429
self.btn_consoleToggle.setText('Show')
@@ -462,7 +460,8 @@ def showHWstatus(self):
462460

463461

464462

465-
@pyqtSlot(int, bool)
463+
464+
466465
def showRPCstatus(self, server_index, fDebug):
467466
# Update displayed status only if selected server is not changed
468467
if server_index == self.header.rpcClientsBox.currentIndex():
@@ -557,7 +556,7 @@ def updateRPCled(self, fDebug=False):
557556

558557

559558

560-
#@pyqtSlot()
559+
561560
def updateRPClist(self):
562561
# Clear old stuff
563562
self.updatingRPCbox = True

src/masternode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import time
77

88
from PyQt5.Qt import QObject
9-
from PyQt5.QtCore import pyqtSlot, pyqtSignal
9+
from PyQt5.QtCore import pyqtSignal
1010

1111
from constants import MPATH
1212
from misc import printOK, printDbg, printException, getCallerName, getFunctionName, ipport

src/misc.py

Lines changed: 44 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -100,31 +100,34 @@ def checkRPCstring(urlstring, action_msg="Malformed credentials"):
100100

101101

102102

103-
def clean_v4_migration(db):
104-
try:
105-
rpc_file = os.path.join(user_dir, 'rpcServer.json')
106-
cache_file = os.path.join(user_dir, 'cache.json')
107-
mn_file = os.path.join(user_dir, 'masternodes.json')
108-
109-
if os.path.exists(rpc_file) or os.path.exists(cache_file) or os.path.exists(mn_file):
110-
printDbg("Clean migration to v0.4.0 data storage")
111-
112-
if os.path.exists(rpc_file):
113-
# If RPC file exists
114-
printDbg("found old rpcServer.json file")
103+
def clean_v4_migration(wnd):
104+
rpc_file = os.path.join(user_dir, 'rpcServer.json')
105+
cache_file = os.path.join(user_dir, 'cache.json')
106+
mn_file = os.path.join(user_dir, 'masternodes.json')
107+
messTitle = "Clean migration to v0.4.0 data storage"
108+
109+
if os.path.exists(rpc_file) or os.path.exists(cache_file) or os.path.exists(mn_file):
110+
printDbg(messTitle)
111+
112+
if os.path.exists(rpc_file):
113+
# If RPC file exists
114+
try:
115115
with open(rpc_file) as data_file:
116116
rpc_config = json.load(data_file)
117117
# copy to database
118118
rpc_host = "%s:%d" % (rpc_config['rpc_ip'], rpc_config['rpc_port'])
119-
db.editRPCServer("http", rpc_host, rpc_config['rpc_user'], rpc_config['rpc_password'], 0)
119+
wnd.db.editRPCServer("http", rpc_host, rpc_config['rpc_user'], rpc_config['rpc_password'], 0)
120120
printDbg("...saved to Database")
121121
# and delete old file
122122
os.remove(rpc_file)
123123
printDbg("old rpcServer.json file deleted")
124-
125-
if os.path.exists(cache_file):
126-
# If cache file exists
127-
printDbg("found old cache.json file")
124+
except Exception as e:
125+
mess = "Error importing old rpc_config file"
126+
printException(getCallerName(), getFunctionName(), mess, e)
127+
128+
if os.path.exists(cache_file):
129+
# If cache file exists
130+
try:
128131
with open(cache_file) as data_file:
129132
cache = json.load(data_file)
130133
# copy to Settings
@@ -133,23 +136,25 @@ def clean_v4_migration(db):
133136
# and delete old file
134137
os.remove(cache_file)
135138
printDbg("old cache.json file deleted")
136-
137-
if os.path.exists(mn_file):
138-
# If mn file exists
139-
printDbg("found old masternodes.json file")
139+
except Exception as e:
140+
mess = "Error importing old cache file"
141+
printException(getCallerName(), getFunctionName(), mess, e)
142+
143+
if os.path.exists(mn_file):
144+
# If mn file exists
145+
try:
140146
with open(mn_file) as data_file:
141147
mnList = json.load(data_file)
142148
# add to database
143149
for mn in mnList:
144-
db.addMasternode(mn)
150+
wnd.db.addMasternode(mn)
145151
printDbg("...saved to Database")
146152
# and delete old file
147153
os.remove(mn_file)
148-
printDbg("old masternodes.json file deleted")
149-
150-
except Exception as e:
151-
printDbg(e)
152-
154+
printDbg("old masternodes.json file deleted")
155+
except Exception as e:
156+
mess = "Error importing old masternodes_config file"
157+
printException(getCallerName(), getFunctionName(), mess, e)
153158

154159

155160

@@ -442,24 +447,22 @@ def removeMNfromList(mainWnd, mn, removeFromDB=True):
442447
def saveCacheSettings(cache, old_version=False):
443448
settings = QSettings('PIVX', 'SecurePivxMasternodeTool')
444449
settings.setValue('cache_lastAddress', cache.get('lastAddress'))
445-
settings.setValue('cache_winWidth', cache.get('window_width'))
446-
settings.setValue('cache_winHeight', cache.get('window_height'))
447-
if old_version:
448-
settings.setValue('cache_splitterX', cache.get('splitter_sizes')[0])
449-
settings.setValue('cache_splitterY', cache.get('splitter_sizes')[1])
450-
else:
451-
settings.setValue('cache_splitterX', cache.get('splitter_x'))
452-
settings.setValue('cache_splitterY', cache.get('splitter_y'))
453-
settings.setValue('cache_mnOrder', json.dumps(cache.get('mnList_order')))
454-
settings.setValue('cache_consoleHidden', cache.get('console_hidden'))
455450
settings.setValue('cache_useSwiftX', cache.get('useSwiftX'))
456-
settings.setValue('cache_votingMNs', json.dumps(cache.get('votingMasternodes')))
457451
settings.setValue('cache_vdCheck', cache.get('votingDelayCheck'))
458452
settings.setValue('cache_vdNeg', cache.get('votingDelayNeg'))
459453
settings.setValue('cache_vdPos', cache.get('votingDelayPos'))
460-
if not old_version:
461-
settings.setValue('cache_RPCindex', cache.get('selectedRPC_index'))
462-
settings.setValue('cache_MNcount', cache.get('MN_count'))
454+
# that's enough for clean_v4_migration
455+
if old_version:
456+
return
457+
settings.setValue('cache_winWidth', cache.get('window_width'))
458+
settings.setValue('cache_winHeight', cache.get('window_height'))
459+
settings.setValue('cache_splitterX', cache.get('splitter_x'))
460+
settings.setValue('cache_splitterY', cache.get('splitter_y'))
461+
settings.setValue('cache_mnOrder', json.dumps(cache.get('mnList_order')))
462+
settings.setValue('cache_consoleHidden', cache.get('console_hidden'))
463+
settings.setValue('cache_votingMNs', json.dumps(cache.get('votingMasternodes')))
464+
settings.setValue('cache_RPCindex', cache.get('selectedRPC_index'))
465+
settings.setValue('cache_MNcount', cache.get('MN_count'))
463466

464467

465468

src/qt/dlg_budgetProjection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
3-
from PyQt5.QtCore import Qt, pyqtSlot
3+
from PyQt5.QtCore import Qt
44
from PyQt5.QtWidgets import QDialog, QVBoxLayout, QTableWidget, QAbstractItemView, QHeaderView, \
55
QTableWidgetItem, QPushButton, QLabel, QGroupBox, QHBoxLayout, QFormLayout
66

src/qt/dlg_configureRPCservers.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
3-
from PyQt5.QtCore import pyqtSlot
43
from PyQt5.QtWidgets import QDialog, QHBoxLayout, QVBoxLayout, QLabel,\
54
QListWidget, QFrame, QFormLayout, QComboBox, QLineEdit, QListWidgetItem,\
65
QWidget, QPushButton, QMessageBox
@@ -94,7 +93,7 @@ def loadEditFrame(self, index):
9493
self.ui.host_edt.setText(server['host'])
9594

9695

97-
@pyqtSlot(int)
96+
9897
def onAddServer(self, index=None):
9998
# Save current index (None for new entry)
10099
self.changing_index = index
@@ -112,7 +111,7 @@ def onAddServer(self, index=None):
112111
self.loadEditFrame(index)
113112

114113

115-
@pyqtSlot()
114+
116115
def onCancel(self):
117116
# Show 'Add' and 'Close' buttons and enable serversBox
118117
self.ui.addServer_btn.show()
@@ -124,13 +123,13 @@ def onCancel(self):
124123
self.clearEditFrame()
125124

126125

127-
@pyqtSlot()
126+
128127
def onClose(self):
129128
# close dialog
130129
self.close()
131130

132131

133-
@pyqtSlot(int)
132+
134133
def onRemoveServer(self, index):
135134
mess = "Are you sure you want to remove server with index %d (%s) from list?" % (
136135
index, self.main_wnd.mainWindow.rpcServersList[index].get('host'))
@@ -140,8 +139,7 @@ def onRemoveServer(self, index):
140139
self.main_wnd.db.removeRPCServer(index)
141140

142141

143-
144-
@pyqtSlot()
142+
145143
def onSave(self):
146144
# Get new config data
147145
protocol = "http" if self.ui.protocol_select.currentIndex() == 0 else "https"

0 commit comments

Comments
 (0)