Qt lists: always show item detail on double click
No longer enter edit mode for editable columns. (that behaviour was difficult to learn, because it is not explicit which columns are editable)
This commit is contained in:
@@ -115,6 +115,10 @@ class AddressList(MyTreeView):
|
||||
self.update()
|
||||
self.sortByColumn(self.Columns.TYPE, Qt.AscendingOrder)
|
||||
|
||||
def on_double_click(self, idx):
|
||||
addr = self.get_role_data_for_current_item(col=0, role=self.ROLE_ADDRESS_STR)
|
||||
self.main_window.show_address(addr)
|
||||
|
||||
def create_toolbar(self, config):
|
||||
toolbar, menu = self.create_toolbar_with_menu('')
|
||||
self.num_addr_label = toolbar.itemAt(0).widget()
|
||||
|
||||
@@ -217,6 +217,11 @@ class ChannelsList(MyTreeView):
|
||||
return
|
||||
self.main_window.rebalance_dialog(chan1, chan2)
|
||||
|
||||
def on_double_click(self, idx):
|
||||
channel_id = idx.sibling(idx.row(), self.Columns.NODE_ALIAS).data(ROLE_CHANNEL_ID)
|
||||
chan = self.lnworker.get_channel_by_id(channel_id) or self.lnworker.channel_backups[channel_id]
|
||||
self.main_window.show_channel_details(chan)
|
||||
|
||||
def create_menu(self, position):
|
||||
menu = QMenu()
|
||||
menu.setSeparatorsCollapsible(True) # consecutive separators are merged together
|
||||
|
||||
@@ -33,7 +33,7 @@ import threading
|
||||
import enum
|
||||
from decimal import Decimal
|
||||
|
||||
from PyQt5.QtGui import QMouseEvent, QFont, QBrush, QColor
|
||||
from PyQt5.QtGui import QFont, QBrush, QColor
|
||||
from PyQt5.QtCore import (Qt, QPersistentModelIndex, QModelIndex, QAbstractItemModel,
|
||||
QSortFilterProxyModel, QVariant, QItemSelectionModel, QDate, QPoint)
|
||||
from PyQt5.QtWidgets import (QMenu, QHeaderView, QLabel, QMessageBox,
|
||||
@@ -708,25 +708,17 @@ class HistoryList(MyTreeView, AcceptFileDragDrop):
|
||||
else:
|
||||
assert False
|
||||
|
||||
def mouseDoubleClickEvent(self, event: QMouseEvent):
|
||||
org_idx: QModelIndex = self.indexAt(event.pos())
|
||||
idx = self.proxy.mapToSource(org_idx)
|
||||
if not idx.isValid():
|
||||
# can happen e.g. before list is populated for the first time
|
||||
return
|
||||
def on_double_click(self, idx):
|
||||
tx_item = idx.internalPointer().get_data()
|
||||
if self.hm.flags(idx) & Qt.ItemIsEditable:
|
||||
super().mouseDoubleClickEvent(event)
|
||||
else:
|
||||
if tx_item.get('lightning'):
|
||||
if tx_item['type'] == 'payment':
|
||||
self.main_window.show_lightning_transaction(tx_item)
|
||||
return
|
||||
tx_hash = tx_item['txid']
|
||||
tx = self.wallet.adb.get_transaction(tx_hash)
|
||||
if not tx:
|
||||
return
|
||||
self.main_window.show_transaction(tx)
|
||||
if tx_item.get('lightning'):
|
||||
if tx_item['type'] == 'payment':
|
||||
self.main_window.show_lightning_transaction(tx_item)
|
||||
return
|
||||
tx_hash = tx_item['txid']
|
||||
tx = self.wallet.adb.get_transaction(tx_hash)
|
||||
if not tx:
|
||||
return
|
||||
self.main_window.show_transaction(tx)
|
||||
|
||||
def add_copy_menu(self, menu, idx):
|
||||
cc = menu.addMenu(_("Copy"))
|
||||
|
||||
@@ -82,6 +82,10 @@ class InvoiceList(MyTreeView):
|
||||
self.setSortingEnabled(True)
|
||||
self.setSelectionMode(QAbstractItemView.ExtendedSelection)
|
||||
|
||||
def on_double_click(self, idx):
|
||||
key = idx.sibling(idx.row(), self.Columns.DATE).data(ROLE_REQUEST_ID)
|
||||
self.show_invoice(key)
|
||||
|
||||
def refresh_row(self, key, row):
|
||||
assert row is not None
|
||||
invoice = self.wallet.get_invoice(key)
|
||||
@@ -133,6 +137,13 @@ class InvoiceList(MyTreeView):
|
||||
self.sortByColumn(self.Columns.DATE, Qt.DescendingOrder)
|
||||
self.hide_if_empty()
|
||||
|
||||
def show_invoice(self, key):
|
||||
invoice = self.wallet.get_invoice(key)
|
||||
if invoice.is_lightning():
|
||||
self.main_window.show_lightning_invoice(invoice)
|
||||
else:
|
||||
self.main_window.show_onchain_invoice(invoice)
|
||||
|
||||
def hide_if_empty(self):
|
||||
b = self.std_model.rowCount() > 0
|
||||
self.setVisible(b)
|
||||
@@ -163,10 +174,7 @@ class InvoiceList(MyTreeView):
|
||||
address = invoice.get_address()
|
||||
if address:
|
||||
copy_menu.addAction(_("Address"), lambda: self.main_window.do_copy(invoice.get_address(), title='Bitcoin Address'))
|
||||
if invoice.is_lightning():
|
||||
menu.addAction(_("Details"), lambda: self.main_window.show_lightning_invoice(invoice))
|
||||
else:
|
||||
menu.addAction(_("Details"), lambda: self.main_window.show_onchain_invoice(invoice))
|
||||
menu.addAction(_("Details"), lambda: self.show_invoice(key))
|
||||
status = wallet.get_invoice_status(invoice)
|
||||
if status == PR_UNPAID:
|
||||
menu.addAction(_("Pay") + "...", lambda: self.send_tab.do_pay_invoice(invoice))
|
||||
|
||||
@@ -15,7 +15,7 @@ from typing import (NamedTuple, Callable, Optional, TYPE_CHECKING, Union, List,
|
||||
|
||||
from PyQt5 import QtWidgets, QtCore
|
||||
from PyQt5.QtGui import (QFont, QColor, QCursor, QPixmap, QStandardItem, QImage,
|
||||
QPalette, QIcon, QFontMetrics, QShowEvent, QPainter, QHelpEvent)
|
||||
QPalette, QIcon, QFontMetrics, QShowEvent, QPainter, QHelpEvent, QMouseEvent)
|
||||
from PyQt5.QtCore import (Qt, QPersistentModelIndex, QModelIndex, pyqtSignal,
|
||||
QCoreApplication, QItemSelectionModel, QThread,
|
||||
QSortFilterProxyModel, QSize, QLocale, QAbstractItemModel,
|
||||
@@ -665,6 +665,7 @@ class MyTreeView(QTreeView):
|
||||
self._forced_update = False
|
||||
|
||||
self._default_bg_brush = QStandardItem().background()
|
||||
self.proxy = None # history, and address tabs use a proxy
|
||||
|
||||
def create_menu(self, position: QPoint) -> None:
|
||||
pass
|
||||
@@ -724,6 +725,18 @@ class MyTreeView(QTreeView):
|
||||
return
|
||||
super().keyPressEvent(event)
|
||||
|
||||
def mouseDoubleClickEvent(self, event: QMouseEvent):
|
||||
idx: QModelIndex = self.indexAt(event.pos())
|
||||
if self.proxy:
|
||||
idx = self.proxy.mapToSource(idx)
|
||||
if not idx.isValid():
|
||||
# can happen e.g. before list is populated for the first time
|
||||
return
|
||||
self.on_double_click(idx)
|
||||
|
||||
def on_double_click(self, idx):
|
||||
pass
|
||||
|
||||
def on_activated(self, idx):
|
||||
# on 'enter' we show the menu
|
||||
pt = self.visualRect(idx).bottomLeft()
|
||||
|
||||
@@ -263,6 +263,11 @@ class UTXOList(MyTreeView):
|
||||
self.main_window.send_tab.pay_onchain_dialog(outputs)
|
||||
self.clear_coincontrol()
|
||||
|
||||
def on_double_click(self, idx):
|
||||
outpoint = idx.sibling(idx.row(), self.Columns.OUTPOINT).data(self.ROLE_PREVOUT_STR)
|
||||
utxo = self._utxo_dict[outpoint]
|
||||
self.main_window.show_utxo(utxo)
|
||||
|
||||
def create_menu(self, position):
|
||||
selected = self.get_selected_outpoints()
|
||||
menu = QMenu()
|
||||
|
||||
Reference in New Issue
Block a user