|
1 | 1 | import pandas as pd |
2 | 2 | from PySide6.QtCore import (Qt, QAbstractTableModel, QModelIndex, Signal, |
3 | 3 | QSortFilterProxyModel, QMimeData) |
4 | | -from PySide6.QtGui import QColor, QBrush |
5 | | - |
| 4 | +from PySide6.QtGui import QColor, QBrush, QPalette |
| 5 | +from PySide6.QtWidgets import QApplication |
6 | 6 | from ..C import COLUMNS |
7 | 7 | from ..utils import validate_value, create_empty_dataframe, is_invalid, \ |
8 | 8 | get_selected |
@@ -61,7 +61,7 @@ def data(self, index, role=Qt.DisplayRole): |
61 | 61 | elif role == Qt.ForegroundRole: |
62 | 62 | # Return yellow text if this cell is a match |
63 | 63 | if (row, column) in self.highlighted_cells: |
64 | | - return QBrush(QColor(255, 255, 0)) # Yellow color |
| 64 | + return QApplication.palette().color(QPalette.HighlightedText) |
65 | 65 | return QBrush(QColor(0, 0, 0)) # Default black text |
66 | 66 | return None |
67 | 67 |
|
@@ -444,6 +444,8 @@ def determine_background_color(self, row, column): |
444 | 444 | """ |
445 | 445 | if (row, column) == (self._data_frame.shape[0], 0): |
446 | 446 | return QColor(144, 238, 144, 150) |
| 447 | + if (row, column) in self.highlighted_cells: |
| 448 | + return QApplication.palette().color(QPalette.Highlight) |
447 | 449 | if (row, column) in self._invalid_cells: |
448 | 450 | return QColor(255, 100, 100, 150) |
449 | 451 | if row % 2 == 0: |
@@ -538,6 +540,11 @@ def data(self, index, role=Qt.DisplayRole): |
538 | 540 | return str(value) |
539 | 541 | elif role == Qt.BackgroundRole: |
540 | 542 | return self.determine_background_color(row, column) |
| 543 | + elif role == Qt.ForegroundRole: |
| 544 | + # Return yellow text if this cell is a match |
| 545 | + if (row, column) in self.highlighted_cells: |
| 546 | + return QApplication.palette().color(QPalette.HighlightedText) |
| 547 | + return QBrush(QColor(0, 0, 0)) # Default black text |
541 | 548 | return None |
542 | 549 |
|
543 | 550 | def headerData(self, section, orientation, role=Qt.DisplayRole): |
|
0 commit comments