some fix to thread qdialog
This commit is contained in:
50
qt.py
50
qt.py
@@ -49,7 +49,7 @@ from PyQt6.QtWidgets import (QAbstractItemView, QCheckBox, QComboBox,
|
|||||||
QLineEdit, QTextEdit, QMenu, QMenuBar, QPushButton,
|
QLineEdit, QTextEdit, QMenu, QMenuBar, QPushButton,
|
||||||
QScrollArea, QSizePolicy, QSpinBox,
|
QScrollArea, QSizePolicy, QSpinBox,
|
||||||
QStackedWidget, QStyle, QStyleOptionFrame,
|
QStackedWidget, QStyle, QStyleOptionFrame,
|
||||||
QVBoxLayout, QWidget)
|
QVBoxLayout, QWidget,QDialog)
|
||||||
|
|
||||||
from .bal import BalPlugin,BalTimestamp
|
from .bal import BalPlugin,BalTimestamp
|
||||||
from .heirs import HEIR_DUST_AMOUNT, HEIR_REAL_AMOUNT, Heirs
|
from .heirs import HEIR_DUST_AMOUNT, HEIR_REAL_AMOUNT, Heirs
|
||||||
@@ -741,7 +741,7 @@ class BalWindow:
|
|||||||
self.init_heirs_to_locktime(self.bal_plugin.ENABLE_MULTIVERSE.get())
|
self.init_heirs_to_locktime(self.bal_plugin.ENABLE_MULTIVERSE.get())
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log_error(e, self)
|
log_error(e )
|
||||||
_logger.error(f"init_class_variables: {e}")
|
_logger.error(f"init_class_variables: {e}")
|
||||||
|
|
||||||
raise e
|
raise e
|
||||||
@@ -1124,18 +1124,20 @@ class BalWindow:
|
|||||||
def check_transactions_task(self, will):
|
def check_transactions_task(self, will):
|
||||||
start = time.time()
|
start = time.time()
|
||||||
for wid, w in will.items():
|
for wid, w in will.items():
|
||||||
self.waiting_dialog.update(
|
if w.we:
|
||||||
"checking transaction: {}\n willexecutor: {}".format(wid, w.we["url"])
|
self.waiting_dialog.update(
|
||||||
)
|
"checking transaction: {}\n willexecutor: {}".format(wid, w.we["url"])
|
||||||
|
)
|
||||||
|
|
||||||
w.set_check_willexecutor(Willexecutors.check_transaction(wid, w.we["url"]))
|
w.set_check_willexecutor(Willexecutors.check_transaction(wid, w.we["url"]))
|
||||||
|
|
||||||
if time.time() - start < 3:
|
if time.time() - start < 3:
|
||||||
time.sleep(3 - (time.time() - start))
|
time.sleep(3 - (time.time() - start))
|
||||||
|
|
||||||
def check_transactions(self, will):
|
def check_transactions(self, will):
|
||||||
def on_success(result):
|
def on_success(result):
|
||||||
del self.waiting_dialog
|
if hasattr(self,"waiting_dialog"):
|
||||||
|
del self.waiting_dialog
|
||||||
self.update_all()
|
self.update_all()
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -1172,7 +1174,7 @@ class BalWindow:
|
|||||||
fn_on_failure = log_error
|
fn_on_failure = log_error
|
||||||
welist_server = self.bal_plugin.WELIST_SERVER.get()
|
welist_server = self.bal_plugin.WELIST_SERVER.get()
|
||||||
task = partial(Willexecutors.download_list, willexecutors, welist_server)
|
task = partial(Willexecutors.download_list, willexecutors, welist_server)
|
||||||
msg = _(f"Downloadinf willexecutors list from {welist_server}")
|
msg = _(f"Downloading willexecutors list from {welist_server}")
|
||||||
self.waiting_dialog = BalWaitingDialog(
|
self.waiting_dialog = BalWaitingDialog(
|
||||||
self, msg, task, on_success, on_failure, exe=False
|
self, msg, task, on_success, on_failure, exe=False
|
||||||
)
|
)
|
||||||
@@ -1730,12 +1732,10 @@ class WillSettingsWidget(QWidget):
|
|||||||
days_difference = (locktime - threshold).days
|
days_difference = (locktime - threshold).days
|
||||||
|
|
||||||
heirs_details = "\r\n".join(f" {heir} - {self.bal_window.heirs[heir][0]}, {self.bal_window.heirs[heir][1]}" for heir in self.bal_window.heirs)
|
heirs_details = "\r\n".join(f" {heir} - {self.bal_window.heirs[heir][0]}, {self.bal_window.heirs[heir][1]}" for heir in self.bal_window.heirs)
|
||||||
print("heirs",heirs_details)
|
|
||||||
event_description = BalCalendar.ical_escape(
|
event_description = BalCalendar.ical_escape(
|
||||||
f"{self.bal_window.bal_plugin.EVENT_DESCRIPTION.get()}".replace("$wallet_name",str(self.bal_window.wallet)).replace("$heirs_complete",heirs_details)
|
f"{self.bal_window.bal_plugin.EVENT_DESCRIPTION.get()}".replace("$wallet_name",str(self.bal_window.wallet)).replace("$heirs_complete",heirs_details)
|
||||||
)
|
)
|
||||||
#event_description =f"{event_description}{heirs_details}"
|
#event_description =f"{event_description}{heirs_details}"
|
||||||
print("event description",event_description)
|
|
||||||
uid = f"bal-{str(self.bal_window.wallet)}"
|
uid = f"bal-{str(self.bal_window.wallet)}"
|
||||||
summary = BalCalendar.ical_escape(
|
summary = BalCalendar.ical_escape(
|
||||||
f"{self.bal_window.bal_plugin.EVENT_SUMMARY.get()}".replace("$wallet_name",str(self.bal_window.wallet))
|
f"{self.bal_window.bal_plugin.EVENT_SUMMARY.get()}".replace("$wallet_name",str(self.bal_window.wallet))
|
||||||
@@ -1759,7 +1759,6 @@ class WillSettingsWidget(QWidget):
|
|||||||
])
|
])
|
||||||
|
|
||||||
ics_content = "\r\n".join(lines) + "\r\n"
|
ics_content = "\r\n".join(lines) + "\r\n"
|
||||||
print(ics_content)
|
|
||||||
self.temp_path = BalCalendar.write_temp_ics(ics_content)
|
self.temp_path = BalCalendar.write_temp_ics(ics_content)
|
||||||
opened = BalCalendar.open_with_default_app(
|
opened = BalCalendar.open_with_default_app(
|
||||||
self.bal_window.bal_plugin.CALENDAR_APP.get(), self.temp_path
|
self.bal_window.bal_plugin.CALENDAR_APP.get(), self.temp_path
|
||||||
@@ -1874,24 +1873,25 @@ class PercAmountEdit(BTCAmountEdit):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class BalDialog(WindowModalDialog):
|
class BalDialog(QDialog,MessageBoxMixin):
|
||||||
def __init__(self, parent, bal_plugin, title=None, icon="icons/bal16x16.png"):
|
def __init__(self, parent, bal_plugin, title=None, icon="icons/bal16x16.png"):
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.thread = None
|
self.thread = None
|
||||||
WindowModalDialog.__init__(self, parent, title)
|
super().__init__(parent)
|
||||||
|
if title:
|
||||||
|
self.setWindowTitle(title)
|
||||||
# WindowModalDialog.__init__(self,parent)
|
# WindowModalDialog.__init__(self,parent)
|
||||||
#print(bal_plugin.read_file(icon))
|
self.setWindowIcon(read_QIcon_from_bytes(bal_plugin.read_file(icon)))
|
||||||
#self.setWindowIcon(read_QIcon_from_bytes(bal_plugin.read_file(icon)))
|
|
||||||
|
|
||||||
def closeEvent(self, event):
|
def closeEvent(self, event):
|
||||||
self._stopping = True
|
self._stopping = True
|
||||||
if self.thread:
|
#if self.thread:
|
||||||
self.thread.stop()
|
# self.thread.stop()
|
||||||
|
|
||||||
def hideEvent(self, event):
|
def hideEvent(self, event):
|
||||||
self._stopping = True
|
self._stopping = True
|
||||||
if self.thread:
|
#if self.thread:
|
||||||
self.thread.stop()
|
# self.thread.stop()
|
||||||
|
|
||||||
|
|
||||||
class BalWizardDialog(BalDialog):
|
class BalWizardDialog(BalDialog):
|
||||||
@@ -2714,6 +2714,7 @@ class BalBuildWillDialog(BalDialog):
|
|||||||
button.clicked.connect(self.close)
|
button.clicked.connect(self.close)
|
||||||
self.vbox.addWidget(button)
|
self.vbox.addWidget(button)
|
||||||
self.resize(self.vbox.sizeHint()+button.sizeHint()*2)
|
self.resize(self.vbox.sizeHint()+button.sizeHint()*2)
|
||||||
|
self.repaint()
|
||||||
def on_error_phase2(self, error):
|
def on_error_phase2(self, error):
|
||||||
self.bal_window.upade_all()
|
self.bal_window.upade_all()
|
||||||
a, b, c = error
|
a, b, c = error
|
||||||
@@ -3996,7 +3997,8 @@ class CheckAliveError(Exception):
|
|||||||
|
|
||||||
def log_error(exec_info, window=None):
|
def log_error(exec_info, window=None):
|
||||||
_logger.error(exec_info)
|
_logger.error(exec_info)
|
||||||
tb = traceback.format_exc()
|
#tb = traceback.format_exc()
|
||||||
|
tb=exec_info[1]
|
||||||
_logger.error(tb)
|
_logger.error(tb)
|
||||||
if window is not None:
|
if window is not None:
|
||||||
window.show_error(exec_info)
|
window.show_error(exec_info)
|
||||||
@@ -4058,28 +4060,22 @@ class BalCalendar:
|
|||||||
.replace(b";", b"\\;")
|
.replace(b";", b"\\;")
|
||||||
.replace(b",", b"\\,")
|
.replace(b",", b"\\,")
|
||||||
)
|
)
|
||||||
print("escaped",text)
|
|
||||||
out =""
|
out =""
|
||||||
temp=text.split(b"\r\n")
|
temp=text.split(b"\r\n")
|
||||||
print("temp",temp)
|
|
||||||
for s in temp:
|
for s in temp:
|
||||||
encoded= s
|
encoded= s
|
||||||
print("encoded",encoded)
|
|
||||||
cut =0
|
cut =0
|
||||||
while len(encoded) >75:
|
while len(encoded) >75:
|
||||||
cut+=5
|
cut+=5
|
||||||
encoded=f"{s[:len(s)-cut]}"
|
encoded=f"{s[:len(s)-cut]}"
|
||||||
print("encoded -1",encoded[-1])
|
|
||||||
if encoded[-1]==b"\\" and encoded[-2]!=b"\\\\":
|
if encoded[-1]==b"\\" and encoded[-2]!=b"\\\\":
|
||||||
cut += 1
|
cut += 1
|
||||||
encoded=f"{s[:len(s)-cut]}"
|
encoded=f"{s[:len(s)-cut]}"
|
||||||
encoded=f"{encoded}...\r\n".encode("utf-8")
|
encoded=f"{encoded}...\r\n".encode("utf-8")
|
||||||
print("cut",encoded,cut)
|
|
||||||
if cut>0:
|
if cut>0:
|
||||||
out+=str(f"{s[:len(s)-cut].decode()}...\r\n")
|
out+=str(f"{s[:len(s)-cut].decode()}...\r\n")
|
||||||
else:
|
else:
|
||||||
out+=str(f"{s.decode()}\r\n")
|
out+=str(f"{s.decode()}\r\n")
|
||||||
print("out",out)
|
|
||||||
|
|
||||||
return out[:-2]
|
return out[:-2]
|
||||||
|
|
||||||
|
|||||||
@@ -131,6 +131,8 @@ class Willexecutors:
|
|||||||
def send_request(
|
def send_request(
|
||||||
method, url, data=None, *, timeout=10, handle_response=None, count_reply=0
|
method, url, data=None, *, timeout=10, handle_response=None, count_reply=0
|
||||||
):
|
):
|
||||||
|
import time
|
||||||
|
time.sleep(10)
|
||||||
network = Network.get_instance()
|
network = Network.get_instance()
|
||||||
if not network:
|
if not network:
|
||||||
raise Exception("You are offline.")
|
raise Exception("You are offline.")
|
||||||
|
|||||||
Reference in New Issue
Block a user