Browse Source

fix #6111, and show channels tab even if lightning is disabled (follow-up 527e0b9b89)

master
ThomasV 5 years ago
parent
commit
ab5338b46b
  1. 15
      electrum/gui/qt/channels_list.py
  2. 6
      electrum/gui/qt/main_window.py

15
electrum/gui/qt/channels_list.py

@ -11,7 +11,7 @@ from PyQt5.QtGui import QFont, QStandardItem, QBrush
from electrum.util import bh2u, NotEnoughFunds, NoDynamicFeeEstimates from electrum.util import bh2u, NotEnoughFunds, NoDynamicFeeEstimates
from electrum.i18n import _ from electrum.i18n import _
from electrum.lnchannel import Channel, PeerState from electrum.lnchannel import AbstractChannel, PeerState
from electrum.wallet import Abstract_Wallet from electrum.wallet import Abstract_Wallet
from electrum.lnutil import LOCAL, REMOTE, format_short_channel_id, LN_MAX_FUNDING_SAT from electrum.lnutil import LOCAL, REMOTE, format_short_channel_id, LN_MAX_FUNDING_SAT
from electrum.lnworker import LNWallet from electrum.lnworker import LNWallet
@ -26,7 +26,7 @@ ROLE_CHANNEL_ID = Qt.UserRole
class ChannelsList(MyTreeView): class ChannelsList(MyTreeView):
update_rows = QtCore.pyqtSignal(Abstract_Wallet) update_rows = QtCore.pyqtSignal(Abstract_Wallet)
update_single_row = QtCore.pyqtSignal(Channel) update_single_row = QtCore.pyqtSignal(AbstractChannel)
class Columns(IntEnum): class Columns(IntEnum):
SHORT_CHANID = 0 SHORT_CHANID = 0
@ -196,8 +196,8 @@ class ChannelsList(MyTreeView):
menu.addAction(_("Delete"), lambda: self.remove_channel(channel_id)) menu.addAction(_("Delete"), lambda: self.remove_channel(channel_id))
menu.exec_(self.viewport().mapToGlobal(position)) menu.exec_(self.viewport().mapToGlobal(position))
@QtCore.pyqtSlot(Channel) @QtCore.pyqtSlot(AbstractChannel)
def do_update_single_row(self, chan: Channel): def do_update_single_row(self, chan: AbstractChannel):
lnworker = self.parent.wallet.lnworker lnworker = self.parent.wallet.lnworker
if not lnworker: if not lnworker:
return return
@ -235,7 +235,7 @@ class ChannelsList(MyTreeView):
self.sortByColumn(self.Columns.SHORT_CHANID, Qt.DescendingOrder) self.sortByColumn(self.Columns.SHORT_CHANID, Qt.DescendingOrder)
def _update_chan_frozen_bg(self, *, chan: Channel, items: Sequence[QStandardItem]): def _update_chan_frozen_bg(self, *, chan: AbstractChannel, items: Sequence[QStandardItem]):
assert self._default_item_bg_brush is not None assert self._default_item_bg_brush is not None
# frozen for sending # frozen for sending
item = items[self.Columns.LOCAL_BALANCE] item = items[self.Columns.LOCAL_BALANCE]
@ -266,10 +266,11 @@ class ChannelsList(MyTreeView):
self.can_send_label = QLabel('') self.can_send_label = QLabel('')
h.addWidget(self.can_send_label) h.addWidget(self.can_send_label)
h.addStretch() h.addStretch()
h.addWidget(EnterButton(_('Open Channel'), self.new_channel_dialog)) self.new_channel_button = EnterButton(_('Open Channel'), self.new_channel_dialog)
self.new_channel_button.setEnabled(self.parent.wallet.has_lightning())
h.addWidget(self.new_channel_button)
return h return h
def statistics_dialog(self): def statistics_dialog(self):
channel_db = self.parent.network.channel_db channel_db = self.parent.network.channel_db
capacity = self.parent.format_amount(channel_db.capacity()) + ' '+ self.parent.base_unit() capacity = self.parent.format_amount(channel_db.capacity()) + ' '+ self.parent.base_unit()

6
electrum/gui/qt/main_window.py

@ -224,8 +224,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
tabs.addTab(tab, icon, description.replace("&", "")) tabs.addTab(tab, icon, description.replace("&", ""))
add_optional_tab(tabs, self.addresses_tab, read_QIcon("tab_addresses.png"), _("&Addresses"), "addresses") add_optional_tab(tabs, self.addresses_tab, read_QIcon("tab_addresses.png"), _("&Addresses"), "addresses")
if self.wallet.has_lightning(): add_optional_tab(tabs, self.channels_tab, read_QIcon("lightning.png"), _("Channels"), "channels")
add_optional_tab(tabs, self.channels_tab, read_QIcon("lightning.png"), _("Channels"), "channels")
add_optional_tab(tabs, self.utxo_tab, read_QIcon("tab_coins.png"), _("Co&ins"), "utxo") add_optional_tab(tabs, self.utxo_tab, read_QIcon("tab_coins.png"), _("Co&ins"), "utxo")
add_optional_tab(tabs, self.contacts_tab, read_QIcon("tab_contacts.png"), _("Con&tacts"), "contacts") add_optional_tab(tabs, self.contacts_tab, read_QIcon("tab_contacts.png"), _("Con&tacts"), "contacts")
add_optional_tab(tabs, self.console_tab, read_QIcon("tab_console.png"), _("Con&sole"), "console") add_optional_tab(tabs, self.console_tab, read_QIcon("tab_console.png"), _("Con&sole"), "console")
@ -693,8 +692,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
view_menu = menubar.addMenu(_("&View")) view_menu = menubar.addMenu(_("&View"))
add_toggle_action(view_menu, self.addresses_tab) add_toggle_action(view_menu, self.addresses_tab)
add_toggle_action(view_menu, self.utxo_tab) add_toggle_action(view_menu, self.utxo_tab)
if self.wallet.has_lightning(): add_toggle_action(view_menu, self.channels_tab)
add_toggle_action(view_menu, self.channels_tab)
add_toggle_action(view_menu, self.contacts_tab) add_toggle_action(view_menu, self.contacts_tab)
add_toggle_action(view_menu, self.console_tab) add_toggle_action(view_menu, self.console_tab)

Loading…
Cancel
Save