Move theme and project instances to new shared data class
This commit is contained in:
@@ -49,7 +49,7 @@ from PyQt5.QtWidgets import (
|
||||
QPushButton, QShortcut, QTextEdit, QToolBar, QToolButton, QWidget
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.enum import nwAlert, nwDocAction, nwDocInsert, nwDocMode, nwItemClass
|
||||
from novelwriter.common import minmax, transferCase
|
||||
from novelwriter.constants import nwConst, nwKeyWords, nwUnicode
|
||||
@@ -132,8 +132,8 @@ class GuiDocEditor(QTextEdit):
|
||||
self.docSearch = GuiDocEditSearch(self)
|
||||
|
||||
# Syntax
|
||||
self.spEnchant = NWSpellEnchant(self.mainGui.project)
|
||||
self.highLight = GuiDocHighlighter(qDoc, self.mainGui, self.spEnchant)
|
||||
self.spEnchant = NWSpellEnchant(SHARED.project)
|
||||
self.highLight = GuiDocHighlighter(qDoc, self.spEnchant)
|
||||
|
||||
# Context Menu
|
||||
self.setContextMenuPolicy(Qt.CustomContextMenu)
|
||||
@@ -227,14 +227,14 @@ class GuiDocEditor(QTextEdit):
|
||||
"""Update the syntax highlighting theme.
|
||||
"""
|
||||
mainPalette = self.palette()
|
||||
mainPalette.setColor(QPalette.Window, QColor(*CONFIG.theme.colBack))
|
||||
mainPalette.setColor(QPalette.Base, QColor(*CONFIG.theme.colBack))
|
||||
mainPalette.setColor(QPalette.Text, QColor(*CONFIG.theme.colText))
|
||||
mainPalette.setColor(QPalette.Window, QColor(*SHARED.theme.colBack))
|
||||
mainPalette.setColor(QPalette.Base, QColor(*SHARED.theme.colBack))
|
||||
mainPalette.setColor(QPalette.Text, QColor(*SHARED.theme.colText))
|
||||
self.setPalette(mainPalette)
|
||||
|
||||
docPalette = self.viewport().palette()
|
||||
docPalette.setColor(QPalette.Base, QColor(*CONFIG.theme.colBack))
|
||||
docPalette.setColor(QPalette.Text, QColor(*CONFIG.theme.colText))
|
||||
docPalette.setColor(QPalette.Base, QColor(*SHARED.theme.colBack))
|
||||
docPalette.setColor(QPalette.Text, QColor(*SHARED.theme.colText))
|
||||
self.viewport().setPalette(docPalette)
|
||||
|
||||
self.docHeader.matchColours()
|
||||
@@ -340,7 +340,7 @@ class GuiDocEditor(QTextEdit):
|
||||
document is new (empty string), we set up the editor for editing
|
||||
the file.
|
||||
"""
|
||||
self._nwDocument = self.mainGui.project.storage.getDocument(tHandle)
|
||||
self._nwDocument = SHARED.project.storage.getDocument(tHandle)
|
||||
self._nwItem = self._nwDocument.getCurrentItem()
|
||||
|
||||
theDoc = self._nwDocument.readDocument()
|
||||
@@ -516,10 +516,10 @@ class GuiDocEditor(QTextEdit):
|
||||
self.setDocumentChanged(False)
|
||||
|
||||
oldHeader = self._nwItem.mainHeading
|
||||
oldCount = self.mainGui.project.index.getHandleHeaderCount(tHandle)
|
||||
self.mainGui.project.index.scanText(tHandle, docText)
|
||||
oldCount = SHARED.project.index.getHandleHeaderCount(tHandle)
|
||||
SHARED.project.index.scanText(tHandle, docText)
|
||||
newHeader = self._nwItem.mainHeading
|
||||
newCount = self.mainGui.project.index.getHandleHeaderCount(tHandle)
|
||||
newCount = SHARED.project.index.getHandleHeaderCount(tHandle)
|
||||
|
||||
if self._nwItem.itemClass == nwItemClass.NOVEL:
|
||||
if oldCount == newCount:
|
||||
@@ -698,10 +698,10 @@ class GuiDocEditor(QTextEdit):
|
||||
"""Set the spell checker dictionary language, and emit the
|
||||
dictionary changed signal.
|
||||
"""
|
||||
if self.mainGui.project.data.spellLang is None:
|
||||
if SHARED.project.data.spellLang is None:
|
||||
theLang = CONFIG.spellLanguage
|
||||
else:
|
||||
theLang = self.mainGui.project.data.spellLang
|
||||
theLang = SHARED.project.data.spellLang
|
||||
|
||||
self.spEnchant.setLanguage(theLang)
|
||||
_, theProvider = self.spEnchant.describeDict()
|
||||
@@ -734,7 +734,7 @@ class GuiDocEditor(QTextEdit):
|
||||
|
||||
self._spellCheck = theMode
|
||||
self.mainGui.mainMenu.setSpellCheck(theMode)
|
||||
self.mainGui.project.data.setSpellCheck(theMode)
|
||||
SHARED.project.data.setSpellCheck(theMode)
|
||||
self.highLight.setSpellCheck(theMode)
|
||||
if not self._bigDoc or theMode is False:
|
||||
# We don't run the spell checker automatically on big docs
|
||||
@@ -1916,7 +1916,7 @@ class GuiDocEditor(QTextEdit):
|
||||
|
||||
if theText.startswith("@"):
|
||||
|
||||
isGood, tBits, tPos = self.mainGui.project.index.scanThis(theText)
|
||||
isGood, tBits, tPos = SHARED.project.index.scanThis(theText)
|
||||
if not isGood:
|
||||
return False
|
||||
|
||||
@@ -2233,9 +2233,9 @@ class GuiDocEditSearch(QFrame):
|
||||
self.doMatchCap = CONFIG.searchMatchCap
|
||||
|
||||
mPx = CONFIG.pxInt(6)
|
||||
tPx = int(0.8*CONFIG.theme.fontPixelSize)
|
||||
self.boxFont = CONFIG.theme.guiFont
|
||||
self.boxFont.setPointSizeF(0.9*CONFIG.theme.fontPointSize)
|
||||
tPx = int(0.8*SHARED.theme.fontPixelSize)
|
||||
self.boxFont = SHARED.theme.guiFont
|
||||
self.boxFont.setPointSizeF(0.9*SHARED.theme.fontPointSize)
|
||||
|
||||
self.setContentsMargins(0, 0, 0, 0)
|
||||
self.setAutoFillBackground(True)
|
||||
@@ -2268,7 +2268,7 @@ class GuiDocEditSearch(QFrame):
|
||||
|
||||
self.resultLabel = QLabel("?/?")
|
||||
self.resultLabel.setFont(self.boxFont)
|
||||
self.resultLabel.setMinimumWidth(CONFIG.theme.getTextWidth("?/?", self.boxFont))
|
||||
self.resultLabel.setMinimumWidth(SHARED.theme.getTextWidth("?/?", self.boxFont))
|
||||
|
||||
self.toggleCase = QAction(self.tr("Case Sensitive"), self)
|
||||
self.toggleCase.setCheckable(True)
|
||||
@@ -2374,15 +2374,15 @@ class GuiDocEditSearch(QFrame):
|
||||
self.replaceBox.setPalette(qPalette)
|
||||
|
||||
# Set icons
|
||||
self.toggleCase.setIcon(CONFIG.theme.getIcon("search_case"))
|
||||
self.toggleWord.setIcon(CONFIG.theme.getIcon("search_word"))
|
||||
self.toggleRegEx.setIcon(CONFIG.theme.getIcon("search_regex"))
|
||||
self.toggleLoop.setIcon(CONFIG.theme.getIcon("search_loop"))
|
||||
self.toggleProject.setIcon(CONFIG.theme.getIcon("search_project"))
|
||||
self.toggleMatchCap.setIcon(CONFIG.theme.getIcon("search_preserve"))
|
||||
self.cancelSearch.setIcon(CONFIG.theme.getIcon("search_cancel"))
|
||||
self.searchButton.setIcon(CONFIG.theme.getIcon("search"))
|
||||
self.replaceButton.setIcon(CONFIG.theme.getIcon("search_replace"))
|
||||
self.toggleCase.setIcon(SHARED.theme.getIcon("search_case"))
|
||||
self.toggleWord.setIcon(SHARED.theme.getIcon("search_word"))
|
||||
self.toggleRegEx.setIcon(SHARED.theme.getIcon("search_regex"))
|
||||
self.toggleLoop.setIcon(SHARED.theme.getIcon("search_loop"))
|
||||
self.toggleProject.setIcon(SHARED.theme.getIcon("search_project"))
|
||||
self.toggleMatchCap.setIcon(SHARED.theme.getIcon("search_preserve"))
|
||||
self.cancelSearch.setIcon(SHARED.theme.getIcon("search_cancel"))
|
||||
self.searchButton.setIcon(SHARED.theme.getIcon("search"))
|
||||
self.replaceButton.setIcon(SHARED.theme.getIcon("search_replace"))
|
||||
|
||||
# Set stylesheets
|
||||
self.searchOpt.setStyleSheet("QToolBar {padding: 0;}")
|
||||
@@ -2474,7 +2474,7 @@ class GuiDocEditSearch(QFrame):
|
||||
"""
|
||||
currRes = "?" if currRes is None else currRes
|
||||
resCount = "?" if resCount is None else "1000+" if resCount > 1000 else resCount
|
||||
minWidth = CONFIG.theme.getTextWidth(f"{resCount}//{resCount}", self.boxFont)
|
||||
minWidth = SHARED.theme.getTextWidth(f"{resCount}//{resCount}", self.boxFont)
|
||||
self.resultLabel.setText(f"{currRes}/{resCount}")
|
||||
self.resultLabel.setMinimumWidth(minWidth)
|
||||
self.adjustSize()
|
||||
@@ -2639,7 +2639,7 @@ class GuiDocEditHeader(QWidget):
|
||||
|
||||
self._docHandle = None
|
||||
|
||||
fPx = int(0.9*CONFIG.theme.fontPixelSize)
|
||||
fPx = int(0.9*SHARED.theme.fontPixelSize)
|
||||
hSp = CONFIG.pxInt(6)
|
||||
|
||||
# Main Widget Settings
|
||||
@@ -2656,7 +2656,7 @@ class GuiDocEditHeader(QWidget):
|
||||
self.theTitle.setFixedHeight(fPx)
|
||||
|
||||
lblFont = self.theTitle.font()
|
||||
lblFont.setPointSizeF(0.9*CONFIG.theme.fontPointSize)
|
||||
lblFont.setPointSizeF(0.9*SHARED.theme.fontPointSize)
|
||||
self.theTitle.setFont(lblFont)
|
||||
|
||||
# Buttons
|
||||
@@ -2726,15 +2726,15 @@ class GuiDocEditHeader(QWidget):
|
||||
def updateTheme(self):
|
||||
"""Update theme elements.
|
||||
"""
|
||||
self.editButton.setIcon(CONFIG.theme.getIcon("edit"))
|
||||
self.searchButton.setIcon(CONFIG.theme.getIcon("search"))
|
||||
self.minmaxButton.setIcon(CONFIG.theme.getIcon("maximise"))
|
||||
self.closeButton.setIcon(CONFIG.theme.getIcon("close"))
|
||||
self.editButton.setIcon(SHARED.theme.getIcon("edit"))
|
||||
self.searchButton.setIcon(SHARED.theme.getIcon("search"))
|
||||
self.minmaxButton.setIcon(SHARED.theme.getIcon("maximise"))
|
||||
self.closeButton.setIcon(SHARED.theme.getIcon("close"))
|
||||
|
||||
buttonStyle = (
|
||||
"QToolButton {{border: none; background: transparent;}} "
|
||||
"QToolButton:hover {{border: none; background: rgba({0},{1},{2},0.2);}}"
|
||||
).format(*CONFIG.theme.colText)
|
||||
).format(*SHARED.theme.colText)
|
||||
|
||||
self.editButton.setStyleSheet(buttonStyle)
|
||||
self.searchButton.setStyleSheet(buttonStyle)
|
||||
@@ -2750,9 +2750,9 @@ class GuiDocEditHeader(QWidget):
|
||||
theme rather than the main GUI.
|
||||
"""
|
||||
thePalette = QPalette()
|
||||
thePalette.setColor(QPalette.Window, QColor(*CONFIG.theme.colBack))
|
||||
thePalette.setColor(QPalette.WindowText, QColor(*CONFIG.theme.colText))
|
||||
thePalette.setColor(QPalette.Text, QColor(*CONFIG.theme.colText))
|
||||
thePalette.setColor(QPalette.Window, QColor(*SHARED.theme.colBack))
|
||||
thePalette.setColor(QPalette.WindowText, QColor(*SHARED.theme.colText))
|
||||
thePalette.setColor(QPalette.Text, QColor(*SHARED.theme.colText))
|
||||
|
||||
self.setPalette(thePalette)
|
||||
self.theTitle.setPalette(thePalette)
|
||||
@@ -2772,7 +2772,7 @@ class GuiDocEditHeader(QWidget):
|
||||
self.minmaxButton.setVisible(False)
|
||||
return True
|
||||
|
||||
pTree = self.mainGui.project.tree
|
||||
pTree = SHARED.project.tree
|
||||
if CONFIG.showFullPath:
|
||||
tTitle = []
|
||||
tTree = pTree.getItemPath(tHandle)
|
||||
@@ -2801,9 +2801,9 @@ class GuiDocEditHeader(QWidget):
|
||||
toggleFocusMode function and should not be activated directly.
|
||||
"""
|
||||
if self.mainGui.isFocusMode:
|
||||
self.minmaxButton.setIcon(CONFIG.theme.getIcon("minimise"))
|
||||
self.minmaxButton.setIcon(SHARED.theme.getIcon("minimise"))
|
||||
else:
|
||||
self.minmaxButton.setIcon(CONFIG.theme.getIcon("maximise"))
|
||||
self.minmaxButton.setIcon(SHARED.theme.getIcon("maximise"))
|
||||
return
|
||||
|
||||
##
|
||||
@@ -2876,13 +2876,13 @@ class GuiDocEditFooter(QWidget):
|
||||
|
||||
self._docSelection = False
|
||||
|
||||
self.sPx = int(round(0.9*CONFIG.theme.baseIconSize))
|
||||
fPx = int(0.9*CONFIG.theme.fontPixelSize)
|
||||
self.sPx = int(round(0.9*SHARED.theme.baseIconSize))
|
||||
fPx = int(0.9*SHARED.theme.fontPixelSize)
|
||||
bSp = CONFIG.pxInt(4)
|
||||
hSp = CONFIG.pxInt(6)
|
||||
|
||||
lblFont = self.font()
|
||||
lblFont.setPointSizeF(0.9*CONFIG.theme.fontPointSize)
|
||||
lblFont.setPointSizeF(0.9*SHARED.theme.fontPointSize)
|
||||
|
||||
# Main Widget Settings
|
||||
self.setContentsMargins(0, 0, 0, 0)
|
||||
@@ -2969,8 +2969,8 @@ class GuiDocEditFooter(QWidget):
|
||||
def updateTheme(self):
|
||||
"""Update theme elements.
|
||||
"""
|
||||
self.linesIcon.setPixmap(CONFIG.theme.getPixmap("status_lines", (self.sPx, self.sPx)))
|
||||
self.wordsIcon.setPixmap(CONFIG.theme.getPixmap("status_stats", (self.sPx, self.sPx)))
|
||||
self.linesIcon.setPixmap(SHARED.theme.getPixmap("status_lines", (self.sPx, self.sPx)))
|
||||
self.wordsIcon.setPixmap(SHARED.theme.getPixmap("status_stats", (self.sPx, self.sPx)))
|
||||
|
||||
self.matchColours()
|
||||
|
||||
@@ -2981,9 +2981,9 @@ class GuiDocEditFooter(QWidget):
|
||||
theme rather than the main GUI.
|
||||
"""
|
||||
thePalette = QPalette()
|
||||
thePalette.setColor(QPalette.Window, QColor(*CONFIG.theme.colBack))
|
||||
thePalette.setColor(QPalette.WindowText, QColor(*CONFIG.theme.colText))
|
||||
thePalette.setColor(QPalette.Text, QColor(*CONFIG.theme.colText))
|
||||
thePalette.setColor(QPalette.Window, QColor(*SHARED.theme.colBack))
|
||||
thePalette.setColor(QPalette.WindowText, QColor(*SHARED.theme.colText))
|
||||
thePalette.setColor(QPalette.Text, QColor(*SHARED.theme.colText))
|
||||
|
||||
self.setPalette(thePalette)
|
||||
self.statusText.setPalette(thePalette)
|
||||
@@ -3000,7 +3000,7 @@ class GuiDocEditFooter(QWidget):
|
||||
logger.debug("No handle set, so clearing the editor footer")
|
||||
self._theItem = None
|
||||
else:
|
||||
self._theItem = self.mainGui.project.tree[self._docHandle]
|
||||
self._theItem = SHARED.project.tree[self._docHandle]
|
||||
|
||||
self.setHasSelection(False)
|
||||
self.updateInfo()
|
||||
|
||||
@@ -32,7 +32,7 @@ from PyQt5.QtGui import (
|
||||
QColor, QTextCharFormat, QFont, QSyntaxHighlighter, QBrush
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.common import checkInt
|
||||
from novelwriter.constants import nwRegEx, nwUnicode
|
||||
|
||||
@@ -46,14 +46,13 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
BLOCK_META = 2
|
||||
BLOCK_TITLE = 4
|
||||
|
||||
def __init__(self, theDoc, mainGui, spEnchant):
|
||||
def __init__(self, theDoc, spEnchant):
|
||||
super().__init__(theDoc)
|
||||
|
||||
logger.debug("Create: GuiDocHighlighter")
|
||||
|
||||
self.theDoc = theDoc
|
||||
self.spEnchant = spEnchant
|
||||
self.mainGui = mainGui
|
||||
self.theHandle = None
|
||||
self.spellCheck = False
|
||||
self.spellRx = None
|
||||
@@ -85,24 +84,24 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
"""
|
||||
logger.debug("Setting up highlighting rules")
|
||||
|
||||
self.colHead = QColor(*CONFIG.theme.colHead)
|
||||
self.colHeadH = QColor(*CONFIG.theme.colHeadH)
|
||||
self.colDialN = QColor(*CONFIG.theme.colDialN)
|
||||
self.colDialD = QColor(*CONFIG.theme.colDialD)
|
||||
self.colDialS = QColor(*CONFIG.theme.colDialS)
|
||||
self.colHidden = QColor(*CONFIG.theme.colHidden)
|
||||
self.colKey = QColor(*CONFIG.theme.colKey)
|
||||
self.colVal = QColor(*CONFIG.theme.colVal)
|
||||
self.colSpell = QColor(*CONFIG.theme.colSpell)
|
||||
self.colError = QColor(*CONFIG.theme.colError)
|
||||
self.colRepTag = QColor(*CONFIG.theme.colRepTag)
|
||||
self.colMod = QColor(*CONFIG.theme.colMod)
|
||||
self.colBreak = QColor(*CONFIG.theme.colEmph)
|
||||
self.colHead = QColor(*SHARED.theme.colHead)
|
||||
self.colHeadH = QColor(*SHARED.theme.colHeadH)
|
||||
self.colDialN = QColor(*SHARED.theme.colDialN)
|
||||
self.colDialD = QColor(*SHARED.theme.colDialD)
|
||||
self.colDialS = QColor(*SHARED.theme.colDialS)
|
||||
self.colHidden = QColor(*SHARED.theme.colHidden)
|
||||
self.colKey = QColor(*SHARED.theme.colKey)
|
||||
self.colVal = QColor(*SHARED.theme.colVal)
|
||||
self.colSpell = QColor(*SHARED.theme.colSpell)
|
||||
self.colError = QColor(*SHARED.theme.colError)
|
||||
self.colRepTag = QColor(*SHARED.theme.colRepTag)
|
||||
self.colMod = QColor(*SHARED.theme.colMod)
|
||||
self.colBreak = QColor(*SHARED.theme.colEmph)
|
||||
self.colBreak.setAlpha(64)
|
||||
|
||||
self.colEmph = None
|
||||
if CONFIG.highlightEmph:
|
||||
self.colEmph = QColor(*CONFIG.theme.colEmph)
|
||||
self.colEmph = QColor(*SHARED.theme.colEmph)
|
||||
|
||||
self.hStyles = {
|
||||
"header1": self._makeFormat(self.colHead, "bold", 1.8),
|
||||
@@ -285,8 +284,8 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
|
||||
if theText.startswith("@"): # Keywords and commands
|
||||
self.setCurrentBlockState(self.BLOCK_META)
|
||||
pIndex = self.mainGui.project.index
|
||||
tItem = self.mainGui.project.tree[self.theHandle]
|
||||
pIndex = SHARED.project.index
|
||||
tItem = SHARED.project.tree[self.theHandle]
|
||||
isValid, theBits, thePos = pIndex.scanThis(theText)
|
||||
isGood = pIndex.checkThese(theBits, tItem)
|
||||
if isValid:
|
||||
|
||||
@@ -40,7 +40,7 @@ from PyQt5.QtWidgets import (
|
||||
QAction, QMenu, QFrame
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.enum import nwItemType, nwDocAction, nwDocMode
|
||||
from novelwriter.error import logException
|
||||
from novelwriter.constants import nwUnicode
|
||||
@@ -119,14 +119,14 @@ class GuiDocViewer(QTextBrowser):
|
||||
|
||||
# Set the widget colours to match syntax theme
|
||||
mainPalette = self.palette()
|
||||
mainPalette.setColor(QPalette.Window, QColor(*CONFIG.theme.colBack))
|
||||
mainPalette.setColor(QPalette.Base, QColor(*CONFIG.theme.colBack))
|
||||
mainPalette.setColor(QPalette.Text, QColor(*CONFIG.theme.colText))
|
||||
mainPalette.setColor(QPalette.Window, QColor(*SHARED.theme.colBack))
|
||||
mainPalette.setColor(QPalette.Base, QColor(*SHARED.theme.colBack))
|
||||
mainPalette.setColor(QPalette.Text, QColor(*SHARED.theme.colText))
|
||||
self.setPalette(mainPalette)
|
||||
|
||||
docPalette = self.viewport().palette()
|
||||
docPalette.setColor(QPalette.Base, QColor(*CONFIG.theme.colBack))
|
||||
docPalette.setColor(QPalette.Text, QColor(*CONFIG.theme.colText))
|
||||
docPalette.setColor(QPalette.Base, QColor(*SHARED.theme.colBack))
|
||||
docPalette.setColor(QPalette.Text, QColor(*SHARED.theme.colText))
|
||||
self.viewport().setPalette(docPalette)
|
||||
|
||||
self.docHeader.matchColours()
|
||||
@@ -162,7 +162,7 @@ class GuiDocViewer(QTextBrowser):
|
||||
def loadText(self, tHandle, updateHistory=True):
|
||||
"""Load text into the viewer from an item handle.
|
||||
"""
|
||||
if not self.mainGui.project.tree.checkType(tHandle, nwItemType.FILE):
|
||||
if not SHARED.project.tree.checkType(tHandle, nwItemType.FILE):
|
||||
logger.warning("Item not found")
|
||||
return False
|
||||
|
||||
@@ -170,7 +170,7 @@ class GuiDocViewer(QTextBrowser):
|
||||
qApp.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||
|
||||
sPos = self.verticalScrollBar().value()
|
||||
aDoc = ToHtml(self.mainGui.project)
|
||||
aDoc = ToHtml(SHARED.project)
|
||||
aDoc.setPreview(CONFIG.viewComments, CONFIG.viewSynopsis)
|
||||
aDoc.setLinkHeaders(True)
|
||||
|
||||
@@ -210,7 +210,7 @@ class GuiDocViewer(QTextBrowser):
|
||||
self.verticalScrollBar().setValue(sPos)
|
||||
|
||||
self._docHandle = tHandle
|
||||
self.mainGui.project.data.setLastHandle(tHandle, "viewer")
|
||||
SHARED.project.data.setLastHandle(tHandle, "viewer")
|
||||
self.docHeader.setTitleFromHandle(self._docHandle)
|
||||
self.updateDocMargins()
|
||||
|
||||
@@ -506,27 +506,27 @@ class GuiDocViewer(QTextBrowser):
|
||||
" text-align: center;"
|
||||
"}}\n"
|
||||
).format(
|
||||
tColR=CONFIG.theme.colText[0],
|
||||
tColG=CONFIG.theme.colText[1],
|
||||
tColB=CONFIG.theme.colText[2],
|
||||
hColR=CONFIG.theme.colHead[0],
|
||||
hColG=CONFIG.theme.colHead[1],
|
||||
hColB=CONFIG.theme.colHead[2],
|
||||
aColR=CONFIG.theme.colVal[0],
|
||||
aColG=CONFIG.theme.colVal[1],
|
||||
aColB=CONFIG.theme.colVal[2],
|
||||
eColR=CONFIG.theme.colEmph[0],
|
||||
eColG=CONFIG.theme.colEmph[1],
|
||||
eColB=CONFIG.theme.colEmph[2],
|
||||
kColR=CONFIG.theme.colKey[0],
|
||||
kColG=CONFIG.theme.colKey[1],
|
||||
kColB=CONFIG.theme.colKey[2],
|
||||
cColR=CONFIG.theme.colHidden[0],
|
||||
cColG=CONFIG.theme.colHidden[1],
|
||||
cColB=CONFIG.theme.colHidden[2],
|
||||
mColR=CONFIG.theme.colMod[0],
|
||||
mColG=CONFIG.theme.colMod[1],
|
||||
mColB=CONFIG.theme.colMod[2],
|
||||
tColR=SHARED.theme.colText[0],
|
||||
tColG=SHARED.theme.colText[1],
|
||||
tColB=SHARED.theme.colText[2],
|
||||
hColR=SHARED.theme.colHead[0],
|
||||
hColG=SHARED.theme.colHead[1],
|
||||
hColB=SHARED.theme.colHead[2],
|
||||
aColR=SHARED.theme.colVal[0],
|
||||
aColG=SHARED.theme.colVal[1],
|
||||
aColB=SHARED.theme.colVal[2],
|
||||
eColR=SHARED.theme.colEmph[0],
|
||||
eColG=SHARED.theme.colEmph[1],
|
||||
eColB=SHARED.theme.colEmph[2],
|
||||
kColR=SHARED.theme.colKey[0],
|
||||
kColG=SHARED.theme.colKey[1],
|
||||
kColB=SHARED.theme.colKey[2],
|
||||
cColR=SHARED.theme.colHidden[0],
|
||||
cColG=SHARED.theme.colHidden[1],
|
||||
cColB=SHARED.theme.colHidden[2],
|
||||
mColR=SHARED.theme.colMod[0],
|
||||
mColG=SHARED.theme.colMod[1],
|
||||
mColB=SHARED.theme.colMod[2],
|
||||
)
|
||||
self.document().setDefaultStyleSheet(styleSheet)
|
||||
|
||||
@@ -685,7 +685,7 @@ class GuiDocViewHeader(QWidget):
|
||||
# Internal Variables
|
||||
self._docHandle = None
|
||||
|
||||
fPx = int(0.9*CONFIG.theme.fontPixelSize)
|
||||
fPx = int(0.9*SHARED.theme.fontPixelSize)
|
||||
hSp = CONFIG.pxInt(6)
|
||||
|
||||
# Main Widget Settings
|
||||
@@ -702,7 +702,7 @@ class GuiDocViewHeader(QWidget):
|
||||
self.theTitle.setFixedHeight(fPx)
|
||||
|
||||
lblFont = self.theTitle.font()
|
||||
lblFont.setPointSizeF(0.9*CONFIG.theme.fontPointSize)
|
||||
lblFont.setPointSizeF(0.9*SHARED.theme.fontPointSize)
|
||||
self.theTitle.setFont(lblFont)
|
||||
|
||||
# Buttons
|
||||
@@ -773,15 +773,15 @@ class GuiDocViewHeader(QWidget):
|
||||
def updateTheme(self):
|
||||
"""Update theme elements.
|
||||
"""
|
||||
self.backButton.setIcon(CONFIG.theme.getIcon("backward"))
|
||||
self.forwardButton.setIcon(CONFIG.theme.getIcon("forward"))
|
||||
self.refreshButton.setIcon(CONFIG.theme.getIcon("refresh"))
|
||||
self.closeButton.setIcon(CONFIG.theme.getIcon("close"))
|
||||
self.backButton.setIcon(SHARED.theme.getIcon("backward"))
|
||||
self.forwardButton.setIcon(SHARED.theme.getIcon("forward"))
|
||||
self.refreshButton.setIcon(SHARED.theme.getIcon("refresh"))
|
||||
self.closeButton.setIcon(SHARED.theme.getIcon("close"))
|
||||
|
||||
buttonStyle = (
|
||||
"QToolButton {{border: none; background: transparent;}} "
|
||||
"QToolButton:hover {{border: none; background: rgba({0},{1},{2},0.2);}}"
|
||||
).format(*CONFIG.theme.colText)
|
||||
).format(*SHARED.theme.colText)
|
||||
|
||||
self.backButton.setStyleSheet(buttonStyle)
|
||||
self.forwardButton.setStyleSheet(buttonStyle)
|
||||
@@ -797,9 +797,9 @@ class GuiDocViewHeader(QWidget):
|
||||
theme rather than the main GUI.
|
||||
"""
|
||||
thePalette = QPalette()
|
||||
thePalette.setColor(QPalette.Window, QColor(*CONFIG.theme.colBack))
|
||||
thePalette.setColor(QPalette.WindowText, QColor(*CONFIG.theme.colText))
|
||||
thePalette.setColor(QPalette.Text, QColor(*CONFIG.theme.colText))
|
||||
thePalette.setColor(QPalette.Window, QColor(*SHARED.theme.colBack))
|
||||
thePalette.setColor(QPalette.WindowText, QColor(*SHARED.theme.colText))
|
||||
thePalette.setColor(QPalette.Text, QColor(*SHARED.theme.colText))
|
||||
|
||||
self.setPalette(thePalette)
|
||||
self.theTitle.setPalette(thePalette)
|
||||
@@ -819,7 +819,7 @@ class GuiDocViewHeader(QWidget):
|
||||
self.refreshButton.setVisible(False)
|
||||
return True
|
||||
|
||||
pTree = self.mainGui.project.tree
|
||||
pTree = SHARED.project.tree
|
||||
if CONFIG.showFullPath:
|
||||
tTitle = []
|
||||
tTree = pTree.getItemPath(tHandle)
|
||||
@@ -902,7 +902,7 @@ class GuiDocViewFooter(QWidget):
|
||||
# Internal Variables
|
||||
self._docHandle = None
|
||||
|
||||
fPx = int(0.9*CONFIG.theme.fontPixelSize)
|
||||
fPx = int(0.9*SHARED.theme.fontPixelSize)
|
||||
bSp = CONFIG.pxInt(2)
|
||||
hSp = CONFIG.pxInt(8)
|
||||
|
||||
@@ -987,7 +987,7 @@ class GuiDocViewFooter(QWidget):
|
||||
self.lblSynopsis.setAlignment(Qt.AlignLeft | Qt.AlignTop)
|
||||
|
||||
lblFont = self.font()
|
||||
lblFont.setPointSizeF(0.9*CONFIG.theme.fontPointSize)
|
||||
lblFont.setPointSizeF(0.9*SHARED.theme.fontPointSize)
|
||||
self.lblRefs.setFont(lblFont)
|
||||
self.lblSticky.setFont(lblFont)
|
||||
self.lblComments.setFont(lblFont)
|
||||
@@ -1032,21 +1032,21 @@ class GuiDocViewFooter(QWidget):
|
||||
"""
|
||||
# Icons
|
||||
|
||||
fPx = int(0.9*CONFIG.theme.fontPixelSize)
|
||||
fPx = int(0.9*SHARED.theme.fontPixelSize)
|
||||
|
||||
stickyOn = CONFIG.theme.getPixmap("sticky-on", (fPx, fPx))
|
||||
stickyOff = CONFIG.theme.getPixmap("sticky-off", (fPx, fPx))
|
||||
stickyOn = SHARED.theme.getPixmap("sticky-on", (fPx, fPx))
|
||||
stickyOff = SHARED.theme.getPixmap("sticky-off", (fPx, fPx))
|
||||
stickyIcon = QIcon()
|
||||
stickyIcon.addPixmap(stickyOn, QIcon.Normal, QIcon.On)
|
||||
stickyIcon.addPixmap(stickyOff, QIcon.Normal, QIcon.Off)
|
||||
|
||||
bulletOn = CONFIG.theme.getPixmap("bullet-on", (fPx, fPx))
|
||||
bulletOff = CONFIG.theme.getPixmap("bullet-off", (fPx, fPx))
|
||||
bulletOn = SHARED.theme.getPixmap("bullet-on", (fPx, fPx))
|
||||
bulletOff = SHARED.theme.getPixmap("bullet-off", (fPx, fPx))
|
||||
bulletIcon = QIcon()
|
||||
bulletIcon.addPixmap(bulletOn, QIcon.Normal, QIcon.On)
|
||||
bulletIcon.addPixmap(bulletOff, QIcon.Normal, QIcon.Off)
|
||||
|
||||
self.showHide.setIcon(CONFIG.theme.getIcon("reference"))
|
||||
self.showHide.setIcon(SHARED.theme.getIcon("reference"))
|
||||
self.stickyRefs.setIcon(stickyIcon)
|
||||
self.showComments.setIcon(bulletIcon)
|
||||
self.showSynopsis.setIcon(bulletIcon)
|
||||
@@ -1056,7 +1056,7 @@ class GuiDocViewFooter(QWidget):
|
||||
buttonStyle = (
|
||||
"QToolButton {{border: none; background: transparent;}} "
|
||||
"QToolButton:hover {{border: none; background: rgba({0},{1},{2},0.2);}}"
|
||||
).format(*CONFIG.theme.colText)
|
||||
).format(*SHARED.theme.colText)
|
||||
|
||||
self.showHide.setStyleSheet(buttonStyle)
|
||||
self.stickyRefs.setStyleSheet(buttonStyle)
|
||||
@@ -1072,9 +1072,9 @@ class GuiDocViewFooter(QWidget):
|
||||
theme rather than the main GUI.
|
||||
"""
|
||||
thePalette = QPalette()
|
||||
thePalette.setColor(QPalette.Window, QColor(*CONFIG.theme.colBack))
|
||||
thePalette.setColor(QPalette.WindowText, QColor(*CONFIG.theme.colText))
|
||||
thePalette.setColor(QPalette.Text, QColor(*CONFIG.theme.colText))
|
||||
thePalette.setColor(QPalette.Window, QColor(*SHARED.theme.colBack))
|
||||
thePalette.setColor(QPalette.WindowText, QColor(*SHARED.theme.colText))
|
||||
thePalette.setColor(QPalette.Text, QColor(*SHARED.theme.colText))
|
||||
|
||||
self.setPalette(thePalette)
|
||||
self.lblRefs.setPalette(thePalette)
|
||||
@@ -1145,7 +1145,7 @@ class GuiDocViewDetails(QScrollArea):
|
||||
self.refList.setScaledContents(True)
|
||||
self.refList.linkActivated.connect(self._linkClicked)
|
||||
|
||||
self.linkStyle = "style='color: rgb({0},{1},{2})'".format(*CONFIG.theme.colLink)
|
||||
self.linkStyle = "style='color: rgb({0},{1},{2})'".format(*SHARED.theme.colLink)
|
||||
|
||||
# Assemble
|
||||
self.outerWidget = QWidget()
|
||||
@@ -1172,10 +1172,10 @@ class GuiDocViewDetails(QScrollArea):
|
||||
if self.mainGui.docViewer.stickyRef:
|
||||
return
|
||||
|
||||
theRefs = self.mainGui.project.index.getBackReferenceList(tHandle)
|
||||
theRefs = SHARED.project.index.getBackReferenceList(tHandle)
|
||||
theList = []
|
||||
for tHandle in theRefs:
|
||||
tItem = self.mainGui.project.tree[tHandle]
|
||||
tItem = SHARED.project.tree[tHandle]
|
||||
if tItem is not None:
|
||||
theList.append("<a href='%s#%s' %s>%s</a>" % (
|
||||
tHandle, theRefs[tHandle], self.linkStyle, tItem.itemName
|
||||
|
||||
@@ -29,7 +29,7 @@ from PyQt5.QtCore import Qt, pyqtSlot
|
||||
from PyQt5.QtGui import QFont, QPixmap
|
||||
from PyQt5.QtWidgets import QWidget, QGridLayout, QLabel
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.constants import trConst, nwLabels
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -42,8 +42,6 @@ class GuiItemDetails(QWidget):
|
||||
|
||||
logger.debug("Create: GuiItemDetails")
|
||||
|
||||
self.mainGui = mainGui
|
||||
|
||||
# Internal Variables
|
||||
self._itemHandle = None
|
||||
|
||||
@@ -51,7 +49,7 @@ class GuiItemDetails(QWidget):
|
||||
hSp = CONFIG.pxInt(6)
|
||||
vSp = CONFIG.pxInt(1)
|
||||
mPx = CONFIG.pxInt(6)
|
||||
fPt = CONFIG.theme.fontPointSize
|
||||
fPt = SHARED.theme.fontPointSize
|
||||
|
||||
fntLabel = QFont()
|
||||
fntLabel.setBold(True)
|
||||
@@ -176,8 +174,8 @@ class GuiItemDetails(QWidget):
|
||||
self.updateTheme()
|
||||
|
||||
# Make sure the columns for flags and counts don't resize too often
|
||||
flagWidth = CONFIG.theme.getTextWidth("Mm", fntValue)
|
||||
countWidth = CONFIG.theme.getTextWidth("99,999", fntValue)
|
||||
flagWidth = SHARED.theme.getTextWidth("Mm", fntValue)
|
||||
countWidth = SHARED.theme.getTextWidth("99,999", fntValue)
|
||||
self.mainBox.setColumnMinimumWidth(1, flagWidth)
|
||||
self.mainBox.setColumnMinimumWidth(4, countWidth)
|
||||
|
||||
@@ -233,13 +231,13 @@ class GuiItemDetails(QWidget):
|
||||
self.clearDetails()
|
||||
return
|
||||
|
||||
nwItem = self.mainGui.project.tree[tHandle]
|
||||
nwItem = SHARED.project.tree[tHandle]
|
||||
if nwItem is None:
|
||||
self.clearDetails()
|
||||
return
|
||||
|
||||
self._itemHandle = tHandle
|
||||
iPx = int(round(0.8*CONFIG.theme.baseIconSize))
|
||||
iPx = int(round(0.8*SHARED.theme.baseIconSize))
|
||||
|
||||
# Label
|
||||
# =====
|
||||
@@ -250,11 +248,11 @@ class GuiItemDetails(QWidget):
|
||||
|
||||
if nwItem.isFileType():
|
||||
if nwItem.isActive:
|
||||
self.labelIcon.setPixmap(CONFIG.theme.getPixmap("checked", (iPx, iPx)))
|
||||
self.labelIcon.setPixmap(SHARED.theme.getPixmap("checked", (iPx, iPx)))
|
||||
else:
|
||||
self.labelIcon.setPixmap(CONFIG.theme.getPixmap("unchecked", (iPx, iPx)))
|
||||
self.labelIcon.setPixmap(SHARED.theme.getPixmap("unchecked", (iPx, iPx)))
|
||||
else:
|
||||
self.labelIcon.setPixmap(CONFIG.theme.getPixmap("noncheckable", (iPx, iPx)))
|
||||
self.labelIcon.setPixmap(SHARED.theme.getPixmap("noncheckable", (iPx, iPx)))
|
||||
|
||||
self.labelData.setText(theLabel)
|
||||
|
||||
@@ -268,14 +266,14 @@ class GuiItemDetails(QWidget):
|
||||
# Class
|
||||
# =====
|
||||
|
||||
classIcon = CONFIG.theme.getIcon(nwLabels.CLASS_ICON[nwItem.itemClass])
|
||||
classIcon = SHARED.theme.getIcon(nwLabels.CLASS_ICON[nwItem.itemClass])
|
||||
self.classIcon.setPixmap(classIcon.pixmap(iPx, iPx))
|
||||
self.classData.setText(trConst(nwLabels.CLASS_NAME[nwItem.itemClass]))
|
||||
|
||||
# Layout
|
||||
# ======
|
||||
|
||||
usageIcon = CONFIG.theme.getItemIcon(
|
||||
usageIcon = SHARED.theme.getItemIcon(
|
||||
nwItem.itemType, nwItem.itemClass, nwItem.itemLayout, nwItem.mainHeading
|
||||
)
|
||||
self.usageIcon.setPixmap(usageIcon.pixmap(iPx, iPx))
|
||||
|
||||
@@ -33,7 +33,7 @@ from PyQt5.QtCore import QUrl
|
||||
from PyQt5.QtGui import QDesktopServices
|
||||
from PyQt5.QtWidgets import QMenuBar, QAction
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.enum import nwDocAction, nwDocInsert, nwWidget
|
||||
from novelwriter.constants import nwConst, trConst, nwKeyWords, nwLabels, nwUnicode
|
||||
|
||||
@@ -795,7 +795,7 @@ class GuiMainMenu(QMenuBar):
|
||||
# Tools > Check Spelling
|
||||
self.aSpellCheck = QAction(self.tr("Check Spelling"), self)
|
||||
self.aSpellCheck.setCheckable(True)
|
||||
self.aSpellCheck.setChecked(self.mainGui.project.data.spellCheck)
|
||||
self.aSpellCheck.setChecked(SHARED.project.data.spellCheck)
|
||||
self.aSpellCheck.triggered.connect(self._toggleSpellCheck) # triggered, not toggled!
|
||||
self.aSpellCheck.setShortcut("Ctrl+F7")
|
||||
self.toolsMenu.addAction(self.aSpellCheck)
|
||||
@@ -825,7 +825,7 @@ class GuiMainMenu(QMenuBar):
|
||||
|
||||
# Tools > Backup Project
|
||||
self.aBackupProject = QAction(self.tr("Backup Project"), self)
|
||||
self.aBackupProject.triggered.connect(lambda: self.mainGui.project.backupProject(True))
|
||||
self.aBackupProject.triggered.connect(lambda: SHARED.project.backupProject(True))
|
||||
self.toolsMenu.addAction(self.aBackupProject)
|
||||
|
||||
# Tools > Build Manuscript
|
||||
|
||||
@@ -38,7 +38,7 @@ from PyQt5.QtWidgets import (
|
||||
QTreeWidgetItem, QVBoxLayout, QWidget
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.enum import nwDocMode, nwItemClass, nwOutline
|
||||
from novelwriter.common import minmax
|
||||
from novelwriter.constants import nwHeaders, nwKeyWords, nwLabels, trConst
|
||||
@@ -117,16 +117,16 @@ class GuiNovelView(QWidget):
|
||||
def openProjectTasks(self):
|
||||
"""Run open project tasks.
|
||||
"""
|
||||
lastNovel = self.mainGui.project.data.getLastHandle("novelTree")
|
||||
if lastNovel not in self.mainGui.project.tree:
|
||||
lastNovel = self.mainGui.project.tree.findRoot(nwItemClass.NOVEL)
|
||||
lastNovel = SHARED.project.data.getLastHandle("novelTree")
|
||||
if lastNovel not in SHARED.project.tree:
|
||||
lastNovel = SHARED.project.tree.findRoot(nwItemClass.NOVEL)
|
||||
|
||||
logger.debug("Setting novel tree to root item '%s'", lastNovel)
|
||||
|
||||
lastCol = self.mainGui.project.options.getEnum(
|
||||
lastCol = SHARED.project.options.getEnum(
|
||||
"GuiNovelView", "lastCol", NovelTreeColumn, NovelTreeColumn.HIDDEN
|
||||
)
|
||||
lastColSize = self.mainGui.project.options.getInt(
|
||||
lastColSize = SHARED.project.options.getInt(
|
||||
"GuiNovelView", "lastColSize", 25
|
||||
)
|
||||
|
||||
@@ -146,7 +146,7 @@ class GuiNovelView(QWidget):
|
||||
"""
|
||||
lastColType = self.novelTree.lastColType
|
||||
lastColSize = self.novelTree.lastColSize
|
||||
pOptions = self.mainGui.project.options
|
||||
pOptions = SHARED.project.options
|
||||
pOptions.setValue("GuiNovelView", "lastCol", lastColType)
|
||||
pOptions.setValue("GuiNovelView", "lastColSize", lastColSize)
|
||||
return
|
||||
@@ -170,7 +170,7 @@ class GuiNovelView(QWidget):
|
||||
def refreshTree(self):
|
||||
"""Refresh the current tree.
|
||||
"""
|
||||
self.novelTree.refreshTree(rootHandle=self.mainGui.project.data.getLastHandle("novelTree"))
|
||||
self.novelTree.refreshTree(rootHandle=SHARED.project.data.getLastHandle("novelTree"))
|
||||
return
|
||||
|
||||
@pyqtSlot(str)
|
||||
@@ -201,7 +201,7 @@ class GuiNovelToolBar(QWidget):
|
||||
self.novelView = novelView
|
||||
self.mainGui = novelView.mainGui
|
||||
|
||||
iPx = CONFIG.theme.baseIconSize
|
||||
iPx = SHARED.theme.baseIconSize
|
||||
mPx = CONFIG.pxInt(2)
|
||||
|
||||
self.setContentsMargins(0, 0, 0, 0)
|
||||
@@ -211,7 +211,7 @@ class GuiNovelToolBar(QWidget):
|
||||
selFont = self.font()
|
||||
selFont.setWeight(QFont.Bold)
|
||||
self.novelPrefix = self.tr("Outline of {0}")
|
||||
self.novelValue = NovelSelector(self, self.mainGui)
|
||||
self.novelValue = NovelSelector(self)
|
||||
self.novelValue.setFont(selFont)
|
||||
self.novelValue.setMinimumWidth(CONFIG.pxInt(150))
|
||||
self.novelValue.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
||||
@@ -274,9 +274,9 @@ class GuiNovelToolBar(QWidget):
|
||||
"""Update theme elements.
|
||||
"""
|
||||
# Icons
|
||||
self.tbNovel.setIcon(CONFIG.theme.getIcon("cls_novel"))
|
||||
self.tbRefresh.setIcon(CONFIG.theme.getIcon("refresh"))
|
||||
self.tbMore.setIcon(CONFIG.theme.getIcon("menu"))
|
||||
self.tbNovel.setIcon(SHARED.theme.getIcon("cls_novel"))
|
||||
self.tbRefresh.setIcon(SHARED.theme.getIcon("refresh"))
|
||||
self.tbMore.setIcon(SHARED.theme.getIcon("menu"))
|
||||
|
||||
qPalette = self.palette()
|
||||
qPalette.setBrush(QPalette.Window, qPalette.base())
|
||||
@@ -345,7 +345,7 @@ class GuiNovelToolBar(QWidget):
|
||||
def _refreshNovelTree(self):
|
||||
"""Rebuild the current tree.
|
||||
"""
|
||||
rootHandle = self.mainGui.project.data.getLastHandle("novelTree")
|
||||
rootHandle = SHARED.project.data.getLastHandle("novelTree")
|
||||
self.novelView.novelTree.refreshTree(rootHandle=rootHandle, overRide=True)
|
||||
return
|
||||
|
||||
@@ -415,7 +415,7 @@ class GuiNovelTree(QTreeWidget):
|
||||
# Build GUI
|
||||
# =========
|
||||
|
||||
iPx = CONFIG.theme.baseIconSize
|
||||
iPx = SHARED.theme.baseIconSize
|
||||
cMg = CONFIG.pxInt(6)
|
||||
|
||||
self.setIconSize(QSize(iPx, iPx))
|
||||
@@ -481,8 +481,8 @@ class GuiNovelTree(QTreeWidget):
|
||||
def updateTheme(self):
|
||||
"""Update theme elements.
|
||||
"""
|
||||
iPx = CONFIG.theme.baseIconSize
|
||||
self._pMore = CONFIG.theme.loadDecoration("deco_doc_more", pxH=iPx)
|
||||
iPx = SHARED.theme.baseIconSize
|
||||
self._pMore = SHARED.theme.loadDecoration("deco_doc_more", pxH=iPx)
|
||||
return
|
||||
|
||||
##
|
||||
@@ -514,10 +514,10 @@ class GuiNovelTree(QTreeWidget):
|
||||
"""
|
||||
logger.debug("Requesting refresh of the novel tree")
|
||||
if rootHandle is None:
|
||||
rootHandle = self.mainGui.project.tree.findRoot(nwItemClass.NOVEL)
|
||||
rootHandle = SHARED.project.tree.findRoot(nwItemClass.NOVEL)
|
||||
|
||||
treeChanged = self.mainGui.projView.changedSince(self._lastBuild)
|
||||
indexChanged = self.mainGui.project.index.rootChangedSince(rootHandle, self._lastBuild)
|
||||
indexChanged = SHARED.project.index.rootChangedSince(rootHandle, self._lastBuild)
|
||||
if not (treeChanged or indexChanged or overRide):
|
||||
logger.debug("No changes have been made to the novel index")
|
||||
return
|
||||
@@ -528,7 +528,7 @@ class GuiNovelTree(QTreeWidget):
|
||||
titleKey = selItem[0].data(self.C_DATA, self.D_KEY)
|
||||
|
||||
self._populateTree(rootHandle)
|
||||
self.mainGui.project.data.setLastHandle(rootHandle, "novelTree")
|
||||
SHARED.project.data.setLastHandle(rootHandle, "novelTree")
|
||||
|
||||
if titleKey is not None and titleKey in self._treeMap:
|
||||
self._treeMap[titleKey].setSelected(True)
|
||||
@@ -538,7 +538,7 @@ class GuiNovelTree(QTreeWidget):
|
||||
def refreshHandle(self, tHandle):
|
||||
"""Refresh the data for a given handle.
|
||||
"""
|
||||
idxData = self.mainGui.project.index.getItemData(tHandle)
|
||||
idxData = SHARED.project.index.getItemData(tHandle)
|
||||
if idxData is None:
|
||||
return
|
||||
|
||||
@@ -575,7 +575,7 @@ class GuiNovelTree(QTreeWidget):
|
||||
self._lastCol = colType
|
||||
self.setColumnHidden(self.C_EXTRA, colType == NovelTreeColumn.HIDDEN)
|
||||
if doRefresh:
|
||||
lastNovel = self.mainGui.project.data.getLastHandle("novelTree")
|
||||
lastNovel = SHARED.project.data.getLastHandle("novelTree")
|
||||
self.refreshTree(rootHandle=lastNovel, overRide=True)
|
||||
return
|
||||
|
||||
@@ -707,7 +707,7 @@ class GuiNovelTree(QTreeWidget):
|
||||
tStart = time()
|
||||
logger.debug("Building novel tree for root item '%s'", rootHandle)
|
||||
|
||||
novStruct = self.mainGui.project.index.novelStructure(rootHandle=rootHandle, skipExcl=True)
|
||||
novStruct = SHARED.project.index.novelStructure(rootHandle=rootHandle, skipExcl=True)
|
||||
for tKey, tHandle, sTitle, novIdx in novStruct:
|
||||
if novIdx.level == "H0":
|
||||
continue
|
||||
@@ -733,7 +733,7 @@ class GuiNovelTree(QTreeWidget):
|
||||
"""Set the tree item values from the index entry.
|
||||
"""
|
||||
iLevel = nwHeaders.H_LEVEL.get(idxItem.level, 0)
|
||||
hDec = CONFIG.theme.getHeaderDecoration(iLevel)
|
||||
hDec = SHARED.theme.getHeaderDecoration(iLevel)
|
||||
|
||||
trItem.setData(self.C_TITLE, Qt.DecorationRole, hDec)
|
||||
trItem.setText(self.C_TITLE, idxItem.title)
|
||||
@@ -759,7 +759,7 @@ class GuiNovelTree(QTreeWidget):
|
||||
|
||||
refData = []
|
||||
refName = ""
|
||||
theRefs = self.mainGui.project.index.getReferences(tHandle, sTitle)
|
||||
theRefs = SHARED.project.index.getReferences(tHandle, sTitle)
|
||||
if self._lastCol == NovelTreeColumn.POV:
|
||||
refData = theRefs[nwKeyWords.POV_KEY]
|
||||
refName = self._povLabel
|
||||
@@ -783,7 +783,7 @@ class GuiNovelTree(QTreeWidget):
|
||||
"""
|
||||
logger.debug("Generating meta data tooltip for '%s:%s'", tHandle, sTitle)
|
||||
|
||||
pIndex = self.mainGui.project.index
|
||||
pIndex = SHARED.project.index
|
||||
novIdx = pIndex.getItemHeader(tHandle, sTitle)
|
||||
refTags = pIndex.getReferences(tHandle, sTitle)
|
||||
|
||||
|
||||
+28
-34
@@ -41,7 +41,7 @@ from PyQt5.QtWidgets import (
|
||||
QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.enum import (
|
||||
nwDocMode, nwItemClass, nwItemLayout, nwItemType, nwOutline
|
||||
)
|
||||
@@ -62,8 +62,6 @@ class GuiOutlineView(QWidget):
|
||||
def __init__(self, mainGui):
|
||||
super().__init__(parent=mainGui)
|
||||
|
||||
self.mainGui = mainGui
|
||||
|
||||
# Build GUI
|
||||
self.outlineTree = GuiOutlineTree(self)
|
||||
self.outlineData = GuiOutlineDetails(self)
|
||||
@@ -117,7 +115,7 @@ class GuiOutlineView(QWidget):
|
||||
def refreshTree(self):
|
||||
"""Refresh the current tree.
|
||||
"""
|
||||
self.outlineTree.refreshTree(rootHandle=self.mainGui.project.data.getLastHandle("outline"))
|
||||
self.outlineTree.refreshTree(rootHandle=SHARED.project.data.getLastHandle("outline"))
|
||||
return
|
||||
|
||||
def clearProject(self):
|
||||
@@ -130,9 +128,9 @@ class GuiOutlineView(QWidget):
|
||||
def openProjectTasks(self):
|
||||
"""Run open project tasks.
|
||||
"""
|
||||
lastOutline = self.mainGui.project.data.getLastHandle("outline")
|
||||
if not (lastOutline in self.mainGui.project.tree or lastOutline is None):
|
||||
lastOutline = self.mainGui.project.tree.findRoot(nwItemClass.NOVEL)
|
||||
lastOutline = SHARED.project.data.getLastHandle("outline")
|
||||
if not (lastOutline in SHARED.project.tree or lastOutline is None):
|
||||
lastOutline = SHARED.project.tree.findRoot(nwItemClass.NOVEL)
|
||||
|
||||
logger.debug("Setting outline tree to root item '%s'", lastOutline)
|
||||
|
||||
@@ -214,8 +212,6 @@ class GuiOutlineToolBar(QToolBar):
|
||||
|
||||
logger.debug("Create: GuiOutlineToolBar")
|
||||
|
||||
self.mainGui = theOutline.mainGui
|
||||
|
||||
iPx = CONFIG.pxInt(22)
|
||||
mPx = CONFIG.pxInt(12)
|
||||
|
||||
@@ -230,7 +226,7 @@ class GuiOutlineToolBar(QToolBar):
|
||||
self.novelLabel = QLabel(self.tr("Outline of"))
|
||||
self.novelLabel.setContentsMargins(0, 0, mPx, 0)
|
||||
|
||||
self.novelValue = NovelSelector(self, self.mainGui)
|
||||
self.novelValue = NovelSelector(self)
|
||||
self.novelValue.setMinimumWidth(CONFIG.pxInt(200))
|
||||
self.novelValue.novelSelectionChanged.connect(self._novelValueChanged)
|
||||
|
||||
@@ -272,8 +268,8 @@ class GuiOutlineToolBar(QToolBar):
|
||||
self.setStyleSheet("QToolBar {border: 0px;}")
|
||||
|
||||
self.novelValue.updateList(includeAll=True)
|
||||
self.aRefresh.setIcon(CONFIG.theme.getIcon("refresh"))
|
||||
self.tbColumns.setIcon(CONFIG.theme.getIcon("menu"))
|
||||
self.aRefresh.setIcon(SHARED.theme.getIcon("refresh"))
|
||||
self.tbColumns.setIcon(SHARED.theme.getIcon("menu"))
|
||||
|
||||
return
|
||||
|
||||
@@ -370,7 +366,6 @@ class GuiOutlineTree(QTreeWidget):
|
||||
logger.debug("Create: GuiOutlineTree")
|
||||
|
||||
self.outlineView = outlineView
|
||||
self.mainGui = outlineView.mainGui
|
||||
|
||||
self.setUniformRowHeights(True)
|
||||
self.setFrameStyle(QFrame.NoFrame)
|
||||
@@ -381,7 +376,7 @@ class GuiOutlineTree(QTreeWidget):
|
||||
self.itemDoubleClicked.connect(self._treeDoubleClick)
|
||||
self.itemSelectionChanged.connect(self._itemSelected)
|
||||
|
||||
iPx = CONFIG.theme.baseIconSize
|
||||
iPx = SHARED.theme.baseIconSize
|
||||
self.setIconSize(QSize(iPx, iPx))
|
||||
self.setIndentation(0)
|
||||
|
||||
@@ -398,11 +393,11 @@ class GuiOutlineTree(QTreeWidget):
|
||||
|
||||
self._hFonts = [self.font(), fH1, fH2, self.font(), self.font()]
|
||||
self._dIcon = {
|
||||
"H0": CONFIG.theme.getItemIcon(nwItemType.FILE, None, nwItemLayout.DOCUMENT, "H0"),
|
||||
"H1": CONFIG.theme.getItemIcon(nwItemType.FILE, None, nwItemLayout.DOCUMENT, "H1"),
|
||||
"H2": CONFIG.theme.getItemIcon(nwItemType.FILE, None, nwItemLayout.DOCUMENT, "H2"),
|
||||
"H3": CONFIG.theme.getItemIcon(nwItemType.FILE, None, nwItemLayout.DOCUMENT, "H3"),
|
||||
"H4": CONFIG.theme.getItemIcon(nwItemType.FILE, None, nwItemLayout.DOCUMENT, "H4"),
|
||||
"H0": SHARED.theme.getItemIcon(nwItemType.FILE, None, nwItemLayout.DOCUMENT, "H0"),
|
||||
"H1": SHARED.theme.getItemIcon(nwItemType.FILE, None, nwItemLayout.DOCUMENT, "H1"),
|
||||
"H2": SHARED.theme.getItemIcon(nwItemType.FILE, None, nwItemLayout.DOCUMENT, "H2"),
|
||||
"H3": SHARED.theme.getItemIcon(nwItemType.FILE, None, nwItemLayout.DOCUMENT, "H3"),
|
||||
"H4": SHARED.theme.getItemIcon(nwItemType.FILE, None, nwItemLayout.DOCUMENT, "H4"),
|
||||
}
|
||||
|
||||
# Internals
|
||||
@@ -488,13 +483,13 @@ class GuiOutlineTree(QTreeWidget):
|
||||
|
||||
# If the novel index or novel tree has changed since the tree
|
||||
# was last built, we rebuild the tree from the updated index.
|
||||
indexChanged = self.mainGui.project.index.rootChangedSince(rootHandle, self._lastBuild)
|
||||
indexChanged = SHARED.project.index.rootChangedSince(rootHandle, self._lastBuild)
|
||||
if not (novelChanged or indexChanged or overRide):
|
||||
logger.debug("No changes have been made to the novel index")
|
||||
return
|
||||
|
||||
self._populateTree(rootHandle)
|
||||
self.mainGui.project.data.setLastHandle(rootHandle or None, "outline")
|
||||
SHARED.project.data.setLastHandle(rootHandle or None, "outline")
|
||||
|
||||
return
|
||||
|
||||
@@ -574,7 +569,7 @@ class GuiOutlineTree(QTreeWidget):
|
||||
"""
|
||||
# Load whatever we saved last time, regardless of wether it
|
||||
# contains the correct names or number of columns.
|
||||
colState = self.mainGui.project.options.getValue("GuiOutline", "columnState", {})
|
||||
colState = SHARED.project.options.getValue("GuiOutline", "columnState", {})
|
||||
|
||||
tmpOrder = []
|
||||
tmpHidden = {}
|
||||
@@ -625,7 +620,7 @@ class GuiOutlineTree(QTreeWidget):
|
||||
logHidden, orgWidth if logHidden and logWidth == 0 else logWidth
|
||||
]
|
||||
|
||||
pOptions = self.mainGui.project.options
|
||||
pOptions = SHARED.project.options
|
||||
pOptions.setValue("GuiOutline", "columnState", colState)
|
||||
pOptions.saveSettings()
|
||||
|
||||
@@ -661,7 +656,7 @@ class GuiOutlineTree(QTreeWidget):
|
||||
headItem.setTextAlignment(self._colIdx[nwOutline.WCOUNT], Qt.AlignRight)
|
||||
headItem.setTextAlignment(self._colIdx[nwOutline.PCOUNT], Qt.AlignRight)
|
||||
|
||||
novStruct = self.mainGui.project.index.novelStructure(rootHandle=rootHandle, skipExcl=True)
|
||||
novStruct = SHARED.project.index.novelStructure(rootHandle=rootHandle, skipExcl=True)
|
||||
for _, tHandle, sTitle, novIdx in novStruct:
|
||||
|
||||
iLevel = nwHeaders.H_LEVEL.get(novIdx.level, 0)
|
||||
@@ -669,8 +664,8 @@ class GuiOutlineTree(QTreeWidget):
|
||||
continue
|
||||
|
||||
trItem = QTreeWidgetItem()
|
||||
nwItem = self.mainGui.project.tree[tHandle]
|
||||
hDec = CONFIG.theme.getHeaderDecoration(iLevel)
|
||||
nwItem = SHARED.project.tree[tHandle]
|
||||
hDec = SHARED.theme.getHeaderDecoration(iLevel)
|
||||
|
||||
trItem.setData(self._colIdx[nwOutline.TITLE], Qt.DecorationRole, hDec)
|
||||
trItem.setText(self._colIdx[nwOutline.TITLE], novIdx.title)
|
||||
@@ -689,7 +684,7 @@ class GuiOutlineTree(QTreeWidget):
|
||||
trItem.setTextAlignment(self._colIdx[nwOutline.WCOUNT], Qt.AlignRight)
|
||||
trItem.setTextAlignment(self._colIdx[nwOutline.PCOUNT], Qt.AlignRight)
|
||||
|
||||
refs = self.mainGui.project.index.getReferences(tHandle, sTitle)
|
||||
refs = SHARED.project.index.getReferences(tHandle, sTitle)
|
||||
trItem.setText(self._colIdx[nwOutline.POV], ", ".join(refs[nwKeyWords.POV_KEY]))
|
||||
trItem.setText(self._colIdx[nwOutline.FOCUS], ", ".join(refs[nwKeyWords.FOCUS_KEY]))
|
||||
trItem.setText(self._colIdx[nwOutline.CHAR], ", ".join(refs[nwKeyWords.CHAR_KEY]))
|
||||
@@ -770,12 +765,11 @@ class GuiOutlineDetails(QScrollArea):
|
||||
logger.debug("Create: GuiOutlineDetails")
|
||||
|
||||
self.theOutline = theOutline
|
||||
self.mainGui = theOutline.mainGui
|
||||
|
||||
# Sizes
|
||||
minTitle = 30*CONFIG.theme.textNWidth
|
||||
maxTitle = 40*CONFIG.theme.textNWidth
|
||||
wCount = CONFIG.theme.getTextWidth("999,999")
|
||||
minTitle = 30*SHARED.theme.textNWidth
|
||||
maxTitle = 40*SHARED.theme.textNWidth
|
||||
wCount = SHARED.theme.getTextWidth("999,999")
|
||||
hSpace = int(CONFIG.pxInt(10))
|
||||
vSpace = int(CONFIG.pxInt(4))
|
||||
|
||||
@@ -1005,8 +999,8 @@ class GuiOutlineDetails(QScrollArea):
|
||||
"""Update the content of the tree with the given handle and line
|
||||
number pointing to a header.
|
||||
"""
|
||||
pIndex = self.mainGui.project.index
|
||||
nwItem = self.mainGui.project.tree[tHandle]
|
||||
pIndex = SHARED.project.index
|
||||
nwItem = SHARED.project.tree[tHandle]
|
||||
novIdx = pIndex.getItemHeader(tHandle, sTitle)
|
||||
theRefs = pIndex.getReferences(tHandle, sTitle)
|
||||
if nwItem is None or novIdx is None:
|
||||
@@ -1049,7 +1043,7 @@ class GuiOutlineDetails(QScrollArea):
|
||||
def updateClasses(self):
|
||||
"""Update the visibility status of class details.
|
||||
"""
|
||||
usedClasses = self.mainGui.project.tree.rootClasses()
|
||||
usedClasses = SHARED.project.tree.rootClasses()
|
||||
|
||||
pltVisible = nwItemClass.PLOT in usedClasses
|
||||
timVisible = nwItemClass.TIMELINE in usedClasses
|
||||
|
||||
+72
-72
@@ -39,7 +39,7 @@ from PyQt5.QtWidgets import (
|
||||
QVBoxLayout, QWidget
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.common import minmax
|
||||
from novelwriter.constants import nwHeaders, nwUnicode, trConst, nwLabels
|
||||
from novelwriter.core.item import NWItem
|
||||
@@ -236,7 +236,7 @@ class GuiProjectToolBar(QWidget):
|
||||
self.projTree = projView.projTree
|
||||
self.mainGui = projView.mainGui
|
||||
|
||||
iPx = CONFIG.theme.baseIconSize
|
||||
iPx = SHARED.theme.baseIconSize
|
||||
mPx = CONFIG.pxInt(2)
|
||||
|
||||
self.setContentsMargins(0, 0, 0, 0)
|
||||
@@ -367,16 +367,16 @@ class GuiProjectToolBar(QWidget):
|
||||
self.tbAdd.setStyleSheet(buttonStyle)
|
||||
self.tbMore.setStyleSheet(buttonStyle)
|
||||
|
||||
self.tbQuick.setIcon(CONFIG.theme.getIcon("bookmark"))
|
||||
self.tbMoveU.setIcon(CONFIG.theme.getIcon("up"))
|
||||
self.tbMoveD.setIcon(CONFIG.theme.getIcon("down"))
|
||||
self.aAddEmpty.setIcon(CONFIG.theme.getIcon("proj_document"))
|
||||
self.aAddChap.setIcon(CONFIG.theme.getIcon("proj_chapter"))
|
||||
self.aAddScene.setIcon(CONFIG.theme.getIcon("proj_scene"))
|
||||
self.aAddNote.setIcon(CONFIG.theme.getIcon("proj_note"))
|
||||
self.aAddFolder.setIcon(CONFIG.theme.getIcon("proj_folder"))
|
||||
self.tbAdd.setIcon(CONFIG.theme.getIcon("add"))
|
||||
self.tbMore.setIcon(CONFIG.theme.getIcon("menu"))
|
||||
self.tbQuick.setIcon(SHARED.theme.getIcon("bookmark"))
|
||||
self.tbMoveU.setIcon(SHARED.theme.getIcon("up"))
|
||||
self.tbMoveD.setIcon(SHARED.theme.getIcon("down"))
|
||||
self.aAddEmpty.setIcon(SHARED.theme.getIcon("proj_document"))
|
||||
self.aAddChap.setIcon(SHARED.theme.getIcon("proj_chapter"))
|
||||
self.aAddScene.setIcon(SHARED.theme.getIcon("proj_scene"))
|
||||
self.aAddNote.setIcon(SHARED.theme.getIcon("proj_note"))
|
||||
self.aAddFolder.setIcon(SHARED.theme.getIcon("proj_folder"))
|
||||
self.tbAdd.setIcon(SHARED.theme.getIcon("add"))
|
||||
self.tbMore.setIcon(SHARED.theme.getIcon("menu"))
|
||||
|
||||
self.buildQuickLinkMenu()
|
||||
self._buildRootMenu()
|
||||
@@ -392,10 +392,10 @@ class GuiProjectToolBar(QWidget):
|
||||
"""Build the quick link menu."""
|
||||
logger.debug("Rebuilding quick links menu")
|
||||
self.mQuick.clear()
|
||||
for n, (tHandle, nwItem) in enumerate(self.mainGui.project.tree.iterRoots(None)):
|
||||
for n, (tHandle, nwItem) in enumerate(SHARED.project.tree.iterRoots(None)):
|
||||
aRoot = self.mQuick.addAction(nwItem.itemName)
|
||||
aRoot.setData(tHandle)
|
||||
aRoot.setIcon(CONFIG.theme.getIcon(nwLabels.CLASS_ICON[nwItem.itemClass]))
|
||||
aRoot.setIcon(SHARED.theme.getIcon(nwLabels.CLASS_ICON[nwItem.itemClass]))
|
||||
aRoot.triggered.connect(
|
||||
lambda n, tHandle=tHandle: self.projView.setSelectedHandle(tHandle, doScroll=True)
|
||||
)
|
||||
@@ -409,7 +409,7 @@ class GuiProjectToolBar(QWidget):
|
||||
"""Build the rood folder menu."""
|
||||
def addClass(itemClass):
|
||||
aNew = self.mAddRoot.addAction(trConst(nwLabels.CLASS_NAME[itemClass]))
|
||||
aNew.setIcon(CONFIG.theme.getIcon(nwLabels.CLASS_ICON[itemClass]))
|
||||
aNew.setIcon(SHARED.theme.getIcon(nwLabels.CLASS_ICON[itemClass]))
|
||||
aNew.triggered.connect(lambda: self.projTree.newTreeItem(nwItemType.ROOT, itemClass))
|
||||
self.mAddRoot.addAction(aNew)
|
||||
return
|
||||
@@ -438,7 +438,7 @@ class GuiProjectToolBar(QWidget):
|
||||
documents. They should only be visible if novel documents can
|
||||
actually be added.
|
||||
"""
|
||||
nwItem = self.mainGui.project.tree[tHandle]
|
||||
nwItem = SHARED.project.tree[tHandle]
|
||||
allowDoc = isinstance(nwItem, NWItem) and nwItem.documentAllowed()
|
||||
self.aAddEmpty.setVisible(allowDoc)
|
||||
self.aAddChap.setVisible(allowDoc)
|
||||
@@ -480,7 +480,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
self.customContextMenuRequested.connect(self._openContextMenu)
|
||||
|
||||
# Tree Settings
|
||||
iPx = CONFIG.theme.baseIconSize
|
||||
iPx = SHARED.theme.baseIconSize
|
||||
cMg = CONFIG.pxInt(6)
|
||||
|
||||
self.setIconSize(QSize(iPx, iPx))
|
||||
@@ -572,15 +572,15 @@ class GuiProjectTree(QTreeWidget):
|
||||
|
||||
if itemType == nwItemType.ROOT and isinstance(itemClass, nwItemClass):
|
||||
|
||||
tHandle = self.mainGui.project.newRoot(itemClass)
|
||||
tHandle = SHARED.project.newRoot(itemClass)
|
||||
sHandle = self.getSelectedHandle()
|
||||
pItem = self.mainGui.project.tree[sHandle] if sHandle else None
|
||||
pItem = SHARED.project.tree[sHandle] if sHandle else None
|
||||
nHandle = pItem.itemRoot if pItem else None
|
||||
|
||||
elif itemType in (nwItemType.FILE, nwItemType.FOLDER):
|
||||
|
||||
sHandle = self.getSelectedHandle()
|
||||
pItem = self.mainGui.project.tree[sHandle] if sHandle else None
|
||||
pItem = SHARED.project.tree[sHandle] if sHandle else None
|
||||
if sHandle is None or pItem is None:
|
||||
self.mainGui.makeAlert(self.tr(
|
||||
"Did not find anywhere to add the file or folder!"
|
||||
@@ -592,7 +592,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
sLevel = nwHeaders.H_LEVEL.get(pItem.mainHeading, 0)
|
||||
sIsParent = False if qItem is None else qItem.childCount() > 0
|
||||
|
||||
if self.mainGui.project.tree.isTrash(sHandle):
|
||||
if SHARED.project.tree.isTrash(sHandle):
|
||||
self.mainGui.makeAlert(self.tr(
|
||||
"Cannot add new files or folders to the Trash folder."
|
||||
), level=nwAlert.ERROR)
|
||||
@@ -635,9 +635,9 @@ class GuiProjectTree(QTreeWidget):
|
||||
|
||||
# Add the file or folder
|
||||
if itemType == nwItemType.FILE:
|
||||
tHandle = self.mainGui.project.newFile(newLabel, sHandle)
|
||||
tHandle = SHARED.project.newFile(newLabel, sHandle)
|
||||
else:
|
||||
tHandle = self.mainGui.project.newFolder(newLabel, sHandle)
|
||||
tHandle = SHARED.project.newFolder(newLabel, sHandle)
|
||||
|
||||
else:
|
||||
logger.error("Failed to add new item")
|
||||
@@ -650,7 +650,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
|
||||
# Handle new file creation
|
||||
if itemType == nwItemType.FILE and hLevel > 0:
|
||||
self.mainGui.project.writeNewFile(tHandle, hLevel, not isNote)
|
||||
SHARED.project.writeNewFile(tHandle, hLevel, not isNote)
|
||||
|
||||
# Add the new item to the project tree
|
||||
self.revealNewTreeItem(tHandle, nHandle=nHandle, wordCount=True)
|
||||
@@ -661,7 +661,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
def revealNewTreeItem(self, tHandle: str | None, nHandle: str | None = None,
|
||||
wordCount: bool = False) -> bool:
|
||||
"""Reveal a newly added project item in the project tree."""
|
||||
nwItem = self.mainGui.project.tree[tHandle] if tHandle else None
|
||||
nwItem = SHARED.project.tree[tHandle] if tHandle else None
|
||||
if tHandle is None or nwItem is None:
|
||||
return False
|
||||
|
||||
@@ -670,7 +670,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
return False
|
||||
|
||||
if nwItem.isFileType() and wordCount:
|
||||
wC = self.mainGui.project.index.getCounts(tHandle)[1]
|
||||
wC = SHARED.project.index.getCounts(tHandle)[1]
|
||||
self.propagateCount(tHandle, wC)
|
||||
self.projView.wordCountsChanged.emit()
|
||||
|
||||
@@ -745,7 +745,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
|
||||
def renameTreeItem(self, tHandle: str) -> bool:
|
||||
"""Open a dialog to edit the label of an item."""
|
||||
tItem = self.mainGui.project.tree[tHandle]
|
||||
tItem = SHARED.project.tree[tHandle]
|
||||
if tItem is None:
|
||||
return False
|
||||
|
||||
@@ -769,7 +769,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
if isinstance(item, QTreeWidgetItem):
|
||||
theList = self._scanChildren(theList, item, i)
|
||||
logger.debug("Saving project tree item order")
|
||||
self.mainGui.project.setTreeOrder(theList)
|
||||
SHARED.project.setTreeOrder(theList)
|
||||
return
|
||||
|
||||
def getTreeFromHandle(self, tHandle: str) -> list[str]:
|
||||
@@ -802,16 +802,16 @@ class GuiProjectTree(QTreeWidget):
|
||||
logger.error("There is no item to delete")
|
||||
return False
|
||||
|
||||
trashHandle = self.mainGui.project.tree.trashRoot()
|
||||
trashHandle = SHARED.project.tree.trashRoot()
|
||||
if tHandle == trashHandle:
|
||||
logger.error("Cannot delete the Trash folder")
|
||||
return False
|
||||
|
||||
nwItem = self.mainGui.project.tree[tHandle]
|
||||
nwItem = SHARED.project.tree[tHandle]
|
||||
if nwItem is None:
|
||||
return False
|
||||
|
||||
if self.mainGui.project.tree.isTrash(tHandle) or nwItem.isRootType():
|
||||
if SHARED.project.tree.isTrash(tHandle) or nwItem.isRootType():
|
||||
status = self.permDeleteItem(tHandle)
|
||||
else:
|
||||
status = self.moveItemToTrash(tHandle)
|
||||
@@ -827,7 +827,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
logger.error("No project open")
|
||||
return False
|
||||
|
||||
trashHandle = self.mainGui.project.tree.trashRoot()
|
||||
trashHandle = SHARED.project.tree.trashRoot()
|
||||
|
||||
logger.debug("Emptying Trash folder")
|
||||
if trashHandle is None:
|
||||
@@ -870,13 +870,13 @@ class GuiProjectTree(QTreeWidget):
|
||||
so such a request is cancelled.
|
||||
"""
|
||||
trItemS = self._getTreeItem(tHandle)
|
||||
nwItemS = self.mainGui.project.tree[tHandle]
|
||||
nwItemS = SHARED.project.tree[tHandle]
|
||||
|
||||
if trItemS is None or nwItemS is None:
|
||||
logger.error("Could not find tree item for deletion")
|
||||
return False
|
||||
|
||||
if self.mainGui.project.tree.isTrash(tHandle):
|
||||
if SHARED.project.tree.isTrash(tHandle):
|
||||
logger.error("Item is already in the Trash folder")
|
||||
return False
|
||||
|
||||
@@ -920,7 +920,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
Root items are handled a little different than other items.
|
||||
"""
|
||||
trItemS = self._getTreeItem(tHandle)
|
||||
nwItemS = self.mainGui.project.tree[tHandle]
|
||||
nwItemS = SHARED.project.tree[tHandle]
|
||||
if trItemS is None or nwItemS is None:
|
||||
logger.error("Could not find tree item for deletion")
|
||||
return False
|
||||
@@ -937,7 +937,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
|
||||
tIndex = self.indexOfTopLevelItem(trItemS)
|
||||
self.takeTopLevelItem(tIndex)
|
||||
self.mainGui.project.removeItem(tHandle)
|
||||
SHARED.project.removeItem(tHandle)
|
||||
self._treeMap.pop(tHandle, None)
|
||||
self._alertTreeChange(tHandle, flush=True)
|
||||
|
||||
@@ -966,7 +966,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
for dHandle in reversed(self.getTreeFromHandle(tHandle)):
|
||||
if self.mainGui.docEditor.docHandle() == dHandle:
|
||||
self.mainGui.closeDocument()
|
||||
self.mainGui.project.removeItem(dHandle)
|
||||
SHARED.project.removeItem(dHandle)
|
||||
self._treeMap.pop(dHandle, None)
|
||||
|
||||
self._alertTreeChange(tHandle, flush=flush)
|
||||
@@ -984,13 +984,13 @@ class GuiProjectTree(QTreeWidget):
|
||||
already coming from the project tree.
|
||||
"""
|
||||
trItem = self._getTreeItem(tHandle)
|
||||
nwItem = self.mainGui.project.tree[tHandle]
|
||||
nwItem = SHARED.project.tree[tHandle]
|
||||
if trItem is None or nwItem is None:
|
||||
return
|
||||
|
||||
itemStatus, statusIcon = nwItem.getImportStatus(incIcon=True)
|
||||
hLevel = nwItem.mainHeading
|
||||
itemIcon = CONFIG.theme.getItemIcon(
|
||||
itemIcon = SHARED.theme.getItemIcon(
|
||||
nwItem.itemType, nwItem.itemClass, nwItem.itemLayout, hLevel
|
||||
)
|
||||
|
||||
@@ -1006,7 +1006,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
else:
|
||||
iconName = "noncheckable"
|
||||
|
||||
trItem.setIcon(self.C_ACTIVE, CONFIG.theme.getIcon(iconName))
|
||||
trItem.setIcon(self.C_ACTIVE, SHARED.theme.getIcon(iconName))
|
||||
|
||||
if CONFIG.emphLabels and nwItem.isDocumentLayout():
|
||||
trFont = trItem.font(self.C_NAME)
|
||||
@@ -1046,10 +1046,10 @@ class GuiProjectTree(QTreeWidget):
|
||||
pHandle = pItem.data(self.C_DATA, self.D_HANDLE)
|
||||
|
||||
if pHandle:
|
||||
if self.mainGui.project.tree.checkType(pHandle, nwItemType.FILE):
|
||||
if SHARED.project.tree.checkType(pHandle, nwItemType.FILE):
|
||||
# A file has an internal word count we need to account
|
||||
# for, but a folder always has 0 words on its own.
|
||||
pCount += self.mainGui.project.index.getCounts(pHandle)[1]
|
||||
pCount += SHARED.project.index.getCounts(pHandle)[1]
|
||||
|
||||
self.propagateCount(pHandle, pCount, countChildren=False)
|
||||
|
||||
@@ -1064,7 +1064,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
logger.debug("Building the project tree ...")
|
||||
self.clearTree()
|
||||
count = 0
|
||||
for nwItem in self.mainGui.project.getProjectItems():
|
||||
for nwItem in SHARED.project.getProjectItems():
|
||||
count += 1
|
||||
self._addTreeItem(nwItem)
|
||||
if count > 0:
|
||||
@@ -1177,7 +1177,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
if tHandle is None:
|
||||
return
|
||||
|
||||
tItem = self.mainGui.project.tree[tHandle]
|
||||
tItem = SHARED.project.tree[tHandle]
|
||||
if tItem is None:
|
||||
return
|
||||
|
||||
@@ -1199,7 +1199,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
selItem = self.itemAt(clickPos)
|
||||
if isinstance(selItem, QTreeWidgetItem):
|
||||
tHandle = selItem.data(self.C_DATA, self.D_HANDLE)
|
||||
tItem = self.mainGui.project.tree[tHandle]
|
||||
tItem = SHARED.project.tree[tHandle]
|
||||
hasChild = selItem.childCount() > 0
|
||||
|
||||
if tItem is None or tHandle is None:
|
||||
@@ -1211,7 +1211,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
# Trash Folder
|
||||
# ============
|
||||
|
||||
trashHandle = self.mainGui.project.tree.trashRoot()
|
||||
trashHandle = SHARED.project.tree.trashRoot()
|
||||
if tItem.itemHandle == trashHandle and trashHandle is not None:
|
||||
# The trash folder only has one option
|
||||
aEmptyTrash = ctxMenu.addAction(self.tr("Empty Trash"))
|
||||
@@ -1250,7 +1250,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
checkMark = f" ({nwUnicode.U_CHECK})"
|
||||
if tItem.isNovelLike():
|
||||
mStatus = ctxMenu.addMenu(self.tr("Set Status to ..."))
|
||||
for n, (key, entry) in enumerate(self.mainGui.project.data.itemStatus.items()):
|
||||
for n, (key, entry) in enumerate(SHARED.project.data.itemStatus.items()):
|
||||
entryName = entry["name"] + (checkMark if tItem.itemStatus == key else "")
|
||||
aStatus = mStatus.addAction(entry["icon"], entryName)
|
||||
aStatus.triggered.connect(
|
||||
@@ -1263,7 +1263,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
)
|
||||
else:
|
||||
mImport = ctxMenu.addMenu(self.tr("Set Importance to ..."))
|
||||
for n, (key, entry) in enumerate(self.mainGui.project.data.itemImport.items()):
|
||||
for n, (key, entry) in enumerate(SHARED.project.data.itemImport.items()):
|
||||
entryName = entry["name"] + (checkMark if tItem.itemImport == key else "")
|
||||
aImport = mImport.addAction(entry["icon"], entryName)
|
||||
aImport.triggered.connect(
|
||||
@@ -1375,7 +1375,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
return
|
||||
|
||||
tHandle = selItem.data(self.C_DATA, self.D_HANDLE)
|
||||
tItem = self.mainGui.project.tree[tHandle]
|
||||
tItem = SHARED.project.tree[tHandle]
|
||||
if tItem is None:
|
||||
return
|
||||
|
||||
@@ -1419,7 +1419,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
def _postItemMove(self, tHandle: str, wCount: int) -> bool:
|
||||
"""Run various maintenance tasks for a moved item."""
|
||||
trItemS = self._getTreeItem(tHandle)
|
||||
nwItemS = self.mainGui.project.tree[tHandle]
|
||||
nwItemS = SHARED.project.tree[tHandle]
|
||||
trItemP = trItemS.parent() if trItemS else None
|
||||
if trItemP is None or nwItemS is None:
|
||||
logger.error("Failed to find new parent item of '%s'", tHandle)
|
||||
@@ -1436,13 +1436,13 @@ class GuiProjectTree(QTreeWidget):
|
||||
logger.debug("A total of %d item(s) were moved", len(mHandles))
|
||||
for mHandle in mHandles:
|
||||
logger.debug("Updating item '%s'", mHandle)
|
||||
self.mainGui.project.tree.updateItemData(mHandle)
|
||||
SHARED.project.tree.updateItemData(mHandle)
|
||||
|
||||
# Update the index
|
||||
if nwItemS.isInactiveClass():
|
||||
self.mainGui.project.index.deleteHandle(mHandle)
|
||||
SHARED.project.index.deleteHandle(mHandle)
|
||||
else:
|
||||
self.mainGui.project.index.reIndexHandle(mHandle)
|
||||
SHARED.project.index.reIndexHandle(mHandle)
|
||||
|
||||
self.setTreeItemValues(mHandle)
|
||||
|
||||
@@ -1462,7 +1462,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
|
||||
def _toggleItemActive(self, tHandle: str) -> None:
|
||||
"""Toggle the active status of an item."""
|
||||
tItem = self.mainGui.project.tree[tHandle]
|
||||
tItem = SHARED.project.tree[tHandle]
|
||||
if tItem is not None:
|
||||
tItem.setActive(not tItem.isActive)
|
||||
self.setTreeItemValues(tItem.itemHandle)
|
||||
@@ -1483,7 +1483,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
|
||||
def _changeItemStatus(self, tHandle: str, tStatus: str) -> None:
|
||||
"""Set a new status value of an item."""
|
||||
tItem = self.mainGui.project.tree[tHandle]
|
||||
tItem = SHARED.project.tree[tHandle]
|
||||
if tItem is not None:
|
||||
tItem.setStatus(tStatus)
|
||||
self.setTreeItemValues(tItem.itemHandle)
|
||||
@@ -1492,7 +1492,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
|
||||
def _changeItemImport(self, tHandle: str, tImport: str) -> None:
|
||||
"""Set a new importance value of an item."""
|
||||
tItem = self.mainGui.project.tree[tHandle]
|
||||
tItem = SHARED.project.tree[tHandle]
|
||||
if tItem is not None:
|
||||
tItem.setImport(tImport)
|
||||
self.setTreeItemValues(tItem.itemHandle)
|
||||
@@ -1501,7 +1501,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
|
||||
def _changeItemLayout(self, tHandle: str, itemLayout: nwItemLayout) -> None:
|
||||
"""Set a new item layout value of an item."""
|
||||
tItem = self.mainGui.project.tree[tHandle]
|
||||
tItem = SHARED.project.tree[tHandle]
|
||||
if tItem is not None:
|
||||
if itemLayout == nwItemLayout.DOCUMENT and tItem.documentAllowed():
|
||||
tItem.setLayout(nwItemLayout.DOCUMENT)
|
||||
@@ -1515,7 +1515,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
|
||||
def _covertFolderToFile(self, tHandle: str, itemLayout: nwItemLayout) -> None:
|
||||
"""Convert a folder to a note or document."""
|
||||
tItem = self.mainGui.project.tree[tHandle]
|
||||
tItem = SHARED.project.tree[tHandle]
|
||||
if tItem is not None and tItem.isFolderType():
|
||||
msgYes = self.mainGui.askQuestion(self.tr(
|
||||
"Do you want to convert the folder to a {0}? "
|
||||
@@ -1540,7 +1540,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
logger.info("Request to merge items under handle '%s'", tHandle)
|
||||
itemList = self.getTreeFromHandle(tHandle)
|
||||
|
||||
tItem = self.mainGui.project.tree[tHandle]
|
||||
tItem = SHARED.project.tree[tHandle]
|
||||
if tItem is None:
|
||||
return False
|
||||
|
||||
@@ -1566,7 +1566,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
self.mainGui.saveDocument()
|
||||
|
||||
# Create merge object, and append docs
|
||||
docMerger = DocMerger(self.mainGui.project)
|
||||
docMerger = DocMerger(SHARED.project)
|
||||
mLabel = self.tr("Merged")
|
||||
|
||||
if newFile:
|
||||
@@ -1588,7 +1588,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
)
|
||||
return False
|
||||
|
||||
self.mainGui.project.index.reIndexHandle(mHandle)
|
||||
SHARED.project.index.reIndexHandle(mHandle)
|
||||
if newFile:
|
||||
self.revealNewTreeItem(mHandle, nHandle=tHandle, wordCount=True)
|
||||
|
||||
@@ -1613,7 +1613,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
"""Split a document into multiple documents."""
|
||||
logger.info("Request to split items with handle '%s'", tHandle)
|
||||
|
||||
tItem = self.mainGui.project.tree[tHandle]
|
||||
tItem = SHARED.project.tree[tHandle]
|
||||
if tItem is None:
|
||||
return False
|
||||
|
||||
@@ -1632,7 +1632,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
intoFolder = splitData.get("intoFolder", False)
|
||||
docHierarchy = splitData.get("docHierarchy", False)
|
||||
|
||||
docSplit = DocSplitter(self.mainGui.project, tHandle)
|
||||
docSplit = DocSplitter(SHARED.project, tHandle)
|
||||
if intoFolder:
|
||||
fHandle = docSplit.newParentFolder(tItem.itemParent, tItem.itemName)
|
||||
self.revealNewTreeItem(fHandle, nHandle=tHandle)
|
||||
@@ -1642,7 +1642,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
|
||||
docSplit.splitDocument(headerList, splitText)
|
||||
for writeOk, dHandle, nHandle in docSplit.writeDocuments(docHierarchy):
|
||||
self.mainGui.project.index.reIndexHandle(dHandle)
|
||||
SHARED.project.index.reIndexHandle(dHandle)
|
||||
self.revealNewTreeItem(dHandle, nHandle=nHandle, wordCount=True)
|
||||
self._alertTreeChange(dHandle, flush=False)
|
||||
if not writeOk:
|
||||
@@ -1676,10 +1676,10 @@ class GuiProjectTree(QTreeWidget):
|
||||
if not self.mainGui.askQuestion(question):
|
||||
return False
|
||||
|
||||
docDup = DocDuplicator(self.mainGui.project)
|
||||
docDup = DocDuplicator(SHARED.project)
|
||||
dupCount = 0
|
||||
for dHandle, nHandle in docDup.duplicate(itemTree):
|
||||
self.mainGui.project.index.reIndexHandle(dHandle)
|
||||
SHARED.project.index.reIndexHandle(dHandle)
|
||||
self.revealNewTreeItem(dHandle, nHandle=nHandle, wordCount=True)
|
||||
self._alertTreeChange(dHandle, flush=False)
|
||||
dupCount += 1
|
||||
@@ -1699,7 +1699,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
cCount = tItem.childCount()
|
||||
|
||||
# Update tree-related meta data
|
||||
nwItem = self.mainGui.project.tree[tHandle]
|
||||
nwItem = SHARED.project.tree[tHandle]
|
||||
if nwItem is not None:
|
||||
nwItem.setExpanded(tItem.isExpanded() and cCount > 0)
|
||||
nwItem.setOrder(tIndex)
|
||||
@@ -1766,13 +1766,13 @@ class GuiProjectTree(QTreeWidget):
|
||||
"""Adds the trash root folder if it doesn't already exist in the
|
||||
project tree.
|
||||
"""
|
||||
trashHandle = self.mainGui.project.trashFolder()
|
||||
trashHandle = SHARED.project.trashFolder()
|
||||
if trashHandle is None:
|
||||
return None
|
||||
|
||||
trItem = self._getTreeItem(trashHandle)
|
||||
if trItem is None:
|
||||
trItem = self._addTreeItem(self.mainGui.project.tree[trashHandle])
|
||||
trItem = self._addTreeItem(SHARED.project.tree[trashHandle])
|
||||
if trItem is not None:
|
||||
trItem.setExpanded(True)
|
||||
self._alertTreeChange(trashHandle, flush=True)
|
||||
@@ -1785,14 +1785,14 @@ class GuiProjectTree(QTreeWidget):
|
||||
deleted.
|
||||
"""
|
||||
self._timeChanged = time()
|
||||
self.mainGui.project.setProjectChanged(True)
|
||||
SHARED.project.setProjectChanged(True)
|
||||
if flush:
|
||||
self.saveTreeOrder()
|
||||
|
||||
if tHandle is None or tHandle not in self.mainGui.project.tree:
|
||||
if tHandle is None or tHandle not in SHARED.project.tree:
|
||||
return
|
||||
|
||||
tItem = self.mainGui.project.tree[tHandle]
|
||||
tItem = SHARED.project.tree[tHandle]
|
||||
if tItem and tItem.isRootType():
|
||||
self.projView.rootFolderChanged.emit(tHandle)
|
||||
|
||||
|
||||
+10
-10
@@ -30,7 +30,7 @@ from PyQt5.QtWidgets import (
|
||||
QToolBar, QWidget, QSizePolicy, QAction, QMenu, QToolButton
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.enum import nwView
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -51,8 +51,8 @@ class GuiSideBar(QToolBar):
|
||||
iPx = CONFIG.pxInt(22)
|
||||
mPx = CONFIG.pxInt(60)
|
||||
|
||||
lblFont = CONFIG.theme.guiFont
|
||||
lblFont.setPointSizeF(0.65*CONFIG.theme.fontPointSize)
|
||||
lblFont = SHARED.theme.guiFont
|
||||
lblFont.setPointSizeF(0.65*SHARED.theme.fontPointSize)
|
||||
|
||||
self.setMovable(False)
|
||||
self.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
|
||||
@@ -130,13 +130,13 @@ class GuiSideBar(QToolBar):
|
||||
"""
|
||||
self.setStyleSheet("QToolBar {border: 0px;}")
|
||||
|
||||
self.aProject.setIcon(CONFIG.theme.getIcon("view_editor"))
|
||||
self.aNovel.setIcon(CONFIG.theme.getIcon("view_novel"))
|
||||
self.aOutline.setIcon(CONFIG.theme.getIcon("view_outline"))
|
||||
self.aBuild.setIcon(CONFIG.theme.getIcon("view_build"))
|
||||
self.aDetails.setIcon(CONFIG.theme.getIcon("proj_details"))
|
||||
self.aStats.setIcon(CONFIG.theme.getIcon("proj_stats"))
|
||||
self.tbSettings.setIcon(CONFIG.theme.getIcon("settings"))
|
||||
self.aProject.setIcon(SHARED.theme.getIcon("view_editor"))
|
||||
self.aNovel.setIcon(SHARED.theme.getIcon("view_novel"))
|
||||
self.aOutline.setIcon(SHARED.theme.getIcon("view_outline"))
|
||||
self.aBuild.setIcon(SHARED.theme.getIcon("view_build"))
|
||||
self.aDetails.setIcon(SHARED.theme.getIcon("proj_details"))
|
||||
self.aStats.setIcon(SHARED.theme.getIcon("proj_stats"))
|
||||
self.tbSettings.setIcon(SHARED.theme.getIcon("settings"))
|
||||
|
||||
return
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ from PyQt5.QtCore import pyqtSlot, QLocale
|
||||
from PyQt5.QtGui import QColor
|
||||
from PyQt5.QtWidgets import qApp, QStatusBar, QLabel
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.common import formatTime
|
||||
from novelwriter.extensions.statusled import StatusLED
|
||||
|
||||
@@ -50,11 +50,11 @@ class GuiMainStatus(QStatusBar):
|
||||
self.refTime = None
|
||||
self.userIdle = False
|
||||
|
||||
colNone = QColor(*CONFIG.theme.statNone)
|
||||
colSaved = QColor(*CONFIG.theme.statSaved)
|
||||
colUnsaved = QColor(*CONFIG.theme.statUnsaved)
|
||||
colNone = QColor(*SHARED.theme.statNone)
|
||||
colSaved = QColor(*SHARED.theme.statSaved)
|
||||
colUnsaved = QColor(*SHARED.theme.statUnsaved)
|
||||
|
||||
iPx = CONFIG.theme.baseIconSize
|
||||
iPx = SHARED.theme.baseIconSize
|
||||
|
||||
# Permanent Widgets
|
||||
# =================
|
||||
@@ -98,7 +98,7 @@ class GuiMainStatus(QStatusBar):
|
||||
self.timeIcon = QLabel()
|
||||
self.timeText = QLabel("")
|
||||
self.timeText.setToolTip(self.tr("Session Time"))
|
||||
self.timeText.setMinimumWidth(CONFIG.theme.getTextWidth("00:00:00:"))
|
||||
self.timeText.setMinimumWidth(SHARED.theme.getTextWidth("00:00:00:"))
|
||||
self.timeIcon.setContentsMargins(0, 0, 0, 0)
|
||||
self.timeText.setContentsMargins(0, 0, 0, 0)
|
||||
self.addPermanentWidget(self.timeIcon)
|
||||
@@ -128,13 +128,13 @@ class GuiMainStatus(QStatusBar):
|
||||
def updateTheme(self):
|
||||
"""Update theme elements.
|
||||
"""
|
||||
iPx = CONFIG.theme.baseIconSize
|
||||
iPx = SHARED.theme.baseIconSize
|
||||
|
||||
self.langIcon.setPixmap(CONFIG.theme.getPixmap("status_lang", (iPx, iPx)))
|
||||
self.statsIcon.setPixmap(CONFIG.theme.getPixmap("status_stats", (iPx, iPx)))
|
||||
self.langIcon.setPixmap(SHARED.theme.getPixmap("status_lang", (iPx, iPx)))
|
||||
self.statsIcon.setPixmap(SHARED.theme.getPixmap("status_stats", (iPx, iPx)))
|
||||
|
||||
self.timePixmap = CONFIG.theme.getPixmap("status_time", (iPx, iPx))
|
||||
self.idlePixmap = CONFIG.theme.getPixmap("status_idle", (iPx, iPx))
|
||||
self.timePixmap = SHARED.theme.getPixmap("status_time", (iPx, iPx))
|
||||
self.idlePixmap = SHARED.theme.getPixmap("status_idle", (iPx, iPx))
|
||||
|
||||
self.timeIcon.setPixmap(self.timePixmap)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user