Use screen size as upper bound for qr code size
also fix some typing issues
This commit is contained in:
@@ -200,8 +200,7 @@ Pane {
|
||||
|
||||
function createRequest(ignoreGaplimit = false) {
|
||||
var qamt = Config.unitsToSats(amount.text)
|
||||
console.log('about to create req for ' + qamt.satsInt + ' sats')
|
||||
if (qamt.satsInt > Daemon.currentWallet.lightningCanReceive) {
|
||||
if (qamt.satsInt > Daemon.currentWallet.lightningCanReceive.satsInt) {
|
||||
console.log('Creating OnChain request')
|
||||
Daemon.currentWallet.create_request(qamt, message.text, expires.currentValue, false, ignoreGaplimit)
|
||||
} else {
|
||||
|
||||
@@ -153,7 +153,9 @@ class ElectrumQmlApplication(QGuiApplication):
|
||||
self.engine = QQmlApplicationEngine(parent=self)
|
||||
self.engine.addImportPath('./qml')
|
||||
|
||||
self.qr_ip = QEQRImageProvider()
|
||||
screensize = self.primaryScreen().size()
|
||||
|
||||
self.qr_ip = QEQRImageProvider((7/8)*min(screensize.width(), screensize.height()))
|
||||
self.engine.addImageProvider('qrgen', self.qr_ip)
|
||||
|
||||
# add a monospace font as we can't rely on device having one
|
||||
|
||||
@@ -118,20 +118,22 @@ class QEQRParser(QObject):
|
||||
return result
|
||||
|
||||
class QEQRImageProvider(QQuickImageProvider):
|
||||
def __init__(self, parent=None):
|
||||
def __init__(self, max_size, parent=None):
|
||||
super().__init__(QQuickImageProvider.Image)
|
||||
self._max_size = max_size
|
||||
|
||||
_logger = get_logger(__name__)
|
||||
|
||||
@profiler
|
||||
def requestImage(self, qstr, size):
|
||||
self._logger.debug('QR requested for %s' % qstr)
|
||||
qr = qrcode.QRCode(version=1, box_size=6, border=2)
|
||||
qr = qrcode.QRCode(version=1, border=2)
|
||||
qr.add_data(qstr)
|
||||
|
||||
# calculate best box_size, aim for 400 px
|
||||
# calculate best box_size
|
||||
pixelsize = min(self._max_size, 400)
|
||||
modules = 17 + 4 * qr.best_fit()
|
||||
qr.box_size = math.floor(400/(modules+2))
|
||||
qr.box_size = math.floor(pixelsize/(modules+2*2))
|
||||
|
||||
qr.make(fit=True)
|
||||
|
||||
|
||||
@@ -305,21 +305,21 @@ class QEWallet(QObject):
|
||||
def lightningBalance(self):
|
||||
if not self.isLightning:
|
||||
return QEAmount()
|
||||
self._lightningbalance = QEAmount(amount_sat=self.wallet.lnworker.get_balance())
|
||||
self._lightningbalance = QEAmount(amount_sat=int(self.wallet.lnworker.get_balance()))
|
||||
return self._lightningbalance
|
||||
|
||||
@pyqtProperty(QEAmount, notify=balanceChanged)
|
||||
def lightningCanSend(self):
|
||||
if not self.isLightning:
|
||||
return QEAmount()
|
||||
self._lightningcansend = QEAmount(amount_sat=self.wallet.lnworker.num_sats_can_send())
|
||||
self._lightningcansend = QEAmount(amount_sat=int(self.wallet.lnworker.num_sats_can_send()))
|
||||
return self._lightningcansend
|
||||
|
||||
@pyqtProperty(QEAmount, notify=balanceChanged)
|
||||
def lightningCanReceive(self):
|
||||
if not self.isLightning:
|
||||
return QEAmount()
|
||||
self._lightningcanreceive = QEAmount(amount_sat=self.wallet.lnworker.num_sats_can_receive())
|
||||
self._lightningcanreceive = QEAmount(amount_sat=int(self.wallet.lnworker.num_sats_can_receive()))
|
||||
return self._lightningcanreceive
|
||||
|
||||
@pyqtSlot()
|
||||
|
||||
Reference in New Issue
Block a user