URI: 
       tMerge pull request #3700 from bauerj/console-warning - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 8116b807655b61691fc7126e2920e9de021f24f8
   DIR parent f24a449d376f2cd33fe53566a4ce79a198d0ba79
  HTML Author: ThomasV <thomasv@electrum.org>
       Date:   Tue, 26 Jun 2018 17:12:25 +0200
       
       Merge pull request #3700 from bauerj/console-warning
       
       Add a warning about harmful code to the console
       Diffstat:
         M gui/qt/console.py                   |      40 +++++++++++++++++++++++++++++++
       
       1 file changed, 40 insertions(+), 0 deletions(-)
       ---
   DIR diff --git a/gui/qt/console.py b/gui/qt/console.py
       t@@ -7,6 +7,7 @@ from PyQt5 import QtCore
        from PyQt5 import QtGui
        from PyQt5 import QtWidgets
        from electrum import util
       +from electrum.i18n import _
        
        
        if platform.system() == 'Windows':
       t@@ -17,6 +18,33 @@ else:
            MONOSPACE_FONT = 'monospace'
        
        
       +class OverlayLabel(QtWidgets.QLabel):
       +    STYLESHEET = '''
       +    QLabel, QLabel link {
       +        color: rgb(0, 0, 0);
       +        background-color: rgb(248, 240, 200);
       +        border: 1px solid;
       +        border-color: rgb(255, 114, 47);
       +        padding: 2px;
       +    }
       +    '''
       +    def __init__(self, text, parent):
       +        super().__init__(text, parent)
       +        self.setMinimumHeight(150)
       +        self.setGeometry(0, 0, self.width(), self.height())
       +        self.setStyleSheet(self.STYLESHEET)
       +        self.setMargin(0)
       +        parent.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
       +        self.setWordWrap(True)
       +
       +    def mousePressEvent(self, e):
       +        self.hide()
       +
       +    def on_resize(self, w):
       +        padding = 2  # px, from the stylesheet above
       +        self.setFixedWidth(w - padding)
       +
       +
        class Console(QtWidgets.QPlainTextEdit):
            def __init__(self, prompt='>> ', startup_message='', parent=None):
                QtWidgets.QPlainTextEdit.__init__(self, parent)
       t@@ -35,6 +63,18 @@ class Console(QtWidgets.QPlainTextEdit):
                self.updateNamespace({'run':self.run_script})
                self.set_json(False)
        
       +        warning_text = "<h1>{}</h1><br>{}<br><br>{}".format(
       +            _("Warning!"),
       +            _("Do not paste code here that you don't understand. Executing the wrong code could lead "
       +              "to your coins being irreversibly lost."),
       +            _("Click here to hide this message.")
       +        )
       +        self.messageOverlay = OverlayLabel(warning_text, self)
       +
       +    def resizeEvent(self, e):
       +        self.messageOverlay.on_resize(self.width() - self.verticalScrollBar().width())
       +
       +
            def set_json(self, b):
                self.is_json = b