Skip to content

Commit

Permalink
fix: Improved background color for indicating differences. fixed #221
Browse files Browse the repository at this point in the history
  • Loading branch information
bookfere committed Mar 8, 2024
1 parent f428be1 commit 9bf9326
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
14 changes: 10 additions & 4 deletions components/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
try:
from qt.core import (
Qt, QTableWidget, QHeaderView, QMenu, QAbstractItemView, QCursor,
QBrush, QTableWidgetItem, pyqtSignal, QTableWidgetSelectionRange)
QBrush, QTableWidgetItem, pyqtSignal, QTableWidgetSelectionRange,
QColor)
except ImportError:
from PyQt5.Qt import (
Qt, QTableWidget, QHeaderView, QMenu, QAbstractItemView, QCursor,
QBrush, QTableWidgetItem, pyqtSignal, QTableWidgetSelectionRange)
QBrush, QTableWidgetItem, pyqtSignal, QTableWidgetSelectionRange,
QColor)

load_translations()

Expand Down Expand Up @@ -77,21 +79,25 @@ def check_row_alignment(self, paragraph):
item = self.verticalHeaderItem(paragraph.row)
if paragraph.background is None:
paragraph.background = item.background()
if paragraph.foreground is None:
paragraph.foreground = item.foreground()

engine = get_engine_class(paragraph.engine_name)
if engine is None or paragraph.is_alignment(engine.separator):
background = paragraph.background
foreground = paragraph.foreground
tip = ''
paragraph.aligned = True
else:
background = QBrush(Qt.yellow)
background = QBrush(QColor(255, 255, 0, 100))
foreground = QBrush(Qt.black)
tip = _(
'The number of lines differs between the original text and '
'the translated text.')
paragraph.aligned = False

item.setBackground(background)
# item.setForeground(QBrush(Qt.white))
item.setForeground(foreground)
item.setToolTip(tip)
for column in range(self.columnCount()):
item = self.item(paragraph.row, column)
Expand Down
1 change: 1 addition & 0 deletions lib/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def __init__(self, id, md5, raw, original, ignored=False, attributes=None,

self.aligned = True
self.background = None
self.foreground = None

def get_attributes(self):
if self.attributes:
Expand Down

0 comments on commit 9bf9326

Please sign in to comment.