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.update()
|
||||||
self.sortByColumn(self.Columns.TYPE, Qt.AscendingOrder)
|
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):
|
def create_toolbar(self, config):
|
||||||
toolbar, menu = self.create_toolbar_with_menu('')
|
toolbar, menu = self.create_toolbar_with_menu('')
|
||||||
self.num_addr_label = toolbar.itemAt(0).widget()
|
self.num_addr_label = toolbar.itemAt(0).widget()
|
||||||
|
|||||||
@@ -217,6 +217,11 @@ class ChannelsList(MyTreeView):
|
|||||||
return
|
return
|
||||||
self.main_window.rebalance_dialog(chan1, chan2)
|
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):
|
def create_menu(self, position):
|
||||||
menu = QMenu()
|
menu = QMenu()
|
||||||
menu.setSeparatorsCollapsible(True) # consecutive separators are merged together
|
menu.setSeparatorsCollapsible(True) # consecutive separators are merged together
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import threading
|
|||||||
import enum
|
import enum
|
||||||
from decimal import Decimal
|
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,
|
from PyQt5.QtCore import (Qt, QPersistentModelIndex, QModelIndex, QAbstractItemModel,
|
||||||
QSortFilterProxyModel, QVariant, QItemSelectionModel, QDate, QPoint)
|
QSortFilterProxyModel, QVariant, QItemSelectionModel, QDate, QPoint)
|
||||||
from PyQt5.QtWidgets import (QMenu, QHeaderView, QLabel, QMessageBox,
|
from PyQt5.QtWidgets import (QMenu, QHeaderView, QLabel, QMessageBox,
|
||||||
@@ -708,25 +708,17 @@ class HistoryList(MyTreeView, AcceptFileDragDrop):
|
|||||||
else:
|
else:
|
||||||
assert False
|
assert False
|
||||||
|
|
||||||
def mouseDoubleClickEvent(self, event: QMouseEvent):
|
def on_double_click(self, idx):
|
||||||
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
|
|
||||||
tx_item = idx.internalPointer().get_data()
|
tx_item = idx.internalPointer().get_data()
|
||||||
if self.hm.flags(idx) & Qt.ItemIsEditable:
|
if tx_item.get('lightning'):
|
||||||
super().mouseDoubleClickEvent(event)
|
if tx_item['type'] == 'payment':
|
||||||
else:
|
self.main_window.show_lightning_transaction(tx_item)
|
||||||
if tx_item.get('lightning'):
|
return
|
||||||
if tx_item['type'] == 'payment':
|
tx_hash = tx_item['txid']
|
||||||
self.main_window.show_lightning_transaction(tx_item)
|
tx = self.wallet.adb.get_transaction(tx_hash)
|
||||||
return
|
if not tx:
|
||||||
tx_hash = tx_item['txid']
|
return
|
||||||
tx = self.wallet.adb.get_transaction(tx_hash)
|
self.main_window.show_transaction(tx)
|
||||||
if not tx:
|
|
||||||
return
|
|
||||||
self.main_window.show_transaction(tx)
|
|
||||||
|
|
||||||
def add_copy_menu(self, menu, idx):
|
def add_copy_menu(self, menu, idx):
|
||||||
cc = menu.addMenu(_("Copy"))
|
cc = menu.addMenu(_("Copy"))
|
||||||
|
|||||||
@@ -82,6 +82,10 @@ class InvoiceList(MyTreeView):
|
|||||||
self.setSortingEnabled(True)
|
self.setSortingEnabled(True)
|
||||||
self.setSelectionMode(QAbstractItemView.ExtendedSelection)
|
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):
|
def refresh_row(self, key, row):
|
||||||
assert row is not None
|
assert row is not None
|
||||||
invoice = self.wallet.get_invoice(key)
|
invoice = self.wallet.get_invoice(key)
|
||||||
@@ -133,6 +137,13 @@ class InvoiceList(MyTreeView):
|
|||||||
self.sortByColumn(self.Columns.DATE, Qt.DescendingOrder)
|
self.sortByColumn(self.Columns.DATE, Qt.DescendingOrder)
|
||||||
self.hide_if_empty()
|
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):
|
def hide_if_empty(self):
|
||||||
b = self.std_model.rowCount() > 0
|
b = self.std_model.rowCount() > 0
|
||||||
self.setVisible(b)
|
self.setVisible(b)
|
||||||
@@ -163,10 +174,7 @@ class InvoiceList(MyTreeView):
|
|||||||
address = invoice.get_address()
|
address = invoice.get_address()
|
||||||
if address:
|
if address:
|
||||||
copy_menu.addAction(_("Address"), lambda: self.main_window.do_copy(invoice.get_address(), title='Bitcoin 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.show_invoice(key))
|
||||||
menu.addAction(_("Details"), lambda: self.main_window.show_lightning_invoice(invoice))
|
|
||||||
else:
|
|
||||||
menu.addAction(_("Details"), lambda: self.main_window.show_onchain_invoice(invoice))
|
|
||||||
status = wallet.get_invoice_status(invoice)
|
status = wallet.get_invoice_status(invoice)
|
||||||
if status == PR_UNPAID:
|
if status == PR_UNPAID:
|
||||||
menu.addAction(_("Pay") + "...", lambda: self.send_tab.do_pay_invoice(invoice))
|
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 import QtWidgets, QtCore
|
||||||
from PyQt5.QtGui import (QFont, QColor, QCursor, QPixmap, QStandardItem, QImage,
|
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,
|
from PyQt5.QtCore import (Qt, QPersistentModelIndex, QModelIndex, pyqtSignal,
|
||||||
QCoreApplication, QItemSelectionModel, QThread,
|
QCoreApplication, QItemSelectionModel, QThread,
|
||||||
QSortFilterProxyModel, QSize, QLocale, QAbstractItemModel,
|
QSortFilterProxyModel, QSize, QLocale, QAbstractItemModel,
|
||||||
@@ -665,6 +665,7 @@ class MyTreeView(QTreeView):
|
|||||||
self._forced_update = False
|
self._forced_update = False
|
||||||
|
|
||||||
self._default_bg_brush = QStandardItem().background()
|
self._default_bg_brush = QStandardItem().background()
|
||||||
|
self.proxy = None # history, and address tabs use a proxy
|
||||||
|
|
||||||
def create_menu(self, position: QPoint) -> None:
|
def create_menu(self, position: QPoint) -> None:
|
||||||
pass
|
pass
|
||||||
@@ -724,6 +725,18 @@ class MyTreeView(QTreeView):
|
|||||||
return
|
return
|
||||||
super().keyPressEvent(event)
|
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):
|
def on_activated(self, idx):
|
||||||
# on 'enter' we show the menu
|
# on 'enter' we show the menu
|
||||||
pt = self.visualRect(idx).bottomLeft()
|
pt = self.visualRect(idx).bottomLeft()
|
||||||
|
|||||||
@@ -263,6 +263,11 @@ class UTXOList(MyTreeView):
|
|||||||
self.main_window.send_tab.pay_onchain_dialog(outputs)
|
self.main_window.send_tab.pay_onchain_dialog(outputs)
|
||||||
self.clear_coincontrol()
|
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):
|
def create_menu(self, position):
|
||||||
selected = self.get_selected_outpoints()
|
selected = self.get_selected_outpoints()
|
||||||
menu = QMenu()
|
menu = QMenu()
|
||||||
|
|||||||
Reference in New Issue
Block a user