|
30 | 30 | ) |
31 | 31 | from AnyQt.QtGui import ( |
32 | 32 | QStandardItemModel, QStandardItem, QKeySequence, QIcon, QBrush, QPalette, |
33 | | - QHelpEvent |
| 33 | + QHelpEvent, QColor |
34 | 34 | ) |
35 | 35 | from AnyQt.QtCore import ( |
36 | 36 | Qt, QSize, QModelIndex, QAbstractItemModel, QPersistentModelIndex, QRect, |
37 | 37 | QPoint, QItemSelectionModel |
38 | 38 | ) |
39 | 39 | from AnyQt.QtCore import pyqtSignal as Signal, pyqtSlot as Slot |
40 | 40 |
|
| 41 | +from orangecanvas.gui.utils import luminance |
41 | 42 | from orangecanvas.utils import assocf |
42 | 43 | from orangewidget.utils.listview import ListViewSearch |
43 | 44 |
|
@@ -1639,7 +1640,15 @@ def set_color(palette: QPalette, color): |
1639 | 1640 | if isinstance(multiplicity, int) and multiplicity > 1: |
1640 | 1641 | set_color(option.palette, Qt.red) |
1641 | 1642 | 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) |
1643 | 1652 |
|
1644 | 1653 | def helpEvent(self, event: QHelpEvent, view: QAbstractItemView, |
1645 | 1654 | option: QStyleOptionViewItem, index: QModelIndex) -> bool: |
|
0 commit comments