15 pyqtSlot, pyqtSignal, QAbstractTableModel, QModelIndex, Qt, |
15 pyqtSlot, pyqtSignal, QAbstractTableModel, QModelIndex, Qt, |
16 QItemSelectionModel, QLocale |
16 QItemSelectionModel, QLocale |
17 ) |
17 ) |
18 from PyQt6.QtGui import QColor |
18 from PyQt6.QtGui import QColor |
19 from PyQt6.QtWidgets import QWidget, QHeaderView, QAbstractItemView |
19 from PyQt6.QtWidgets import QWidget, QHeaderView, QAbstractItemView |
|
20 |
|
21 from EricWidgets.EricApplication import ericApp |
20 |
22 |
21 from .Ui_SymbolsWidget import Ui_SymbolsWidget |
23 from .Ui_SymbolsWidget import Ui_SymbolsWidget |
22 |
24 |
23 import UI.PixmapCache |
25 import UI.PixmapCache |
24 import Preferences |
26 import Preferences |
43 self.tr("Char"), |
45 self.tr("Char"), |
44 self.tr("Hex"), |
46 self.tr("Hex"), |
45 self.tr("HTML"), |
47 self.tr("HTML"), |
46 self.tr("Name"), |
48 self.tr("Name"), |
47 ] |
49 ] |
|
50 |
|
51 self.__isDark = ericApp().usesDarkPalette() |
48 |
52 |
49 self.__tables = [ |
53 self.__tables = [ |
50 # first last display name |
54 # first last display name |
51 (0x0, 0x1f, self.tr("Control Characters")), |
55 (0x0, 0x1f, self.tr("Control Characters")), |
52 (0x20, 0x7f, self.tr("Basic Latin")), |
56 (0x20, 0x7f, self.tr("Basic Latin")), |
375 |
379 |
376 if ( |
380 if ( |
377 role == Qt.ItemDataRole.BackgroundRole and |
381 role == Qt.ItemDataRole.BackgroundRole and |
378 index.column() == 0 |
382 index.column() == 0 |
379 ): |
383 ): |
380 # TODO: adapt color to current palette |
384 if self.__isDark: |
381 return QColor(Qt.GlobalColor.lightGray) |
385 return QColor("#4d4d4d") |
|
386 else: |
|
387 return QColor(Qt.GlobalColor.lightGray) |
382 |
388 |
383 if role == Qt.ItemDataRole.ForegroundRole: |
389 if role == Qt.ItemDataRole.ForegroundRole: |
384 char = chr(symbolId) |
390 char = chr(symbolId) |
385 # TODO: adapt color to current palette |
391 if self.__isDark: |
386 if self.__isDigit(char): |
392 if self.__isDigit(char): |
387 return QColor(Qt.GlobalColor.darkBlue) |
393 return QColor("#8787ff") |
388 elif self.__isLetter(char): |
394 elif self.__isLetter(char): |
389 return QColor(Qt.GlobalColor.darkGreen) |
395 return QColor("#87ff87") |
390 elif self.__isMark(char): |
396 elif self.__isMark(char): |
391 return QColor(Qt.GlobalColor.darkRed) |
397 return QColor("#ff8787") |
392 elif self.__isSymbol(char): |
398 elif self.__isSymbol(char): |
393 return QColor(Qt.GlobalColor.black) |
399 return QColor("#ffc060") |
394 elif self.__isPunct(char): |
400 elif self.__isPunct(char): |
395 return QColor(Qt.GlobalColor.darkMagenta) |
401 return QColor("#d080ff") |
|
402 else: |
|
403 return QColor(Qt.GlobalColor.lightGray) |
396 else: |
404 else: |
397 return QColor(Qt.GlobalColor.darkGray) |
405 if self.__isDigit(char): |
|
406 return QColor(Qt.GlobalColor.darkBlue) |
|
407 elif self.__isLetter(char): |
|
408 return QColor(Qt.GlobalColor.darkGreen) |
|
409 elif self.__isMark(char): |
|
410 return QColor(Qt.GlobalColor.darkRed) |
|
411 elif self.__isSymbol(char): |
|
412 return QColor(Qt.GlobalColor.darkYellow) |
|
413 elif self.__isPunct(char): |
|
414 return QColor(Qt.GlobalColor.darkMagenta) |
|
415 else: |
|
416 return QColor(Qt.GlobalColor.darkGray) |
398 |
417 |
399 if ( |
418 if ( |
400 role == Qt.ItemDataRole.TextAlignmentRole and |
419 role == Qt.ItemDataRole.TextAlignmentRole and |
401 index.column() in [0, 1, 3] |
420 index.column() in [0, 1, 3] |
402 ): |
421 ): |