mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
qt channels: expose long channel id (in ctx menu and details dlg)
Also add separators to context menu to more visible separate close/delete actions from rest.
This commit is contained in:
parent
1448bfe937
commit
7488cc91cd
4 changed files with 13 additions and 5 deletions
|
@ -153,7 +153,7 @@ class ChannelDetailsDialog(QtWidgets.QDialog):
|
|||
|
||||
form_layout = QtWidgets.QFormLayout(None)
|
||||
# add form content
|
||||
form_layout.addRow(_('Channel ID:'), SelectableLabel(chan.get_id_for_log()))
|
||||
form_layout.addRow(_('Channel ID:'), SelectableLabel(f"{chan.channel_id.hex()} (Short: {chan.short_channel_id})"))
|
||||
form_layout.addRow(_('State:'), SelectableLabel(chan.get_state_for_GUI()))
|
||||
self.initiator = 'Local' if chan.constraints.is_initiator else 'Remote'
|
||||
form_layout.addRow(_('Initiator:'), SelectableLabel(self.initiator))
|
||||
|
|
|
@ -120,6 +120,7 @@ class ChannelsList(MyTreeView):
|
|||
|
||||
def create_menu(self, position):
|
||||
menu = QMenu()
|
||||
menu.setSeparatorsCollapsible(True) # consecutive separators are merged together
|
||||
idx = self.selectionModel().currentIndex()
|
||||
item = self.model().itemFromIndex(idx)
|
||||
if not item:
|
||||
|
@ -127,14 +128,18 @@ class ChannelsList(MyTreeView):
|
|||
channel_id = idx.sibling(idx.row(), self.Columns.NODE_ID).data(ROLE_CHANNEL_ID)
|
||||
chan = self.lnworker.channels[channel_id]
|
||||
menu.addAction(_("Details..."), lambda: self.parent.show_channel(channel_id))
|
||||
self.add_copy_menu(menu, idx)
|
||||
cc = self.add_copy_menu(menu, idx)
|
||||
cc.addAction(_("Long Channel ID"), lambda: self.place_text_on_clipboard(channel_id.hex(),
|
||||
title=_("Long Channel ID")))
|
||||
funding_tx = self.parent.wallet.db.get_transaction(chan.funding_outpoint.txid)
|
||||
if funding_tx:
|
||||
menu.addAction(_("View funding transaction"), lambda: self.parent.show_transaction(funding_tx))
|
||||
if not chan.is_closed():
|
||||
menu.addSeparator()
|
||||
if chan.peer_state == peer_states.GOOD:
|
||||
menu.addAction(_("Close channel"), lambda: self.close_channel(channel_id))
|
||||
menu.addAction(_("Force-close channel"), lambda: self.force_close(channel_id))
|
||||
menu.addSeparator()
|
||||
else:
|
||||
item = chan.get_closing_height()
|
||||
if item:
|
||||
|
@ -143,6 +148,7 @@ class ChannelsList(MyTreeView):
|
|||
if closing_tx:
|
||||
menu.addAction(_("View closing transaction"), lambda: self.parent.show_transaction(closing_tx))
|
||||
if chan.is_redeemed():
|
||||
menu.addSeparator()
|
||||
menu.addAction(_("Delete"), lambda: self.remove_channel(channel_id))
|
||||
menu.exec_(self.viewport().mapToGlobal(position))
|
||||
|
||||
|
|
|
@ -20,7 +20,8 @@ from PyQt5.QtWidgets import (QPushButton, QLabel, QMessageBox, QHBoxLayout,
|
|||
QAbstractItemView, QVBoxLayout, QLineEdit,
|
||||
QStyle, QDialog, QGroupBox, QButtonGroup, QRadioButton,
|
||||
QFileDialog, QWidget, QToolButton, QTreeView, QPlainTextEdit,
|
||||
QHeaderView, QApplication, QToolTip, QTreeWidget, QStyledItemDelegate)
|
||||
QHeaderView, QApplication, QToolTip, QTreeWidget, QStyledItemDelegate,
|
||||
QMenu)
|
||||
|
||||
from electrum.i18n import _, languages
|
||||
from electrum.util import FileImportFailed, FileExportFailed, make_aiohttp_session, resource_path
|
||||
|
@ -658,7 +659,7 @@ class MyTreeView(QTreeView):
|
|||
def toggle_toolbar(self, config=None):
|
||||
self.show_toolbar(not self.toolbar_shown, config)
|
||||
|
||||
def add_copy_menu(self, menu, idx):
|
||||
def add_copy_menu(self, menu: QMenu, idx) -> QMenu:
|
||||
cc = menu.addMenu(_("Copy"))
|
||||
for column in self.Columns:
|
||||
column_title = self.model().horizontalHeaderItem(column).text()
|
||||
|
@ -669,6 +670,7 @@ class MyTreeView(QTreeView):
|
|||
cc.addAction(column_title,
|
||||
lambda text=clipboard_data, title=column_title:
|
||||
self.place_text_on_clipboard(text, title=title))
|
||||
return cc
|
||||
|
||||
def place_text_on_clipboard(self, text: str, *, title: str = None) -> None:
|
||||
self.parent.do_copy(text, title=title)
|
||||
|
|
|
@ -203,7 +203,7 @@ class LNWorker(Logger):
|
|||
if last_tried + PEER_RETRY_INTERVAL < now:
|
||||
await self._add_peer(peer.host, peer.port, peer.pubkey)
|
||||
|
||||
async def _add_peer(self, host, port, node_id):
|
||||
async def _add_peer(self, host, port, node_id) -> Peer:
|
||||
if node_id in self.peers:
|
||||
return self.peers[node_id]
|
||||
port = int(port)
|
||||
|
|
Loading…
Add table
Reference in a new issue