class BitcoindRestartLayout(QGridLayout): bitcoin: Bitcoin timer = QTimer def __init__(self, bitcoin: Bitcoin): super(BitcoindRestartLayout, self).__init__() self.timer = QTimer(self.parentWidget()) self.bitcoin = bitcoin columns = 2 self.section_name = SectionName('Restart Required') self.addWidget(self.section_name, column_span=columns) self.bitcoin_restart_required = WarningText('Bitcoin: ') self.addWidget(self.bitcoin_restart_required) self.bitcoin_restart_required.hide() self.bitcoin.file.file_watcher.fileChanged.connect( self.check_restart_required) self.timer.start(1000) self.timer.timeout.connect(self.check_restart_required) def check_restart_required(self): restart_required = self.bitcoin.restart_required self.bitcoin_restart_required.setText( f'Bitcoin: {self.bitcoin.restart_required}') if restart_required: self.section_name.show() self.bitcoin_restart_required.show() else: self.section_name.hide() self.bitcoin_restart_required.hide()
class LndRestartLayout(QGridLayout): node_set: NodeSet timer = QTimer def __init__(self, lnd: LndNode): super(LndRestartLayout, self).__init__() self.timer = QTimer(self.parentWidget()) self.lnd = lnd columns = 2 self.section_name = SectionName('Restart Required') self.addWidget(self.section_name, column_span=columns) self.lnd_restart_required = WarningText('Lnd: ') self.addWidget(self.lnd_restart_required, same_row=True, column=columns) self.lnd_restart_required.hide() # self.lnd.file.file_watcher.fileChanged.connect(self.check_restart_required) self.timer.start(1000) # self.timer.timeout.connect(self.check_restart_required) def check_restart_required(self): restart_required = self.lnd.restart_required self.lnd_restart_required.setText(f'Lnd: {self.lnd.restart_required}') if restart_required: self.section_name.show() self.lnd_restart_required.show() else: self.section_name.hide() self.lnd_restart_required.hide()
class LndPortsLayout(QGridLayout): def __init__(self, lnd: Lnd): super(LndPortsLayout, self).__init__() self.lnd = lnd self.network_ports = SectionName( f'Network Ports (for <a ' f'href="https://www.wikihow.com/Set-Up-Port-Forwarding-on-a-Router"' f'>port forwarding</a>)' ) self.addWidget(self.network_ports) self.lnd_network_port = SelectableText( f'LND network peer port: {self.lnd.node_port}' ) self.addWidget(self.lnd_network_port) self.addWidget(HorizontalLine()) self.client_ports = SelectableText( f'Client Ports (you can lose money port forwarding these!)' ) self.addWidget(self.client_ports) self.grpc_port = SelectableText( f'LND gRPC port: {self.lnd.grpc_port}' ) self.addWidget(self.grpc_port) self.rest_port = SelectableText( f'LND REST port: {self.lnd.rest_port}' ) self.addWidget(self.rest_port) self.lnd_restart_required = WarningText( 'Config file changed: Restart LND' ) self.addWidget(self.lnd_restart_required) self.lnd_restart_required.hide() self.lnd.file.file_watcher.fileChanged.connect(self.refresh_lnd_ports) def refresh_lnd_ports(self): self.lnd_network_port.setText( f'LND network peer port: {self.lnd.node_port}' ) self.grpc_port.setText( f'LND gRPC port: {self.lnd.grpc_port}' ) self.rest_port.setText( f'LND REST port: {self.lnd.rest_port}' ) self.check_restart_required() def check_restart_required(self): if self.lnd.restart_required: self.lnd_restart_required.show() else: self.lnd_restart_required.hide()
class BitcoindPortsLayout(QGridLayout): def __init__(self, bitcoin: Bitcoin): super(BitcoindPortsLayout, self).__init__() self.bitcoin = bitcoin self.network_ports = SectionName( f'Network Ports (for <a ' f'href="https://www.wikihow.com/Set-Up-Port-Forwarding-on-a-Router"' f'>port forwarding</a>)' ) self.bitcoin_network_port = SelectableText( f'Bitcoin network peer port: {self.bitcoin.node_port}' ) self.addWidget(self.network_ports) self.addWidget(self.bitcoin_network_port) self.addWidget(HorizontalLine()) self.client_ports = SelectableText( f'Client Ports (you can lose money port forwarding these!)' ) self.addWidget(self.client_ports) self.zmq_ports = SelectableText( f'Bitcoin ZMQ block/tx ports:' f' {self.bitcoin.zmq_block_port}' f'/{self.bitcoin.zmq_tx_port}' ) self.addWidget(self.zmq_ports) self.rpc_port = SelectableText( f'Bitcoin RPC port: {self.bitcoin.rpc_port}' ) self.addWidget(self.rpc_port) self.bitcoin_restart_required = WarningText( 'Config file changed: Restart Bitcoin' ) self.addWidget(self.bitcoin_restart_required) self.bitcoin_restart_required.hide() self.bitcoin.file.file_watcher.fileChanged.connect(self.refresh_bitcoin_ports) def refresh_bitcoin_ports(self): self.bitcoin_network_port.setText( f'Bitcoin network peer port: {self.bitcoin.node_port}' ) self.zmq_ports.setText( f'Bitcoin ZMQ block/tx ports:' f' {self.bitcoin.zmq_block_port}' f'/{self.bitcoin.zmq_tx_port}' ) self.rpc_port.setText( f'Bitcoin RPC port: {self.bitcoin.rpc_port}' ) self.check_restart_required() def check_restart_required(self): if self.bitcoin.restart_required: self.bitcoin_restart_required.show() else: self.bitcoin_restart_required.hide()