Browse Source

qt dark theme: on mac, AmountEdit units were using dark text on dark bg

see #6281
bip39-recovery
SomberNight 5 years ago
parent
commit
0d7bcde2db
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 5
      electrum/gui/qt/amountedit.py
  2. 5
      electrum/gui/qt/locktimeedit.py
  3. 1
      electrum/gui/qt/util.py

5
electrum/gui/qt/amountedit.py

@ -7,7 +7,7 @@ from PyQt5.QtCore import pyqtSignal, Qt
from PyQt5.QtGui import QPalette, QPainter from PyQt5.QtGui import QPalette, QPainter
from PyQt5.QtWidgets import (QLineEdit, QStyle, QStyleOptionFrame) from PyQt5.QtWidgets import (QLineEdit, QStyle, QStyleOptionFrame)
from .util import char_width_in_lineedit from .util import char_width_in_lineedit, ColorScheme
from electrum.util import (format_satoshis_plain, decimal_point_to_base_unit_name, from electrum.util import (format_satoshis_plain, decimal_point_to_base_unit_name,
FEERATE_PRECISION, quantize_feerate) FEERATE_PRECISION, quantize_feerate)
@ -32,7 +32,6 @@ class AmountEdit(FreezableLineEdit):
self.textChanged.connect(self.numbify) self.textChanged.connect(self.numbify)
self.is_int = is_int self.is_int = is_int
self.is_shortcut = False self.is_shortcut = False
self.help_palette = QPalette()
self.extra_precision = 0 self.extra_precision = 0
def decimal_point(self): def decimal_point(self):
@ -69,7 +68,7 @@ class AmountEdit(FreezableLineEdit):
textRect = self.style().subElementRect(QStyle.SE_LineEditContents, panel, self) textRect = self.style().subElementRect(QStyle.SE_LineEditContents, panel, self)
textRect.adjust(2, 0, -10, 0) textRect.adjust(2, 0, -10, 0)
painter = QPainter(self) painter = QPainter(self)
painter.setPen(self.help_palette.brush(QPalette.Disabled, QPalette.Text).color()) painter.setPen(ColorScheme.GRAY.as_color())
painter.drawText(textRect, Qt.AlignRight | Qt.AlignVCenter, self.base_unit()) painter.drawText(textRect, Qt.AlignRight | Qt.AlignVCenter, self.base_unit())
def get_amount(self) -> Union[None, Decimal, int]: def get_amount(self) -> Union[None, Decimal, int]:

5
electrum/gui/qt/locktimeedit.py

@ -14,7 +14,7 @@ from PyQt5.QtWidgets import (QWidget, QLineEdit, QStyle, QStyleOptionFrame, QCom
from electrum.i18n import _ from electrum.i18n import _
from electrum.bitcoin import NLOCKTIME_MIN, NLOCKTIME_MAX, NLOCKTIME_BLOCKHEIGHT_MAX from electrum.bitcoin import NLOCKTIME_MIN, NLOCKTIME_MAX, NLOCKTIME_BLOCKHEIGHT_MAX
from .util import char_width_in_lineedit from .util import char_width_in_lineedit, ColorScheme
class LockTimeEdit(QWidget): class LockTimeEdit(QWidget):
@ -133,7 +133,6 @@ class LockTimeHeightEdit(LockTimeRawEdit):
def __init__(self, parent=None): def __init__(self, parent=None):
LockTimeRawEdit.__init__(self, parent) LockTimeRawEdit.__init__(self, parent)
self.setFixedWidth(20 * char_width_in_lineedit()) self.setFixedWidth(20 * char_width_in_lineedit())
self.help_palette = QPalette()
def paintEvent(self, event): def paintEvent(self, event):
super().paintEvent(event) super().paintEvent(event)
@ -142,7 +141,7 @@ class LockTimeHeightEdit(LockTimeRawEdit):
textRect = self.style().subElementRect(QStyle.SE_LineEditContents, panel, self) textRect = self.style().subElementRect(QStyle.SE_LineEditContents, panel, self)
textRect.adjust(2, 0, -10, 0) textRect.adjust(2, 0, -10, 0)
painter = QPainter(self) painter = QPainter(self)
painter.setPen(self.help_palette.brush(QPalette.Disabled, QPalette.Text).color()) painter.setPen(ColorScheme.GRAY.as_color())
painter.drawText(textRect, Qt.AlignRight | Qt.AlignVCenter, "height") painter.drawText(textRect, Qt.AlignRight | Qt.AlignVCenter, "height")

1
electrum/gui/qt/util.py

@ -870,6 +870,7 @@ class ColorScheme:
RED = ColorSchemeItem("#7c1111", "#f18c8c") RED = ColorSchemeItem("#7c1111", "#f18c8c")
BLUE = ColorSchemeItem("#123b7c", "#8cb3f2") BLUE = ColorSchemeItem("#123b7c", "#8cb3f2")
DEFAULT = ColorSchemeItem("black", "white") DEFAULT = ColorSchemeItem("black", "white")
GRAY = ColorSchemeItem("gray", "gray")
@staticmethod @staticmethod
def has_dark_background(widget): def has_dark_background(widget):

Loading…
Cancel
Save