From 886b9fa87ed815d98ee60b00e2e8cf6796c2afd0 Mon Sep 17 00:00:00 2001 From: sinus Date: Thu, 19 Dec 2024 12:53:04 +0100 Subject: [PATCH] add btn show/hide for wallet encryptpass --- application.py | 116 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 87 insertions(+), 29 deletions(-) diff --git a/application.py b/application.py index b8b98f2..7100543 100755 --- a/application.py +++ b/application.py @@ -72,6 +72,7 @@ from PySide6.QtPdf import QPdfDocument from PySide6.QtPdfWidgets import QPdfView from PySide6.QtWebSockets import QWebSocket from PySide6.QtWidgets import ( + QAbstractItemView, QApplication, QDialog, QDialogButtonBox, @@ -80,8 +81,9 @@ from PySide6.QtWidgets import ( QFrame, QGraphicsOpacityEffect, QGridLayout, -# QHBoxLayout, -# QInputDialog, + QHeaderView, + QHBoxLayout, + # QInputDialog, QLabel, QLineEdit, QMainWindow, @@ -93,11 +95,10 @@ from PySide6.QtWidgets import ( QSystemTrayIcon, QTableView, QTabWidget, + QToolButton, QToolBar, QVBoxLayout, - QWidget, - QAbstractItemView, - QHeaderView + QWidget ) from queue import Queue from solders.account_decoder import ( @@ -228,7 +229,7 @@ APP_FULL_NAME: str = "Khadhroony Solana Raydium Liquidity Pool v4 Trading App" """Application Full Name""" APP_DESC: str = "Khadhroony Solana Raydium Liquidity Pool v4 Trading Application" """Application Version""" -APP_VERSION_INFO = ('1', '0', '0') +APP_VERSION_INFO = ('1', '0', '1') APP_VERSION = '.'.join(APP_VERSION_INFO) """Application Name + Version""" APP_NAME_VERSION = "Khadhroony Solana Raydium Liquidity Pool v4 Trading Application @ " + APP_VERSION @@ -1050,14 +1051,14 @@ class ConnectionPool(QObject): self.wsConnexionStatusSigs = [] # changement de status de connexion pour pour _wsClients[i] for _ in range(self._num_ws_clients): self.wsConnexionStatusSigs.append(SocketStateSignal()) - self.httpMsgSentSigs = [] # message envoyé via httpClient - self.httpMsgReceivedSigs = [] # nouveau message via httpClient + self.httpPostSentSigs = [] # message envoyé via httpClient + self.httpReplyReceivedSigs = [] # nouveau message via httpClient for _ in range(self._num_async_http_clients): - self.httpMsgSentSigs.append(SimpleSignal()) - self.httpMsgReceivedSigs.append(SimpleSignal()) - self.wsMainMessageReceivedSig = SimpleSignal() # nouveau message reçu et stocké pour _wsMainClient - self.wsMessageReceivedSig = SimpleSignal() # nouveau ws message reçu et stocké pour _wsClients[i] - self.httpMessageReceivedSig = SimpleSignal() # nouveau ws message reçu et stocké pour _asyncHttpClients[i] + self.httpPostSentSigs.append(SimpleSignal()) + self.httpReplyReceivedSigs.append(SimpleSignal()) + self.wsMainReplyReceivedSig = SimpleSignal() # nouveau message reçu et stocké pour _wsMainClient + self.wsReplyReceivedSig = SimpleSignal() # nouveau ws message reçu et stocké pour _wsClients[i] + self.httpReplyReceivedSig = SimpleSignal() # nouveau ws message reçu et stocké pour _asyncHttpClients[i] # connexion des signaux des clients self._wsMainClient.socketStateSig.conn(self._handle_ws_main_connect_status) self._wsMainClient.socketErrorSig.conn(self._handle_ws_main_error) @@ -1186,7 +1187,7 @@ class ConnectionPool(QObject): timestamp = datetime.now() self._wsMainReceivedMessages.append((timestamp, resp)) self._currentDataSize += len(resp.encode("utf-8")) - self.wsMainMessageReceivedSig.signal() + self.wsMainReplyReceivedSig.signal() def _handle_ws_new_msg(self): """ Handle _wsClients[index].responseOkSig """ @@ -1196,14 +1197,14 @@ class ConnectionPool(QObject): timestamp = datetime.now() self._wsReceivedMessages.append((timestamp, resp)) self._currentDataSize += len(resp.encode("utf-8")) - self.wsMessageReceivedSig.signal() + self.wsReplyReceivedSig.signal() return handler def _handle_async_http_msg_sent(self, index: int): """ Handle _asyncHttpClients[index].requestSentSig """ def handler(): """ handler for Signal """ - self.httpMsgSentSigs[index].signal() + self.httpPostSentSigs[index].signal() return handler @@ -1234,8 +1235,8 @@ class ConnectionPool(QObject): timestamp = datetime.now() self._httpReceivedMessages.append((timestamp, reply.body)) self._currentDataSize += reply.size - self.httpMsgReceivedSigs[index].signal() - self.httpMessageReceivedSig.signal() + self.httpReplyReceivedSigs[index].signal() + self.httpReplyReceivedSig.signal() return handler def _start(self): @@ -2471,7 +2472,20 @@ class NewWalletNameAndPassDialog(QDialog): self._walletEncyptPass_Qle = QLineEdit() self._walletEncyptPass_Qle.setEchoMode(QLineEdit.EchoMode.Password) main_qflo.addRow(self.tr("Wallet Name:"), self._walletName_Qle) - main_qflo.addRow(self.tr("Wallet EncryptPass:"), self._walletEncyptPass_Qle) + # main_qflo.addRow(self.tr("Wallet EncryptPass:"), self._walletEncyptPass_Qle) + # Password toggle button + self._toggle_qtbtn = QToolButton() + self._toggle_qtbtn.setIcon(QIcon(":icoEyeShow")) # Replace with the actual eye icon path + self._toggle_qtbtn.setCheckable(True) + self._toggle_qtbtn.setToolTip(self.tr("Show/Hide Password")) + self._toggle_qtbtn.clicked.connect(self._toggle_password_visibility) + + # Add Wallet EncryptPass field and toggle button to layout + pass_layout = QHBoxLayout() + pass_layout = QHBoxLayout() + pass_layout.addWidget(self._walletEncyptPass_Qle) + pass_layout.addWidget(self._toggle_qtbtn) + main_qflo.addRow(self.tr("Wallet EncryptPass:"), pass_layout) validate_qpbtn = QPushButton(self.tr("Validate")) cancel_qpbtn = QPushButton(self.tr("Cancel")) @@ -2489,6 +2503,18 @@ class NewWalletNameAndPassDialog(QDialog): self.walletName = None self.walletEncyptPass = None + def _toggle_password_visibility(self): + """ + Toggle the password visibility in the QLineEdit + """ + is_visible = self._walletEncyptPass_Qle.echoMode() == QLineEdit.EchoMode.Normal + if is_visible: + self._walletEncyptPass_Qle.setEchoMode(QLineEdit.EchoMode.Password) + self._toggle_qtbtn.setIcon(QIcon(":icoEyeShow")) + else: + self._walletEncyptPass_Qle.setEchoMode(QLineEdit.EchoMode.Normal) + self._toggle_qtbtn.setIcon(QIcon(":icoEyeHide")) + def _validate_and_accept(self): """ validation of the QLineEdit contents @@ -2515,6 +2541,8 @@ class NewWalletNameAndPassDialog(QDialog): fired on show event """ super().showEvent(event) + size = self.size() + self.setFixedSize(size) center_on_screen(self) @@ -2545,6 +2573,8 @@ class NewWalletFileDialog(QFileDialog): fired on show event """ super().showEvent(event) + size = self.size() + self.setMinimumSize(size) center_on_screen(self) @@ -2562,7 +2592,19 @@ class LoadWalletPassDialog(QDialog): self.setLayout(main_qflo) self._walletEncyptPass_Qle = QLineEdit() self._walletEncyptPass_Qle.setEchoMode(QLineEdit.EchoMode.Password) - main_qflo.addRow(self.tr("Wallet EncryptPass:"), self._walletEncyptPass_Qle) + # main_qflo.addRow(self.tr("Wallet EncryptPass:"), self._walletEncyptPass_Qle) + # Password toggle button + self._toggle_qtbtn = QToolButton() + self._toggle_qtbtn.setIcon(QIcon(":icoEyeShow")) # Replace with the actual eye icon path + self._toggle_qtbtn.setCheckable(True) + self._toggle_qtbtn.setToolTip(self.tr("Show/Hide Password")) + self._toggle_qtbtn.clicked.connect(self._toggle_password_visibility) + + # Add Wallet EncryptPass field and toggle button to layout + pass_layout = QHBoxLayout() + pass_layout.addWidget(self._walletEncyptPass_Qle) + pass_layout.addWidget(self._toggle_qtbtn) + main_qflo.addRow(self.tr("Wallet EncryptPass:"), pass_layout) validate_qpbtn = QPushButton(self.tr("Validate")) cancel_qpbtn = QPushButton(self.tr("Cancel")) @@ -2575,6 +2617,18 @@ class LoadWalletPassDialog(QDialog): main_qflo.addWidget(button_qdbbox) self.walletEncyptPass = None + def _toggle_password_visibility(self): + """ + Toggle the password visibility in the QLineEdit + """ + is_visible = self._walletEncyptPass_Qle.echoMode() == QLineEdit.EchoMode.Normal + if is_visible: + self._walletEncyptPass_Qle.setEchoMode(QLineEdit.EchoMode.Password) + self._toggle_qtbtn.setIcon(QIcon(":icoEyeShow")) + else: + self._walletEncyptPass_Qle.setEchoMode(QLineEdit.EchoMode.Normal) + self._toggle_qtbtn.setIcon(QIcon(":icoEyeHide")) + def _validate_and_accept(self): """ validation of the QLineEdit content @@ -2594,6 +2648,8 @@ class LoadWalletPassDialog(QDialog): fired on show event """ super().showEvent(event) + size = self.size() + self.setFixedSize(size) center_on_screen(self) @@ -2624,6 +2680,8 @@ class LoadWalletFileDialog(QFileDialog): fired on show event """ super().showEvent(event) + size = self.size() + self.setMinimumSize(size) center_on_screen(self) @@ -3360,8 +3418,8 @@ class MainWindow(QMainWindow): self.wsCnxImgs = [] self.httpMsgImgs = [] # self.main_Qstb.addPermanentWidget(self._get_vertical_separator()) - self.netReachabilityImg = QLabel() - self.netReachabilityImg.setPixmap(self.reachabilityUnknown_Qpxm.scaled(16, 16, Qt.AspectRatioMode.KeepAspectRatio)) + # self.netReachabilityImg = QLabel() + # self.netReachabilityImg.setPixmap(self.reachabilityUnknown_Qpxm.scaled(16, 16, Qt.AspectRatioMode.KeepAspectRatio)) # if self.connPool.check_reachability() == QNetworkInformation.Reachability.Online: # self.netReachabilityImg.setPixmap(self.reachabilityOnline_Qpxm.scaled(16, 16, Qt.AspectRatioMode.KeepAspectRatio)) # elif self.connPool.check_reachability() == QNetworkInformation.Reachability.Site: @@ -3372,9 +3430,9 @@ class MainWindow(QMainWindow): # self.netReachabilityImg.setPixmap(self.reachabilityDisconnected_Qpxm.scaled(16, 16, Qt.AspectRatioMode.KeepAspectRatio)) # elif self.connPool.check_reachability() == QNetworkInformation.Reachability.Unknown: # self.netReachabilityImg.setPixmap(self.reachabilityUnknown_Qpxm.scaled(16, 16, Qt.AspectRatioMode.KeepAspectRatio)) - self.main_Qstb.addWidget(self.netReachabilityImg) + # self.main_Qstb.addWidget(self.netReachabilityImg) # self.connPool.reachabilitySig.conn(self._update_reachability_status) - self.main_Qstb.addWidget(self._get_vertical_separator()) + # self.main_Qstb.addWidget(self._get_vertical_separator()) self.wsMainCnxImg = QLabel() self.wsMainCnxImg.setPixmap(self.wsDisconnected_Qpxm.scaled(16, 16, Qt.AspectRatioMode.KeepAspectRatio)) self.main_Qstb.addWidget(self.wsMainCnxImg) @@ -3394,8 +3452,8 @@ class MainWindow(QMainWindow): self.httpMsgImgs.append(lbl) self.main_Qstb.addWidget(lbl) # Connecter le signal - self.connPool.httpMsgSentSigs[idx].conn(lambda cid = idx: self.update_http_pxm_sent(cid)) - self.connPool.httpMsgReceivedSigs[idx].conn(lambda cid = idx: self.update_http_pxm_received(cid)) + self.connPool.httpPostSentSigs[idx].conn(lambda cid = idx: self.update_http_pxm_sent(cid)) + self.connPool.httpReplyReceivedSigs[idx].conn(lambda cid = idx: self.update_http_pxm_received(cid)) self.main_Qstb.addPermanentWidget(self._get_vertical_separator()) @@ -3412,9 +3470,9 @@ class MainWindow(QMainWindow): self.statusMsg_Qled.setText(self.tr("Ready")) self.main_Qstb.addPermanentWidget(self.statusMsg_Qled) - self.connPool.wsMainMessageReceivedSig.conn(self.read_ws_main_sol_msg) - self.connPool.wsMessageReceivedSig.conn(self.read_ws_sol_msg) - self.connPool.httpMessageReceivedSig.conn(self.read_http_sol_msg) + self.connPool.wsMainReplyReceivedSig.conn(self.read_ws_main_sol_msg) + self.connPool.wsReplyReceivedSig.conn(self.read_ws_sol_msg) + self.connPool.httpReplyReceivedSig.conn(self.read_http_sol_msg) self.update_display() logger.success(self.tr("Init of {appName}").format(appName = APP_ABOUT_NAME))