Browse Source

Add QR code support to the GUI

master
Kristaps Kaupe 7 years ago
parent
commit
79eb790e27
  1. 1
      docs/INSTALL.md
  2. 1
      install.sh
  3. 28
      scripts/joinmarket-qt.py

1
docs/INSTALL.md

@ -89,6 +89,7 @@ command line scripts as explained in the [scripts README](https://github.com/Ada
6) Setup joinmarket-qt
```
pip install PySide2
pip install qrcode[pil]
pip install https://github.com/sunu/qt5reactor/archive/58410aaead2185e9917ae9cac9c50fe7b70e4a60.zip
python setupall.py --all
```

1
install.sh

@ -427,6 +427,7 @@ qt_deps_install ()
{
pip install \
PySide2 \
qrcode[pil] \
https://github.com/sunu/qt5reactor/archive/58410aaead2185e9917ae9cac9c50fe7b70e4a60.zip
return "$?"

28
scripts/joinmarket-qt.py

@ -25,7 +25,7 @@ Some widgets copied and modified from https://github.com/spesmilo/electrum
import sys, datetime, os, logging
import platform, json, threading, time
import qrcode
from decimal import Decimal
from PySide2 import QtCore
@ -34,6 +34,8 @@ from PySide2.QtGui import *
from PySide2.QtWidgets import *
from PIL.ImageQt import ImageQt
if platform.system() == 'Windows':
MONOSPACE_FONT = 'Lucida Console'
elif platform.system() == 'Darwin':
@ -1101,6 +1103,24 @@ class CoinsTab(QWidget):
lambda: app.clipboard().setText(txid))
menu.exec_(self.cTW.viewport().mapToGlobal(position))
class BitcoinQRCodePopup(QDialog):
def __init__(self, parent, address):
super(BitcoinQRCodePopup, self).__init__(parent)
self.address = address
self.setWindowTitle(address)
img = qrcode.make('bitcoin:' + address)
self.imageLabel = QLabel()
self.imageLabel.setPixmap(QPixmap.fromImage(ImageQt(img)))
layout = QVBoxLayout()
layout.addWidget(self.imageLabel)
self.setLayout(layout)
self.initUI()
def initUI(self):
self.show()
class JMWalletTab(QWidget):
def __init__(self):
@ -1152,6 +1172,8 @@ class JMWalletTab(QWidget):
if address_valid:
menu.addAction("Copy address to clipboard",
lambda: app.clipboard().setText(txt))
menu.addAction("Show QR code",
lambda: self.openQRCodePopup(txt))
if xpub_exists:
menu.addAction("Copy extended pubkey to clipboard",
lambda: app.clipboard().setText(xpub))
@ -1160,6 +1182,10 @@ class JMWalletTab(QWidget):
#TODO add more items to context menu
menu.exec_(self.walletTree.viewport().mapToGlobal(position))
def openQRCodePopup(self, address):
popup = BitcoinQRCodePopup(self, address)
popup.show()
def updateWalletInfo(self, walletinfo=None):
l = self.walletTree
l.clear()

Loading…
Cancel
Save