mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix some bugs when clicking on language names caused by the support for embedding
This commit is contained in:
parent
97d476811a
commit
2e569b0a49
@ -176,6 +176,7 @@ class Voices(QTreeWidget):
|
||||
if column == 0 and item.parent() is not self.invisibleRootItem() and not self.ignore_item_changes:
|
||||
if item.checkState(0) == Qt.CheckState.Checked:
|
||||
p = item.parent()
|
||||
if p is not None:
|
||||
for child in (p.child(i) for i in range(p.childCount())):
|
||||
if child is not item and child.checkState(0) == Qt.CheckState.Checked:
|
||||
self.ignore_item_changes = True
|
||||
@ -201,6 +202,7 @@ class Voices(QTreeWidget):
|
||||
|
||||
def set_item_downloaded_state(self, ans: QTreeWidgetItem) -> None:
|
||||
voice = ans.data(0, Qt.ItemDataRole.UserRole)
|
||||
if isinstance(voice, Voice):
|
||||
is_downloaded = bool(voice and voice.engine_data and voice.engine_data.get('is_downloaded'))
|
||||
ans.setFont(0, self.highlight_font if is_downloaded else self.normal_font)
|
||||
|
||||
@ -272,11 +274,13 @@ class Voices(QTreeWidget):
|
||||
def current_voice(self) -> Voice | None:
|
||||
ci = self.currentItem()
|
||||
if ci is not None:
|
||||
return ci.data(0, Qt.ItemDataRole.UserRole)
|
||||
ans = ci.data(0, Qt.ItemDataRole.UserRole)
|
||||
if isinstance(ans, Voice):
|
||||
return ans
|
||||
|
||||
def refresh_current_item(self) -> None:
|
||||
ci = self.currentItem()
|
||||
if ci is not None:
|
||||
if ci is not None and ci.parent() is not self.invisibleRootItem():
|
||||
self.set_item_downloaded_state(ci)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user