Skip to content

Commit 2868416

Browse files
committed
oweditdomain: Increase warning text color contrast
1 parent 27280fd commit 2868416

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Orange/widgets/data/oweditdomain.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@
3030
)
3131
from AnyQt.QtGui import (
3232
QStandardItemModel, QStandardItem, QKeySequence, QIcon, QBrush, QPalette,
33-
QHelpEvent
33+
QHelpEvent, QColor
3434
)
3535
from AnyQt.QtCore import (
3636
Qt, QSize, QModelIndex, QAbstractItemModel, QPersistentModelIndex, QRect,
3737
QPoint, QItemSelectionModel
3838
)
3939
from AnyQt.QtCore import pyqtSignal as Signal, pyqtSlot as Slot
4040

41+
from orangecanvas.gui.utils import luminance
4142
from orangecanvas.utils import assocf
4243
from orangewidget.utils.listview import ListViewSearch
4344

@@ -1639,7 +1640,15 @@ def set_color(palette: QPalette, color):
16391640
if isinstance(multiplicity, int) and multiplicity > 1:
16401641
set_color(option.palette, Qt.red)
16411642
elif warnings_:
1642-
set_color(option.palette, Qt.yellow)
1643+
set_color(option.palette, self.warning_text_color(option.palette))
1644+
1645+
@staticmethod
1646+
def warning_text_color(palette: QPalette):
1647+
background = palette.color(QPalette.ColorRole.Base)
1648+
if luminance(background) > 0.5:
1649+
return QColor(255, 148, 11)
1650+
else:
1651+
return QColor(Qt.GlobalColor.yellow)
16431652

16441653
def helpEvent(self, event: QHelpEvent, view: QAbstractItemView,
16451654
option: QStyleOptionViewItem, index: QModelIndex) -> bool:

0 commit comments

Comments
 (0)