prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Feature request: Label colour - History Window
  The transaction amount of outgoing transactions, when viewed in the history window, is coloured red. 
  
  It would be a nice if the label of these transactions could be coloured the same red colour so that they stand out more against the other incoming transactions. 
  
  Not a big issue but would be a 'nice to have'.
  
  
  </issue>
  <code>
  [start of gui/qt/history_widget.py]
  1 #!/usr/bin/env python
  2 #
  3 # Electrum - lightweight Bitcoin client
  4 # Copyright (C) 2015 Thomas Voegtlin
  5 #
  6 # Permission is hereby granted, free of charge, to any person
  7 # obtaining a copy of this software and associated documentation files
  8 # (the "Software"), to deal in the Software without restriction,
  9 # including without limitation the rights to use, copy, modify, merge,
  10 # publish, distribute, sublicense, and/or sell copies of the Software,
  11 # and to permit persons to whom the Software is furnished to do so,
  12 # subject to the following conditions:
  13 #
  14 # The above copyright notice and this permission notice shall be
  15 # included in all copies or substantial portions of the Software.
  16 #
  17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  18 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  20 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  21 # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  22 # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  23 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  24 # SOFTWARE.
  25 
  26 
  27 import webbrowser
  28 
  29 from util import *
  30 from electrum.i18n import _
  31 from electrum.util import block_explorer_URL, format_satoshis, format_time
  32 from electrum.plugins import run_hook
  33 
  34 
  35 class HistoryWidget(MyTreeWidget):
  36 
  37     def __init__(self, parent=None):
  38         MyTreeWidget.__init__(self, parent, self.create_menu, [], 3)
  39         self.refresh_headers()
  40         self.setColumnHidden(1, True)
  41         self.config = self.parent.config
  42 
  43     def refresh_headers(self):
  44         headers = ['', '', _('Date'), _('Description') , _('Amount'),
  45                    _('Balance')]
  46         run_hook('history_tab_headers', headers)
  47         self.update_headers(headers)
  48 
  49     def get_icon(self, conf, timestamp):
  50         time_str = _("unknown")
  51         if conf > 0:
  52             time_str = format_time(timestamp)
  53         if conf == -1:
  54             time_str = _('Not Verified')
  55             icon = QIcon(":icons/unconfirmed.png")
  56         elif conf == 0:
  57             time_str = _('Unconfirmed')
  58             icon = QIcon(":icons/unconfirmed.png")
  59         elif conf < 6:
  60             icon = QIcon(":icons/clock%d.png"%conf)
  61         else:
  62             icon = QIcon(":icons/confirmed.png")
  63         return icon, time_str
  64 
  65     def get_domain(self):
  66         '''Replaced in address_dialog.py'''
  67         return self.wallet.get_account_addresses(self.parent.current_account)
  68 
  69     def on_update(self):
  70         self.wallet = self.parent.wallet
  71         h = self.wallet.get_history(self.get_domain())
  72 
  73         item = self.currentItem()
  74         current_tx = item.data(0, Qt.UserRole).toString() if item else None
  75         self.clear()
  76         run_hook('history_tab_update_begin')
  77         for tx in h:
  78             tx_hash, conf, value, timestamp, balance = tx
  79             if conf is None and timestamp is None:
  80                 continue  # skip history in offline mode
  81             icon, time_str = self.get_icon(conf, timestamp)
  82             v_str = self.parent.format_amount(value, True, whitespaces=True)
  83             balance_str = self.parent.format_amount(balance, whitespaces=True)
  84             label = self.wallet.get_label(tx_hash)
  85             entry = ['', tx_hash, time_str, label, v_str, balance_str]
  86             run_hook('history_tab_update', tx, entry)
  87             item = QTreeWidgetItem(entry)
  88             item.setIcon(0, icon)
  89             for i in range(len(entry)):
  90                 if i>3:
  91                     item.setTextAlignment(i, Qt.AlignRight)
  92                 if i!=2:
  93                     item.setFont(i, QFont(MONOSPACE_FONT))
  94             if value < 0:
  95                 item.setForeground(4, QBrush(QColor("#BC1E1E")))
  96             if tx_hash:
  97                 item.setData(0, Qt.UserRole, tx_hash)
  98             self.insertTopLevelItem(0, item)
  99             if current_tx == tx_hash:
  100                 self.setCurrentItem(item)
  101 
  102     def update_item(self, tx_hash, conf, timestamp):
  103         icon, time_str = self.get_icon(conf, timestamp)
  104         items = self.findItems(tx_hash, Qt.UserRole|Qt.MatchContains|Qt.MatchRecursive, column=1)
  105         if items:
  106             item = items[0]
  107             item.setIcon(0, icon)
  108             item.setText(2, time_str)
  109 
  110     def create_menu(self, position):
  111         self.selectedIndexes()
  112         item = self.currentItem()
  113         if not item:
  114             return
  115         tx_hash = str(item.data(0, Qt.UserRole).toString())
  116         if not tx_hash:
  117             return
  118         tx_URL = block_explorer_URL(self.config, 'tx', tx_hash)
  119         if not tx_URL:
  120             return
  121         menu = QMenu()
  122         menu.addAction(_("Copy ID to Clipboard"), lambda: self.parent.app.clipboard().setText(tx_hash))
  123         menu.addAction(_("Details"), lambda: self.parent.show_transaction(self.wallet.transactions.get(tx_hash)))
  124         menu.addAction(_("Edit description"), lambda: self.editItem(item, self.editable_columns[0]))
  125         menu.addAction(_("View on block explorer"), lambda: webbrowser.open(tx_URL))
  126         menu.exec_(self.viewport().mapToGlobal(position))
  127
  [end of gui/qt/history_widget.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/gui/qt/history_widget.py b/gui/qt/history_widget.py
  --- a/gui/qt/history_widget.py
  +++ b/gui/qt/history_widget.py
  @@ -92,6 +92,7 @@
                   if i!=2:
                       item.setFont(i, QFont(MONOSPACE_FONT))
               if value < 0:
  +                item.setForeground(3, QBrush(QColor("#BC1E1E")))
                   item.setForeground(4, QBrush(QColor("#BC1E1E")))
               if tx_hash:
                   item.setData(0, Qt.UserRole, tx_hash)
  
verification_info: {"golden_diff": "diff --git a/gui/qt/history_widget.py b/gui/qt/history_widget.py\n--- a/gui/qt/history_widget.py\n+++ b/gui/qt/history_widget.py\n@@ -92,6 +92,7 @@\n                 if i!=2:\n                     item.setFont(i, QFont(MONOSPACE_FONT))\n             if value < 0:\n+                item.setForeground(3, QBrush(QColor(\"#BC1E1E\")))\n                 item.setForeground(4, QBrush(QColor(\"#BC1E1E\")))\n             if tx_hash:\n                 item.setData(0, Qt.UserRole, tx_hash)\n", "issue": "Feature request: Label colour - History Window\nThe transaction amount of outgoing transactions, when viewed in the history window, is coloured red. \n\nIt would be a nice if the label of these transactions could be coloured the same red colour so that they stand out more against the other incoming transactions. \n\nNot a big issue but would be a 'nice to have'.\n\n", "before_files": [{"content": "#!/usr/bin/env python\n#\n# Electrum - lightweight Bitcoin client\n# Copyright (C) 2015 Thomas Voegtlin\n#\n# Permission is hereby granted, free of charge, to any person\n# obtaining a copy of this software and associated documentation files\n# (the \"Software\"), to deal in the Software without restriction,\n# including without limitation the rights to use, copy, modify, merge,\n# publish, distribute, sublicense, and/or sell copies of the Software,\n# and to permit persons to whom the Software is furnished to do so,\n# subject to the following conditions:\n#\n# The above copyright notice and this permission notice shall be\n# included in all copies or substantial portions of the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\n# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\n# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\n\nimport webbrowser\n\nfrom util import *\nfrom electrum.i18n import _\nfrom electrum.util import block_explorer_URL, format_satoshis, format_time\nfrom electrum.plugins import run_hook\n\n\nclass HistoryWidget(MyTreeWidget):\n\n    def __init__(self, parent=None):\n        MyTreeWidget.__init__(self, parent, self.create_menu, [], 3)\n        self.refresh_headers()\n        self.setColumnHidden(1, True)\n        self.config = self.parent.config\n\n    def refresh_headers(self):\n        headers = ['', '', _('Date'), _('Description') , _('Amount'),\n                   _('Balance')]\n        run_hook('history_tab_headers', headers)\n        self.update_headers(headers)\n\n    def get_icon(self, conf, timestamp):\n        time_str = _(\"unknown\")\n        if conf > 0:\n            time_str = format_time(timestamp)\n        if conf == -1:\n            time_str = _('Not Verified')\n            icon = QIcon(\":icons/unconfirmed.png\")\n        elif conf == 0:\n            time_str = _('Unconfirmed')\n            icon = QIcon(\":icons/unconfirmed.png\")\n        elif conf < 6:\n            icon = QIcon(\":icons/clock%d.png\"%conf)\n        else:\n            icon = QIcon(\":icons/confirmed.png\")\n        return icon, time_str\n\n    def get_domain(self):\n        '''Replaced in address_dialog.py'''\n        return self.wallet.get_account_addresses(self.parent.current_account)\n\n    def on_update(self):\n        self.wallet = self.parent.wallet\n        h = self.wallet.get_history(self.get_domain())\n\n        item = self.currentItem()\n        current_tx = item.data(0, Qt.UserRole).toString() if item else None\n        self.clear()\n        run_hook('history_tab_update_begin')\n        for tx in h:\n            tx_hash, conf, value, timestamp, balance = tx\n            if conf is None and timestamp is None:\n                continue  # skip history in offline mode\n            icon, time_str = self.get_icon(conf, timestamp)\n            v_str = self.parent.format_amount(value, True, whitespaces=True)\n            balance_str = self.parent.format_amount(balance, whitespaces=True)\n            label = self.wallet.get_label(tx_hash)\n            entry = ['', tx_hash, time_str, label, v_str, balance_str]\n            run_hook('history_tab_update', tx, entry)\n            item = QTreeWidgetItem(entry)\n            item.setIcon(0, icon)\n            for i in range(len(entry)):\n                if i>3:\n                    item.setTextAlignment(i, Qt.AlignRight)\n                if i!=2:\n                    item.setFont(i, QFont(MONOSPACE_FONT))\n            if value < 0:\n                item.setForeground(4, QBrush(QColor(\"#BC1E1E\")))\n            if tx_hash:\n                item.setData(0, Qt.UserRole, tx_hash)\n            self.insertTopLevelItem(0, item)\n            if current_tx == tx_hash:\n                self.setCurrentItem(item)\n\n    def update_item(self, tx_hash, conf, timestamp):\n        icon, time_str = self.get_icon(conf, timestamp)\n        items = self.findItems(tx_hash, Qt.UserRole|Qt.MatchContains|Qt.MatchRecursive, column=1)\n        if items:\n            item = items[0]\n            item.setIcon(0, icon)\n            item.setText(2, time_str)\n\n    def create_menu(self, position):\n        self.selectedIndexes()\n        item = self.currentItem()\n        if not item:\n            return\n        tx_hash = str(item.data(0, Qt.UserRole).toString())\n        if not tx_hash:\n            return\n        tx_URL = block_explorer_URL(self.config, 'tx', tx_hash)\n        if not tx_URL:\n            return\n        menu = QMenu()\n        menu.addAction(_(\"Copy ID to Clipboard\"), lambda: self.parent.app.clipboard().setText(tx_hash))\n        menu.addAction(_(\"Details\"), lambda: self.parent.show_transaction(self.wallet.transactions.get(tx_hash)))\n        menu.addAction(_(\"Edit description\"), lambda: self.editItem(item, self.editable_columns[0]))\n        menu.addAction(_(\"View on block explorer\"), lambda: webbrowser.open(tx_URL))\n        menu.exec_(self.viewport().mapToGlobal(position))\n", "path": "gui/qt/history_widget.py"}]}