bugfix
This commit is contained in:
		
							parent
							
								
									2ec5d060d3
								
							
						
					
					
						commit
						a9b50105a6
					
				
							
								
								
									
										76
									
								
								qt.py
									
									
									
									
									
								
							
							
						
						
									
										76
									
								
								qt.py
									
									
									
									
									
								
							| @ -331,7 +331,6 @@ _logger = get_logger(__name__) | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class Plugin(BalPlugin,Logger): | class Plugin(BalPlugin,Logger): | ||||||
| 
 |  | ||||||
|     def __init__(self, parent, config, name): |     def __init__(self, parent, config, name): | ||||||
|         Logger.__init__(self) |         Logger.__init__(self) | ||||||
|         self.logger.info("INIT BALPLUGIN") |         self.logger.info("INIT BALPLUGIN") | ||||||
| @ -764,14 +763,11 @@ class BalWindow(Logger): | |||||||
|     def show_critical(self,text): |     def show_critical(self,text): | ||||||
|         self.window.show_critical(text) |         self.window.show_critical(text) | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|     def init_heirs_to_locktime(self): |     def init_heirs_to_locktime(self): | ||||||
|         for heir in self.heirs: |         for heir in self.heirs: | ||||||
|             h=self.heirs[heir] |             h=self.heirs[heir] | ||||||
|             self.heirs[heir]=[h[0],h[1],self.will_settings['locktime']] |             self.heirs[heir]=[h[0],h[1],self.will_settings['locktime']] | ||||||
| 
 | 
 | ||||||
|      |  | ||||||
|     def init_class_variables(self): |     def init_class_variables(self): | ||||||
|             if not self.heirs: |             if not self.heirs: | ||||||
|                 raise NoHeirsException() |                 raise NoHeirsException() | ||||||
| @ -858,6 +854,7 @@ class BalWindow(Logger): | |||||||
|             return self.willitems |             return self.willitems | ||||||
|         except Exception as e: |         except Exception as e: | ||||||
|             raise e |             raise e | ||||||
|  | 
 | ||||||
