Fix theme update in outline view
This commit is contained in:
@@ -90,12 +90,13 @@ class NovelSelector(QComboBox):
|
|||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def refreshNovelList(self) -> None:
|
def refreshNovelList(self) -> None:
|
||||||
"""Rebuild the list of novel items."""
|
"""Rebuild the list of novel items."""
|
||||||
|
cHandle = self.currentData()
|
||||||
|
|
||||||
self._blockSignal = True
|
self._blockSignal = True
|
||||||
self._firstHandle = None
|
self._firstHandle = None
|
||||||
self.clear()
|
self.clear()
|
||||||
|
|
||||||
icon = SHARED.theme.getIcon(nwLabels.CLASS_ICON[nwItemClass.NOVEL], "blue")
|
icon = SHARED.theme.getIcon(nwLabels.CLASS_ICON[nwItemClass.NOVEL], "blue")
|
||||||
handle = self.currentData()
|
|
||||||
for tHandle, nwItem in SHARED.project.tree.iterRoots(nwItemClass.NOVEL):
|
for tHandle, nwItem in SHARED.project.tree.iterRoots(nwItemClass.NOVEL):
|
||||||
if self._listFormat:
|
if self._listFormat:
|
||||||
name = self._listFormat.format(nwItem.itemName)
|
name = self._listFormat.format(nwItem.itemName)
|
||||||
@@ -110,7 +111,7 @@ class NovelSelector(QComboBox):
|
|||||||
self.insertSeparator(self.count())
|
self.insertSeparator(self.count())
|
||||||
self.addItem(icon, self.tr("All Novel Folders"), "")
|
self.addItem(icon, self.tr("All Novel Folders"), "")
|
||||||
|
|
||||||
self.setHandle(handle)
|
self.setHandle(cHandle)
|
||||||
self.setEnabled(self.count() > 1)
|
self.setEnabled(self.count() > 1)
|
||||||
self._blockSignal = False
|
self._blockSignal = False
|
||||||
|
|
||||||
|
|||||||
+21
-12
@@ -34,6 +34,7 @@ from enum import Enum
|
|||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
from PyQt5.QtCore import QT_TRANSLATE_NOOP, Qt, pyqtSignal, pyqtSlot
|
from PyQt5.QtCore import QT_TRANSLATE_NOOP, Qt, pyqtSignal, pyqtSlot
|
||||||
|
from PyQt5.QtGui import QIcon
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QAbstractItemView, QAction, QFileDialog, QFrame, QGridLayout, QGroupBox,
|
QAbstractItemView, QAction, QFileDialog, QFrame, QGridLayout, QGroupBox,
|
||||||
QHBoxLayout, QLabel, QMenu, QScrollArea, QSplitter, QToolBar, QToolButton,
|
QHBoxLayout, QLabel, QMenu, QScrollArea, QSplitter, QToolBar, QToolButton,
|
||||||
@@ -103,7 +104,10 @@ class GuiOutlineView(QWidget):
|
|||||||
def updateTheme(self) -> None:
|
def updateTheme(self) -> None:
|
||||||
"""Update theme elements."""
|
"""Update theme elements."""
|
||||||
self.outlineBar.updateTheme()
|
self.outlineBar.updateTheme()
|
||||||
self.refreshTree()
|
self.outlineTree.updateTheme()
|
||||||
|
self.outlineTree.refreshTree(
|
||||||
|
rootHandle=SHARED.project.data.getLastHandle("outline"), overRide=True
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
def initSettings(self) -> None:
|
def initSettings(self) -> None:
|
||||||
@@ -397,18 +401,8 @@ class GuiOutlineTree(QTreeWidget):
|
|||||||
fH2 = self.font()
|
fH2 = self.font()
|
||||||
fH2.setBold(True)
|
fH2.setBold(True)
|
||||||
|
|
||||||
iType = nwItemType.FILE
|
|
||||||
iClass = nwItemClass.NO_CLASS
|
|
||||||
iLayout = nwItemLayout.DOCUMENT
|
|
||||||
|
|
||||||
self._hFonts = [self.font(), fH1, fH2, self.font(), self.font()]
|
self._hFonts = [self.font(), fH1, fH2, self.font(), self.font()]
|
||||||
self._dIcon = {
|
self._dIcon: dict[str, QIcon] = {}
|
||||||
"H0": SHARED.theme.getItemIcon(iType, iClass, iLayout, "H0"),
|
|
||||||
"H1": SHARED.theme.getItemIcon(iType, iClass, iLayout, "H1"),
|
|
||||||
"H2": SHARED.theme.getItemIcon(iType, iClass, iLayout, "H2"),
|
|
||||||
"H3": SHARED.theme.getItemIcon(iType, iClass, iLayout, "H3"),
|
|
||||||
"H4": SHARED.theme.getItemIcon(iType, iClass, iLayout, "H4"),
|
|
||||||
}
|
|
||||||
|
|
||||||
# Internals
|
# Internals
|
||||||
self._treeOrder = []
|
self._treeOrder = []
|
||||||
@@ -419,6 +413,7 @@ class GuiOutlineTree(QTreeWidget):
|
|||||||
self._firstView = True
|
self._firstView = True
|
||||||
self._lastBuild = 0
|
self._lastBuild = 0
|
||||||
|
|
||||||
|
self.updateTheme()
|
||||||
self.initSettings()
|
self.initSettings()
|
||||||
self.clearContent()
|
self.clearContent()
|
||||||
|
|
||||||
@@ -480,6 +475,20 @@ class GuiOutlineTree(QTreeWidget):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def updateTheme(self) -> None:
|
||||||
|
"""Update theme elements."""
|
||||||
|
iType = nwItemType.FILE
|
||||||
|
iClass = nwItemClass.NO_CLASS
|
||||||
|
iLayout = nwItemLayout.DOCUMENT
|
||||||
|
self._dIcon = {
|
||||||
|
"H0": SHARED.theme.getItemIcon(iType, iClass, iLayout, "H0"),
|
||||||
|
"H1": SHARED.theme.getItemIcon(iType, iClass, iLayout, "H1"),
|
||||||
|
"H2": SHARED.theme.getItemIcon(iType, iClass, iLayout, "H2"),
|
||||||
|
"H3": SHARED.theme.getItemIcon(iType, iClass, iLayout, "H3"),
|
||||||
|
"H4": SHARED.theme.getItemIcon(iType, iClass, iLayout, "H4"),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
def refreshTree(
|
def refreshTree(
|
||||||
self, rootHandle: str | None = None,
|
self, rootHandle: str | None = None,
|
||||||
overRide: bool = False, novelChanged: bool = False
|
overRide: bool = False, novelChanged: bool = False
|
||||||
|
|||||||
Reference in New Issue
Block a user