From 4d82201d0696c290a1c54ff765be20326e06831d Mon Sep 17 00:00:00 2001
From: Daniel Gretzke
Date: Sun, 8 Sep 2019 21:25:34 +0200
Subject: [PATCH] implemented disconnect button in payment channel screen
---
plug_py/plug.py | 24 ++++++++++++++++++++----
plug_py/qt/mainwindow.ui | 18 +++++++++++++++++-
plug_py/ui_mainwindow.py | 11 +++++++++--
3 files changed, 46 insertions(+), 7 deletions(-)
diff --git a/plug_py/plug.py b/plug_py/plug.py
index ceb1eb8..3ad383a 100644
--- a/plug_py/plug.py
+++ b/plug_py/plug.py
@@ -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
@@ -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
diff --git a/plug_py/qt/mainwindow.ui b/plug_py/qt/mainwindow.ui
index e44afe9..adde0a0 100644
--- a/plug_py/qt/mainwindow.ui
+++ b/plug_py/qt/mainwindow.ui
@@ -133,7 +133,7 @@ Smart Socket
color: white; background-color:rgba(255,0,0,0.5); border-radius: 4px; font-weight: bold; font-size: 20px
- Disconnect
+ End process
@@ -253,6 +253,22 @@ QListWidget::item:selected:disabled {
payment process
+
+
+
+ 290
+ 340
+ 220
+ 70
+
+
+
+ color: white; background-color:rgba(255,0,0,0.5); border-radius: 4px; font-weight: bold; font-size: 20px
+
+
+ Disconnect
+
+
diff --git a/plug_py/ui_mainwindow.py b/plug_py/ui_mainwindow.py
index 462ea30..290fb8e 100644
--- a/plug_py/ui_mainwindow.py
+++ b/plug_py/ui_mainwindow.py
@@ -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!
@@ -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)
@@ -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", "
TextLabel
", None, -1))
self.hourLabel.setText(QtWidgets.QApplication.translate(
@@ -129,3 +134,5 @@ def retranslateUi(self, MainWindow):
"MainWindow", "
", 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))