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,11 +176,12 @@ class Voices(QTreeWidget):
|
|||||||
if column == 0 and item.parent() is not self.invisibleRootItem() and not self.ignore_item_changes:
|
if column == 0 and item.parent() is not self.invisibleRootItem() and not self.ignore_item_changes:
|
||||||
if item.checkState(0) == Qt.CheckState.Checked:
|
if item.checkState(0) == Qt.CheckState.Checked:
|
||||||
p = item.parent()
|
p = item.parent()
|
||||||
for child in (p.child(i) for i in range(p.childCount())):
|
if p is not None:
|
||||||
if child is not item and child.checkState(0) == Qt.CheckState.Checked:
|
for child in (p.child(i) for i in range(p.childCount())):
|
||||||
self.ignore_item_changes = True
|
if child is not item and child.checkState(0) == Qt.CheckState.Checked:
|
||||||
child.setCheckState(0, Qt.CheckState.Unchecked)
|
self.ignore_item_changes = True
|
||||||
self.ignore_item_changes = False
|
child.setCheckState(0, Qt.CheckState.Unchecked)
|
||||||
|
self.ignore_item_changes = False
|
||||||
|
|
||||||
def mousePressEvent(self, event):
|
def mousePressEvent(self, event):
|
||||||
item = self.itemAt(event.pos())
|
item = self.itemAt(event.pos())
|
||||||
@ -201,8 +202,9 @@ class Voices(QTreeWidget):
|
|||||||
|
|
||||||
def set_item_downloaded_state(self, ans: QTreeWidgetItem) -> None:
|
def set_item_downloaded_state(self, ans: QTreeWidgetItem) -> None:
|
||||||
voice = ans.data(0, Qt.ItemDataRole.UserRole)
|
voice = ans.data(0, Qt.ItemDataRole.UserRole)
|
||||||
is_downloaded = bool(voice and voice.engine_data and voice.engine_data.get('is_downloaded'))
|
if isinstance(voice, Voice):
|
||||||
ans.setFont(0, self.highlight_font if is_downloaded else self.normal_font)
|
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)
|
||||||
|
|
||||||
def set_voices(
|
def set_voices(
|
||||||
self, all_voices: tuple[Voice, ...], current_voice: str, engine_metadata: EngineMetadata,
|
self, all_voices: tuple[Voice, ...], current_voice: str, engine_metadata: EngineMetadata,
|
||||||
@ -272,11 +274,13 @@ class Voices(QTreeWidget):
|
|||||||
def current_voice(self) -> Voice | None:
|
def current_voice(self) -> Voice | None:
|
||||||
ci = self.currentItem()
|
ci = self.currentItem()
|
||||||
if ci is not None:
|
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:
|
def refresh_current_item(self) -> None:
|
||||||
ci = self.currentItem()
|
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)
|
self.set_item_downloaded_state(ci)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user