|     def show_transaction_real( |     def show_transaction_real( | ||||||
|         self, |         self, | ||||||
|         tx: Transaction, |         tx: Transaction, | ||||||
| @ -968,7 +965,6 @@ class BalWindow(Logger): | |||||||
|                 password = self.get_wallet_password(message) |                 password = self.get_wallet_password(message) | ||||||
|         return password |         return password | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|     def on_close(self): |     def on_close(self): | ||||||
|         try: |         try: | ||||||
|             if not self.disable_plugin: |             if not self.disable_plugin: | ||||||
| @ -1144,11 +1140,13 @@ class BalWindow(Logger): | |||||||
|             else: |             else: | ||||||
|                 pinged.append(url) |                 pinged.append(url) | ||||||
|              |              | ||||||
|     def ping_willexecutors(self,wes): |     def ping_willexecutors(self,wes,parent=None): | ||||||
|  |         if not parent: | ||||||
|  |             parent=self | ||||||
|         def on_success(result): |         def on_success(result): | ||||||
|             del self.waiting_dialog |             del self.waiting_dialog | ||||||
|             try: |             try: | ||||||
|                 self.willexecutor_dialog.willexecutor_list.update() |                 parent.willexecutor_list.update() | ||||||
|             except Exception as e: |             except Exception as e: | ||||||
|                 _logger.error(f"error updating willexecutors {e}") |                 _logger.error(f"error updating willexecutors {e}") | ||||||
|                 pass |                 pass | ||||||
| @ -1177,9 +1175,7 @@ def add_widget(grid,label,widget,row,help_): | |||||||
|     grid.addWidget(widget,row,1) |     grid.addWidget(widget,row,1) | ||||||
|     grid.addWidget(HelpButton(help_),row,2) |     grid.addWidget(HelpButton(help_),row,2) | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| class HeirsLockTimeEdit(QWidget): | class HeirsLockTimeEdit(QWidget): | ||||||
| 
 |  | ||||||
|     valueEdited = pyqtSignal() |     valueEdited = pyqtSignal() | ||||||
|     locktime_threshold = 50000000 |     locktime_threshold = 50000000 | ||||||
|     def __init__(self, parent=None,default_index = 1): |     def __init__(self, parent=None,default_index = 1): | ||||||
| @ -1244,7 +1240,6 @@ class HeirsLockTimeEdit(QWidget): | |||||||
|     def set_locktime(self, x: Any,force=True) -> None: |     def set_locktime(self, x: Any,force=True) -> None: | ||||||
|         self.editor.set_locktime(x,force) |         self.editor.set_locktime(x,force) | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| class _LockTimeEditor: | class _LockTimeEditor: | ||||||
|     min_allowed_value = NLOCKTIME_MIN |     min_allowed_value = NLOCKTIME_MIN | ||||||
|     max_allowed_value = NLOCKTIME_MAX |     max_allowed_value = NLOCKTIME_MAX | ||||||
| @ -1264,9 +1259,7 @@ class _LockTimeEditor: | |||||||
|             return False |             return False | ||||||
|         return cls.min_allowed_value <= x <= cls.max_allowed_value |         return cls.min_allowed_value <= x <= cls.max_allowed_value | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| class LockTimeRawEdit(QLineEdit, _LockTimeEditor): | class LockTimeRawEdit(QLineEdit, _LockTimeEditor): | ||||||
| 
 |  | ||||||
|     def __init__(self, parent=None,time_edit=None): |     def __init__(self, parent=None,time_edit=None): | ||||||
|         QLineEdit.__init__(self, parent) |         QLineEdit.__init__(self, parent) | ||||||
|         self.setFixedWidth(14 * char_width_in_lineedit()) |         self.setFixedWidth(14 * char_width_in_lineedit()) | ||||||
| @ -1363,7 +1356,6 @@ class LockTimeHeightEdit(LockTimeRawEdit): | |||||||
|         painter.setPen(ColorScheme.GRAY.as_color()) |         painter.setPen(ColorScheme.GRAY.as_color()) | ||||||
|         painter.drawText(textRect, int(Qt.AlignRight | Qt.AlignVCenter), "height") |         painter.drawText(textRect, int(Qt.AlignRight | Qt.AlignVCenter), "height") | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| def get_max_allowed_timestamp() -> int: | def get_max_allowed_timestamp() -> int: | ||||||
|     ts = NLOCKTIME_MAX |     ts = NLOCKTIME_MAX | ||||||
|     # Test if this value is within the valid timestamp limits (which is platform-dependent). |     # Test if this value is within the valid timestamp limits (which is platform-dependent). | ||||||
| @ -1375,7 +1367,6 @@ def get_max_allowed_timestamp() -> int: | |||||||
|         datetime.fromtimestamp(ts)  # test if raises |         datetime.fromtimestamp(ts)  # test if raises | ||||||
|     return ts |     return ts | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| class LockTimeDateEdit(QDateTimeEdit, _LockTimeEditor): | class LockTimeDateEdit(QDateTimeEdit, _LockTimeEditor): | ||||||
|     min_allowed_value = NLOCKTIME_BLOCKHEIGHT_MAX + 1 |     min_allowed_value = NLOCKTIME_BLOCKHEIGHT_MAX + 1 | ||||||
|     max_allowed_value = get_max_allowed_timestamp() |     max_allowed_value = get_max_allowed_timestamp() | ||||||
| @ -1404,10 +1395,8 @@ class LockTimeDateEdit(QDateTimeEdit, _LockTimeEditor): | |||||||
|         dt = datetime.fromtimestamp(x) |         dt = datetime.fromtimestamp(x) | ||||||
|         self.setDateTime(dt) |         self.setDateTime(dt) | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| _NOT_GIVEN = object()  # sentinel value | _NOT_GIVEN = object()  # sentinel value | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| class PercAmountEdit(BTCAmountEdit): | class PercAmountEdit(BTCAmountEdit): | ||||||
|     def __init__(self, decimal_point, is_int=False, parent=None, *, max_amount=_NOT_GIVEN): |     def __init__(self, decimal_point, is_int=False, parent=None, *, max_amount=_NOT_GIVEN): | ||||||
|         super().__init__(decimal_point, is_int, parent, max_amount=max_amount) |         super().__init__(decimal_point, is_int, parent, max_amount=max_amount) | ||||||
| @ -1466,13 +1455,15 @@ class PercAmountEdit(BTCAmountEdit): | |||||||
|             if len(self.text())==0: |             if len(self.text())==0: | ||||||
|                 painter.drawText(textRect, int(Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter), self.base_unit() + " or perc value") |                 painter.drawText(textRect, int(Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter), self.base_unit() + " or perc value") | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| class BalDialog(WindowModalDialog): | class BalDialog(WindowModalDialog): | ||||||
| 
 |  | ||||||
|     def __init__(self,parent,title=None, icon = 'bal32x32.png'): |     def __init__(self,parent,title=None, icon = 'bal32x32.png'): | ||||||
|  |         #print("éééééééééééé") | ||||||
|  |         #print(parent) | ||||||
|  |         #print(dir(parent)) | ||||||
|  |         #print("éééééééééééééééééé") | ||||||
|         self.parent=parent |         self.parent=parent | ||||||
|         WindowModalDialog.__init__(self,self.parent,title) |         WindowModalDialog.__init__(self,parent,title) | ||||||
|  |         #WindowModalDialog.__init__(self,parent) | ||||||
|         self.setWindowIcon(read_bal_QIcon(icon)) |         self.setWindowIcon(read_bal_QIcon(icon)) | ||||||
| 
 | 
 | ||||||
| class BalWizardDialog(BalDialog): | class BalWizardDialog(BalDialog): | ||||||
| @ -1527,7 +1518,6 @@ class BalWizardDialog(BalDialog): | |||||||
|         print("close event") |         print("close event") | ||||||
|         pass |         pass | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| class BalWizardWidget(QWidget): | class BalWizardWidget(QWidget): | ||||||
|     title = None |     title = None | ||||||
|     message = None |     message = None | ||||||
| @ -1588,7 +1578,6 @@ class BalWizardWidget(QWidget): | |||||||
|     def validate(self): |     def validate(self): | ||||||
|         return True |         return True | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| class BalWizardHeirsWidget(BalWizardWidget): | class BalWizardHeirsWidget(BalWizardWidget): | ||||||
|     title="Bitcoin After Life Heirs" |     title="Bitcoin After Life Heirs" | ||||||
|     message="Please add your heirs\n remember that 100% of wallet balance will be spent" |     message="Please add your heirs\n remember that 100% of wallet balance will be spent" | ||||||
| @ -1637,10 +1626,22 @@ class BalWizardWEDownloadWidget(BalWizardWidget): | |||||||
|         index = self.combo.currentIndex() |         index = self.combo.currentIndex() | ||||||
|         _logger.debug(f"selected index:{index}") |         _logger.debug(f"selected index:{index}") | ||||||
|         if index < 2: |         if index < 2: | ||||||
|             willexecutors = Willexecutors.download_list(self.bal_window.bal_plugin) |             def on_success(willexecutors): | ||||||
|  |                 self.bal_window.willexecutors.update(willexecutors) | ||||||
|  |                 self.bal_window.ping_willexecutors(self.bal_window.willexecutors) | ||||||
|                 if index < 1: |                 if index < 1: | ||||||
|                 for we in willexecutors.values(): |                     for we in self.bal_window.willexecutors: | ||||||
|                     we['selected']=True |                         if self.bal_window.willexecutors[we]['status']==200: | ||||||
|  |                             self.bal_window.willexecutors[we]['selected']=True | ||||||
|  |                 Willexecutors.save(self.bal_window.bal_plugin,self.bal_window.willexecutors) | ||||||
|  |             def on_failure(fail): | ||||||
|  |                 print(f"fail") | ||||||
|  |                 pass | ||||||
|  | 
 | ||||||
|  |             task = partial(Willexecutors.download_list,self.bal_window.bal_plugin) | ||||||
|  |             msg = _("Downloading Will-Executors list") | ||||||
|  |             self.waiting_dialog = BalWaitingDialog(self.bal_window, msg, task, on_success, on_failure,exe=False) | ||||||
|  |             self.waiting_dialog.exe() | ||||||
|              |              | ||||||
|         elif index == 2: |         elif index == 2: | ||||||
|             #TODO import from file |             #TODO import from file | ||||||
| @ -1782,8 +1783,6 @@ class BalWaitingDialog(BalDialog): | |||||||
|     def closeEvent(self,event): |     def closeEvent(self,event): | ||||||
|         self.thread.stop() |         self.thread.stop() | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| class BalBlockingWaitingDialog(BalDialog): | class BalBlockingWaitingDialog(BalDialog): | ||||||
|     def __init__(self, bal_window: 'BalWindow', message: str, task: Callable[[], Any]): |     def __init__(self, bal_window: 'BalWindow', message: str, task: Callable[[], Any]): | ||||||
|         BalDialog.__init__(self, bal_window, _("Please wait")) |         BalDialog.__init__(self, bal_window, _("Please wait")) | ||||||
| @ -1812,10 +1811,6 @@ class bal_checkbox(QCheckBox): | |||||||
|             variable.get() |             variable.get() | ||||||
|         self.stateChanged.connect(on_check) |         self.stateChanged.connect(on_check) | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| class BalBuildWillDialog(BalDialog): | class BalBuildWillDialog(BalDialog): | ||||||
|     updatemessage=pyqtSignal() |     updatemessage=pyqtSignal() | ||||||
|     def __init__(self,bal_window,parent=None): |     def __init__(self,bal_window,parent=None): | ||||||
| @ -2140,13 +2135,9 @@ class BalBuildWillDialog(BalDialog): | |||||||
| 
 | 
 | ||||||
|     def get_text(self): |     def get_text(self): | ||||||
|         return self.message_label.text() |         return self.message_label.text() | ||||||
| def ThreadStopped(Exception): |  | ||||||
|     pass |     pass | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| class HeirList(MyTreeView,MessageBoxMixin): | class HeirList(MyTreeView,MessageBoxMixin): | ||||||
| 
 |  | ||||||
|     class Columns(MyTreeView.BaseColumnsEnum): |     class Columns(MyTreeView.BaseColumnsEnum): | ||||||
|         NAME = enum.auto() |         NAME = enum.auto() | ||||||
|         ADDRESS = enum.auto() |         ADDRESS = enum.auto() | ||||||
| @ -2670,8 +2661,6 @@ def read_bal_QIcon(icon_basename: str=DEFAULT_ICON) -> QIcon: | |||||||
| def read_bal_QPixmap(icon_basename: str=DEFAULT_ICON) -> QPixmap: | def read_bal_QPixmap(icon_basename: str=DEFAULT_ICON) -> QPixmap: | ||||||
|     return QPixmap(icon_path(icon_basename)) |     return QPixmap(icon_path(icon_basename)) | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| class WillDetailDialog(BalDialog): | class WillDetailDialog(BalDialog): | ||||||
|     def __init__(self, bal_window): |     def __init__(self, bal_window): | ||||||
| 
 | 
 | ||||||
| @ -2823,7 +2812,6 @@ class WillWidget(QWidget): | |||||||
|                 hlayout.addWidget(detailw) |                 hlayout.addWidget(detailw) | ||||||
|                 hlayout.addWidget(WillWidget(w,parent = parent)) |                 hlayout.addWidget(WillWidget(w,parent = parent)) | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| class WillExecutorList(MyTreeView): | class WillExecutorList(MyTreeView): | ||||||
|     class Columns(MyTreeView.BaseColumnsEnum): |     class Columns(MyTreeView.BaseColumnsEnum): | ||||||
|         SELECTED = enum.auto() |         SELECTED = enum.auto() | ||||||
| @ -2997,7 +2985,6 @@ class WillExecutorList(MyTreeView): | |||||||
|         except Exception as e: |         except Exception as e: | ||||||
|             _logger.error(e) |             _logger.error(e) | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| class WillExecutorWidget(QWidget,MessageBoxMixin): | class WillExecutorWidget(QWidget,MessageBoxMixin): | ||||||
|     def __init__(self,parent,bal_window,willexecutors=None): |     def __init__(self,parent,bal_window,willexecutors=None): | ||||||
|         self.bal_window=bal_window |         self.bal_window=bal_window | ||||||
| @ -3070,9 +3057,9 @@ class WillExecutorWidget(QWidget,MessageBoxMixin): | |||||||
| 
 | 
 | ||||||
|     def update_willexecutors(self,wes=None): |     def update_willexecutors(self,wes=None): | ||||||
|         if not wes: |         if not wes: | ||||||
|             self.willexecutors_list = Willexecutors.get_willexecutors(self.bal_plugin, update = True, bal_window = self.bal_window,force=True) |             self.willexecutors_list = Willexecutors.get_willexecutors(self.bal_plugin, update = True, bal_window = self.bal_window,force=True,task=self) | ||||||
|         else: |         else: | ||||||
|             self.bal_window.ping_willexecutors(wes) |             self.bal_window.ping_willexecutors(wes,self.parent) | ||||||
|             self.willexecutors_list.update(wes) |             self.willexecutors_list.update(wes) | ||||||
|             self.willexecutor_list.update() |             self.willexecutor_list.update() | ||||||
| 
 | 
 | ||||||
| @ -3091,11 +3078,12 @@ class WillExecutorWidget(QWidget,MessageBoxMixin): | |||||||
|         Willexecutors.save(self.bal_window.bal_plugin, self.willexecutors_list) |         Willexecutors.save(self.bal_window.bal_plugin, self.willexecutors_list) | ||||||
| 
 | 
 | ||||||
| class WillExecutorDialog(BalDialog,MessageBoxMixin): | class WillExecutorDialog(BalDialog,MessageBoxMixin): | ||||||
|     def __init__(self, bal_window): |     def __init__(self, bal_window,parent=None): | ||||||
|         BalDialog.__init__(self,bal_window.window) |         if not parent: | ||||||
|  |             parent=bal_window.window | ||||||
|  |         BalDialog.__init__(self,parent) | ||||||
|         self.bal_plugin = bal_window.bal_plugin |         self.bal_plugin = bal_window.bal_plugin | ||||||
|         self.config = self.bal_plugin.config |         self.config = self.bal_plugin.config | ||||||
|         self.window = bal_window.window |  | ||||||
|         self.bal_window = bal_window |         self.bal_window = bal_window | ||||||
|         self.willexecutors_list = Willexecutors.get_willexecutors(self.bal_plugin) |         self.willexecutors_list = Willexecutors.get_willexecutors(self.bal_plugin) | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -18,7 +18,6 @@ class Willexecutors: | |||||||
|     def save(bal_plugin, willexecutors): |     def save(bal_plugin, willexecutors): | ||||||
|         aw=bal_plugin.WILLEXECUTORS.get() |         aw=bal_plugin.WILLEXECUTORS.get() | ||||||
|         aw[constants.net.NET_NAME]=willexecutors |         aw[constants.net.NET_NAME]=willexecutors | ||||||
|         print("save",aw) |  | ||||||
|         bal_plugin.WILLEXECUTORS.set(aw) |         bal_plugin.WILLEXECUTORS.set(aw) | ||||||
| 
 | 
 | ||||||
|     def get_willexecutors(bal_plugin, update = False,bal_window=False,force=False,task=True): |     def get_willexecutors(bal_plugin, update = False,bal_window=False,force=False,task=True): | ||||||
| @ -46,7 +45,7 @@ class Willexecutors: | |||||||
| 
 | 
 | ||||||
|                     if ping_willexecutors: |                     if ping_willexecutors: | ||||||
|                         if task: |                         if task: | ||||||
|                             bal_window.ping_willexecutors(willexecutors) |                             bal_window.ping_willexecutors(willexecutors,task) | ||||||
|                         else: |                         else: | ||||||
|                             bal_window.ping_willexecutors_task(willexecutors) |                             bal_window.ping_willexecutors_task(willexecutors) | ||||||
|         w_sorted = dict(sorted(willexecutors.items(), key=lambda w:w[1].get('sort',0),reverse=True)) |         w_sorted = dict(sorted(willexecutors.items(), key=lambda w:w[1].get('sort',0),reverse=True)) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user