commit 06cdb7ff39bc2a2617c6d038d4cc1c4f61ff32e2
parent d33b53f850d1195b7393392ddd032a44f55c7281
Author: ThomasV <thomasv@gitorious>
Date: Thu, 31 Jul 2014 10:10:14 +0200
move pointofsale plugin to main codebase
Diffstat:
3 files changed, 112 insertions(+), 122 deletions(-)
diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py
@@ -188,6 +188,7 @@ class ElectrumWindow(QMainWindow):
self.wallet = None
self.payment_request = None
+ self.qr_window = None
def update_account_selector(self):
# account selector
@@ -431,6 +432,8 @@ class ElectrumWindow(QMainWindow):
return fileName
def close(self):
+ if self.qr_window:
+ self.qr_window.close()
QMainWindow.close(self)
run_hook('close_main_window')
@@ -705,6 +708,7 @@ class ElectrumWindow(QMainWindow):
self.receive_qr = QRCodeWidget(fixedSize=200)
grid.addWidget(self.receive_qr, 0, 4, 5, 2)
+ self.receive_qr.mousePressEvent = lambda x: self.toggle_qr_window()
grid.setRowStretch(5, 1)
@@ -786,6 +790,22 @@ class ElectrumWindow(QMainWindow):
self.receive_message_e.setText('')
self.receive_amount_e.setAmount(None)
+ def toggle_qr_window(self):
+ import qrwindow
+ if not self.qr_window:
+ self.qr_window = qrwindow.QR_Window(self)
+ self.qr_window.setVisible(True)
+ self.qr_window_geometry = self.qr_window.geometry()
+ else:
+ if not self.qr_window.isVisible():
+ self.qr_window.setVisible(True)
+ self.qr_window.setGeometry(self.qr_window_geometry)
+ else:
+ self.qr_window_geometry = self.qr_window.geometry()
+ self.qr_window.setVisible(False)
+ self.update_receive_qr()
+
+
def receive_at(self, addr):
if not bitcoin.is_address(addr):
return
@@ -823,7 +843,8 @@ class ElectrumWindow(QMainWindow):
else:
url = ""
self.receive_qr.setData(url)
- run_hook('update_receive_qr', addr, amount, message, url)
+ if self.qr_window:
+ self.qr_window.set_content(addr, amount, message, url)
def create_send_tab(self):
diff --git a/gui/qt/qrwindow.py b/gui/qt/qrwindow.py
@@ -0,0 +1,90 @@
+#!/usr/bin/env python
+#
+# Electrum - lightweight Bitcoin client
+# Copyright (C) 2014 Thomas Voegtlin
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import re
+import platform
+from decimal import Decimal
+from urllib import quote
+
+from PyQt4.QtGui import *
+from PyQt4.QtCore import *
+import PyQt4.QtCore as QtCore
+import PyQt4.QtGui as QtGui
+
+from electrum_gui.qt.qrcodewidget import QRCodeWidget
+from electrum.i18n import _
+
+if platform.system() == 'Windows':
+ MONOSPACE_FONT = 'Lucida Console'
+elif platform.system() == 'Darwin':
+ MONOSPACE_FONT = 'Monaco'
+else:
+ MONOSPACE_FONT = 'monospace'
+
+column_index = 4
+
+class QR_Window(QWidget):
+
+ def __init__(self, win):
+ QWidget.__init__(self)
+ self.win = win
+ self.setWindowTitle('Electrum - '+_('Invoice'))
+ self.setMinimumSize(800, 250)
+ self.address = ''
+ self.label = ''
+ self.amount = 0
+ self.setFocusPolicy(QtCore.Qt.NoFocus)
+
+ main_box = QHBoxLayout()
+
+ self.qrw = QRCodeWidget()
+ main_box.addWidget(self.qrw, 1)
+
+ vbox = QVBoxLayout()
+ main_box.addLayout(vbox)
+
+ self.address_label = QLabel("")
+ #self.address_label.setFont(QFont(MONOSPACE_FONT))
+ vbox.addWidget(self.address_label)
+
+ self.label_label = QLabel("")
+ vbox.addWidget(self.label_label)
+
+ self.amount_label = QLabel("")
+ vbox.addWidget(self.amount_label)
+
+ vbox.addStretch(1)
+ self.setLayout(main_box)
+
+
+ def set_content(self, address, amount, message, url):
+ address_text = "<span style='font-size: 18pt'>%s</span>" % address if address else ""
+ self.address_label.setText(address_text)
+ if amount:
+ amount = self.win.format_amount(amount)
+ amount_text = "<span style='font-size: 21pt'>%s</span> <span style='font-size: 16pt'>%s</span> " % (amount, self.win.base_unit())
+ else:
+ amount_text = ''
+ self.amount_label.setText(amount_text)
+ label_text = "<span style='font-size: 21pt'>%s</span>" % message if message else ""
+ self.label_label.setText(label_text)
+ self.qrw.setData(url)
+
+
+
+
diff --git a/plugins/pointofsale.py b/plugins/pointofsale.py
@@ -1,121 +0,0 @@
-import re
-import platform
-from decimal import Decimal
-from urllib import quote
-
-from PyQt4.QtGui import *
-from PyQt4.QtCore import *
-import PyQt4.QtCore as QtCore
-import PyQt4.QtGui as QtGui
-
-from electrum_gui.qt.qrcodewidget import QRCodeWidget
-from electrum import BasePlugin
-from electrum.i18n import _
-
-
-if platform.system() == 'Windows':
- MONOSPACE_FONT = 'Lucida Console'
-elif platform.system() == 'Darwin':
- MONOSPACE_FONT = 'Monaco'
-else:
- MONOSPACE_FONT = 'monospace'
-
-column_index = 4
-
-class QR_Window(QWidget):
-
- def __init__(self, win):
- QWidget.__init__(self)
- self.win = win
- self.setWindowTitle('Electrum - '+_('Invoice'))
- self.setMinimumSize(800, 250)
- self.address = ''
- self.label = ''
- self.amount = 0
- self.setFocusPolicy(QtCore.Qt.NoFocus)
-
- main_box = QHBoxLayout()
-
- self.qrw = QRCodeWidget()
- main_box.addWidget(self.qrw, 1)
-
- vbox = QVBoxLayout()
- main_box.addLayout(vbox)
-
- self.address_label = QLabel("")
- #self.address_label.setFont(QFont(MONOSPACE_FONT))
- vbox.addWidget(self.address_label)
-
- self.label_label = QLabel("")
- vbox.addWidget(self.label_label)
-
- self.amount_label = QLabel("")
- vbox.addWidget(self.amount_label)
-
- vbox.addStretch(1)
- self.setLayout(main_box)
-
-
- def set_content(self, address, amount, message, url):
- address_text = "<span style='font-size: 18pt'>%s</span>" % address if address else ""
- self.address_label.setText(address_text)
- if amount:
- amount = self.win.format_amount(amount)
- amount_text = "<span style='font-size: 21pt'>%s</span> <span style='font-size: 16pt'>%s</span> " % (amount, self.win.base_unit())
- else:
- amount_text = ''
- self.amount_label.setText(amount_text)
- label_text = "<span style='font-size: 21pt'>%s</span>" % message if message else ""
- self.label_label.setText(label_text)
- self.qrw.setData(url)
-
-
-
-
-class Plugin(BasePlugin):
-
- def fullname(self):
- return 'Point of Sale'
-
-
- def description(self):
- return _('Show payment requests in a large, separate window.')
-
-
- def init(self):
- self.window = self.gui.main_window
- self.qr_window = None
- self.toggle_QR_window(True)
-
-
- def close(self):
- self.toggle_QR_window(False)
-
-
- def close_main_window(self):
- if self.qr_window:
- self.qr_window.close()
- self.qr_window = None
-
-
- def update_receive_qr(self, address, amount, message, url):
- self.qr_window.set_content( address, amount, message, url )
-
-
- def toggle_QR_window(self, show):
- if show and not self.qr_window:
- self.qr_window = QR_Window(self.gui.main_window)
- self.qr_window.setVisible(True)
- self.qr_window_geometry = self.qr_window.geometry()
-
- elif show and self.qr_window and not self.qr_window.isVisible():
- self.qr_window.setVisible(True)
- self.qr_window.setGeometry(self.qr_window_geometry)
-
- elif not show and self.qr_window and self.qr_window.isVisible():
- self.qr_window_geometry = self.qr_window.geometry()
- self.qr_window.setVisible(False)
-
-
-
-