Browse Source

Restoring old behavior of the outpoint copy to clipboard feature (#5879)

* Restoring old behavior of the outpoint copy to clipboard feature

* Small code style adjustments
master
Nelson Perez 6 years ago committed by ghost43
parent
commit
7968531065
  1. 7
      electrum/gui/qt/util.py
  2. 1
      electrum/gui/qt/utxo_list.py

7
electrum/gui/qt/util.py

@ -480,6 +480,7 @@ class ElectrumItemDelegate(QStyledItemDelegate):
return super().createEditor(parent, option, idx)
class MyTreeView(QTreeView):
ROLE_CLIPBOARD_DATA = Qt.UserRole + 100
def __init__(self, parent: 'ElectrumWindow', create_menu, *,
stretch_column=None, editable_columns=None):
@ -653,9 +654,11 @@ class MyTreeView(QTreeView):
for column in self.Columns:
column_title = self.model().horizontalHeaderItem(column).text()
item_col = self.model().itemFromIndex(idx.sibling(idx.row(), column))
column_data = item_col.text().strip()
clipboard_data = item_col.data(self.ROLE_CLIPBOARD_DATA)
if clipboard_data is None:
clipboard_data = item_col.text().strip()
cc.addAction(column_title,
lambda text=column_data, title=column_title:
lambda text=clipboard_data, title=column_title:
self.place_text_on_clipboard(text, title=title))
def place_text_on_clipboard(self, text: str, *, title: str = None) -> None:

1
electrum/gui/qt/utxo_list.py

@ -97,6 +97,7 @@ class UTXOList(MyTreeView):
labels = [name_short, address, label, amount, '%d'%height]
utxo_item = [QStandardItem(x) for x in labels]
self.set_editability(utxo_item)
utxo_item[self.Columns.OUTPOINT].setData(name, self.ROLE_CLIPBOARD_DATA)
utxo_item[self.Columns.ADDRESS].setFont(QFont(MONOSPACE_FONT))
utxo_item[self.Columns.AMOUNT].setFont(QFont(MONOSPACE_FONT))
utxo_item[self.Columns.OUTPOINT].setFont(QFont(MONOSPACE_FONT))

Loading…
Cancel
Save