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

see #6281
This commit is contained in:
SomberNight 2020-06-28 03:50:34 +02:00
parent 93a4969fba
commit 0d7bcde2db
No known key found for this signature in database
GPG key ID: B33B5F232C6271E9
3 changed files with 5 additions and 6 deletions

View file

@ -7,7 +7,7 @@ from PyQt5.QtCore import pyqtSignal, Qt
from PyQt5.QtGui import QPalette, QPainter
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,
FEERATE_PRECISION, quantize_feerate)
@ -32,7 +32,6 @@ class AmountEdit(FreezableLineEdit):
self.textChanged.connect(self.numbify)
self.is_int = is_int
self.is_shortcut = False
self.help_palette = QPalette()
self.extra_precision = 0
def decimal_point(self):
@ -69,7 +68,7 @@ class AmountEdit(FreezableLineEdit):
textRect = self.style().subElementRect(QStyle.SE_LineEditContents, panel, self)
textRect.adjust(2, 0, -10, 0)
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())
def get_amount(self) -> Union[None, Decimal, int]:

View file

@ -14,7 +14,7 @@ from PyQt5.QtWidgets import (QWidget, QLineEdit, QStyle, QStyleOptionFrame, QCom
from electrum.i18n import _
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):
@ -133,7 +133,6 @@ class LockTimeHeightEdit(LockTimeRawEdit):
def __init__(self, parent=None):
LockTimeRawEdit.__init__(self, parent)
self.setFixedWidth(20 * char_width_in_lineedit())
self.help_palette = QPalette()
def paintEvent(self, event):
super().paintEvent(event)
@ -142,7 +141,7 @@ class LockTimeHeightEdit(LockTimeRawEdit):
textRect = self.style().subElementRect(QStyle.SE_LineEditContents, panel, self)
textRect.adjust(2, 0, -10, 0)
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")

View file

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