Skip to content

Commit

Permalink
implemented disconnect button in payment channel screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Gretzke committed Sep 8, 2019
1 parent f073846 commit 4d82201
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 7 deletions.
24 changes: 20 additions & 4 deletions plug_py/plug.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def __init__(self, parent=None):
self.ui.startButton.clicked.connect(self.connectWS)
self.ui.selectButton.clicked.connect(self.getMaxSeconds)
self.ui.acceptPriceButton.clicked.connect(self.acceptPrice)
self.ui.disconnectButton.clicked.connect(self.rejectPrice)
self.ui.rejectButton.clicked.connect(self.rejectPrice)
self.ui.disconnectButton.clicked.connect(self.disconnect)
self.ui.pcClosedButton.clicked.connect(self.resetToStart)

itemHeight = self.ui.hourList.height()/5
Expand Down Expand Up @@ -213,11 +214,26 @@ def resetToStart(self):
self.ui.pcClosedButton.setVisible(False)
self.ui.startButton.setVisible(True)

def disconnect(self):
self.ws_thread.paymentState = State.closed

def closeEvent(self, event):
# cleanup and end threads
self.terminateThread('node_thread')
self.terminateThread('ws_thread')
self.terminateThread('cm_thread')
try:
self.node_thread.threadActive = False
self.node_thread.wait()
except:
pass
try:
self.ws_thread.threadActive = False
self.ws_thread.wait()
except:
pass
try:
self.cm_thread.threadActive = False
self.cm_thread.wait()
except:
pass
# GPIO.cleanup()
event.accept() # let the window close

Expand Down
18 changes: 17 additions & 1 deletion plug_py/qt/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Smart Socket</string>
<string notr="true">color: white; background-color:rgba(255,0,0,0.5); border-radius: 4px; font-weight: bold; font-size: 20px</string>
</property>
<property name="text">
<string>Disconnect</string>
<string>End process</string>
</property>
</widget>
<widget class="QLabel" name="ampsLabel">
Expand Down Expand Up @@ -253,6 +253,22 @@ QListWidget::item:selected:disabled {
payment process</string>
</property>
</widget>
<widget class="QPushButton" name="rejectButton">
<property name="geometry">
<rect>
<x>290</x>
<y>340</y>
<width>220</width>
<height>70</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">color: white; background-color:rgba(255,0,0,0.5); border-radius: 4px; font-weight: bold; font-size: 20px</string>
</property>
<property name="text">
<string>Disconnect</string>
</property>
</widget>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
Expand Down
11 changes: 9 additions & 2 deletions plug_py/ui_mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Form implementation generated from reading ui file 'qt/mainwindow.ui',
# licensing of 'qt/mainwindow.ui' applies.
#
# Created: Sun Sep 8 20:12:44 2019
# Created: Sun Sep 8 21:24:25 2019
# by: pyside2-uic running on PySide2 5.13.1
#
# WARNING! All changes made in this file will be lost!
Expand Down Expand Up @@ -98,6 +98,11 @@ def setupUi(self, MainWindow):
self.pcClosedButton.setStyleSheet(
"color: rgb(50, 50, 50); background-color: rgba(0,255, 0, 0.75); border: none; font-size: 32px; border-radius:5px; font-weight: bold;")
self.pcClosedButton.setObjectName("pcClosedButton")
self.rejectButton = QtWidgets.QPushButton(self.centralWidget)
self.rejectButton.setGeometry(QtCore.QRect(290, 340, 220, 70))
self.rejectButton.setStyleSheet(
"color: white; background-color:rgba(255,0,0,0.5); border-radius: 4px; font-weight: bold; font-size: 20px")
self.rejectButton.setObjectName("rejectButton")
MainWindow.setCentralWidget(self.centralWidget)

self.retranslateUi(MainWindow)
Expand All @@ -120,7 +125,7 @@ def retranslateUi(self, MainWindow):
self.acceptPriceButton.setText(QtWidgets.QApplication.translate(
"MainWindow", "Accept Price", None, -1))
self.disconnectButton.setText(QtWidgets.QApplication.translate(
"MainWindow", "Disconnect", None, -1))
"MainWindow", "End process", None, -1))
self.ampsLabel.setText(QtWidgets.QApplication.translate(
"MainWindow", "<html><head/><body><p><span style=\" font-size:18pt;\">TextLabel</span></p></body></html>", None, -1))
self.hourLabel.setText(QtWidgets.QApplication.translate(
Expand All @@ -129,3 +134,5 @@ def retranslateUi(self, MainWindow):
"MainWindow", "<html><head/><body><p><br/></p></body></html>", None, -1))
self.pcClosedButton.setText(QtWidgets.QApplication.translate("MainWindow", "Start a new\n"
"payment process", None, -1))
self.rejectButton.setText(QtWidgets.QApplication.translate(
"MainWindow", "Disconnect", None, -1))

0 comments on commit 4d82201

Please sign in to comment.