Skip to content

Commit

Permalink
fix: Fixed the bug that prevented setting the color for the original …
Browse files Browse the repository at this point in the history
…text.
  • Loading branch information
bookfere committed May 4, 2024
1 parent fea4edf commit b3afafd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ def layout_progress(self):
title.setMaximumWidth(cover_image.width())
title.setText(title.fontMetrics().elidedText(
self.ebook.title, Qt.ElideRight, title.width()))
title.setToolTip(self.ebook.title)

progress_bar = QProgressBar()
progress_bar.setFormat('')
Expand Down
4 changes: 3 additions & 1 deletion lib/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,9 @@ def _create_new_element(
def add_translation(self, translation=None):
# self.element.tail = None # Make sure the element has no tail
if self.original_color is not None:
self.element.set('style', 'color:%s' % self.original_color)
for element in self.element.iter():
if element.text is not None or len(list(element)) > 0:
element.set('style', 'color:%s' % self.original_color)
if translation is None:
if self.position in ('left', 'right'):
self.element.addnext(self._create_table())
Expand Down
5 changes: 4 additions & 1 deletion tests/test_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,10 @@ def test_add_translation_below(self):
self.element.add_translation('test')

original, translation = self.xhtml.findall('.//x:p', namespaces=ns)
self.assertEqual('color:red', original.get('style'))
for element in original:
with self.subTest(element=element):
if get_name(element) != 'img':
self.assertEqual('color:red', element.get('style'))
self.assertEqual('color:blue', translation.get('style'))
self.assertIn('>test<', get_string(translation))

Expand Down

0 comments on commit b3afafd

Please sign in to comment.