Move theme and project instances to new shared data class
This commit is contained in:
+3
-18
@@ -3,7 +3,8 @@ novelWriter – Config Class
|
|||||||
==========================
|
==========================
|
||||||
|
|
||||||
File History:
|
File History:
|
||||||
Created: 2018-09-22 [0.0.1] Config
|
Created: 2018-09-22 [0.0.1] Config
|
||||||
|
Created: 2022-11-09 [2.0rc2] RecentProjects
|
||||||
|
|
||||||
This file is a part of novelWriter
|
This file is a part of novelWriter
|
||||||
Copyright 2018–2023, Veronica Berglyd Olsen
|
Copyright 2018–2023, Veronica Berglyd Olsen
|
||||||
@@ -28,7 +29,6 @@ import json
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from time import time
|
from time import time
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from PyQt5.QtGui import QFontDatabase
|
from PyQt5.QtGui import QFontDatabase
|
||||||
@@ -42,9 +42,6 @@ from novelwriter.error import formatException, logException
|
|||||||
from novelwriter.common import NWConfigParser, checkInt, checkPath, formatTimeStamp
|
from novelwriter.common import NWConfigParser, checkInt, checkPath, formatTimeStamp
|
||||||
from novelwriter.constants import nwFiles, nwUnicode
|
from novelwriter.constants import nwFiles, nwUnicode
|
||||||
|
|
||||||
if TYPE_CHECKING: # pragma: no cover
|
|
||||||
from novelwriter.gui.theme import GuiTheme
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@@ -96,7 +93,6 @@ class Config:
|
|||||||
# User Settings
|
# User Settings
|
||||||
# =============
|
# =============
|
||||||
|
|
||||||
self._themeObj = None
|
|
||||||
self._recentObj = RecentProjects(self)
|
self._recentObj = RecentProjects(self)
|
||||||
|
|
||||||
# General GUI Settings
|
# General GUI Settings
|
||||||
@@ -244,12 +240,6 @@ class Config:
|
|||||||
def recentProjects(self) -> RecentProjects:
|
def recentProjects(self) -> RecentProjects:
|
||||||
return self._recentObj
|
return self._recentObj
|
||||||
|
|
||||||
@property
|
|
||||||
def theme(self) -> GuiTheme:
|
|
||||||
if self._themeObj is None:
|
|
||||||
raise Exception("Cannot access GUI theme before it is initialised")
|
|
||||||
return self._themeObj
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def mainWinSize(self) -> list[int]:
|
def mainWinSize(self) -> list[int]:
|
||||||
return [int(x*self.guiScale) for x in self._mainWinSize]
|
return [int(x*self.guiScale) for x in self._mainWinSize]
|
||||||
@@ -297,11 +287,6 @@ class Config:
|
|||||||
# Setters
|
# Setters
|
||||||
##
|
##
|
||||||
|
|
||||||
def setThemeInstance(self, theme: GuiTheme) -> None:
|
|
||||||
"""Set the applications theme instance."""
|
|
||||||
self._themeObj = theme
|
|
||||||
return
|
|
||||||
|
|
||||||
def setMainWinSize(self, width: int, height: int) -> None:
|
def setMainWinSize(self, width: int, height: int) -> None:
|
||||||
"""Set the size of the main window, but only if the change is
|
"""Set the size of the main window, but only if the change is
|
||||||
larger than 5 pixels. The OS window manager will sometimes
|
larger than 5 pixels. The OS window manager will sometimes
|
||||||
@@ -499,7 +484,7 @@ class Config:
|
|||||||
self._recentObj.loadCache()
|
self._recentObj.loadCache()
|
||||||
self._checkOptionalPackages()
|
self._checkOptionalPackages()
|
||||||
|
|
||||||
logger.debug("Config initialisation complete")
|
logger.debug("Config instance initialised")
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -533,7 +533,7 @@ class NWIndex:
|
|||||||
|
|
||||||
def getTableOfContents(
|
def getTableOfContents(
|
||||||
self, rHandle: str, maxDepth: int, skipExcl: bool = True
|
self, rHandle: str, maxDepth: int, skipExcl: bool = True
|
||||||
) -> list[tuple[str, str, str, int]]:
|
) -> list[tuple[str, int, str, int]]:
|
||||||
"""Generate a table of contents up to a maximum depth."""
|
"""Generate a table of contents up to a maximum depth."""
|
||||||
tOrder = []
|
tOrder = []
|
||||||
tData = {}
|
tData = {}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ from PyQt5.QtWidgets import (
|
|||||||
QTextBrowser, QVBoxLayout, QWidget
|
QTextBrowser, QVBoxLayout, QWidget
|
||||||
)
|
)
|
||||||
|
|
||||||
from novelwriter import CONFIG
|
from novelwriter import CONFIG, SHARED
|
||||||
from novelwriter.common import readTextFile
|
from novelwriter.common import readTextFile
|
||||||
from novelwriter.constants import nwConst
|
from novelwriter.constants import nwConst
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ class GuiAbout(QDialog):
|
|||||||
|
|
||||||
nPx = CONFIG.pxInt(96)
|
nPx = CONFIG.pxInt(96)
|
||||||
self.nwIcon = QLabel()
|
self.nwIcon = QLabel()
|
||||||
self.nwIcon.setPixmap(CONFIG.theme.getPixmap("novelwriter", (nPx, nPx)))
|
self.nwIcon.setPixmap(SHARED.theme.getPixmap("novelwriter", (nPx, nPx)))
|
||||||
self.lblName = QLabel("<b>novelWriter</b>")
|
self.lblName = QLabel("<b>novelWriter</b>")
|
||||||
self.lblVers = QLabel(f"v{novelwriter.__version__}")
|
self.lblVers = QLabel(f"v{novelwriter.__version__}")
|
||||||
self.lblDate = QLabel(datetime.strptime(novelwriter.__date__, "%Y-%m-%d").strftime("%x"))
|
self.lblDate = QLabel(datetime.strptime(novelwriter.__date__, "%Y-%m-%d").strftime("%x"))
|
||||||
@@ -228,12 +228,12 @@ class GuiAbout(QDialog):
|
|||||||
" color: rgb({kColR},{kColG},{kColB});"
|
" color: rgb({kColR},{kColG},{kColB});"
|
||||||
"}}\n"
|
"}}\n"
|
||||||
).format(
|
).format(
|
||||||
hColR=CONFIG.theme.colHead[0],
|
hColR=SHARED.theme.colHead[0],
|
||||||
hColG=CONFIG.theme.colHead[1],
|
hColG=SHARED.theme.colHead[1],
|
||||||
hColB=CONFIG.theme.colHead[2],
|
hColB=SHARED.theme.colHead[2],
|
||||||
kColR=CONFIG.theme.colKey[0],
|
kColR=SHARED.theme.colKey[0],
|
||||||
kColG=CONFIG.theme.colKey[1],
|
kColG=SHARED.theme.colKey[1],
|
||||||
kColB=CONFIG.theme.colKey[2],
|
kColB=SHARED.theme.colKey[2],
|
||||||
)
|
)
|
||||||
self.pageAbout.document().setDefaultStyleSheet(styleSheet)
|
self.pageAbout.document().setDefaultStyleSheet(styleSheet)
|
||||||
self.pageNotes.document().setDefaultStyleSheet(styleSheet)
|
self.pageNotes.document().setDefaultStyleSheet(styleSheet)
|
||||||
|
|||||||
@@ -29,10 +29,10 @@ import logging
|
|||||||
from PyQt5.QtCore import Qt, QSize
|
from PyQt5.QtCore import Qt, QSize
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QAbstractItemView, QDialog, QDialogButtonBox, QGridLayout, QLabel,
|
QAbstractItemView, QDialog, QDialogButtonBox, QGridLayout, QLabel,
|
||||||
QListWidget, QListWidgetItem, QVBoxLayout,
|
QListWidget, QListWidgetItem, QVBoxLayout, QWidget
|
||||||
)
|
)
|
||||||
|
|
||||||
from novelwriter import CONFIG
|
from novelwriter import CONFIG, SHARED
|
||||||
from novelwriter.extensions.switch import NSwitch
|
from novelwriter.extensions.switch import NSwitch
|
||||||
from novelwriter.extensions.configlayout import NHelpLabel
|
from novelwriter.extensions.configlayout import NHelpLabel
|
||||||
|
|
||||||
@@ -43,24 +43,21 @@ class GuiDocMerge(QDialog):
|
|||||||
|
|
||||||
D_HANDLE = Qt.ItemDataRole.UserRole
|
D_HANDLE = Qt.ItemDataRole.UserRole
|
||||||
|
|
||||||
def __init__(self, mainGui, sHandle, itemList):
|
def __init__(self, parent: QWidget, sHandle: str, itemList: list[str]) -> None:
|
||||||
super().__init__(parent=mainGui)
|
super().__init__(parent=parent)
|
||||||
|
|
||||||
logger.debug("Create: GuiDocMerge")
|
logger.debug("Create: GuiDocMerge")
|
||||||
self.setObjectName("GuiDocMerge")
|
self.setObjectName("GuiDocMerge")
|
||||||
|
self.setWindowTitle(self.tr("Merge Documents"))
|
||||||
self.mainGui = mainGui
|
|
||||||
|
|
||||||
self._data = {}
|
self._data = {}
|
||||||
|
|
||||||
self.setWindowTitle(self.tr("Merge Documents"))
|
|
||||||
|
|
||||||
self.headLabel = QLabel("<b>{0}</b>".format(self.tr("Documents to Merge")))
|
self.headLabel = QLabel("<b>{0}</b>".format(self.tr("Documents to Merge")))
|
||||||
self.helpLabel = NHelpLabel(self.tr(
|
self.helpLabel = NHelpLabel(self.tr(
|
||||||
"Drag and drop items to change the order, or uncheck to exclude."
|
"Drag and drop items to change the order, or uncheck to exclude."
|
||||||
), CONFIG.theme.helpText)
|
), SHARED.theme.helpText)
|
||||||
|
|
||||||
iPx = CONFIG.theme.baseIconSize
|
iPx = SHARED.theme.baseIconSize
|
||||||
hSp = CONFIG.pxInt(12)
|
hSp = CONFIG.pxInt(12)
|
||||||
vSp = CONFIG.pxInt(8)
|
vSp = CONFIG.pxInt(8)
|
||||||
bSp = CONFIG.pxInt(12)
|
bSp = CONFIG.pxInt(12)
|
||||||
@@ -155,11 +152,11 @@ class GuiDocMerge(QDialog):
|
|||||||
|
|
||||||
self.listBox.clear()
|
self.listBox.clear()
|
||||||
for tHandle in itemList:
|
for tHandle in itemList:
|
||||||
nwItem = self.mainGui.project.tree[tHandle]
|
nwItem = SHARED.project.tree[tHandle]
|
||||||
if nwItem is None or not nwItem.isFileType():
|
if nwItem is None or not nwItem.isFileType():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
itemIcon = CONFIG.theme.getItemIcon(
|
itemIcon = SHARED.theme.getItemIcon(
|
||||||
nwItem.itemType, nwItem.itemClass, nwItem.itemLayout, nwItem.mainHeading
|
nwItem.itemType, nwItem.itemClass, nwItem.itemLayout, nwItem.mainHeading
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ from PyQt5.QtWidgets import (
|
|||||||
QListWidgetItem, QDialogButtonBox, QLabel, QGridLayout
|
QListWidgetItem, QDialogButtonBox, QLabel, QGridLayout
|
||||||
)
|
)
|
||||||
|
|
||||||
from novelwriter import CONFIG
|
from novelwriter import CONFIG, SHARED
|
||||||
from novelwriter.extensions.switch import NSwitch
|
from novelwriter.extensions.switch import NSwitch
|
||||||
from novelwriter.extensions.configlayout import NHelpLabel
|
from novelwriter.extensions.configlayout import NHelpLabel
|
||||||
|
|
||||||
@@ -45,14 +45,12 @@ class GuiDocSplit(QDialog):
|
|||||||
LEVEL_ROLE = Qt.ItemDataRole.UserRole + 1
|
LEVEL_ROLE = Qt.ItemDataRole.UserRole + 1
|
||||||
LABEL_ROLE = Qt.ItemDataRole.UserRole + 2
|
LABEL_ROLE = Qt.ItemDataRole.UserRole + 2
|
||||||
|
|
||||||
def __init__(self, mainGui, sHandle):
|
def __init__(self, parent, sHandle):
|
||||||
super().__init__(parent=mainGui)
|
super().__init__(parent=parent)
|
||||||
|
|
||||||
logger.debug("Create: GuiDocSplit")
|
logger.debug("Create: GuiDocSplit")
|
||||||
self.setObjectName("GuiDocSplit")
|
self.setObjectName("GuiDocSplit")
|
||||||
|
|
||||||
self.mainGui = mainGui
|
|
||||||
|
|
||||||
self._data = {}
|
self._data = {}
|
||||||
self._text = []
|
self._text = []
|
||||||
|
|
||||||
@@ -61,16 +59,16 @@ class GuiDocSplit(QDialog):
|
|||||||
self.headLabel = QLabel("<b>{0}</b>".format(self.tr("Document Headers")))
|
self.headLabel = QLabel("<b>{0}</b>".format(self.tr("Document Headers")))
|
||||||
self.helpLabel = NHelpLabel(
|
self.helpLabel = NHelpLabel(
|
||||||
self.tr("Select the maximum level to split into files."),
|
self.tr("Select the maximum level to split into files."),
|
||||||
CONFIG.theme.helpText
|
SHARED.theme.helpText
|
||||||
)
|
)
|
||||||
|
|
||||||
# Values
|
# Values
|
||||||
iPx = CONFIG.theme.baseIconSize
|
iPx = SHARED.theme.baseIconSize
|
||||||
hSp = CONFIG.pxInt(12)
|
hSp = CONFIG.pxInt(12)
|
||||||
vSp = CONFIG.pxInt(8)
|
vSp = CONFIG.pxInt(8)
|
||||||
bSp = CONFIG.pxInt(12)
|
bSp = CONFIG.pxInt(12)
|
||||||
|
|
||||||
pOptions = self.mainGui.project.options
|
pOptions = SHARED.project.options
|
||||||
spLevel = pOptions.getInt("GuiDocSplit", "spLevel", 3)
|
spLevel = pOptions.getInt("GuiDocSplit", "spLevel", 3)
|
||||||
intoFolder = pOptions.getBool("GuiDocSplit", "intoFolder", True)
|
intoFolder = pOptions.getBool("GuiDocSplit", "intoFolder", True)
|
||||||
docHierarchy = pOptions.getBool("GuiDocSplit", "docHierarchy", True)
|
docHierarchy = pOptions.getBool("GuiDocSplit", "docHierarchy", True)
|
||||||
@@ -169,7 +167,7 @@ class GuiDocSplit(QDialog):
|
|||||||
self._data["docHierarchy"] = docHierarchy
|
self._data["docHierarchy"] = docHierarchy
|
||||||
self._data["moveToTrash"] = moveToTrash
|
self._data["moveToTrash"] = moveToTrash
|
||||||
|
|
||||||
pOptions = self.mainGui.project.options
|
pOptions = SHARED.project.options
|
||||||
pOptions.setValue("GuiDocSplit", "spLevel", spLevel)
|
pOptions.setValue("GuiDocSplit", "spLevel", spLevel)
|
||||||
pOptions.setValue("GuiDocSplit", "intoFolder", intoFolder)
|
pOptions.setValue("GuiDocSplit", "intoFolder", intoFolder)
|
||||||
pOptions.setValue("GuiDocSplit", "docHierarchy", docHierarchy)
|
pOptions.setValue("GuiDocSplit", "docHierarchy", docHierarchy)
|
||||||
@@ -199,13 +197,13 @@ class GuiDocSplit(QDialog):
|
|||||||
|
|
||||||
self.listBox.clear()
|
self.listBox.clear()
|
||||||
|
|
||||||
nwItem = self.mainGui.project.tree[sHandle]
|
nwItem = SHARED.project.tree[sHandle]
|
||||||
if nwItem is None or not nwItem.isFileType():
|
if nwItem is None or not nwItem.isFileType():
|
||||||
return
|
return
|
||||||
|
|
||||||
spLevel = self.splitLevel.currentData()
|
spLevel = self.splitLevel.currentData()
|
||||||
if not self._text:
|
if not self._text:
|
||||||
inDoc = self.mainGui.project.storage.getDocument(sHandle)
|
inDoc = SHARED.project.storage.getDocument(sHandle)
|
||||||
self._text = (inDoc.readDocument() or "").splitlines()
|
self._text = (inDoc.readDocument() or "").splitlines()
|
||||||
|
|
||||||
for lineNo, aLine in enumerate(self._text):
|
for lineNo, aLine in enumerate(self._text):
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ from PyQt5.QtWidgets import (
|
|||||||
QLineEdit, QFileDialog, QFontDialog, QDoubleSpinBox
|
QLineEdit, QFileDialog, QFontDialog, QDoubleSpinBox
|
||||||
)
|
)
|
||||||
|
|
||||||
from novelwriter import CONFIG
|
from novelwriter import CONFIG, SHARED
|
||||||
from novelwriter.dialogs.quotes import GuiQuoteSelect
|
from novelwriter.dialogs.quotes import GuiQuoteSelect
|
||||||
from novelwriter.extensions.switch import NSwitch
|
from novelwriter.extensions.switch import NSwitch
|
||||||
from novelwriter.extensions.pageddialog import NPagedDialog
|
from novelwriter.extensions.pageddialog import NPagedDialog
|
||||||
@@ -163,7 +163,7 @@ class GuiPreferencesGeneral(QWidget):
|
|||||||
|
|
||||||
# The Form
|
# The Form
|
||||||
self.mainForm = NConfigLayout()
|
self.mainForm = NConfigLayout()
|
||||||
self.mainForm.setHelpTextStyle(CONFIG.theme.helpText)
|
self.mainForm.setHelpTextStyle(SHARED.theme.helpText)
|
||||||
self.setLayout(self.mainForm)
|
self.setLayout(self.mainForm)
|
||||||
|
|
||||||
# Look and Feel
|
# Look and Feel
|
||||||
@@ -190,7 +190,7 @@ class GuiPreferencesGeneral(QWidget):
|
|||||||
# Select Theme
|
# Select Theme
|
||||||
self.guiTheme = QComboBox()
|
self.guiTheme = QComboBox()
|
||||||
self.guiTheme.setMinimumWidth(minWidth)
|
self.guiTheme.setMinimumWidth(minWidth)
|
||||||
self.theThemes = CONFIG.theme.listThemes()
|
self.theThemes = SHARED.theme.listThemes()
|
||||||
for themeDir, themeName in self.theThemes:
|
for themeDir, themeName in self.theThemes:
|
||||||
self.guiTheme.addItem(themeName, themeDir)
|
self.guiTheme.addItem(themeName, themeDir)
|
||||||
themeIdx = self.guiTheme.findData(CONFIG.guiTheme)
|
themeIdx = self.guiTheme.findData(CONFIG.guiTheme)
|
||||||
@@ -206,7 +206,7 @@ class GuiPreferencesGeneral(QWidget):
|
|||||||
# Editor Theme
|
# Editor Theme
|
||||||
self.guiSyntax = QComboBox()
|
self.guiSyntax = QComboBox()
|
||||||
self.guiSyntax.setMinimumWidth(CONFIG.pxInt(200))
|
self.guiSyntax.setMinimumWidth(CONFIG.pxInt(200))
|
||||||
self.theSyntaxes = CONFIG.theme.listSyntax()
|
self.theSyntaxes = SHARED.theme.listSyntax()
|
||||||
for syntaxFile, syntaxName in self.theSyntaxes:
|
for syntaxFile, syntaxName in self.theSyntaxes:
|
||||||
self.guiSyntax.addItem(syntaxName, syntaxFile)
|
self.guiSyntax.addItem(syntaxName, syntaxFile)
|
||||||
syntaxIdx = self.guiSyntax.findData(CONFIG.guiSyntax)
|
syntaxIdx = self.guiSyntax.findData(CONFIG.guiSyntax)
|
||||||
@@ -225,7 +225,7 @@ class GuiPreferencesGeneral(QWidget):
|
|||||||
self.guiFont.setFixedWidth(CONFIG.pxInt(162))
|
self.guiFont.setFixedWidth(CONFIG.pxInt(162))
|
||||||
self.guiFont.setText(CONFIG.guiFont)
|
self.guiFont.setText(CONFIG.guiFont)
|
||||||
self.fontButton = QPushButton("...")
|
self.fontButton = QPushButton("...")
|
||||||
self.fontButton.setMaximumWidth(int(2.5*CONFIG.theme.getTextWidth("...")))
|
self.fontButton.setMaximumWidth(int(2.5*SHARED.theme.getTextWidth("...")))
|
||||||
self.fontButton.clicked.connect(self._selectFont)
|
self.fontButton.clicked.connect(self._selectFont)
|
||||||
self.mainForm.addRow(
|
self.mainForm.addRow(
|
||||||
self.tr("Font family"),
|
self.tr("Font family"),
|
||||||
@@ -341,7 +341,7 @@ class GuiPreferencesProjects(QWidget):
|
|||||||
|
|
||||||
# The Form
|
# The Form
|
||||||
self.mainForm = NConfigLayout()
|
self.mainForm = NConfigLayout()
|
||||||
self.mainForm.setHelpTextStyle(CONFIG.theme.helpText)
|
self.mainForm.setHelpTextStyle(SHARED.theme.helpText)
|
||||||
self.setLayout(self.mainForm)
|
self.setLayout(self.mainForm)
|
||||||
|
|
||||||
# Automatic Save
|
# Automatic Save
|
||||||
@@ -493,7 +493,7 @@ class GuiPreferencesDocuments(QWidget):
|
|||||||
|
|
||||||
# The Form
|
# The Form
|
||||||
self.mainForm = NConfigLayout()
|
self.mainForm = NConfigLayout()
|
||||||
self.mainForm.setHelpTextStyle(CONFIG.theme.helpText)
|
self.mainForm.setHelpTextStyle(SHARED.theme.helpText)
|
||||||
self.setLayout(self.mainForm)
|
self.setLayout(self.mainForm)
|
||||||
|
|
||||||
# Text Style
|
# Text Style
|
||||||
@@ -506,7 +506,7 @@ class GuiPreferencesDocuments(QWidget):
|
|||||||
self.textFont.setFixedWidth(CONFIG.pxInt(162))
|
self.textFont.setFixedWidth(CONFIG.pxInt(162))
|
||||||
self.textFont.setText(CONFIG.textFont)
|
self.textFont.setText(CONFIG.textFont)
|
||||||
self.fontButton = QPushButton("...")
|
self.fontButton = QPushButton("...")
|
||||||
self.fontButton.setMaximumWidth(int(2.5*CONFIG.theme.getTextWidth("...")))
|
self.fontButton.setMaximumWidth(int(2.5*SHARED.theme.getTextWidth("...")))
|
||||||
self.fontButton.clicked.connect(self._selectFont)
|
self.fontButton.clicked.connect(self._selectFont)
|
||||||
self.mainForm.addRow(
|
self.mainForm.addRow(
|
||||||
self.tr("Font family"),
|
self.tr("Font family"),
|
||||||
@@ -649,7 +649,7 @@ class GuiPreferencesEditor(QWidget):
|
|||||||
|
|
||||||
# The Form
|
# The Form
|
||||||
self.mainForm = NConfigLayout()
|
self.mainForm = NConfigLayout()
|
||||||
self.mainForm.setHelpTextStyle(CONFIG.theme.helpText)
|
self.mainForm.setHelpTextStyle(SHARED.theme.helpText)
|
||||||
self.setLayout(self.mainForm)
|
self.setLayout(self.mainForm)
|
||||||
|
|
||||||
mW = CONFIG.pxInt(250)
|
mW = CONFIG.pxInt(250)
|
||||||
@@ -819,7 +819,7 @@ class GuiPreferencesSyntax(QWidget):
|
|||||||
|
|
||||||
# The Form
|
# The Form
|
||||||
self.mainForm = NConfigLayout()
|
self.mainForm = NConfigLayout()
|
||||||
self.mainForm.setHelpTextStyle(CONFIG.theme.helpText)
|
self.mainForm.setHelpTextStyle(SHARED.theme.helpText)
|
||||||
self.setLayout(self.mainForm)
|
self.setLayout(self.mainForm)
|
||||||
|
|
||||||
# Quotes & Dialogue
|
# Quotes & Dialogue
|
||||||
@@ -921,7 +921,7 @@ class GuiPreferencesAutomation(QWidget):
|
|||||||
|
|
||||||
# The Form
|
# The Form
|
||||||
self.mainForm = NConfigLayout()
|
self.mainForm = NConfigLayout()
|
||||||
self.mainForm.setHelpTextStyle(CONFIG.theme.helpText)
|
self.mainForm.setHelpTextStyle(SHARED.theme.helpText)
|
||||||
self.setLayout(self.mainForm)
|
self.setLayout(self.mainForm)
|
||||||
|
|
||||||
# Automatic Features
|
# Automatic Features
|
||||||
@@ -1072,7 +1072,7 @@ class GuiPreferencesQuotes(QWidget):
|
|||||||
|
|
||||||
# The Form
|
# The Form
|
||||||
self.mainForm = NConfigLayout()
|
self.mainForm = NConfigLayout()
|
||||||
self.mainForm.setHelpTextStyle(CONFIG.theme.helpText)
|
self.mainForm.setHelpTextStyle(SHARED.theme.helpText)
|
||||||
self.setLayout(self.mainForm)
|
self.setLayout(self.mainForm)
|
||||||
|
|
||||||
# Quotation Style
|
# Quotation Style
|
||||||
@@ -1080,7 +1080,7 @@ class GuiPreferencesQuotes(QWidget):
|
|||||||
self.mainForm.addGroupLabel(self.tr("Quotation Style"))
|
self.mainForm.addGroupLabel(self.tr("Quotation Style"))
|
||||||
|
|
||||||
qWidth = CONFIG.pxInt(40)
|
qWidth = CONFIG.pxInt(40)
|
||||||
bWidth = int(2.5*CONFIG.theme.getTextWidth("..."))
|
bWidth = int(2.5*SHARED.theme.getTextWidth("..."))
|
||||||
self.quoteSym = {}
|
self.quoteSym = {}
|
||||||
|
|
||||||
# Single Quote Style
|
# Single Quote Style
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ from PyQt5.QtWidgets import (
|
|||||||
QLineEdit, QSpinBox, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget
|
QLineEdit, QSpinBox, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget
|
||||||
)
|
)
|
||||||
|
|
||||||
from novelwriter import CONFIG
|
from novelwriter import CONFIG, SHARED
|
||||||
from novelwriter.common import formatTime, numberToRoman
|
from novelwriter.common import formatTime, numberToRoman
|
||||||
from novelwriter.constants import nwUnicode
|
from novelwriter.constants import nwUnicode
|
||||||
from novelwriter.extensions.switch import NSwitch
|
from novelwriter.extensions.switch import NSwitch
|
||||||
@@ -45,19 +45,17 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class GuiProjectDetails(NPagedDialog):
|
class GuiProjectDetails(NPagedDialog):
|
||||||
|
|
||||||
def __init__(self, mainGui):
|
def __init__(self, parent):
|
||||||
super().__init__(parent=mainGui)
|
super().__init__(parent=parent)
|
||||||
|
|
||||||
logger.debug("Create: GuiProjectDetails")
|
logger.debug("Create: GuiProjectDetails")
|
||||||
self.setObjectName("GuiProjectDetails")
|
self.setObjectName("GuiProjectDetails")
|
||||||
|
|
||||||
self.mainGui = mainGui
|
|
||||||
|
|
||||||
self.setWindowTitle(self.tr("Project Details"))
|
self.setWindowTitle(self.tr("Project Details"))
|
||||||
|
|
||||||
wW = CONFIG.pxInt(600)
|
wW = CONFIG.pxInt(600)
|
||||||
wH = CONFIG.pxInt(400)
|
wH = CONFIG.pxInt(400)
|
||||||
pOptions = self.mainGui.project.options
|
pOptions = SHARED.project.options
|
||||||
|
|
||||||
self.setMinimumWidth(wW)
|
self.setMinimumWidth(wW)
|
||||||
self.setMinimumHeight(wH)
|
self.setMinimumHeight(wH)
|
||||||
@@ -66,8 +64,8 @@ class GuiProjectDetails(NPagedDialog):
|
|||||||
CONFIG.pxInt(pOptions.getInt("GuiProjectDetails", "winHeight", wH))
|
CONFIG.pxInt(pOptions.getInt("GuiProjectDetails", "winHeight", wH))
|
||||||
)
|
)
|
||||||
|
|
||||||
self.tabMain = GuiProjectDetailsMain(self.mainGui)
|
self.tabMain = GuiProjectDetailsMain(self)
|
||||||
self.tabContents = GuiProjectDetailsContents(self.mainGui)
|
self.tabContents = GuiProjectDetailsContents(self)
|
||||||
|
|
||||||
self.addTab(self.tabMain, self.tr("Overview"))
|
self.addTab(self.tabMain, self.tr("Overview"))
|
||||||
self.addTab(self.tabContents, self.tr("Contents"))
|
self.addTab(self.tabContents, self.tr("Contents"))
|
||||||
@@ -124,7 +122,7 @@ class GuiProjectDetails(NPagedDialog):
|
|||||||
countFrom = self.tabContents.poValue.value()
|
countFrom = self.tabContents.poValue.value()
|
||||||
clearDouble = self.tabContents.dblValue.isChecked()
|
clearDouble = self.tabContents.dblValue.isChecked()
|
||||||
|
|
||||||
pOptions = self.mainGui.project.options
|
pOptions = SHARED.project.options
|
||||||
pOptions.setValue("GuiProjectDetails", "winWidth", winWidth)
|
pOptions.setValue("GuiProjectDetails", "winWidth", winWidth)
|
||||||
pOptions.setValue("GuiProjectDetails", "winHeight", winHeight)
|
pOptions.setValue("GuiProjectDetails", "winHeight", winHeight)
|
||||||
pOptions.setValue("GuiProjectDetails", "widthCol0", widthCol0)
|
pOptions.setValue("GuiProjectDetails", "widthCol0", widthCol0)
|
||||||
@@ -143,13 +141,11 @@ class GuiProjectDetails(NPagedDialog):
|
|||||||
|
|
||||||
class GuiProjectDetailsMain(QWidget):
|
class GuiProjectDetailsMain(QWidget):
|
||||||
|
|
||||||
def __init__(self, mainGui):
|
def __init__(self, parent):
|
||||||
super().__init__(parent=mainGui)
|
super().__init__(parent=parent)
|
||||||
|
|
||||||
self.mainGui = mainGui
|
fPx = SHARED.theme.fontPixelSize
|
||||||
|
fPt = SHARED.theme.fontPointSize
|
||||||
fPx = CONFIG.theme.fontPixelSize
|
|
||||||
fPt = CONFIG.theme.fontPointSize
|
|
||||||
vPx = CONFIG.pxInt(4)
|
vPx = CONFIG.pxInt(4)
|
||||||
hPx = CONFIG.pxInt(12)
|
hPx = CONFIG.pxInt(12)
|
||||||
|
|
||||||
@@ -244,7 +240,7 @@ class GuiProjectDetailsMain(QWidget):
|
|||||||
def updateValues(self):
|
def updateValues(self):
|
||||||
"""Set all the values.
|
"""Set all the values.
|
||||||
"""
|
"""
|
||||||
project = self.mainGui.project
|
project = SHARED.project
|
||||||
pIndex = project.index
|
pIndex = project.index
|
||||||
hCounts = pIndex.getNovelTitleCounts()
|
hCounts = pIndex.getNovelTitleCounts()
|
||||||
nwCount = pIndex.getNovelWordCount()
|
nwCount = pIndex.getNovelWordCount()
|
||||||
@@ -275,26 +271,24 @@ class GuiProjectDetailsContents(QWidget):
|
|||||||
C_PAGE = 3
|
C_PAGE = 3
|
||||||
C_PROG = 4
|
C_PROG = 4
|
||||||
|
|
||||||
def __init__(self, mainGui):
|
def __init__(self, parent):
|
||||||
super().__init__(parent=mainGui)
|
super().__init__(parent=parent)
|
||||||
|
|
||||||
self.mainGui = mainGui
|
|
||||||
|
|
||||||
# Internal
|
# Internal
|
||||||
self._theToC = []
|
self._theToC = []
|
||||||
self._currentRoot = None
|
self._currentRoot = None
|
||||||
|
|
||||||
iPx = CONFIG.theme.baseIconSize
|
iPx = SHARED.theme.baseIconSize
|
||||||
hPx = CONFIG.pxInt(12)
|
hPx = CONFIG.pxInt(12)
|
||||||
vPx = CONFIG.pxInt(4)
|
vPx = CONFIG.pxInt(4)
|
||||||
pOptions = self.mainGui.project.options
|
pOptions = SHARED.project.options
|
||||||
|
|
||||||
# Header
|
# Header
|
||||||
# ======
|
# ======
|
||||||
|
|
||||||
self.tocLabel = QLabel("<b>%s</b>" % self.tr("Table of Contents"))
|
self.tocLabel = QLabel("<b>%s</b>" % self.tr("Table of Contents"))
|
||||||
|
|
||||||
self.novelValue = NovelSelector(self, self.mainGui)
|
self.novelValue = NovelSelector(self)
|
||||||
self.novelValue.setMinimumWidth(CONFIG.pxInt(200))
|
self.novelValue.setMinimumWidth(CONFIG.pxInt(200))
|
||||||
self.novelValue.novelSelectionChanged.connect(self._novelValueChanged)
|
self.novelValue.novelSelectionChanged.connect(self._novelValueChanged)
|
||||||
|
|
||||||
@@ -320,10 +314,11 @@ class GuiProjectDetailsContents(QWidget):
|
|||||||
])
|
])
|
||||||
|
|
||||||
treeHeadItem = self.tocTree.headerItem()
|
treeHeadItem = self.tocTree.headerItem()
|
||||||
treeHeadItem.setTextAlignment(self.C_WORDS, Qt.AlignRight)
|
if treeHeadItem:
|
||||||
treeHeadItem.setTextAlignment(self.C_PAGES, Qt.AlignRight)
|
treeHeadItem.setTextAlignment(self.C_WORDS, Qt.AlignRight)
|
||||||
treeHeadItem.setTextAlignment(self.C_PAGE, Qt.AlignRight)
|
treeHeadItem.setTextAlignment(self.C_PAGES, Qt.AlignRight)
|
||||||
treeHeadItem.setTextAlignment(self.C_PROG, Qt.AlignRight)
|
treeHeadItem.setTextAlignment(self.C_PAGE, Qt.AlignRight)
|
||||||
|
treeHeadItem.setTextAlignment(self.C_PROG, Qt.AlignRight)
|
||||||
|
|
||||||
treeHeader = self.tocTree.header()
|
treeHeader = self.tocTree.header()
|
||||||
treeHeader.setStretchLastSection(True)
|
treeHeader.setStretchLastSection(True)
|
||||||
@@ -347,7 +342,7 @@ class GuiProjectDetailsContents(QWidget):
|
|||||||
|
|
||||||
wordsPerPage = pOptions.getInt("GuiProjectDetails", "wordsPerPage", 350)
|
wordsPerPage = pOptions.getInt("GuiProjectDetails", "wordsPerPage", 350)
|
||||||
countFrom = pOptions.getInt("GuiProjectDetails", "countFrom", 1)
|
countFrom = pOptions.getInt("GuiProjectDetails", "countFrom", 1)
|
||||||
clearDouble = pOptions.getInt("GuiProjectDetails", "clearDouble", True)
|
clearDouble = pOptions.getBool("GuiProjectDetails", "clearDouble", True)
|
||||||
|
|
||||||
wordsHelp = (
|
wordsHelp = (
|
||||||
self.tr("Typical word count for a 5 by 8 inch book page with 11 pt font is 350.")
|
self.tr("Typical word count for a 5 by 8 inch book page with 11 pt font is 350.")
|
||||||
@@ -443,7 +438,7 @@ class GuiProjectDetailsContents(QWidget):
|
|||||||
"""Extract the information from the project index.
|
"""Extract the information from the project index.
|
||||||
"""
|
"""
|
||||||
logger.debug("Populating ToC from handle '%s'", rootHandle)
|
logger.debug("Populating ToC from handle '%s'", rootHandle)
|
||||||
self._theToC = self.mainGui.project.index.getTableOfContents(rootHandle, 2)
|
self._theToC = SHARED.project.index.getTableOfContents(rootHandle, 2)
|
||||||
self._theToC.append(("", 0, self.tr("END"), 0))
|
self._theToC.append(("", 0, self.tr("END"), 0))
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -496,7 +491,7 @@ class GuiProjectDetailsContents(QWidget):
|
|||||||
progPage = f"{cPage:n}"
|
progPage = f"{cPage:n}"
|
||||||
progText = f"{pgProg:.1f}{nwUnicode.U_THSP}%"
|
progText = f"{pgProg:.1f}{nwUnicode.U_THSP}%"
|
||||||
|
|
||||||
hDec = CONFIG.theme.getHeaderDecoration(tLevel)
|
hDec = SHARED.theme.getHeaderDecoration(tLevel)
|
||||||
if tTitle.strip() == "":
|
if tTitle.strip() == "":
|
||||||
tTitle = self.tr("Untitled")
|
tTitle = self.tr("Untitled")
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ from PyQt5.QtWidgets import (
|
|||||||
QFileDialog, QLineEdit
|
QFileDialog, QLineEdit
|
||||||
)
|
)
|
||||||
|
|
||||||
from novelwriter import CONFIG
|
from novelwriter import CONFIG, SHARED
|
||||||
from novelwriter.common import formatInt
|
from novelwriter.common import formatInt
|
||||||
from novelwriter.constants import nwFiles
|
from novelwriter.constants import nwFiles
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ class GuiProjectLoad(QDialog):
|
|||||||
|
|
||||||
sPx = CONFIG.pxInt(16)
|
sPx = CONFIG.pxInt(16)
|
||||||
nPx = CONFIG.pxInt(96)
|
nPx = CONFIG.pxInt(96)
|
||||||
iPx = CONFIG.theme.baseIconSize
|
iPx = SHARED.theme.baseIconSize
|
||||||
|
|
||||||
self.outerBox = QVBoxLayout()
|
self.outerBox = QVBoxLayout()
|
||||||
self.innerBox = QHBoxLayout()
|
self.innerBox = QHBoxLayout()
|
||||||
@@ -79,7 +79,7 @@ class GuiProjectLoad(QDialog):
|
|||||||
self.setMinimumHeight(CONFIG.pxInt(400))
|
self.setMinimumHeight(CONFIG.pxInt(400))
|
||||||
|
|
||||||
self.nwIcon = QLabel()
|
self.nwIcon = QLabel()
|
||||||
self.nwIcon.setPixmap(CONFIG.theme.getPixmap("novelwriter", (nPx, nPx)))
|
self.nwIcon.setPixmap(SHARED.theme.getPixmap("novelwriter", (nPx, nPx)))
|
||||||
self.innerBox.addWidget(self.nwIcon, 0, Qt.AlignTop)
|
self.innerBox.addWidget(self.nwIcon, 0, Qt.AlignTop)
|
||||||
|
|
||||||
self.projectForm = QGridLayout()
|
self.projectForm = QGridLayout()
|
||||||
@@ -110,7 +110,7 @@ class GuiProjectLoad(QDialog):
|
|||||||
self.selPath.setReadOnly(True)
|
self.selPath.setReadOnly(True)
|
||||||
|
|
||||||
self.browseButton = QPushButton("...")
|
self.browseButton = QPushButton("...")
|
||||||
self.browseButton.setMaximumWidth(int(2.5*CONFIG.theme.getTextWidth("...")))
|
self.browseButton.setMaximumWidth(int(2.5*SHARED.theme.getTextWidth("...")))
|
||||||
self.browseButton.clicked.connect(self._doBrowse)
|
self.browseButton.clicked.connect(self._doBrowse)
|
||||||
|
|
||||||
self.projectForm.addWidget(self.lblRecent, 0, 0, 1, 3)
|
self.projectForm.addWidget(self.lblRecent, 0, 0, 1, 3)
|
||||||
@@ -268,7 +268,7 @@ class GuiProjectLoad(QDialog):
|
|||||||
self.listBox.clear()
|
self.listBox.clear()
|
||||||
dataList = CONFIG.recentProjects.listEntries()
|
dataList = CONFIG.recentProjects.listEntries()
|
||||||
sortList = sorted(dataList, key=lambda x: x[3], reverse=True)
|
sortList = sorted(dataList, key=lambda x: x[3], reverse=True)
|
||||||
nwxIcon = CONFIG.theme.getIcon("proj_nwx")
|
nwxIcon = SHARED.theme.getIcon("proj_nwx")
|
||||||
for path, title, words, time in sortList:
|
for path, title, words, time in sortList:
|
||||||
newItem = QTreeWidgetItem([""]*4)
|
newItem = QTreeWidgetItem([""]*4)
|
||||||
newItem.setIcon(self.C_NAME, nwxIcon)
|
newItem.setIcon(self.C_NAME, nwxIcon)
|
||||||
@@ -279,7 +279,7 @@ class GuiProjectLoad(QDialog):
|
|||||||
newItem.setTextAlignment(self.C_NAME, Qt.AlignLeft | Qt.AlignVCenter)
|
newItem.setTextAlignment(self.C_NAME, Qt.AlignLeft | Qt.AlignVCenter)
|
||||||
newItem.setTextAlignment(self.C_COUNT, Qt.AlignRight | Qt.AlignVCenter)
|
newItem.setTextAlignment(self.C_COUNT, Qt.AlignRight | Qt.AlignVCenter)
|
||||||
newItem.setTextAlignment(self.C_TIME, Qt.AlignRight | Qt.AlignVCenter)
|
newItem.setTextAlignment(self.C_TIME, Qt.AlignRight | Qt.AlignVCenter)
|
||||||
newItem.setFont(self.C_TIME, CONFIG.theme.guiFontFixed)
|
newItem.setFont(self.C_TIME, SHARED.theme.guiFontFixed)
|
||||||
self.listBox.addTopLevelItem(newItem)
|
self.listBox.addTopLevelItem(newItem)
|
||||||
|
|
||||||
self.listBox.setCurrentItem(self.listBox.topLevelItem(0))
|
self.listBox.setCurrentItem(self.listBox.topLevelItem(0))
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ from PyQt5.QtWidgets import (
|
|||||||
QPushButton, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget
|
QPushButton, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget
|
||||||
)
|
)
|
||||||
|
|
||||||
from novelwriter import CONFIG
|
from novelwriter import CONFIG, SHARED
|
||||||
from novelwriter.enum import nwAlert
|
from novelwriter.enum import nwAlert
|
||||||
from novelwriter.common import simplified
|
from novelwriter.common import simplified
|
||||||
from novelwriter.extensions.switch import NSwitch
|
from novelwriter.extensions.switch import NSwitch
|
||||||
@@ -61,12 +61,12 @@ class GuiProjectSettings(NPagedDialog):
|
|||||||
self.setObjectName("GuiProjectSettings")
|
self.setObjectName("GuiProjectSettings")
|
||||||
|
|
||||||
self.mainGui = mainGui
|
self.mainGui = mainGui
|
||||||
self.mainGui.project.countStatus()
|
SHARED.project.countStatus()
|
||||||
self.setWindowTitle(self.tr("Project Settings"))
|
self.setWindowTitle(self.tr("Project Settings"))
|
||||||
|
|
||||||
wW = CONFIG.pxInt(570)
|
wW = CONFIG.pxInt(570)
|
||||||
wH = CONFIG.pxInt(375)
|
wH = CONFIG.pxInt(375)
|
||||||
pOptions = self.mainGui.project.options
|
pOptions = SHARED.project.options
|
||||||
|
|
||||||
self.setMinimumWidth(wW)
|
self.setMinimumWidth(wW)
|
||||||
self.setMinimumHeight(wH)
|
self.setMinimumHeight(wH)
|
||||||
@@ -115,7 +115,7 @@ class GuiProjectSettings(NPagedDialog):
|
|||||||
def _doSave(self):
|
def _doSave(self):
|
||||||
"""Save settings and close dialog.
|
"""Save settings and close dialog.
|
||||||
"""
|
"""
|
||||||
project = self.mainGui.project
|
project = SHARED.project
|
||||||
projName = self.tabMain.editName.text()
|
projName = self.tabMain.editName.text()
|
||||||
bookTitle = self.tabMain.editTitle.text()
|
bookTitle = self.tabMain.editTitle.text()
|
||||||
bookAuthor = self.tabMain.editAuthor.text()
|
bookAuthor = self.tabMain.editAuthor.text()
|
||||||
@@ -183,7 +183,7 @@ class GuiProjectSettings(NPagedDialog):
|
|||||||
statusColW = CONFIG.rpxInt(self.tabStatus.listBox.columnWidth(0))
|
statusColW = CONFIG.rpxInt(self.tabStatus.listBox.columnWidth(0))
|
||||||
importColW = CONFIG.rpxInt(self.tabImport.listBox.columnWidth(0))
|
importColW = CONFIG.rpxInt(self.tabImport.listBox.columnWidth(0))
|
||||||
|
|
||||||
pOptions = self.mainGui.project.options
|
pOptions = SHARED.project.options
|
||||||
pOptions.setValue("GuiProjectSettings", "winWidth", winWidth)
|
pOptions.setValue("GuiProjectSettings", "winWidth", winWidth)
|
||||||
pOptions.setValue("GuiProjectSettings", "winHeight", winHeight)
|
pOptions.setValue("GuiProjectSettings", "winHeight", winHeight)
|
||||||
pOptions.setValue("GuiProjectSettings", "replaceColW", replaceColW)
|
pOptions.setValue("GuiProjectSettings", "replaceColW", replaceColW)
|
||||||
@@ -204,13 +204,13 @@ class GuiProjectEditMain(QWidget):
|
|||||||
|
|
||||||
# The Form
|
# The Form
|
||||||
self.mainForm = NConfigLayout()
|
self.mainForm = NConfigLayout()
|
||||||
self.mainForm.setHelpTextStyle(CONFIG.theme.helpText)
|
self.mainForm.setHelpTextStyle(SHARED.theme.helpText)
|
||||||
self.setLayout(self.mainForm)
|
self.setLayout(self.mainForm)
|
||||||
|
|
||||||
self.mainForm.addGroupLabel(self.tr("Project Settings"))
|
self.mainForm.addGroupLabel(self.tr("Project Settings"))
|
||||||
|
|
||||||
xW = CONFIG.pxInt(250)
|
xW = CONFIG.pxInt(250)
|
||||||
pData = self.mainGui.project.data
|
pData = SHARED.project.data
|
||||||
|
|
||||||
self.editName = QLineEdit()
|
self.editName = QLineEdit()
|
||||||
self.editName.setMaxLength(200)
|
self.editName.setMaxLength(200)
|
||||||
@@ -291,23 +291,23 @@ class GuiProjectEditStatus(QWidget):
|
|||||||
self.mainGui = projGui.mainGui
|
self.mainGui = projGui.mainGui
|
||||||
|
|
||||||
if isStatus:
|
if isStatus:
|
||||||
self.theStatus = self.mainGui.project.data.itemStatus
|
self.theStatus = SHARED.project.data.itemStatus
|
||||||
pageLabel = self.tr("Novel File Status Levels")
|
pageLabel = self.tr("Novel File Status Levels")
|
||||||
colSetting = "statusColW"
|
colSetting = "statusColW"
|
||||||
else:
|
else:
|
||||||
self.theStatus = self.mainGui.project.data.itemImport
|
self.theStatus = SHARED.project.data.itemImport
|
||||||
pageLabel = self.tr("Note File Importance Levels")
|
pageLabel = self.tr("Note File Importance Levels")
|
||||||
colSetting = "importColW"
|
colSetting = "importColW"
|
||||||
|
|
||||||
wCol0 = CONFIG.pxInt(
|
wCol0 = CONFIG.pxInt(
|
||||||
self.mainGui.project.options.getInt("GuiProjectSettings", colSetting, 130)
|
SHARED.project.options.getInt("GuiProjectSettings", colSetting, 130)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.colDeleted = []
|
self.colDeleted = []
|
||||||
self.colChanged = False
|
self.colChanged = False
|
||||||
self.selColour = QColor(100, 100, 100)
|
self.selColour = QColor(100, 100, 100)
|
||||||
|
|
||||||
self.iPx = CONFIG.theme.baseIconSize
|
self.iPx = SHARED.theme.baseIconSize
|
||||||
|
|
||||||
# The List
|
# The List
|
||||||
# ========
|
# ========
|
||||||
@@ -326,16 +326,16 @@ class GuiProjectEditStatus(QWidget):
|
|||||||
# List Controls
|
# List Controls
|
||||||
# =============
|
# =============
|
||||||
|
|
||||||
self.addButton = QPushButton(CONFIG.theme.getIcon("add"), "")
|
self.addButton = QPushButton(SHARED.theme.getIcon("add"), "")
|
||||||
self.addButton.clicked.connect(self._newItem)
|
self.addButton.clicked.connect(self._newItem)
|
||||||
|
|
||||||
self.delButton = QPushButton(CONFIG.theme.getIcon("remove"), "")
|
self.delButton = QPushButton(SHARED.theme.getIcon("remove"), "")
|
||||||
self.delButton.clicked.connect(self._delItem)
|
self.delButton.clicked.connect(self._delItem)
|
||||||
|
|
||||||
self.upButton = QPushButton(CONFIG.theme.getIcon("up"), "")
|
self.upButton = QPushButton(SHARED.theme.getIcon("up"), "")
|
||||||
self.upButton.clicked.connect(lambda: self._moveItem(-1))
|
self.upButton.clicked.connect(lambda: self._moveItem(-1))
|
||||||
|
|
||||||
self.dnButton = QPushButton(CONFIG.theme.getIcon("down"), "")
|
self.dnButton = QPushButton(SHARED.theme.getIcon("down"), "")
|
||||||
self.dnButton.clicked.connect(lambda: self._moveItem(1))
|
self.dnButton.clicked.connect(lambda: self._moveItem(1))
|
||||||
|
|
||||||
# Edit Form
|
# Edit Form
|
||||||
@@ -578,7 +578,7 @@ class GuiProjectEditReplace(QWidget):
|
|||||||
self.arChanged = False
|
self.arChanged = False
|
||||||
|
|
||||||
wCol0 = CONFIG.pxInt(
|
wCol0 = CONFIG.pxInt(
|
||||||
self.mainGui.project.options.getInt("GuiProjectSettings", "replaceColW", 130)
|
SHARED.project.options.getInt("GuiProjectSettings", "replaceColW", 130)
|
||||||
)
|
)
|
||||||
pageLabel = self.tr("Text Replace List for Preview and Export")
|
pageLabel = self.tr("Text Replace List for Preview and Export")
|
||||||
|
|
||||||
@@ -594,7 +594,7 @@ class GuiProjectEditReplace(QWidget):
|
|||||||
self.listBox.setColumnWidth(self.COL_KEY, wCol0)
|
self.listBox.setColumnWidth(self.COL_KEY, wCol0)
|
||||||
self.listBox.setIndentation(0)
|
self.listBox.setIndentation(0)
|
||||||
|
|
||||||
for aKey, aVal in self.mainGui.project.data.autoReplace.items():
|
for aKey, aVal in SHARED.project.data.autoReplace.items():
|
||||||
newItem = QTreeWidgetItem(["<%s>" % aKey, aVal])
|
newItem = QTreeWidgetItem(["<%s>" % aKey, aVal])
|
||||||
self.listBox.addTopLevelItem(newItem)
|
self.listBox.addTopLevelItem(newItem)
|
||||||
|
|
||||||
@@ -604,10 +604,10 @@ class GuiProjectEditReplace(QWidget):
|
|||||||
# List Controls
|
# List Controls
|
||||||
# =============
|
# =============
|
||||||
|
|
||||||
self.addButton = QPushButton(CONFIG.theme.getIcon("add"), "")
|
self.addButton = QPushButton(SHARED.theme.getIcon("add"), "")
|
||||||
self.addButton.clicked.connect(self._addEntry)
|
self.addButton.clicked.connect(self._addEntry)
|
||||||
|
|
||||||
self.delButton = QPushButton(CONFIG.theme.getIcon("remove"), "")
|
self.delButton = QPushButton(SHARED.theme.getIcon("remove"), "")
|
||||||
self.delButton.clicked.connect(self._delEntry)
|
self.delButton.clicked.connect(self._delEntry)
|
||||||
|
|
||||||
# Edit Form
|
# Edit Form
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ from PyQt5.QtWidgets import (
|
|||||||
qApp, QDialog, QHBoxLayout, QVBoxLayout, QDialogButtonBox, QLabel
|
qApp, QDialog, QHBoxLayout, QVBoxLayout, QDialogButtonBox, QLabel
|
||||||
)
|
)
|
||||||
|
|
||||||
from novelwriter import CONFIG, __version__, __date__
|
from novelwriter import CONFIG, SHARED, __version__, __date__
|
||||||
from novelwriter.common import logException
|
from novelwriter.common import logException
|
||||||
from novelwriter.constants import nwConst
|
from novelwriter.constants import nwConst
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ class GuiUpdates(QDialog):
|
|||||||
|
|
||||||
# Left Box
|
# Left Box
|
||||||
self.nwIcon = QLabel()
|
self.nwIcon = QLabel()
|
||||||
self.nwIcon.setPixmap(CONFIG.theme.getPixmap("novelwriter", (nPx, nPx)))
|
self.nwIcon.setPixmap(SHARED.theme.getPixmap("novelwriter", (nPx, nPx)))
|
||||||
|
|
||||||
self.leftBox = QVBoxLayout()
|
self.leftBox = QVBoxLayout()
|
||||||
self.leftBox.addWidget(self.nwIcon)
|
self.leftBox.addWidget(self.nwIcon)
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ from PyQt5.QtWidgets import (
|
|||||||
QLineEdit, QListWidget, QListWidgetItem, QPushButton, QVBoxLayout
|
QLineEdit, QListWidget, QListWidgetItem, QPushButton, QVBoxLayout
|
||||||
)
|
)
|
||||||
|
|
||||||
from novelwriter import CONFIG
|
from novelwriter import CONFIG, SHARED
|
||||||
from novelwriter.enum import nwAlert
|
from novelwriter.enum import nwAlert
|
||||||
from novelwriter.core.spellcheck import UserDictionary
|
from novelwriter.core.spellcheck import UserDictionary
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ class GuiWordList(QDialog):
|
|||||||
mS = CONFIG.pxInt(250)
|
mS = CONFIG.pxInt(250)
|
||||||
wW = CONFIG.pxInt(320)
|
wW = CONFIG.pxInt(320)
|
||||||
wH = CONFIG.pxInt(340)
|
wH = CONFIG.pxInt(340)
|
||||||
pOptions = self.mainGui.project.options
|
pOptions = SHARED.project.options
|
||||||
|
|
||||||
self.setMinimumWidth(mS)
|
self.setMinimumWidth(mS)
|
||||||
self.setMinimumHeight(mS)
|
self.setMinimumHeight(mS)
|
||||||
@@ -77,10 +77,10 @@ class GuiWordList(QDialog):
|
|||||||
|
|
||||||
self.newEntry = QLineEdit()
|
self.newEntry = QLineEdit()
|
||||||
|
|
||||||
self.addButton = QPushButton(CONFIG.theme.getIcon("add"), "")
|
self.addButton = QPushButton(SHARED.theme.getIcon("add"), "")
|
||||||
self.addButton.clicked.connect(self._doAdd)
|
self.addButton.clicked.connect(self._doAdd)
|
||||||
|
|
||||||
self.delButton = QPushButton(CONFIG.theme.getIcon("remove"), "")
|
self.delButton = QPushButton(SHARED.theme.getIcon("remove"), "")
|
||||||
self.delButton.clicked.connect(self._doDelete)
|
self.delButton.clicked.connect(self._doDelete)
|
||||||
|
|
||||||
self.editBox = QHBoxLayout()
|
self.editBox = QHBoxLayout()
|
||||||
@@ -149,7 +149,7 @@ class GuiWordList(QDialog):
|
|||||||
def _doSave(self):
|
def _doSave(self):
|
||||||
"""Save the new word list and close."""
|
"""Save the new word list and close."""
|
||||||
self._saveGuiSettings()
|
self._saveGuiSettings()
|
||||||
userDict = UserDictionary(self.mainGui.project)
|
userDict = UserDictionary(SHARED.project)
|
||||||
for i in range(self.listBox.count()):
|
for i in range(self.listBox.count()):
|
||||||
item = self.listBox.item(i)
|
item = self.listBox.item(i)
|
||||||
if isinstance(item, QListWidgetItem):
|
if isinstance(item, QListWidgetItem):
|
||||||
@@ -172,7 +172,7 @@ class GuiWordList(QDialog):
|
|||||||
|
|
||||||
def _loadWordList(self):
|
def _loadWordList(self):
|
||||||
"""Load the project's word list, if it exists."""
|
"""Load the project's word list, if it exists."""
|
||||||
userDict = UserDictionary(self.mainGui.project)
|
userDict = UserDictionary(SHARED.project)
|
||||||
userDict.load()
|
userDict.load()
|
||||||
self.listBox.clear()
|
self.listBox.clear()
|
||||||
for word in userDict:
|
for word in userDict:
|
||||||
@@ -185,7 +185,7 @@ class GuiWordList(QDialog):
|
|||||||
winWidth = CONFIG.rpxInt(self.width())
|
winWidth = CONFIG.rpxInt(self.width())
|
||||||
winHeight = CONFIG.rpxInt(self.height())
|
winHeight = CONFIG.rpxInt(self.height())
|
||||||
|
|
||||||
pOptions = self.mainGui.project.options
|
pOptions = SHARED.project.options
|
||||||
pOptions.setValue("GuiWordList", "winWidth", winWidth)
|
pOptions.setValue("GuiWordList", "winWidth", winWidth)
|
||||||
pOptions.setValue("GuiWordList", "winHeight", winHeight)
|
pOptions.setValue("GuiWordList", "winHeight", winHeight)
|
||||||
|
|
||||||
|
|||||||
@@ -25,18 +25,13 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
from PyQt5.QtCore import pyqtSignal, pyqtSlot
|
from PyQt5.QtCore import pyqtSignal, pyqtSlot
|
||||||
from PyQt5.QtWidgets import QComboBox, QWidget
|
from PyQt5.QtWidgets import QComboBox, QWidget
|
||||||
|
|
||||||
from novelwriter import CONFIG
|
from novelwriter import SHARED
|
||||||
from novelwriter.enum import nwItemClass
|
from novelwriter.enum import nwItemClass
|
||||||
from novelwriter.constants import nwLabels
|
from novelwriter.constants import nwLabels
|
||||||
|
|
||||||
if TYPE_CHECKING: # pragma: no cover
|
|
||||||
from novelwriter.guimain import GuiMain
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@@ -44,9 +39,8 @@ class NovelSelector(QComboBox):
|
|||||||
|
|
||||||
novelSelectionChanged = pyqtSignal(str)
|
novelSelectionChanged = pyqtSignal(str)
|
||||||
|
|
||||||
def __init__(self, parent: QWidget, mainGui: GuiMain) -> None:
|
def __init__(self, parent: QWidget) -> None:
|
||||||
super().__init__(parent=parent)
|
super().__init__(parent=parent)
|
||||||
self._mainGui = mainGui
|
|
||||||
self._blockSignal = False
|
self._blockSignal = False
|
||||||
self._firstHandle = None
|
self._firstHandle = None
|
||||||
self.currentIndexChanged.connect(self._indexChanged)
|
self.currentIndexChanged.connect(self._indexChanged)
|
||||||
@@ -86,9 +80,9 @@ class NovelSelector(QComboBox):
|
|||||||
self._firstHandle = None
|
self._firstHandle = None
|
||||||
self.clear()
|
self.clear()
|
||||||
|
|
||||||
icon = CONFIG.theme.getIcon(nwLabels.CLASS_ICON[nwItemClass.NOVEL])
|
icon = SHARED.theme.getIcon(nwLabels.CLASS_ICON[nwItemClass.NOVEL])
|
||||||
handle = self.currentData()
|
handle = self.currentData()
|
||||||
for tHandle, nwItem in self._mainGui.project.tree.iterRoots(nwItemClass.NOVEL):
|
for tHandle, nwItem in SHARED.project.tree.iterRoots(nwItemClass.NOVEL):
|
||||||
if prefix:
|
if prefix:
|
||||||
name = prefix.format(nwItem.itemName)
|
name = prefix.format(nwItem.itemName)
|
||||||
self.addItem(name, tHandle)
|
self.addItem(name, tHandle)
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ from PyQt5.QtWidgets import (
|
|||||||
QPushButton, QShortcut, QTextEdit, QToolBar, QToolButton, QWidget
|
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.enum import nwAlert, nwDocAction, nwDocInsert, nwDocMode, nwItemClass
|
||||||
from novelwriter.common import minmax, transferCase
|
from novelwriter.common import minmax, transferCase
|
||||||
from novelwriter.constants import nwConst, nwKeyWords, nwUnicode
|
from novelwriter.constants import nwConst, nwKeyWords, nwUnicode
|
||||||
@@ -132,8 +132,8 @@ class GuiDocEditor(QTextEdit):
|
|||||||
self.docSearch = GuiDocEditSearch(self)
|
self.docSearch = GuiDocEditSearch(self)
|
||||||
|
|
||||||
# Syntax
|
# Syntax
|
||||||
self.spEnchant = NWSpellEnchant(self.mainGui.project)
|
self.spEnchant = NWSpellEnchant(SHARED.project)
|
||||||
self.highLight = GuiDocHighlighter(qDoc, self.mainGui, self.spEnchant)
|
self.highLight = GuiDocHighlighter(qDoc, self.spEnchant)
|
||||||
|
|
||||||
# Context Menu
|
# Context Menu
|
||||||
self.setContextMenuPolicy(Qt.CustomContextMenu)
|
self.setContextMenuPolicy(Qt.CustomContextMenu)
|
||||||
@@ -227,14 +227,14 @@ class GuiDocEditor(QTextEdit):
|
|||||||
"""Update the syntax highlighting theme.
|
"""Update the syntax highlighting theme.
|
||||||
"""
|
"""
|
||||||
mainPalette = self.palette()
|
mainPalette = self.palette()
|
||||||
mainPalette.setColor(QPalette.Window, QColor(*CONFIG.theme.colBack))
|
mainPalette.setColor(QPalette.Window, QColor(*SHARED.theme.colBack))
|
||||||
mainPalette.setColor(QPalette.Base, QColor(*CONFIG.theme.colBack))
|
mainPalette.setColor(QPalette.Base, QColor(*SHARED.theme.colBack))
|
||||||
mainPalette.setColor(QPalette.Text, QColor(*CONFIG.theme.colText))
|
mainPalette.setColor(QPalette.Text, QColor(*SHARED.theme.colText))
|
||||||
self.setPalette(mainPalette)
|
self.setPalette(mainPalette)
|
||||||
|
|
||||||
docPalette = self.viewport().palette()
|
docPalette = self.viewport().palette()
|
||||||
docPalette.setColor(QPalette.Base, QColor(*CONFIG.theme.colBack))
|
docPalette.setColor(QPalette.Base, QColor(*SHARED.theme.colBack))
|
||||||
docPalette.setColor(QPalette.Text, QColor(*CONFIG.theme.colText))
|
docPalette.setColor(QPalette.Text, QColor(*SHARED.theme.colText))
|
||||||
self.viewport().setPalette(docPalette)
|
self.viewport().setPalette(docPalette)
|
||||||
|
|
||||||
self.docHeader.matchColours()
|
self.docHeader.matchColours()
|
||||||
@@ -340,7 +340,7 @@ class GuiDocEditor(QTextEdit):
|
|||||||
document is new (empty string), we set up the editor for editing
|
document is new (empty string), we set up the editor for editing
|
||||||
the file.
|
the file.
|
||||||
"""
|
"""
|
||||||
self._nwDocument = self.mainGui.project.storage.getDocument(tHandle)
|
self._nwDocument = SHARED.project.storage.getDocument(tHandle)
|
||||||
self._nwItem = self._nwDocument.getCurrentItem()
|
self._nwItem = self._nwDocument.getCurrentItem()
|
||||||
|
|
||||||
theDoc = self._nwDocument.readDocument()
|
theDoc = self._nwDocument.readDocument()
|
||||||
@@ -516,10 +516,10 @@ class GuiDocEditor(QTextEdit):
|
|||||||
self.setDocumentChanged(False)
|
self.setDocumentChanged(False)
|
||||||
|
|
||||||
oldHeader = self._nwItem.mainHeading
|
oldHeader = self._nwItem.mainHeading
|
||||||
oldCount = self.mainGui.project.index.getHandleHeaderCount(tHandle)
|
oldCount = SHARED.project.index.getHandleHeaderCount(tHandle)
|
||||||
self.mainGui.project.index.scanText(tHandle, docText)
|
SHARED.project.index.scanText(tHandle, docText)
|
||||||
newHeader = self._nwItem.mainHeading
|
newHeader = self._nwItem.mainHeading
|
||||||
newCount = self.mainGui.project.index.getHandleHeaderCount(tHandle)
|
newCount = SHARED.project.index.getHandleHeaderCount(tHandle)
|
||||||
|
|
||||||
if self._nwItem.itemClass == nwItemClass.NOVEL:
|
if self._nwItem.itemClass == nwItemClass.NOVEL:
|
||||||
if oldCount == newCount:
|
if oldCount == newCount:
|
||||||
@@ -698,10 +698,10 @@ class GuiDocEditor(QTextEdit):
|
|||||||
"""Set the spell checker dictionary language, and emit the
|
"""Set the spell checker dictionary language, and emit the
|
||||||
dictionary changed signal.
|
dictionary changed signal.
|
||||||
"""
|
"""
|
||||||
if self.mainGui.project.data.spellLang is None:
|
if SHARED.project.data.spellLang is None:
|
||||||
theLang = CONFIG.spellLanguage
|
theLang = CONFIG.spellLanguage
|
||||||
else:
|
else:
|
||||||
theLang = self.mainGui.project.data.spellLang
|
theLang = SHARED.project.data.spellLang
|
||||||
|
|
||||||
self.spEnchant.setLanguage(theLang)
|
self.spEnchant.setLanguage(theLang)
|
||||||
_, theProvider = self.spEnchant.describeDict()
|
_, theProvider = self.spEnchant.describeDict()
|
||||||
@@ -734,7 +734,7 @@ class GuiDocEditor(QTextEdit):
|
|||||||
|
|
||||||
self._spellCheck = theMode
|
self._spellCheck = theMode
|
||||||
self.mainGui.mainMenu.setSpellCheck(theMode)
|
self.mainGui.mainMenu.setSpellCheck(theMode)
|
||||||
self.mainGui.project.data.setSpellCheck(theMode)
|
SHARED.project.data.setSpellCheck(theMode)
|
||||||
self.highLight.setSpellCheck(theMode)
|
self.highLight.setSpellCheck(theMode)
|
||||||
if not self._bigDoc or theMode is False:
|
if not self._bigDoc or theMode is False:
|
||||||
# We don't run the spell checker automatically on big docs
|
# We don't run the spell checker automatically on big docs
|
||||||
@@ -1916,7 +1916,7 @@ class GuiDocEditor(QTextEdit):
|
|||||||
|
|
||||||
if theText.startswith("@"):
|
if theText.startswith("@"):
|
||||||
|
|
||||||
isGood, tBits, tPos = self.mainGui.project.index.scanThis(theText)
|
isGood, tBits, tPos = SHARED.project.index.scanThis(theText)
|
||||||
if not isGood:
|
if not isGood:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -2233,9 +2233,9 @@ class GuiDocEditSearch(QFrame):
|
|||||||
self.doMatchCap = CONFIG.searchMatchCap
|
self.doMatchCap = CONFIG.searchMatchCap
|
||||||
|
|
||||||
mPx = CONFIG.pxInt(6)
|
mPx = CONFIG.pxInt(6)
|
||||||
tPx = int(0.8*CONFIG.theme.fontPixelSize)
|
tPx = int(0.8*SHARED.theme.fontPixelSize)
|
||||||
self.boxFont = CONFIG.theme.guiFont
|
self.boxFont = SHARED.theme.guiFont
|
||||||
self.boxFont.setPointSizeF(0.9*CONFIG.theme.fontPointSize)
|
self.boxFont.setPointSizeF(0.9*SHARED.theme.fontPointSize)
|
||||||
|
|
||||||
self.setContentsMargins(0, 0, 0, 0)
|
self.setContentsMargins(0, 0, 0, 0)
|
||||||
self.setAutoFillBackground(True)
|
self.setAutoFillBackground(True)
|
||||||
@@ -2268,7 +2268,7 @@ class GuiDocEditSearch(QFrame):
|
|||||||
|
|
||||||
self.resultLabel = QLabel("?/?")
|
self.resultLabel = QLabel("?/?")
|
||||||
self.resultLabel.setFont(self.boxFont)
|
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 = QAction(self.tr("Case Sensitive"), self)
|
||||||
self.toggleCase.setCheckable(True)
|
self.toggleCase.setCheckable(True)
|
||||||
@@ -2374,15 +2374,15 @@ class GuiDocEditSearch(QFrame):
|
|||||||
self.replaceBox.setPalette(qPalette)
|
self.replaceBox.setPalette(qPalette)
|
||||||
|
|
||||||
# Set icons
|
# Set icons
|
||||||
self.toggleCase.setIcon(CONFIG.theme.getIcon("search_case"))
|
self.toggleCase.setIcon(SHARED.theme.getIcon("search_case"))
|
||||||
self.toggleWord.setIcon(CONFIG.theme.getIcon("search_word"))
|
self.toggleWord.setIcon(SHARED.theme.getIcon("search_word"))
|
||||||
self.toggleRegEx.setIcon(CONFIG.theme.getIcon("search_regex"))
|
self.toggleRegEx.setIcon(SHARED.theme.getIcon("search_regex"))
|
||||||
self.toggleLoop.setIcon(CONFIG.theme.getIcon("search_loop"))
|
self.toggleLoop.setIcon(SHARED.theme.getIcon("search_loop"))
|
||||||
self.toggleProject.setIcon(CONFIG.theme.getIcon("search_project"))
|
self.toggleProject.setIcon(SHARED.theme.getIcon("search_project"))
|
||||||
self.toggleMatchCap.setIcon(CONFIG.theme.getIcon("search_preserve"))
|
self.toggleMatchCap.setIcon(SHARED.theme.getIcon("search_preserve"))
|
||||||
self.cancelSearch.setIcon(CONFIG.theme.getIcon("search_cancel"))
|
self.cancelSearch.setIcon(SHARED.theme.getIcon("search_cancel"))
|
||||||
self.searchButton.setIcon(CONFIG.theme.getIcon("search"))
|
self.searchButton.setIcon(SHARED.theme.getIcon("search"))
|
||||||
self.replaceButton.setIcon(CONFIG.theme.getIcon("search_replace"))
|
self.replaceButton.setIcon(SHARED.theme.getIcon("search_replace"))
|
||||||
|
|
||||||
# Set stylesheets
|
# Set stylesheets
|
||||||
self.searchOpt.setStyleSheet("QToolBar {padding: 0;}")
|
self.searchOpt.setStyleSheet("QToolBar {padding: 0;}")
|
||||||
@@ -2474,7 +2474,7 @@ class GuiDocEditSearch(QFrame):
|
|||||||
"""
|
"""
|
||||||
currRes = "?" if currRes is None else currRes
|
currRes = "?" if currRes is None else currRes
|
||||||
resCount = "?" if resCount is None else "1000+" if resCount > 1000 else resCount
|
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.setText(f"{currRes}/{resCount}")
|
||||||
self.resultLabel.setMinimumWidth(minWidth)
|
self.resultLabel.setMinimumWidth(minWidth)
|
||||||
self.adjustSize()
|
self.adjustSize()
|
||||||
@@ -2639,7 +2639,7 @@ class GuiDocEditHeader(QWidget):
|
|||||||
|
|
||||||
self._docHandle = None
|
self._docHandle = None
|
||||||
|
|
||||||
fPx = int(0.9*CONFIG.theme.fontPixelSize)
|
fPx = int(0.9*SHARED.theme.fontPixelSize)
|
||||||
hSp = CONFIG.pxInt(6)
|
hSp = CONFIG.pxInt(6)
|
||||||
|
|
||||||
# Main Widget Settings
|
# Main Widget Settings
|
||||||
@@ -2656,7 +2656,7 @@ class GuiDocEditHeader(QWidget):
|
|||||||
self.theTitle.setFixedHeight(fPx)
|
self.theTitle.setFixedHeight(fPx)
|
||||||
|
|
||||||
lblFont = self.theTitle.font()
|
lblFont = self.theTitle.font()
|
||||||
lblFont.setPointSizeF(0.9*CONFIG.theme.fontPointSize)
|
lblFont.setPointSizeF(0.9*SHARED.theme.fontPointSize)
|
||||||
self.theTitle.setFont(lblFont)
|
self.theTitle.setFont(lblFont)
|
||||||
|
|
||||||
# Buttons
|
# Buttons
|
||||||
@@ -2726,15 +2726,15 @@ class GuiDocEditHeader(QWidget):
|
|||||||
def updateTheme(self):
|
def updateTheme(self):
|
||||||
"""Update theme elements.
|
"""Update theme elements.
|
||||||
"""
|
"""
|
||||||
self.editButton.setIcon(CONFIG.theme.getIcon("edit"))
|
self.editButton.setIcon(SHARED.theme.getIcon("edit"))
|
||||||
self.searchButton.setIcon(CONFIG.theme.getIcon("search"))
|
self.searchButton.setIcon(SHARED.theme.getIcon("search"))
|
||||||
self.minmaxButton.setIcon(CONFIG.theme.getIcon("maximise"))
|
self.minmaxButton.setIcon(SHARED.theme.getIcon("maximise"))
|
||||||
self.closeButton.setIcon(CONFIG.theme.getIcon("close"))
|
self.closeButton.setIcon(SHARED.theme.getIcon("close"))
|
||||||
|
|
||||||
buttonStyle = (
|
buttonStyle = (
|
||||||
"QToolButton {{border: none; background: transparent;}} "
|
"QToolButton {{border: none; background: transparent;}} "
|
||||||
"QToolButton:hover {{border: none; background: rgba({0},{1},{2},0.2);}}"
|
"QToolButton:hover {{border: none; background: rgba({0},{1},{2},0.2);}}"
|
||||||
).format(*CONFIG.theme.colText)
|
).format(*SHARED.theme.colText)
|
||||||
|
|
||||||
self.editButton.setStyleSheet(buttonStyle)
|
self.editButton.setStyleSheet(buttonStyle)
|
||||||
self.searchButton.setStyleSheet(buttonStyle)
|
self.searchButton.setStyleSheet(buttonStyle)
|
||||||
@@ -2750,9 +2750,9 @@ class GuiDocEditHeader(QWidget):
|
|||||||
theme rather than the main GUI.
|
theme rather than the main GUI.
|
||||||
"""
|
"""
|
||||||
thePalette = QPalette()
|
thePalette = QPalette()
|
||||||
thePalette.setColor(QPalette.Window, QColor(*CONFIG.theme.colBack))
|
thePalette.setColor(QPalette.Window, QColor(*SHARED.theme.colBack))
|
||||||
thePalette.setColor(QPalette.WindowText, QColor(*CONFIG.theme.colText))
|
thePalette.setColor(QPalette.WindowText, QColor(*SHARED.theme.colText))
|
||||||
thePalette.setColor(QPalette.Text, QColor(*CONFIG.theme.colText))
|
thePalette.setColor(QPalette.Text, QColor(*SHARED.theme.colText))
|
||||||
|
|
||||||
self.setPalette(thePalette)
|
self.setPalette(thePalette)
|
||||||
self.theTitle.setPalette(thePalette)
|
self.theTitle.setPalette(thePalette)
|
||||||
@@ -2772,7 +2772,7 @@ class GuiDocEditHeader(QWidget):
|
|||||||
self.minmaxButton.setVisible(False)
|
self.minmaxButton.setVisible(False)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
pTree = self.mainGui.project.tree
|
pTree = SHARED.project.tree
|
||||||
if CONFIG.showFullPath:
|
if CONFIG.showFullPath:
|
||||||
tTitle = []
|
tTitle = []
|
||||||
tTree = pTree.getItemPath(tHandle)
|
tTree = pTree.getItemPath(tHandle)
|
||||||
@@ -2801,9 +2801,9 @@ class GuiDocEditHeader(QWidget):
|
|||||||
toggleFocusMode function and should not be activated directly.
|
toggleFocusMode function and should not be activated directly.
|
||||||
"""
|
"""
|
||||||
if self.mainGui.isFocusMode:
|
if self.mainGui.isFocusMode:
|
||||||
self.minmaxButton.setIcon(CONFIG.theme.getIcon("minimise"))
|
self.minmaxButton.setIcon(SHARED.theme.getIcon("minimise"))
|
||||||
else:
|
else:
|
||||||
self.minmaxButton.setIcon(CONFIG.theme.getIcon("maximise"))
|
self.minmaxButton.setIcon(SHARED.theme.getIcon("maximise"))
|
||||||
return
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
@@ -2876,13 +2876,13 @@ class GuiDocEditFooter(QWidget):
|
|||||||
|
|
||||||
self._docSelection = False
|
self._docSelection = False
|
||||||
|
|
||||||
self.sPx = int(round(0.9*CONFIG.theme.baseIconSize))
|
self.sPx = int(round(0.9*SHARED.theme.baseIconSize))
|
||||||
fPx = int(0.9*CONFIG.theme.fontPixelSize)
|
fPx = int(0.9*SHARED.theme.fontPixelSize)
|
||||||
bSp = CONFIG.pxInt(4)
|
bSp = CONFIG.pxInt(4)
|
||||||
hSp = CONFIG.pxInt(6)
|
hSp = CONFIG.pxInt(6)
|
||||||
|
|
||||||
lblFont = self.font()
|
lblFont = self.font()
|
||||||
lblFont.setPointSizeF(0.9*CONFIG.theme.fontPointSize)
|
lblFont.setPointSizeF(0.9*SHARED.theme.fontPointSize)
|
||||||
|
|
||||||
# Main Widget Settings
|
# Main Widget Settings
|
||||||
self.setContentsMargins(0, 0, 0, 0)
|
self.setContentsMargins(0, 0, 0, 0)
|
||||||
@@ -2969,8 +2969,8 @@ class GuiDocEditFooter(QWidget):
|
|||||||
def updateTheme(self):
|
def updateTheme(self):
|
||||||
"""Update theme elements.
|
"""Update theme elements.
|
||||||
"""
|
"""
|
||||||
self.linesIcon.setPixmap(CONFIG.theme.getPixmap("status_lines", (self.sPx, self.sPx)))
|
self.linesIcon.setPixmap(SHARED.theme.getPixmap("status_lines", (self.sPx, self.sPx)))
|
||||||
self.wordsIcon.setPixmap(CONFIG.theme.getPixmap("status_stats", (self.sPx, self.sPx)))
|
self.wordsIcon.setPixmap(SHARED.theme.getPixmap("status_stats", (self.sPx, self.sPx)))
|
||||||
|
|
||||||
self.matchColours()
|
self.matchColours()
|
||||||
|
|
||||||
@@ -2981,9 +2981,9 @@ class GuiDocEditFooter(QWidget):
|
|||||||
theme rather than the main GUI.
|
theme rather than the main GUI.
|
||||||
"""
|
"""
|
||||||
thePalette = QPalette()
|
thePalette = QPalette()
|
||||||
thePalette.setColor(QPalette.Window, QColor(*CONFIG.theme.colBack))
|
thePalette.setColor(QPalette.Window, QColor(*SHARED.theme.colBack))
|
||||||
thePalette.setColor(QPalette.WindowText, QColor(*CONFIG.theme.colText))
|
thePalette.setColor(QPalette.WindowText, QColor(*SHARED.theme.colText))
|
||||||
thePalette.setColor(QPalette.Text, QColor(*CONFIG.theme.colText))
|
thePalette.setColor(QPalette.Text, QColor(*SHARED.theme.colText))
|
||||||
|
|
||||||
self.setPalette(thePalette)
|
self.setPalette(thePalette)
|
||||||
self.statusText.setPalette(thePalette)
|
self.statusText.setPalette(thePalette)
|
||||||
@@ -3000,7 +3000,7 @@ class GuiDocEditFooter(QWidget):
|
|||||||
logger.debug("No handle set, so clearing the editor footer")
|
logger.debug("No handle set, so clearing the editor footer")
|
||||||
self._theItem = None
|
self._theItem = None
|
||||||
else:
|
else:
|
||||||
self._theItem = self.mainGui.project.tree[self._docHandle]
|
self._theItem = SHARED.project.tree[self._docHandle]
|
||||||
|
|
||||||
self.setHasSelection(False)
|
self.setHasSelection(False)
|
||||||
self.updateInfo()
|
self.updateInfo()
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ from PyQt5.QtGui import (
|
|||||||
QColor, QTextCharFormat, QFont, QSyntaxHighlighter, QBrush
|
QColor, QTextCharFormat, QFont, QSyntaxHighlighter, QBrush
|
||||||
)
|
)
|
||||||
|
|
||||||
from novelwriter import CONFIG
|
from novelwriter import CONFIG, SHARED
|
||||||
from novelwriter.common import checkInt
|
from novelwriter.common import checkInt
|
||||||
from novelwriter.constants import nwRegEx, nwUnicode
|
from novelwriter.constants import nwRegEx, nwUnicode
|
||||||
|
|
||||||
@@ -46,14 +46,13 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
|||||||
BLOCK_META = 2
|
BLOCK_META = 2
|
||||||
BLOCK_TITLE = 4
|
BLOCK_TITLE = 4
|
||||||
|
|
||||||
def __init__(self, theDoc, mainGui, spEnchant):
|
def __init__(self, theDoc, spEnchant):
|
||||||
super().__init__(theDoc)
|
super().__init__(theDoc)
|
||||||
|
|
||||||
logger.debug("Create: GuiDocHighlighter")
|
logger.debug("Create: GuiDocHighlighter")
|
||||||
|
|
||||||
self.theDoc = theDoc
|
self.theDoc = theDoc
|
||||||
self.spEnchant = spEnchant
|
self.spEnchant = spEnchant
|
||||||
self.mainGui = mainGui
|
|
||||||
self.theHandle = None
|
self.theHandle = None
|
||||||
self.spellCheck = False
|
self.spellCheck = False
|
||||||
self.spellRx = None
|
self.spellRx = None
|
||||||
@@ -85,24 +84,24 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
|||||||
"""
|
"""
|
||||||
logger.debug("Setting up highlighting rules")
|
logger.debug("Setting up highlighting rules")
|
||||||
|
|
||||||
self.colHead = QColor(*CONFIG.theme.colHead)
|
self.colHead = QColor(*SHARED.theme.colHead)
|
||||||
self.colHeadH = QColor(*CONFIG.theme.colHeadH)
|
self.colHeadH = QColor(*SHARED.theme.colHeadH)
|
||||||
self.colDialN = QColor(*CONFIG.theme.colDialN)
|
self.colDialN = QColor(*SHARED.theme.colDialN)
|
||||||
self.colDialD = QColor(*CONFIG.theme.colDialD)
|
self.colDialD = QColor(*SHARED.theme.colDialD)
|
||||||
self.colDialS = QColor(*CONFIG.theme.colDialS)
|
self.colDialS = QColor(*SHARED.theme.colDialS)
|
||||||
self.colHidden = QColor(*CONFIG.theme.colHidden)
|
self.colHidden = QColor(*SHARED.theme.colHidden)
|
||||||
self.colKey = QColor(*CONFIG.theme.colKey)
|
self.colKey = QColor(*SHARED.theme.colKey)
|
||||||
self.colVal = QColor(*CONFIG.theme.colVal)
|
self.colVal = QColor(*SHARED.theme.colVal)
|
||||||
self.colSpell = QColor(*CONFIG.theme.colSpell)
|
self.colSpell = QColor(*SHARED.theme.colSpell)
|
||||||
self.colError = QColor(*CONFIG.theme.colError)
|
self.colError = QColor(*SHARED.theme.colError)
|
||||||
self.colRepTag = QColor(*CONFIG.theme.colRepTag)
|
self.colRepTag = QColor(*SHARED.theme.colRepTag)
|
||||||
self.colMod = QColor(*CONFIG.theme.colMod)
|
self.colMod = QColor(*SHARED.theme.colMod)
|
||||||
self.colBreak = QColor(*CONFIG.theme.colEmph)
|
self.colBreak = QColor(*SHARED.theme.colEmph)
|
||||||
self.colBreak.setAlpha(64)
|
self.colBreak.setAlpha(64)
|
||||||
|
|
||||||
self.colEmph = None
|
self.colEmph = None
|
||||||
if CONFIG.highlightEmph:
|
if CONFIG.highlightEmph:
|
||||||
self.colEmph = QColor(*CONFIG.theme.colEmph)
|
self.colEmph = QColor(*SHARED.theme.colEmph)
|
||||||
|
|
||||||
self.hStyles = {
|
self.hStyles = {
|
||||||
"header1": self._makeFormat(self.colHead, "bold", 1.8),
|
"header1": self._makeFormat(self.colHead, "bold", 1.8),
|
||||||
@@ -285,8 +284,8 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
|||||||
|
|
||||||
if theText.startswith("@"): # Keywords and commands
|
if theText.startswith("@"): # Keywords and commands
|
||||||
self.setCurrentBlockState(self.BLOCK_META)
|
self.setCurrentBlockState(self.BLOCK_META)
|
||||||
pIndex = self.mainGui.project.index
|
pIndex = SHARED.project.index
|
||||||
tItem = self.mainGui.project.tree[self.theHandle]
|
tItem = SHARED.project.tree[self.theHandle]
|
||||||
isValid, theBits, thePos = pIndex.scanThis(theText)
|
isValid, theBits, thePos = pIndex.scanThis(theText)
|
||||||
isGood = pIndex.checkThese(theBits, tItem)
|
isGood = pIndex.checkThese(theBits, tItem)
|
||||||
if isValid:
|
if isValid:
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ from PyQt5.QtWidgets import (
|
|||||||
QAction, QMenu, QFrame
|
QAction, QMenu, QFrame
|
||||||
)
|
)
|
||||||
|
|
||||||
from novelwriter import CONFIG
|
from novelwriter import CONFIG, SHARED
|
||||||
from novelwriter.enum import nwItemType, nwDocAction, nwDocMode
|
from novelwriter.enum import nwItemType, nwDocAction, nwDocMode
|
||||||
from novelwriter.error import logException
|
from novelwriter.error import logException
|
||||||
from novelwriter.constants import nwUnicode
|
from novelwriter.constants import nwUnicode
|
||||||
@@ -119,14 +119,14 @@ class GuiDocViewer(QTextBrowser):
|
|||||||
|
|
||||||
# Set the widget colours to match syntax theme
|
# Set the widget colours to match syntax theme
|
||||||
mainPalette = self.palette()
|
mainPalette = self.palette()
|
||||||
mainPalette.setColor(QPalette.Window, QColor(*CONFIG.theme.colBack))
|
mainPalette.setColor(QPalette.Window, QColor(*SHARED.theme.colBack))
|
||||||
mainPalette.setColor(QPalette.Base, QColor(*CONFIG.theme.colBack))
|
mainPalette.setColor(QPalette.Base, QColor(*SHARED.theme.colBack))
|
||||||
mainPalette.setColor(QPalette.Text, QColor(*CONFIG.theme.colText))
|
mainPalette.setColor(QPalette.Text, QColor(*SHARED.theme.colText))
|
||||||
self.setPalette(mainPalette)
|
self.setPalette(mainPalette)
|
||||||
|
|
||||||
docPalette = self.viewport().palette()
|
docPalette = self.viewport().palette()
|
||||||
docPalette.setColor(QPalette.Base, QColor(*CONFIG.theme.colBack))
|
docPalette.setColor(QPalette.Base, QColor(*SHARED.theme.colBack))
|
||||||
docPalette.setColor(QPalette.Text, QColor(*CONFIG.theme.colText))
|
docPalette.setColor(QPalette.Text, QColor(*SHARED.theme.colText))
|
||||||
self.viewport().setPalette(docPalette)
|
self.viewport().setPalette(docPalette)
|
||||||
|
|
||||||
self.docHeader.matchColours()
|
self.docHeader.matchColours()
|
||||||
@@ -162,7 +162,7 @@ class GuiDocViewer(QTextBrowser):
|
|||||||
def loadText(self, tHandle, updateHistory=True):
|
def loadText(self, tHandle, updateHistory=True):
|
||||||
"""Load text into the viewer from an item handle.
|
"""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")
|
logger.warning("Item not found")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -170,7 +170,7 @@ class GuiDocViewer(QTextBrowser):
|
|||||||
qApp.setOverrideCursor(QCursor(Qt.WaitCursor))
|
qApp.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||||
|
|
||||||
sPos = self.verticalScrollBar().value()
|
sPos = self.verticalScrollBar().value()
|
||||||
aDoc = ToHtml(self.mainGui.project)
|
aDoc = ToHtml(SHARED.project)
|
||||||
aDoc.setPreview(CONFIG.viewComments, CONFIG.viewSynopsis)
|
aDoc.setPreview(CONFIG.viewComments, CONFIG.viewSynopsis)
|
||||||
aDoc.setLinkHeaders(True)
|
aDoc.setLinkHeaders(True)
|
||||||
|
|
||||||
@@ -210,7 +210,7 @@ class GuiDocViewer(QTextBrowser):
|
|||||||
self.verticalScrollBar().setValue(sPos)
|
self.verticalScrollBar().setValue(sPos)
|
||||||
|
|
||||||
self._docHandle = tHandle
|
self._docHandle = tHandle
|
||||||
self.mainGui.project.data.setLastHandle(tHandle, "viewer")
|
SHARED.project.data.setLastHandle(tHandle, "viewer")
|
||||||
self.docHeader.setTitleFromHandle(self._docHandle)
|
self.docHeader.setTitleFromHandle(self._docHandle)
|
||||||
self.updateDocMargins()
|
self.updateDocMargins()
|
||||||
|
|
||||||
@@ -506,27 +506,27 @@ class GuiDocViewer(QTextBrowser):
|
|||||||
" text-align: center;"
|
" text-align: center;"
|
||||||
"}}\n"
|
"}}\n"
|
||||||
).format(
|
).format(
|
||||||
tColR=CONFIG.theme.colText[0],
|
tColR=SHARED.theme.colText[0],
|
||||||
tColG=CONFIG.theme.colText[1],
|
tColG=SHARED.theme.colText[1],
|
||||||
tColB=CONFIG.theme.colText[2],
|
tColB=SHARED.theme.colText[2],
|
||||||
hColR=CONFIG.theme.colHead[0],
|
hColR=SHARED.theme.colHead[0],
|
||||||
hColG=CONFIG.theme.colHead[1],
|
hColG=SHARED.theme.colHead[1],
|
||||||
hColB=CONFIG.theme.colHead[2],
|
hColB=SHARED.theme.colHead[2],
|
||||||
aColR=CONFIG.theme.colVal[0],
|
aColR=SHARED.theme.colVal[0],
|
||||||
aColG=CONFIG.theme.colVal[1],
|
aColG=SHARED.theme.colVal[1],
|
||||||
aColB=CONFIG.theme.colVal[2],
|
aColB=SHARED.theme.colVal[2],
|
||||||
eColR=CONFIG.theme.colEmph[0],
|
eColR=SHARED.theme.colEmph[0],
|
||||||
eColG=CONFIG.theme.colEmph[1],
|
eColG=SHARED.theme.colEmph[1],
|
||||||
eColB=CONFIG.theme.colEmph[2],
|
eColB=SHARED.theme.colEmph[2],
|
||||||
kColR=CONFIG.theme.colKey[0],
|
kColR=SHARED.theme.colKey[0],
|
||||||
kColG=CONFIG.theme.colKey[1],
|
kColG=SHARED.theme.colKey[1],
|
||||||
kColB=CONFIG.theme.colKey[2],
|
kColB=SHARED.theme.colKey[2],
|
||||||
cColR=CONFIG.theme.colHidden[0],
|
cColR=SHARED.theme.colHidden[0],
|
||||||
cColG=CONFIG.theme.colHidden[1],
|
cColG=SHARED.theme.colHidden[1],
|
||||||
cColB=CONFIG.theme.colHidden[2],
|
cColB=SHARED.theme.colHidden[2],
|
||||||
mColR=CONFIG.theme.colMod[0],
|
mColR=SHARED.theme.colMod[0],
|
||||||
mColG=CONFIG.theme.colMod[1],
|
mColG=SHARED.theme.colMod[1],
|
||||||
mColB=CONFIG.theme.colMod[2],
|
mColB=SHARED.theme.colMod[2],
|
||||||
)
|
)
|
||||||
self.document().setDefaultStyleSheet(styleSheet)
|
self.document().setDefaultStyleSheet(styleSheet)
|
||||||
|
|
||||||
@@ -685,7 +685,7 @@ class GuiDocViewHeader(QWidget):
|
|||||||
# Internal Variables
|
# Internal Variables
|
||||||
self._docHandle = None
|
self._docHandle = None
|
||||||
|
|
||||||
fPx = int(0.9*CONFIG.theme.fontPixelSize)
|
fPx = int(0.9*SHARED.theme.fontPixelSize)
|
||||||
hSp = CONFIG.pxInt(6)
|
hSp = CONFIG.pxInt(6)
|
||||||
|
|
||||||
# Main Widget Settings
|
# Main Widget Settings
|
||||||
@@ -702,7 +702,7 @@ class GuiDocViewHeader(QWidget):
|
|||||||
self.theTitle.setFixedHeight(fPx)
|
self.theTitle.setFixedHeight(fPx)
|
||||||
|
|
||||||
lblFont = self.theTitle.font()
|
lblFont = self.theTitle.font()
|
||||||
lblFont.setPointSizeF(0.9*CONFIG.theme.fontPointSize)
|
lblFont.setPointSizeF(0.9*SHARED.theme.fontPointSize)
|
||||||
self.theTitle.setFont(lblFont)
|
self.theTitle.setFont(lblFont)
|
||||||
|
|
||||||
# Buttons
|
# Buttons
|
||||||
@@ -773,15 +773,15 @@ class GuiDocViewHeader(QWidget):
|
|||||||
def updateTheme(self):
|
def updateTheme(self):
|
||||||
"""Update theme elements.
|
"""Update theme elements.
|
||||||
"""
|
"""
|
||||||
self.backButton.setIcon(CONFIG.theme.getIcon("backward"))
|
self.backButton.setIcon(SHARED.theme.getIcon("backward"))
|
||||||
self.forwardButton.setIcon(CONFIG.theme.getIcon("forward"))
|
self.forwardButton.setIcon(SHARED.theme.getIcon("forward"))
|
||||||
self.refreshButton.setIcon(CONFIG.theme.getIcon("refresh"))
|
self.refreshButton.setIcon(SHARED.theme.getIcon("refresh"))
|
||||||
self.closeButton.setIcon(CONFIG.theme.getIcon("close"))
|
self.closeButton.setIcon(SHARED.theme.getIcon("close"))
|
||||||
|
|
||||||
buttonStyle = (
|
buttonStyle = (
|
||||||
"QToolButton {{border: none; background: transparent;}} "
|
"QToolButton {{border: none; background: transparent;}} "
|
||||||
"QToolButton:hover {{border: none; background: rgba({0},{1},{2},0.2);}}"
|
"QToolButton:hover {{border: none; background: rgba({0},{1},{2},0.2);}}"
|
||||||
).format(*CONFIG.theme.colText)
|
).format(*SHARED.theme.colText)
|
||||||
|
|
||||||
self.backButton.setStyleSheet(buttonStyle)
|
self.backButton.setStyleSheet(buttonStyle)
|
||||||
self.forwardButton.setStyleSheet(buttonStyle)
|
self.forwardButton.setStyleSheet(buttonStyle)
|
||||||
@@ -797,9 +797,9 @@ class GuiDocViewHeader(QWidget):
|
|||||||
theme rather than the main GUI.
|
theme rather than the main GUI.
|
||||||
"""
|
"""
|
||||||
thePalette = QPalette()
|
thePalette = QPalette()
|
||||||
thePalette.setColor(QPalette.Window, QColor(*CONFIG.theme.colBack))
|
thePalette.setColor(QPalette.Window, QColor(*SHARED.theme.colBack))
|
||||||
thePalette.setColor(QPalette.WindowText, QColor(*CONFIG.theme.colText))
|
thePalette.setColor(QPalette.WindowText, QColor(*SHARED.theme.colText))
|
||||||
thePalette.setColor(QPalette.Text, QColor(*CONFIG.theme.colText))
|
thePalette.setColor(QPalette.Text, QColor(*SHARED.theme.colText))
|
||||||
|
|
||||||
self.setPalette(thePalette)
|
self.setPalette(thePalette)
|
||||||
self.theTitle.setPalette(thePalette)
|
self.theTitle.setPalette(thePalette)
|
||||||
@@ -819,7 +819,7 @@ class GuiDocViewHeader(QWidget):
|
|||||||
self.refreshButton.setVisible(False)
|
self.refreshButton.setVisible(False)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
pTree = self.mainGui.project.tree
|
pTree = SHARED.project.tree
|
||||||
if CONFIG.showFullPath:
|
if CONFIG.showFullPath:
|
||||||
tTitle = []
|
tTitle = []
|
||||||
tTree = pTree.getItemPath(tHandle)
|
tTree = pTree.getItemPath(tHandle)
|
||||||
@@ -902,7 +902,7 @@ class GuiDocViewFooter(QWidget):
|
|||||||
# Internal Variables
|
# Internal Variables
|
||||||
self._docHandle = None
|
self._docHandle = None
|
||||||
|
|
||||||
fPx = int(0.9*CONFIG.theme.fontPixelSize)
|
fPx = int(0.9*SHARED.theme.fontPixelSize)
|
||||||
bSp = CONFIG.pxInt(2)
|
bSp = CONFIG.pxInt(2)
|
||||||
hSp = CONFIG.pxInt(8)
|
hSp = CONFIG.pxInt(8)
|
||||||
|
|
||||||
@@ -987,7 +987,7 @@ class GuiDocViewFooter(QWidget):
|
|||||||
self.lblSynopsis.setAlignment(Qt.AlignLeft | Qt.AlignTop)
|
self.lblSynopsis.setAlignment(Qt.AlignLeft | Qt.AlignTop)
|
||||||
|
|
||||||
lblFont = self.font()
|
lblFont = self.font()
|
||||||
lblFont.setPointSizeF(0.9*CONFIG.theme.fontPointSize)
|
lblFont.setPointSizeF(0.9*SHARED.theme.fontPointSize)
|
||||||
self.lblRefs.setFont(lblFont)
|
self.lblRefs.setFont(lblFont)
|
||||||
self.lblSticky.setFont(lblFont)
|
self.lblSticky.setFont(lblFont)
|
||||||
self.lblComments.setFont(lblFont)
|
self.lblComments.setFont(lblFont)
|
||||||
@@ -1032,21 +1032,21 @@ class GuiDocViewFooter(QWidget):
|
|||||||
"""
|
"""
|
||||||
# Icons
|
# Icons
|
||||||
|
|
||||||
fPx = int(0.9*CONFIG.theme.fontPixelSize)
|
fPx = int(0.9*SHARED.theme.fontPixelSize)
|
||||||
|
|
||||||
stickyOn = CONFIG.theme.getPixmap("sticky-on", (fPx, fPx))
|
stickyOn = SHARED.theme.getPixmap("sticky-on", (fPx, fPx))
|
||||||
stickyOff = CONFIG.theme.getPixmap("sticky-off", (fPx, fPx))
|
stickyOff = SHARED.theme.getPixmap("sticky-off", (fPx, fPx))
|
||||||
stickyIcon = QIcon()
|
stickyIcon = QIcon()
|
||||||
stickyIcon.addPixmap(stickyOn, QIcon.Normal, QIcon.On)
|
stickyIcon.addPixmap(stickyOn, QIcon.Normal, QIcon.On)
|
||||||
stickyIcon.addPixmap(stickyOff, QIcon.Normal, QIcon.Off)
|
stickyIcon.addPixmap(stickyOff, QIcon.Normal, QIcon.Off)
|
||||||
|
|
||||||
bulletOn = CONFIG.theme.getPixmap("bullet-on", (fPx, fPx))
|
bulletOn = SHARED.theme.getPixmap("bullet-on", (fPx, fPx))
|
||||||
bulletOff = CONFIG.theme.getPixmap("bullet-off", (fPx, fPx))
|
bulletOff = SHARED.theme.getPixmap("bullet-off", (fPx, fPx))
|
||||||
bulletIcon = QIcon()
|
bulletIcon = QIcon()
|
||||||
bulletIcon.addPixmap(bulletOn, QIcon.Normal, QIcon.On)
|
bulletIcon.addPixmap(bulletOn, QIcon.Normal, QIcon.On)
|
||||||
bulletIcon.addPixmap(bulletOff, QIcon.Normal, QIcon.Off)
|
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.stickyRefs.setIcon(stickyIcon)
|
||||||
self.showComments.setIcon(bulletIcon)
|
self.showComments.setIcon(bulletIcon)
|
||||||
self.showSynopsis.setIcon(bulletIcon)
|
self.showSynopsis.setIcon(bulletIcon)
|
||||||
@@ -1056,7 +1056,7 @@ class GuiDocViewFooter(QWidget):
|
|||||||
buttonStyle = (
|
buttonStyle = (
|
||||||
"QToolButton {{border: none; background: transparent;}} "
|
"QToolButton {{border: none; background: transparent;}} "
|
||||||
"QToolButton:hover {{border: none; background: rgba({0},{1},{2},0.2);}}"
|
"QToolButton:hover {{border: none; background: rgba({0},{1},{2},0.2);}}"
|
||||||
).format(*CONFIG.theme.colText)
|
).format(*SHARED.theme.colText)
|
||||||
|
|
||||||
self.showHide.setStyleSheet(buttonStyle)
|
self.showHide.setStyleSheet(buttonStyle)
|
||||||
self.stickyRefs.setStyleSheet(buttonStyle)
|
self.stickyRefs.setStyleSheet(buttonStyle)
|
||||||
@@ -1072,9 +1072,9 @@ class GuiDocViewFooter(QWidget):
|
|||||||
theme rather than the main GUI.
|
theme rather than the main GUI.
|
||||||
"""
|
"""
|
||||||
thePalette = QPalette()
|
thePalette = QPalette()
|
||||||
thePalette.setColor(QPalette.Window, QColor(*CONFIG.theme.colBack))
|
thePalette.setColor(QPalette.Window, QColor(*SHARED.theme.colBack))
|
||||||
thePalette.setColor(QPalette.WindowText, QColor(*CONFIG.theme.colText))
|
thePalette.setColor(QPalette.WindowText, QColor(*SHARED.theme.colText))
|
||||||
thePalette.setColor(QPalette.Text, QColor(*CONFIG.theme.colText))
|
thePalette.setColor(QPalette.Text, QColor(*SHARED.theme.colText))
|
||||||
|
|
||||||
self.setPalette(thePalette)
|
self.setPalette(thePalette)
|
||||||
self.lblRefs.setPalette(thePalette)
|
self.lblRefs.setPalette(thePalette)
|
||||||
@@ -1145,7 +1145,7 @@ class GuiDocViewDetails(QScrollArea):
|
|||||||
self.refList.setScaledContents(True)
|
self.refList.setScaledContents(True)
|
||||||
self.refList.linkActivated.connect(self._linkClicked)
|
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
|
# Assemble
|
||||||
self.outerWidget = QWidget()
|
self.outerWidget = QWidget()
|
||||||
@@ -1172,10 +1172,10 @@ class GuiDocViewDetails(QScrollArea):
|
|||||||
if self.mainGui.docViewer.stickyRef:
|
if self.mainGui.docViewer.stickyRef:
|
||||||
return
|
return
|
||||||
|
|
||||||
theRefs = self.mainGui.project.index.getBackReferenceList(tHandle)
|
theRefs = SHARED.project.index.getBackReferenceList(tHandle)
|
||||||
theList = []
|
theList = []
|
||||||
for tHandle in theRefs:
|
for tHandle in theRefs:
|
||||||
tItem = self.mainGui.project.tree[tHandle]
|
tItem = SHARED.project.tree[tHandle]
|
||||||
if tItem is not None:
|
if tItem is not None:
|
||||||
theList.append("<a href='%s#%s' %s>%s</a>" % (
|
theList.append("<a href='%s#%s' %s>%s</a>" % (
|
||||||
tHandle, theRefs[tHandle], self.linkStyle, tItem.itemName
|
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.QtGui import QFont, QPixmap
|
||||||
from PyQt5.QtWidgets import QWidget, QGridLayout, QLabel
|
from PyQt5.QtWidgets import QWidget, QGridLayout, QLabel
|
||||||
|
|
||||||
from novelwriter import CONFIG
|
from novelwriter import CONFIG, SHARED
|
||||||
from novelwriter.constants import trConst, nwLabels
|
from novelwriter.constants import trConst, nwLabels
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -42,8 +42,6 @@ class GuiItemDetails(QWidget):
|
|||||||
|
|
||||||
logger.debug("Create: GuiItemDetails")
|
logger.debug("Create: GuiItemDetails")
|
||||||
|
|
||||||
self.mainGui = mainGui
|
|
||||||
|
|
||||||
# Internal Variables
|
# Internal Variables
|
||||||
self._itemHandle = None
|
self._itemHandle = None
|
||||||
|
|
||||||
@@ -51,7 +49,7 @@ class GuiItemDetails(QWidget):
|
|||||||
hSp = CONFIG.pxInt(6)
|
hSp = CONFIG.pxInt(6)
|
||||||
vSp = CONFIG.pxInt(1)
|
vSp = CONFIG.pxInt(1)
|
||||||
mPx = CONFIG.pxInt(6)
|
mPx = CONFIG.pxInt(6)
|
||||||
fPt = CONFIG.theme.fontPointSize
|
fPt = SHARED.theme.fontPointSize
|
||||||
|
|
||||||
fntLabel = QFont()
|
fntLabel = QFont()
|
||||||
fntLabel.setBold(True)
|
fntLabel.setBold(True)
|
||||||
@@ -176,8 +174,8 @@ class GuiItemDetails(QWidget):
|
|||||||
self.updateTheme()
|
self.updateTheme()
|
||||||
|
|
||||||
# Make sure the columns for flags and counts don't resize too often
|
# Make sure the columns for flags and counts don't resize too often
|
||||||
flagWidth = CONFIG.theme.getTextWidth("Mm", fntValue)
|
flagWidth = SHARED.theme.getTextWidth("Mm", fntValue)
|
||||||
countWidth = CONFIG.theme.getTextWidth("99,999", fntValue)
|
countWidth = SHARED.theme.getTextWidth("99,999", fntValue)
|
||||||
self.mainBox.setColumnMinimumWidth(1, flagWidth)
|
self.mainBox.setColumnMinimumWidth(1, flagWidth)
|
||||||
self.mainBox.setColumnMinimumWidth(4, countWidth)
|
self.mainBox.setColumnMinimumWidth(4, countWidth)
|
||||||
|
|
||||||
@@ -233,13 +231,13 @@ class GuiItemDetails(QWidget):
|
|||||||
self.clearDetails()
|
self.clearDetails()
|
||||||
return
|
return
|
||||||
|
|
||||||
nwItem = self.mainGui.project.tree[tHandle]
|
nwItem = SHARED.project.tree[tHandle]
|
||||||
if nwItem is None:
|
if nwItem is None:
|
||||||
self.clearDetails()
|
self.clearDetails()
|
||||||
return
|
return
|
||||||
|
|
||||||
self._itemHandle = tHandle
|
self._itemHandle = tHandle
|
||||||
iPx = int(round(0.8*CONFIG.theme.baseIconSize))
|
iPx = int(round(0.8*SHARED.theme.baseIconSize))
|
||||||
|
|
||||||
# Label
|
# Label
|
||||||
# =====
|
# =====
|
||||||
@@ -250,11 +248,11 @@ class GuiItemDetails(QWidget):
|
|||||||
|
|
||||||
if nwItem.isFileType():
|
if nwItem.isFileType():
|
||||||
if nwItem.isActive:
|
if nwItem.isActive:
|
||||||
self.labelIcon.setPixmap(CONFIG.theme.getPixmap("checked", (iPx, iPx)))
|
self.labelIcon.setPixmap(SHARED.theme.getPixmap("checked", (iPx, iPx)))
|
||||||
else:
|
else:
|
||||||
self.labelIcon.setPixmap(CONFIG.theme.getPixmap("unchecked", (iPx, iPx)))
|
self.labelIcon.setPixmap(SHARED.theme.getPixmap("unchecked", (iPx, iPx)))
|
||||||
else:
|
else:
|
||||||
self.labelIcon.setPixmap(CONFIG.theme.getPixmap("noncheckable", (iPx, iPx)))
|
self.labelIcon.setPixmap(SHARED.theme.getPixmap("noncheckable", (iPx, iPx)))
|
||||||
|
|
||||||
self.labelData.setText(theLabel)
|
self.labelData.setText(theLabel)
|
||||||
|
|
||||||
@@ -268,14 +266,14 @@ class GuiItemDetails(QWidget):
|
|||||||
# Class
|
# 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.classIcon.setPixmap(classIcon.pixmap(iPx, iPx))
|
||||||
self.classData.setText(trConst(nwLabels.CLASS_NAME[nwItem.itemClass]))
|
self.classData.setText(trConst(nwLabels.CLASS_NAME[nwItem.itemClass]))
|
||||||
|
|
||||||
# Layout
|
# Layout
|
||||||
# ======
|
# ======
|
||||||
|
|
||||||
usageIcon = CONFIG.theme.getItemIcon(
|
usageIcon = SHARED.theme.getItemIcon(
|
||||||
nwItem.itemType, nwItem.itemClass, nwItem.itemLayout, nwItem.mainHeading
|
nwItem.itemType, nwItem.itemClass, nwItem.itemLayout, nwItem.mainHeading
|
||||||
)
|
)
|
||||||
self.usageIcon.setPixmap(usageIcon.pixmap(iPx, iPx))
|
self.usageIcon.setPixmap(usageIcon.pixmap(iPx, iPx))
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ from PyQt5.QtCore import QUrl
|
|||||||
from PyQt5.QtGui import QDesktopServices
|
from PyQt5.QtGui import QDesktopServices
|
||||||
from PyQt5.QtWidgets import QMenuBar, QAction
|
from PyQt5.QtWidgets import QMenuBar, QAction
|
||||||
|
|
||||||
from novelwriter import CONFIG
|
from novelwriter import CONFIG, SHARED
|
||||||
from novelwriter.enum import nwDocAction, nwDocInsert, nwWidget
|
from novelwriter.enum import nwDocAction, nwDocInsert, nwWidget
|
||||||
from novelwriter.constants import nwConst, trConst, nwKeyWords, nwLabels, nwUnicode
|
from novelwriter.constants import nwConst, trConst, nwKeyWords, nwLabels, nwUnicode
|
||||||
|
|
||||||
@@ -795,7 +795,7 @@ class GuiMainMenu(QMenuBar):
|
|||||||
# Tools > Check Spelling
|
# Tools > Check Spelling
|
||||||
self.aSpellCheck = QAction(self.tr("Check Spelling"), self)
|
self.aSpellCheck = QAction(self.tr("Check Spelling"), self)
|
||||||
self.aSpellCheck.setCheckable(True)
|
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.triggered.connect(self._toggleSpellCheck) # triggered, not toggled!
|
||||||
self.aSpellCheck.setShortcut("Ctrl+F7")
|
self.aSpellCheck.setShortcut("Ctrl+F7")
|
||||||
self.toolsMenu.addAction(self.aSpellCheck)
|
self.toolsMenu.addAction(self.aSpellCheck)
|
||||||
@@ -825,7 +825,7 @@ class GuiMainMenu(QMenuBar):
|
|||||||
|
|
||||||
# Tools > Backup Project
|
# Tools > Backup Project
|
||||||
self.aBackupProject = QAction(self.tr("Backup Project"), self)
|
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)
|
self.toolsMenu.addAction(self.aBackupProject)
|
||||||
|
|
||||||
# Tools > Build Manuscript
|
# Tools > Build Manuscript
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ from PyQt5.QtWidgets import (
|
|||||||
QTreeWidgetItem, QVBoxLayout, QWidget
|
QTreeWidgetItem, QVBoxLayout, QWidget
|
||||||
)
|
)
|
||||||
|
|
||||||
from novelwriter import CONFIG
|
from novelwriter import CONFIG, SHARED
|
||||||
from novelwriter.enum import nwDocMode, nwItemClass, nwOutline
|
from novelwriter.enum import nwDocMode, nwItemClass, nwOutline
|
||||||
from novelwriter.common import minmax
|
from novelwriter.common import minmax
|
||||||
from novelwriter.constants import nwHeaders, nwKeyWords, nwLabels, trConst
|
from novelwriter.constants import nwHeaders, nwKeyWords, nwLabels, trConst
|
||||||
@@ -117,16 +117,16 @@ class GuiNovelView(QWidget):
|
|||||||
def openProjectTasks(self):
|
def openProjectTasks(self):
|
||||||
"""Run open project tasks.
|
"""Run open project tasks.
|
||||||
"""
|
"""
|
||||||
lastNovel = self.mainGui.project.data.getLastHandle("novelTree")
|
lastNovel = SHARED.project.data.getLastHandle("novelTree")
|
||||||
if lastNovel not in self.mainGui.project.tree:
|
if lastNovel not in SHARED.project.tree:
|
||||||
lastNovel = self.mainGui.project.tree.findRoot(nwItemClass.NOVEL)
|
lastNovel = SHARED.project.tree.findRoot(nwItemClass.NOVEL)
|
||||||
|
|
||||||
logger.debug("Setting novel tree to root item '%s'", lastNovel)
|
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
|
"GuiNovelView", "lastCol", NovelTreeColumn, NovelTreeColumn.HIDDEN
|
||||||
)
|
)
|
||||||
lastColSize = self.mainGui.project.options.getInt(
|
lastColSize = SHARED.project.options.getInt(
|
||||||
"GuiNovelView", "lastColSize", 25
|
"GuiNovelView", "lastColSize", 25
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -146,7 +146,7 @@ class GuiNovelView(QWidget):
|
|||||||
"""
|
"""
|
||||||
lastColType = self.novelTree.lastColType
|
lastColType = self.novelTree.lastColType
|
||||||
lastColSize = self.novelTree.lastColSize
|
lastColSize = self.novelTree.lastColSize
|
||||||
pOptions = self.mainGui.project.options
|
pOptions = SHARED.project.options
|
||||||
pOptions.setValue("GuiNovelView", "lastCol", lastColType)
|
pOptions.setValue("GuiNovelView", "lastCol", lastColType)
|
||||||
pOptions.setValue("GuiNovelView", "lastColSize", lastColSize)
|
pOptions.setValue("GuiNovelView", "lastColSize", lastColSize)
|
||||||
return
|
return
|
||||||
@@ -170,7 +170,7 @@ class GuiNovelView(QWidget):
|
|||||||
def refreshTree(self):
|
def refreshTree(self):
|
||||||
"""Refresh the current tree.
|
"""Refresh the current tree.
|
||||||
"""
|
"""
|
||||||
self.novelTree.refreshTree(rootHandle=self.mainGui.project.data.getLastHandle("novelTree"))
|
self.novelTree.refreshTree(rootHandle=SHARED.project.data.getLastHandle("novelTree"))
|
||||||
return
|
return
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
@@ -201,7 +201,7 @@ class GuiNovelToolBar(QWidget):
|
|||||||
self.novelView = novelView
|
self.novelView = novelView
|
||||||
self.mainGui = novelView.mainGui
|
self.mainGui = novelView.mainGui
|
||||||
|
|
||||||
iPx = CONFIG.theme.baseIconSize
|
iPx = SHARED.theme.baseIconSize
|
||||||
mPx = CONFIG.pxInt(2)
|
mPx = CONFIG.pxInt(2)
|
||||||
|
|
||||||
self.setContentsMargins(0, 0, 0, 0)
|
self.setContentsMargins(0, 0, 0, 0)
|
||||||
@@ -211,7 +211,7 @@ class GuiNovelToolBar(QWidget):
|
|||||||
selFont = self.font()
|
selFont = self.font()
|
||||||
selFont.setWeight(QFont.Bold)
|
selFont.setWeight(QFont.Bold)
|
||||||
self.novelPrefix = self.tr("Outline of {0}")
|
self.novelPrefix = self.tr("Outline of {0}")
|
||||||
self.novelValue = NovelSelector(self, self.mainGui)
|
self.novelValue = NovelSelector(self)
|
||||||
self.novelValue.setFont(selFont)
|
self.novelValue.setFont(selFont)
|
||||||
self.novelValue.setMinimumWidth(CONFIG.pxInt(150))
|
self.novelValue.setMinimumWidth(CONFIG.pxInt(150))
|
||||||
self.novelValue.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
self.novelValue.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
||||||
@@ -274,9 +274,9 @@ class GuiNovelToolBar(QWidget):
|
|||||||
"""Update theme elements.
|
"""Update theme elements.
|
||||||
"""
|
"""
|
||||||
# Icons
|
# Icons
|
||||||
self.tbNovel.setIcon(CONFIG.theme.getIcon("cls_novel"))
|
self.tbNovel.setIcon(SHARED.theme.getIcon("cls_novel"))
|
||||||
self.tbRefresh.setIcon(CONFIG.theme.getIcon("refresh"))
|
self.tbRefresh.setIcon(SHARED.theme.getIcon("refresh"))
|
||||||
self.tbMore.setIcon(CONFIG.theme.getIcon("menu"))
|
self.tbMore.setIcon(SHARED.theme.getIcon("menu"))
|
||||||
|
|
||||||
qPalette = self.palette()
|
qPalette = self.palette()
|
||||||
qPalette.setBrush(QPalette.Window, qPalette.base())
|
qPalette.setBrush(QPalette.Window, qPalette.base())
|
||||||
@@ -345,7 +345,7 @@ class GuiNovelToolBar(QWidget):
|
|||||||
def _refreshNovelTree(self):
|
def _refreshNovelTree(self):
|
||||||
"""Rebuild the current tree.
|
"""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)
|
self.novelView.novelTree.refreshTree(rootHandle=rootHandle, overRide=True)
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -415,7 +415,7 @@ class GuiNovelTree(QTreeWidget):
|
|||||||
# Build GUI
|
# Build GUI
|
||||||
# =========
|
# =========
|
||||||
|
|
||||||
iPx = CONFIG.theme.baseIconSize
|
iPx = SHARED.theme.baseIconSize
|
||||||
cMg = CONFIG.pxInt(6)
|
cMg = CONFIG.pxInt(6)
|
||||||
|
|
||||||
self.setIconSize(QSize(iPx, iPx))
|
self.setIconSize(QSize(iPx, iPx))
|
||||||
@@ -481,8 +481,8 @@ class GuiNovelTree(QTreeWidget):
|
|||||||
def updateTheme(self):
|
def updateTheme(self):
|
||||||
"""Update theme elements.
|
"""Update theme elements.
|
||||||
"""
|
"""
|
||||||
iPx = CONFIG.theme.baseIconSize
|
iPx = SHARED.theme.baseIconSize
|
||||||
self._pMore = CONFIG.theme.loadDecoration("deco_doc_more", pxH=iPx)
|
self._pMore = SHARED.theme.loadDecoration("deco_doc_more", pxH=iPx)
|
||||||
return
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
@@ -514,10 +514,10 @@ class GuiNovelTree(QTreeWidget):
|
|||||||
"""
|
"""
|
||||||
logger.debug("Requesting refresh of the novel tree")
|
logger.debug("Requesting refresh of the novel tree")
|
||||||
if rootHandle is None:
|
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)
|
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):
|
if not (treeChanged or indexChanged or overRide):
|
||||||
logger.debug("No changes have been made to the novel index")
|
logger.debug("No changes have been made to the novel index")
|
||||||
return
|
return
|
||||||
@@ -528,7 +528,7 @@ class GuiNovelTree(QTreeWidget):
|
|||||||
titleKey = selItem[0].data(self.C_DATA, self.D_KEY)
|
titleKey = selItem[0].data(self.C_DATA, self.D_KEY)
|
||||||
|
|
||||||
self._populateTree(rootHandle)
|
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:
|
if titleKey is not None and titleKey in self._treeMap:
|
||||||
self._treeMap[titleKey].setSelected(True)
|
self._treeMap[titleKey].setSelected(True)
|
||||||
@@ -538,7 +538,7 @@ class GuiNovelTree(QTreeWidget):
|
|||||||
def refreshHandle(self, tHandle):
|
def refreshHandle(self, tHandle):
|
||||||
"""Refresh the data for a given handle.
|
"""Refresh the data for a given handle.
|
||||||
"""
|
"""
|
||||||
idxData = self.mainGui.project.index.getItemData(tHandle)
|
idxData = SHARED.project.index.getItemData(tHandle)
|
||||||
if idxData is None:
|
if idxData is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -575,7 +575,7 @@ class GuiNovelTree(QTreeWidget):
|
|||||||
self._lastCol = colType
|
self._lastCol = colType
|
||||||
self.setColumnHidden(self.C_EXTRA, colType == NovelTreeColumn.HIDDEN)
|
self.setColumnHidden(self.C_EXTRA, colType == NovelTreeColumn.HIDDEN)
|
||||||
if doRefresh:
|
if doRefresh:
|
||||||
lastNovel = self.mainGui.project.data.getLastHandle("novelTree")
|
lastNovel = SHARED.project.data.getLastHandle("novelTree")
|
||||||
self.refreshTree(rootHandle=lastNovel, overRide=True)
|
self.refreshTree(rootHandle=lastNovel, overRide=True)
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -707,7 +707,7 @@ class GuiNovelTree(QTreeWidget):
|
|||||||
tStart = time()
|
tStart = time()
|
||||||
logger.debug("Building novel tree for root item '%s'", rootHandle)
|
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:
|
for tKey, tHandle, sTitle, novIdx in novStruct:
|
||||||
if novIdx.level == "H0":
|
if novIdx.level == "H0":
|
||||||
continue
|
continue
|
||||||
@@ -733,7 +733,7 @@ class GuiNovelTree(QTreeWidget):
|
|||||||
"""Set the tree item values from the index entry.
|
"""Set the tree item values from the index entry.
|
||||||
"""
|
"""
|
||||||
iLevel = nwHeaders.H_LEVEL.get(idxItem.level, 0)
|
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.setData(self.C_TITLE, Qt.DecorationRole, hDec)
|
||||||
trItem.setText(self.C_TITLE, idxItem.title)
|
trItem.setText(self.C_TITLE, idxItem.title)
|
||||||
@@ -759,7 +759,7 @@ class GuiNovelTree(QTreeWidget):
|
|||||||
|
|
||||||
refData = []
|
refData = []
|
||||||
refName = ""
|
refName = ""
|
||||||
theRefs = self.mainGui.project.index.getReferences(tHandle, sTitle)
|
theRefs = SHARED.project.index.getReferences(tHandle, sTitle)
|
||||||
if self._lastCol == NovelTreeColumn.POV:
|
if self._lastCol == NovelTreeColumn.POV:
|
||||||
refData = theRefs[nwKeyWords.POV_KEY]
|
refData = theRefs[nwKeyWords.POV_KEY]
|
||||||
refName = self._povLabel
|
refName = self._povLabel
|
||||||
@@ -783,7 +783,7 @@ class GuiNovelTree(QTreeWidget):
|
|||||||
"""
|
"""
|
||||||
logger.debug("Generating meta data tooltip for '%s:%s'", tHandle, sTitle)
|
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)
|
novIdx = pIndex.getItemHeader(tHandle, sTitle)
|
||||||
refTags = pIndex.getReferences(tHandle, sTitle)
|
refTags = pIndex.getReferences(tHandle, sTitle)
|
||||||
|
|
||||||
|
|||||||
+28
-34
@@ -41,7 +41,7 @@ from PyQt5.QtWidgets import (
|
|||||||
QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget
|
QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget
|
||||||
)
|
)
|
||||||
|
|
||||||
from novelwriter import CONFIG
|
from novelwriter import CONFIG, SHARED
|
||||||
from novelwriter.enum import (
|
from novelwriter.enum import (
|
||||||
nwDocMode, nwItemClass, nwItemLayout, nwItemType, nwOutline
|
nwDocMode, nwItemClass, nwItemLayout, nwItemType, nwOutline
|
||||||
)
|
)
|
||||||
@@ -62,8 +62,6 @@ class GuiOutlineView(QWidget):
|
|||||||
def __init__(self, mainGui):
|
def __init__(self, mainGui):
|
||||||
super().__init__(parent=mainGui)
|
super().__init__(parent=mainGui)
|
||||||
|
|
||||||
self.mainGui = mainGui
|
|
||||||
|
|
||||||
# Build GUI
|
# Build GUI
|
||||||
self.outlineTree = GuiOutlineTree(self)
|
self.outlineTree = GuiOutlineTree(self)
|
||||||
self.outlineData = GuiOutlineDetails(self)
|
self.outlineData = GuiOutlineDetails(self)
|
||||||
@@ -117,7 +115,7 @@ class GuiOutlineView(QWidget):
|
|||||||
def refreshTree(self):
|
def refreshTree(self):
|
||||||
"""Refresh the current tree.
|
"""Refresh the current tree.
|
||||||
"""
|
"""
|
||||||
self.outlineTree.refreshTree(rootHandle=self.mainGui.project.data.getLastHandle("outline"))
|
self.outlineTree.refreshTree(rootHandle=SHARED.project.data.getLastHandle("outline"))
|
||||||
return
|
return
|
||||||
|
|
||||||
def clearProject(self):
|
def clearProject(self):
|
||||||
@@ -130,9 +128,9 @@ class GuiOutlineView(QWidget):
|
|||||||
def openProjectTasks(self):
|
def openProjectTasks(self):
|
||||||
"""Run open project tasks.
|
"""Run open project tasks.
|
||||||
"""
|
"""
|
||||||
lastOutline = self.mainGui.project.data.getLastHandle("outline")
|
lastOutline = SHARED.project.data.getLastHandle("outline")
|
||||||
if not (lastOutline in self.mainGui.project.tree or lastOutline is None):
|
if not (lastOutline in SHARED.project.tree or lastOutline is None):
|
||||||
lastOutline = self.mainGui.project.tree.findRoot(nwItemClass.NOVEL)
|
lastOutline = SHARED.project.tree.findRoot(nwItemClass.NOVEL)
|
||||||
|
|
||||||
logger.debug("Setting outline tree to root item '%s'", lastOutline)
|
logger.debug("Setting outline tree to root item '%s'", lastOutline)
|
||||||
|
|
||||||
@@ -214,8 +212,6 @@ class GuiOutlineToolBar(QToolBar):
|
|||||||
|
|
||||||
logger.debug("Create: GuiOutlineToolBar")
|
logger.debug("Create: GuiOutlineToolBar")
|
||||||
|
|
||||||
self.mainGui = theOutline.mainGui
|
|
||||||
|
|
||||||
iPx = CONFIG.pxInt(22)
|
iPx = CONFIG.pxInt(22)
|
||||||
mPx = CONFIG.pxInt(12)
|
mPx = CONFIG.pxInt(12)
|
||||||
|
|
||||||
@@ -230,7 +226,7 @@ class GuiOutlineToolBar(QToolBar):
|
|||||||
self.novelLabel = QLabel(self.tr("Outline of"))
|
self.novelLabel = QLabel(self.tr("Outline of"))
|
||||||
self.novelLabel.setContentsMargins(0, 0, mPx, 0)
|
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.setMinimumWidth(CONFIG.pxInt(200))
|
||||||
self.novelValue.novelSelectionChanged.connect(self._novelValueChanged)
|
self.novelValue.novelSelectionChanged.connect(self._novelValueChanged)
|
||||||
|
|
||||||
@@ -272,8 +268,8 @@ class GuiOutlineToolBar(QToolBar):
|
|||||||
self.setStyleSheet("QToolBar {border: 0px;}")
|
self.setStyleSheet("QToolBar {border: 0px;}")
|
||||||
|
|
||||||
self.novelValue.updateList(includeAll=True)
|
self.novelValue.updateList(includeAll=True)
|
||||||
self.aRefresh.setIcon(CONFIG.theme.getIcon("refresh"))
|
self.aRefresh.setIcon(SHARED.theme.getIcon("refresh"))
|
||||||
self.tbColumns.setIcon(CONFIG.theme.getIcon("menu"))
|
self.tbColumns.setIcon(SHARED.theme.getIcon("menu"))
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -370,7 +366,6 @@ class GuiOutlineTree(QTreeWidget):
|
|||||||
logger.debug("Create: GuiOutlineTree")
|
logger.debug("Create: GuiOutlineTree")
|
||||||
|
|
||||||
self.outlineView = outlineView
|
self.outlineView = outlineView
|
||||||
self.mainGui = outlineView.mainGui
|
|
||||||
|
|
||||||
self.setUniformRowHeights(True)
|
self.setUniformRowHeights(True)
|
||||||
self.setFrameStyle(QFrame.NoFrame)
|
self.setFrameStyle(QFrame.NoFrame)
|
||||||
@@ -381,7 +376,7 @@ class GuiOutlineTree(QTreeWidget):
|
|||||||
self.itemDoubleClicked.connect(self._treeDoubleClick)
|
self.itemDoubleClicked.connect(self._treeDoubleClick)
|
||||||
self.itemSelectionChanged.connect(self._itemSelected)
|
self.itemSelectionChanged.connect(self._itemSelected)
|
||||||
|
|
||||||
iPx = CONFIG.theme.baseIconSize
|
iPx = SHARED.theme.baseIconSize
|
||||||
self.setIconSize(QSize(iPx, iPx))
|
self.setIconSize(QSize(iPx, iPx))
|
||||||
self.setIndentation(0)
|
self.setIndentation(0)
|
||||||
|
|
||||||
@@ -398,11 +393,11 @@ class GuiOutlineTree(QTreeWidget):
|
|||||||
|
|
||||||
self._hFonts = [self.font(), fH1, fH2, self.font(), self.font()]
|
self._hFonts = [self.font(), fH1, fH2, self.font(), self.font()]
|
||||||
self._dIcon = {
|
self._dIcon = {
|
||||||
"H0": CONFIG.theme.getItemIcon(nwItemType.FILE, None, nwItemLayout.DOCUMENT, "H0"),
|
"H0": SHARED.theme.getItemIcon(nwItemType.FILE, None, nwItemLayout.DOCUMENT, "H0"),
|
||||||
"H1": CONFIG.theme.getItemIcon(nwItemType.FILE, None, nwItemLayout.DOCUMENT, "H1"),
|
"H1": SHARED.theme.getItemIcon(nwItemType.FILE, None, nwItemLayout.DOCUMENT, "H1"),
|
||||||
"H2": CONFIG.theme.getItemIcon(nwItemType.FILE, None, nwItemLayout.DOCUMENT, "H2"),
|
"H2": SHARED.theme.getItemIcon(nwItemType.FILE, None, nwItemLayout.DOCUMENT, "H2"),
|
||||||
"H3": CONFIG.theme.getItemIcon(nwItemType.FILE, None, nwItemLayout.DOCUMENT, "H3"),
|
"H3": SHARED.theme.getItemIcon(nwItemType.FILE, None, nwItemLayout.DOCUMENT, "H3"),
|
||||||
"H4": CONFIG.theme.getItemIcon(nwItemType.FILE, None, nwItemLayout.DOCUMENT, "H4"),
|
"H4": SHARED.theme.getItemIcon(nwItemType.FILE, None, nwItemLayout.DOCUMENT, "H4"),
|
||||||
}
|
}
|
||||||
|
|
||||||
# Internals
|
# Internals
|
||||||
@@ -488,13 +483,13 @@ class GuiOutlineTree(QTreeWidget):
|
|||||||
|
|
||||||
# If the novel index or novel tree has changed since the tree
|
# If the novel index or novel tree has changed since the tree
|
||||||
# was last built, we rebuild the tree from the updated index.
|
# 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):
|
if not (novelChanged or indexChanged or overRide):
|
||||||
logger.debug("No changes have been made to the novel index")
|
logger.debug("No changes have been made to the novel index")
|
||||||
return
|
return
|
||||||
|
|
||||||
self._populateTree(rootHandle)
|
self._populateTree(rootHandle)
|
||||||
self.mainGui.project.data.setLastHandle(rootHandle or None, "outline")
|
SHARED.project.data.setLastHandle(rootHandle or None, "outline")
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -574,7 +569,7 @@ class GuiOutlineTree(QTreeWidget):
|
|||||||
"""
|
"""
|
||||||
# Load whatever we saved last time, regardless of wether it
|
# Load whatever we saved last time, regardless of wether it
|
||||||
# contains the correct names or number of columns.
|
# contains the correct names or number of columns.
|
||||||
colState = self.mainGui.project.options.getValue("GuiOutline", "columnState", {})
|
colState = SHARED.project.options.getValue("GuiOutline", "columnState", {})
|
||||||
|
|
||||||
tmpOrder = []
|
tmpOrder = []
|
||||||
tmpHidden = {}
|
tmpHidden = {}
|
||||||
@@ -625,7 +620,7 @@ class GuiOutlineTree(QTreeWidget):
|
|||||||
logHidden, orgWidth if logHidden and logWidth == 0 else logWidth
|
logHidden, orgWidth if logHidden and logWidth == 0 else logWidth
|
||||||
]
|
]
|
||||||
|
|
||||||
pOptions = self.mainGui.project.options
|
pOptions = SHARED.project.options
|
||||||
pOptions.setValue("GuiOutline", "columnState", colState)
|
pOptions.setValue("GuiOutline", "columnState", colState)
|
||||||
pOptions.saveSettings()
|
pOptions.saveSettings()
|
||||||
|
|
||||||
@@ -661,7 +656,7 @@ class GuiOutlineTree(QTreeWidget):
|
|||||||
headItem.setTextAlignment(self._colIdx[nwOutline.WCOUNT], Qt.AlignRight)
|
headItem.setTextAlignment(self._colIdx[nwOutline.WCOUNT], Qt.AlignRight)
|
||||||
headItem.setTextAlignment(self._colIdx[nwOutline.PCOUNT], 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:
|
for _, tHandle, sTitle, novIdx in novStruct:
|
||||||
|
|
||||||
iLevel = nwHeaders.H_LEVEL.get(novIdx.level, 0)
|
iLevel = nwHeaders.H_LEVEL.get(novIdx.level, 0)
|
||||||
@@ -669,8 +664,8 @@ class GuiOutlineTree(QTreeWidget):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
trItem = QTreeWidgetItem()
|
trItem = QTreeWidgetItem()
|
||||||
nwItem = self.mainGui.project.tree[tHandle]
|
nwItem = SHARED.project.tree[tHandle]
|
||||||
hDec = CONFIG.theme.getHeaderDecoration(iLevel)
|
hDec = SHARED.theme.getHeaderDecoration(iLevel)
|
||||||
|
|
||||||
trItem.setData(self._colIdx[nwOutline.TITLE], Qt.DecorationRole, hDec)
|
trItem.setData(self._colIdx[nwOutline.TITLE], Qt.DecorationRole, hDec)
|
||||||
trItem.setText(self._colIdx[nwOutline.TITLE], novIdx.title)
|
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.WCOUNT], Qt.AlignRight)
|
||||||
trItem.setTextAlignment(self._colIdx[nwOutline.PCOUNT], 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.POV], ", ".join(refs[nwKeyWords.POV_KEY]))
|
||||||
trItem.setText(self._colIdx[nwOutline.FOCUS], ", ".join(refs[nwKeyWords.FOCUS_KEY]))
|
trItem.setText(self._colIdx[nwOutline.FOCUS], ", ".join(refs[nwKeyWords.FOCUS_KEY]))
|
||||||
trItem.setText(self._colIdx[nwOutline.CHAR], ", ".join(refs[nwKeyWords.CHAR_KEY]))
|
trItem.setText(self._colIdx[nwOutline.CHAR], ", ".join(refs[nwKeyWords.CHAR_KEY]))
|
||||||
@@ -770,12 +765,11 @@ class GuiOutlineDetails(QScrollArea):
|
|||||||
logger.debug("Create: GuiOutlineDetails")
|
logger.debug("Create: GuiOutlineDetails")
|
||||||
|
|
||||||
self.theOutline = theOutline
|
self.theOutline = theOutline
|
||||||
self.mainGui = theOutline.mainGui
|
|
||||||
|
|
||||||
# Sizes
|
# Sizes
|
||||||
minTitle = 30*CONFIG.theme.textNWidth
|
minTitle = 30*SHARED.theme.textNWidth
|
||||||
maxTitle = 40*CONFIG.theme.textNWidth
|
maxTitle = 40*SHARED.theme.textNWidth
|
||||||
wCount = CONFIG.theme.getTextWidth("999,999")
|
wCount = SHARED.theme.getTextWidth("999,999")
|
||||||
hSpace = int(CONFIG.pxInt(10))
|
hSpace = int(CONFIG.pxInt(10))
|
||||||
vSpace = int(CONFIG.pxInt(4))
|
vSpace = int(CONFIG.pxInt(4))
|
||||||
|
|
||||||
@@ -1005,8 +999,8 @@ class GuiOutlineDetails(QScrollArea):
|
|||||||
"""Update the content of the tree with the given handle and line
|
"""Update the content of the tree with the given handle and line
|
||||||
number pointing to a header.
|
number pointing to a header.
|
||||||
"""
|
"""
|
||||||
pIndex = self.mainGui.project.index
|
pIndex = SHARED.project.index
|
||||||
nwItem = self.mainGui.project.tree[tHandle]
|
nwItem = SHARED.project.tree[tHandle]
|
||||||
novIdx = pIndex.getItemHeader(tHandle, sTitle)
|
novIdx = pIndex.getItemHeader(tHandle, sTitle)
|
||||||
theRefs = pIndex.getReferences(tHandle, sTitle)
|
theRefs = pIndex.getReferences(tHandle, sTitle)
|
||||||
if nwItem is None or novIdx is None:
|
if nwItem is None or novIdx is None:
|
||||||
@@ -1049,7 +1043,7 @@ class GuiOutlineDetails(QScrollArea):
|
|||||||
def updateClasses(self):
|
def updateClasses(self):
|
||||||
"""Update the visibility status of class details.
|
"""Update the visibility status of class details.
|
||||||
"""
|
"""
|
||||||
usedClasses = self.mainGui.project.tree.rootClasses()
|
usedClasses = SHARED.project.tree.rootClasses()
|
||||||
|
|
||||||
pltVisible = nwItemClass.PLOT in usedClasses
|
pltVisible = nwItemClass.PLOT in usedClasses
|
||||||
timVisible = nwItemClass.TIMELINE in usedClasses
|
timVisible = nwItemClass.TIMELINE in usedClasses
|
||||||
|
|||||||
+72
-72
@@ -39,7 +39,7 @@ from PyQt5.QtWidgets import (
|
|||||||
QVBoxLayout, QWidget
|
QVBoxLayout, QWidget
|
||||||
)
|
)
|
||||||
|
|
||||||
from novelwriter import CONFIG
|
from novelwriter import CONFIG, SHARED
|
||||||
from novelwriter.common import minmax
|
from novelwriter.common import minmax
|
||||||
from novelwriter.constants import nwHeaders, nwUnicode, trConst, nwLabels
|
from novelwriter.constants import nwHeaders, nwUnicode, trConst, nwLabels
|
||||||
from novelwriter.core.item import NWItem
|
from novelwriter.core.item import NWItem
|
||||||
@@ -236,7 +236,7 @@ class GuiProjectToolBar(QWidget):
|
|||||||
self.projTree = projView.projTree
|
self.projTree = projView.projTree
|
||||||
self.mainGui = projView.mainGui
|
self.mainGui = projView.mainGui
|
||||||
|
|
||||||
iPx = CONFIG.theme.baseIconSize
|
iPx = SHARED.theme.baseIconSize
|
||||||
mPx = CONFIG.pxInt(2)
|
mPx = CONFIG.pxInt(2)
|
||||||
|
|
||||||
self.setContentsMargins(0, 0, 0, 0)
|
self.setContentsMargins(0, 0, 0, 0)
|
||||||
@@ -367,16 +367,16 @@ class GuiProjectToolBar(QWidget):
|
|||||||
self.tbAdd.setStyleSheet(buttonStyle)
|
self.tbAdd.setStyleSheet(buttonStyle)
|
||||||
self.tbMore.setStyleSheet(buttonStyle)
|
self.tbMore.setStyleSheet(buttonStyle)
|
||||||
|
|
||||||
self.tbQuick.setIcon(CONFIG.theme.getIcon("bookmark"))
|
self.tbQuick.setIcon(SHARED.theme.getIcon("bookmark"))
|
||||||
self.tbMoveU.setIcon(CONFIG.theme.getIcon("up"))
|
self.tbMoveU.setIcon(SHARED.theme.getIcon("up"))
|
||||||
self.tbMoveD.setIcon(CONFIG.theme.getIcon("down"))
|
self.tbMoveD.setIcon(SHARED.theme.getIcon("down"))
|
||||||
self.aAddEmpty.setIcon(CONFIG.theme.getIcon("proj_document"))
|
self.aAddEmpty.setIcon(SHARED.theme.getIcon("proj_document"))
|
||||||
self.aAddChap.setIcon(CONFIG.theme.getIcon("proj_chapter"))
|
self.aAddChap.setIcon(SHARED.theme.getIcon("proj_chapter"))
|
||||||
self.aAddScene.setIcon(CONFIG.theme.getIcon("proj_scene"))
|
self.aAddScene.setIcon(SHARED.theme.getIcon("proj_scene"))
|
||||||
self.aAddNote.setIcon(CONFIG.theme.getIcon("proj_note"))
|
self.aAddNote.setIcon(SHARED.theme.getIcon("proj_note"))
|
||||||
self.aAddFolder.setIcon(CONFIG.theme.getIcon("proj_folder"))
|
self.aAddFolder.setIcon(SHARED.theme.getIcon("proj_folder"))
|
||||||
self.tbAdd.setIcon(CONFIG.theme.getIcon("add"))
|
self.tbAdd.setIcon(SHARED.theme.getIcon("add"))
|
||||||
self.tbMore.setIcon(CONFIG.theme.getIcon("menu"))
|
self.tbMore.setIcon(SHARED.theme.getIcon("menu"))
|
||||||
|
|
||||||
self.buildQuickLinkMenu()
|
self.buildQuickLinkMenu()
|
||||||
self._buildRootMenu()
|
self._buildRootMenu()
|
||||||
@@ -392,10 +392,10 @@ class GuiProjectToolBar(QWidget):
|
|||||||
"""Build the quick link menu."""
|
"""Build the quick link menu."""
|
||||||
logger.debug("Rebuilding quick links menu")
|
logger.debug("Rebuilding quick links menu")
|
||||||
self.mQuick.clear()
|
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 = self.mQuick.addAction(nwItem.itemName)
|
||||||
aRoot.setData(tHandle)
|
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(
|
aRoot.triggered.connect(
|
||||||
lambda n, tHandle=tHandle: self.projView.setSelectedHandle(tHandle, doScroll=True)
|
lambda n, tHandle=tHandle: self.projView.setSelectedHandle(tHandle, doScroll=True)
|
||||||
)
|
)
|
||||||
@@ -409,7 +409,7 @@ class GuiProjectToolBar(QWidget):
|
|||||||
"""Build the rood folder menu."""
|
"""Build the rood folder menu."""
|
||||||
def addClass(itemClass):
|
def addClass(itemClass):
|
||||||
aNew = self.mAddRoot.addAction(trConst(nwLabels.CLASS_NAME[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))
|
aNew.triggered.connect(lambda: self.projTree.newTreeItem(nwItemType.ROOT, itemClass))
|
||||||
self.mAddRoot.addAction(aNew)
|
self.mAddRoot.addAction(aNew)
|
||||||
return
|
return
|
||||||
@@ -438,7 +438,7 @@ class GuiProjectToolBar(QWidget):
|
|||||||
documents. They should only be visible if novel documents can
|
documents. They should only be visible if novel documents can
|
||||||
actually be added.
|
actually be added.
|
||||||
"""
|
"""
|
||||||
nwItem = self.mainGui.project.tree[tHandle]
|
nwItem = SHARED.project.tree[tHandle]
|
||||||
allowDoc = isinstance(nwItem, NWItem) and nwItem.documentAllowed()
|
allowDoc = isinstance(nwItem, NWItem) and nwItem.documentAllowed()
|
||||||
self.aAddEmpty.setVisible(allowDoc)
|
self.aAddEmpty.setVisible(allowDoc)
|
||||||
self.aAddChap.setVisible(allowDoc)
|
self.aAddChap.setVisible(allowDoc)
|
||||||
@@ -480,7 +480,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
self.customContextMenuRequested.connect(self._openContextMenu)
|
self.customContextMenuRequested.connect(self._openContextMenu)
|
||||||
|
|
||||||
# Tree Settings
|
# Tree Settings
|
||||||
iPx = CONFIG.theme.baseIconSize
|
iPx = SHARED.theme.baseIconSize
|
||||||
cMg = CONFIG.pxInt(6)
|
cMg = CONFIG.pxInt(6)
|
||||||
|
|
||||||
self.setIconSize(QSize(iPx, iPx))
|
self.setIconSize(QSize(iPx, iPx))
|
||||||
@@ -572,15 +572,15 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
|
|
||||||
if itemType == nwItemType.ROOT and isinstance(itemClass, nwItemClass):
|
if itemType == nwItemType.ROOT and isinstance(itemClass, nwItemClass):
|
||||||
|
|
||||||
tHandle = self.mainGui.project.newRoot(itemClass)
|
tHandle = SHARED.project.newRoot(itemClass)
|
||||||
sHandle = self.getSelectedHandle()
|
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
|
nHandle = pItem.itemRoot if pItem else None
|
||||||
|
|
||||||
elif itemType in (nwItemType.FILE, nwItemType.FOLDER):
|
elif itemType in (nwItemType.FILE, nwItemType.FOLDER):
|
||||||
|
|
||||||
sHandle = self.getSelectedHandle()
|
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:
|
if sHandle is None or pItem is None:
|
||||||
self.mainGui.makeAlert(self.tr(
|
self.mainGui.makeAlert(self.tr(
|
||||||
"Did not find anywhere to add the file or folder!"
|
"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)
|
sLevel = nwHeaders.H_LEVEL.get(pItem.mainHeading, 0)
|
||||||
sIsParent = False if qItem is None else qItem.childCount() > 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(
|
self.mainGui.makeAlert(self.tr(
|
||||||
"Cannot add new files or folders to the Trash folder."
|
"Cannot add new files or folders to the Trash folder."
|
||||||
), level=nwAlert.ERROR)
|
), level=nwAlert.ERROR)
|
||||||
@@ -635,9 +635,9 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
|
|
||||||
# Add the file or folder
|
# Add the file or folder
|
||||||
if itemType == nwItemType.FILE:
|
if itemType == nwItemType.FILE:
|
||||||
tHandle = self.mainGui.project.newFile(newLabel, sHandle)
|
tHandle = SHARED.project.newFile(newLabel, sHandle)
|
||||||
else:
|
else:
|
||||||
tHandle = self.mainGui.project.newFolder(newLabel, sHandle)
|
tHandle = SHARED.project.newFolder(newLabel, sHandle)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
logger.error("Failed to add new item")
|
logger.error("Failed to add new item")
|
||||||
@@ -650,7 +650,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
|
|
||||||
# Handle new file creation
|
# Handle new file creation
|
||||||
if itemType == nwItemType.FILE and hLevel > 0:
|
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
|
# Add the new item to the project tree
|
||||||
self.revealNewTreeItem(tHandle, nHandle=nHandle, wordCount=True)
|
self.revealNewTreeItem(tHandle, nHandle=nHandle, wordCount=True)
|
||||||
@@ -661,7 +661,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
def revealNewTreeItem(self, tHandle: str | None, nHandle: str | None = None,
|
def revealNewTreeItem(self, tHandle: str | None, nHandle: str | None = None,
|
||||||
wordCount: bool = False) -> bool:
|
wordCount: bool = False) -> bool:
|
||||||
"""Reveal a newly added project item in the project tree."""
|
"""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:
|
if tHandle is None or nwItem is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -670,7 +670,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
if nwItem.isFileType() and wordCount:
|
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.propagateCount(tHandle, wC)
|
||||||
self.projView.wordCountsChanged.emit()
|
self.projView.wordCountsChanged.emit()
|
||||||
|
|
||||||
@@ -745,7 +745,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
|
|
||||||
def renameTreeItem(self, tHandle: str) -> bool:
|
def renameTreeItem(self, tHandle: str) -> bool:
|
||||||
"""Open a dialog to edit the label of an item."""
|
"""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:
|
if tItem is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -769,7 +769,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
if isinstance(item, QTreeWidgetItem):
|
if isinstance(item, QTreeWidgetItem):
|
||||||
theList = self._scanChildren(theList, item, i)
|
theList = self._scanChildren(theList, item, i)
|
||||||
logger.debug("Saving project tree item order")
|
logger.debug("Saving project tree item order")
|
||||||
self.mainGui.project.setTreeOrder(theList)
|
SHARED.project.setTreeOrder(theList)
|
||||||
return
|
return
|
||||||
|
|
||||||
def getTreeFromHandle(self, tHandle: str) -> list[str]:
|
def getTreeFromHandle(self, tHandle: str) -> list[str]:
|
||||||
@@ -802,16 +802,16 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
logger.error("There is no item to delete")
|
logger.error("There is no item to delete")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
trashHandle = self.mainGui.project.tree.trashRoot()
|
trashHandle = SHARED.project.tree.trashRoot()
|
||||||
if tHandle == trashHandle:
|
if tHandle == trashHandle:
|
||||||
logger.error("Cannot delete the Trash folder")
|
logger.error("Cannot delete the Trash folder")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
nwItem = self.mainGui.project.tree[tHandle]
|
nwItem = SHARED.project.tree[tHandle]
|
||||||
if nwItem is None:
|
if nwItem is None:
|
||||||
return False
|
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)
|
status = self.permDeleteItem(tHandle)
|
||||||
else:
|
else:
|
||||||
status = self.moveItemToTrash(tHandle)
|
status = self.moveItemToTrash(tHandle)
|
||||||
@@ -827,7 +827,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
logger.error("No project open")
|
logger.error("No project open")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
trashHandle = self.mainGui.project.tree.trashRoot()
|
trashHandle = SHARED.project.tree.trashRoot()
|
||||||
|
|
||||||
logger.debug("Emptying Trash folder")
|
logger.debug("Emptying Trash folder")
|
||||||
if trashHandle is None:
|
if trashHandle is None:
|
||||||
@@ -870,13 +870,13 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
so such a request is cancelled.
|
so such a request is cancelled.
|
||||||
"""
|
"""
|
||||||
trItemS = self._getTreeItem(tHandle)
|
trItemS = self._getTreeItem(tHandle)
|
||||||
nwItemS = self.mainGui.project.tree[tHandle]
|
nwItemS = SHARED.project.tree[tHandle]
|
||||||
|
|
||||||
if trItemS is None or nwItemS is None:
|
if trItemS is None or nwItemS is None:
|
||||||
logger.error("Could not find tree item for deletion")
|
logger.error("Could not find tree item for deletion")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if self.mainGui.project.tree.isTrash(tHandle):
|
if SHARED.project.tree.isTrash(tHandle):
|
||||||
logger.error("Item is already in the Trash folder")
|
logger.error("Item is already in the Trash folder")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -920,7 +920,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
Root items are handled a little different than other items.
|
Root items are handled a little different than other items.
|
||||||
"""
|
"""
|
||||||
trItemS = self._getTreeItem(tHandle)
|
trItemS = self._getTreeItem(tHandle)
|
||||||
nwItemS = self.mainGui.project.tree[tHandle]
|
nwItemS = SHARED.project.tree[tHandle]
|
||||||
if trItemS is None or nwItemS is None:
|
if trItemS is None or nwItemS is None:
|
||||||
logger.error("Could not find tree item for deletion")
|
logger.error("Could not find tree item for deletion")
|
||||||
return False
|
return False
|
||||||
@@ -937,7 +937,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
|
|
||||||
tIndex = self.indexOfTopLevelItem(trItemS)
|
tIndex = self.indexOfTopLevelItem(trItemS)
|
||||||
self.takeTopLevelItem(tIndex)
|
self.takeTopLevelItem(tIndex)
|
||||||
self.mainGui.project.removeItem(tHandle)
|
SHARED.project.removeItem(tHandle)
|
||||||
self._treeMap.pop(tHandle, None)
|
self._treeMap.pop(tHandle, None)
|
||||||
self._alertTreeChange(tHandle, flush=True)
|
self._alertTreeChange(tHandle, flush=True)
|
||||||
|
|
||||||
@@ -966,7 +966,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
for dHandle in reversed(self.getTreeFromHandle(tHandle)):
|
for dHandle in reversed(self.getTreeFromHandle(tHandle)):
|
||||||
if self.mainGui.docEditor.docHandle() == dHandle:
|
if self.mainGui.docEditor.docHandle() == dHandle:
|
||||||
self.mainGui.closeDocument()
|
self.mainGui.closeDocument()
|
||||||
self.mainGui.project.removeItem(dHandle)
|
SHARED.project.removeItem(dHandle)
|
||||||
self._treeMap.pop(dHandle, None)
|
self._treeMap.pop(dHandle, None)
|
||||||
|
|
||||||
self._alertTreeChange(tHandle, flush=flush)
|
self._alertTreeChange(tHandle, flush=flush)
|
||||||
@@ -984,13 +984,13 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
already coming from the project tree.
|
already coming from the project tree.
|
||||||
"""
|
"""
|
||||||
trItem = self._getTreeItem(tHandle)
|
trItem = self._getTreeItem(tHandle)
|
||||||
nwItem = self.mainGui.project.tree[tHandle]
|
nwItem = SHARED.project.tree[tHandle]
|
||||||
if trItem is None or nwItem is None:
|
if trItem is None or nwItem is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
itemStatus, statusIcon = nwItem.getImportStatus(incIcon=True)
|
itemStatus, statusIcon = nwItem.getImportStatus(incIcon=True)
|
||||||
hLevel = nwItem.mainHeading
|
hLevel = nwItem.mainHeading
|
||||||
itemIcon = CONFIG.theme.getItemIcon(
|
itemIcon = SHARED.theme.getItemIcon(
|
||||||
nwItem.itemType, nwItem.itemClass, nwItem.itemLayout, hLevel
|
nwItem.itemType, nwItem.itemClass, nwItem.itemLayout, hLevel
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1006,7 +1006,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
else:
|
else:
|
||||||
iconName = "noncheckable"
|
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():
|
if CONFIG.emphLabels and nwItem.isDocumentLayout():
|
||||||
trFont = trItem.font(self.C_NAME)
|
trFont = trItem.font(self.C_NAME)
|
||||||
@@ -1046,10 +1046,10 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
pHandle = pItem.data(self.C_DATA, self.D_HANDLE)
|
pHandle = pItem.data(self.C_DATA, self.D_HANDLE)
|
||||||
|
|
||||||
if pHandle:
|
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
|
# A file has an internal word count we need to account
|
||||||
# for, but a folder always has 0 words on its own.
|
# 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)
|
self.propagateCount(pHandle, pCount, countChildren=False)
|
||||||
|
|
||||||
@@ -1064,7 +1064,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
logger.debug("Building the project tree ...")
|
logger.debug("Building the project tree ...")
|
||||||
self.clearTree()
|
self.clearTree()
|
||||||
count = 0
|
count = 0
|
||||||
for nwItem in self.mainGui.project.getProjectItems():
|
for nwItem in SHARED.project.getProjectItems():
|
||||||
count += 1
|
count += 1
|
||||||
self._addTreeItem(nwItem)
|
self._addTreeItem(nwItem)
|
||||||
if count > 0:
|
if count > 0:
|
||||||
@@ -1177,7 +1177,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
if tHandle is None:
|
if tHandle is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
tItem = self.mainGui.project.tree[tHandle]
|
tItem = SHARED.project.tree[tHandle]
|
||||||
if tItem is None:
|
if tItem is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -1199,7 +1199,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
selItem = self.itemAt(clickPos)
|
selItem = self.itemAt(clickPos)
|
||||||
if isinstance(selItem, QTreeWidgetItem):
|
if isinstance(selItem, QTreeWidgetItem):
|
||||||
tHandle = selItem.data(self.C_DATA, self.D_HANDLE)
|
tHandle = selItem.data(self.C_DATA, self.D_HANDLE)
|
||||||
tItem = self.mainGui.project.tree[tHandle]
|
tItem = SHARED.project.tree[tHandle]
|
||||||
hasChild = selItem.childCount() > 0
|
hasChild = selItem.childCount() > 0
|
||||||
|
|
||||||
if tItem is None or tHandle is None:
|
if tItem is None or tHandle is None:
|
||||||
@@ -1211,7 +1211,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
# Trash Folder
|
# Trash Folder
|
||||||
# ============
|
# ============
|
||||||
|
|
||||||
trashHandle = self.mainGui.project.tree.trashRoot()
|
trashHandle = SHARED.project.tree.trashRoot()
|
||||||
if tItem.itemHandle == trashHandle and trashHandle is not None:
|
if tItem.itemHandle == trashHandle and trashHandle is not None:
|
||||||
# The trash folder only has one option
|
# The trash folder only has one option
|
||||||
aEmptyTrash = ctxMenu.addAction(self.tr("Empty Trash"))
|
aEmptyTrash = ctxMenu.addAction(self.tr("Empty Trash"))
|
||||||
@@ -1250,7 +1250,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
checkMark = f" ({nwUnicode.U_CHECK})"
|
checkMark = f" ({nwUnicode.U_CHECK})"
|
||||||
if tItem.isNovelLike():
|
if tItem.isNovelLike():
|
||||||
mStatus = ctxMenu.addMenu(self.tr("Set Status to ..."))
|
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 "")
|
entryName = entry["name"] + (checkMark if tItem.itemStatus == key else "")
|
||||||
aStatus = mStatus.addAction(entry["icon"], entryName)
|
aStatus = mStatus.addAction(entry["icon"], entryName)
|
||||||
aStatus.triggered.connect(
|
aStatus.triggered.connect(
|
||||||
@@ -1263,7 +1263,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
mImport = ctxMenu.addMenu(self.tr("Set Importance to ..."))
|
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 "")
|
entryName = entry["name"] + (checkMark if tItem.itemImport == key else "")
|
||||||
aImport = mImport.addAction(entry["icon"], entryName)
|
aImport = mImport.addAction(entry["icon"], entryName)
|
||||||
aImport.triggered.connect(
|
aImport.triggered.connect(
|
||||||
@@ -1375,7 +1375,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
return
|
return
|
||||||
|
|
||||||
tHandle = selItem.data(self.C_DATA, self.D_HANDLE)
|
tHandle = selItem.data(self.C_DATA, self.D_HANDLE)
|
||||||
tItem = self.mainGui.project.tree[tHandle]
|
tItem = SHARED.project.tree[tHandle]
|
||||||
if tItem is None:
|
if tItem is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -1419,7 +1419,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
def _postItemMove(self, tHandle: str, wCount: int) -> bool:
|
def _postItemMove(self, tHandle: str, wCount: int) -> bool:
|
||||||
"""Run various maintenance tasks for a moved item."""
|
"""Run various maintenance tasks for a moved item."""
|
||||||
trItemS = self._getTreeItem(tHandle)
|
trItemS = self._getTreeItem(tHandle)
|
||||||
nwItemS = self.mainGui.project.tree[tHandle]
|
nwItemS = SHARED.project.tree[tHandle]
|
||||||
trItemP = trItemS.parent() if trItemS else None
|
trItemP = trItemS.parent() if trItemS else None
|
||||||
if trItemP is None or nwItemS is None:
|
if trItemP is None or nwItemS is None:
|
||||||
logger.error("Failed to find new parent item of '%s'", tHandle)
|
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))
|
logger.debug("A total of %d item(s) were moved", len(mHandles))
|
||||||
for mHandle in mHandles:
|
for mHandle in mHandles:
|
||||||
logger.debug("Updating item '%s'", mHandle)
|
logger.debug("Updating item '%s'", mHandle)
|
||||||
self.mainGui.project.tree.updateItemData(mHandle)
|
SHARED.project.tree.updateItemData(mHandle)
|
||||||
|
|
||||||
# Update the index
|
# Update the index
|
||||||
if nwItemS.isInactiveClass():
|
if nwItemS.isInactiveClass():
|
||||||
self.mainGui.project.index.deleteHandle(mHandle)
|
SHARED.project.index.deleteHandle(mHandle)
|
||||||
else:
|
else:
|
||||||
self.mainGui.project.index.reIndexHandle(mHandle)
|
SHARED.project.index.reIndexHandle(mHandle)
|
||||||
|
|
||||||
self.setTreeItemValues(mHandle)
|
self.setTreeItemValues(mHandle)
|
||||||
|
|
||||||
@@ -1462,7 +1462,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
|
|
||||||
def _toggleItemActive(self, tHandle: str) -> None:
|
def _toggleItemActive(self, tHandle: str) -> None:
|
||||||
"""Toggle the active status of an item."""
|
"""Toggle the active status of an item."""
|
||||||
tItem = self.mainGui.project.tree[tHandle]
|
tItem = SHARED.project.tree[tHandle]
|
||||||
if tItem is not None:
|
if tItem is not None:
|
||||||
tItem.setActive(not tItem.isActive)
|
tItem.setActive(not tItem.isActive)
|
||||||
self.setTreeItemValues(tItem.itemHandle)
|
self.setTreeItemValues(tItem.itemHandle)
|
||||||
@@ -1483,7 +1483,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
|
|
||||||
def _changeItemStatus(self, tHandle: str, tStatus: str) -> None:
|
def _changeItemStatus(self, tHandle: str, tStatus: str) -> None:
|
||||||
"""Set a new status value of an item."""
|
"""Set a new status value of an item."""
|
||||||
tItem = self.mainGui.project.tree[tHandle]
|
tItem = SHARED.project.tree[tHandle]
|
||||||
if tItem is not None:
|
if tItem is not None:
|
||||||
tItem.setStatus(tStatus)
|
tItem.setStatus(tStatus)
|
||||||
self.setTreeItemValues(tItem.itemHandle)
|
self.setTreeItemValues(tItem.itemHandle)
|
||||||
@@ -1492,7 +1492,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
|
|
||||||
def _changeItemImport(self, tHandle: str, tImport: str) -> None:
|
def _changeItemImport(self, tHandle: str, tImport: str) -> None:
|
||||||
"""Set a new importance value of an item."""
|
"""Set a new importance value of an item."""
|
||||||
tItem = self.mainGui.project.tree[tHandle]
|
tItem = SHARED.project.tree[tHandle]
|
||||||
if tItem is not None:
|
if tItem is not None:
|
||||||
tItem.setImport(tImport)
|
tItem.setImport(tImport)
|
||||||
self.setTreeItemValues(tItem.itemHandle)
|
self.setTreeItemValues(tItem.itemHandle)
|
||||||
@@ -1501,7 +1501,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
|
|
||||||
def _changeItemLayout(self, tHandle: str, itemLayout: nwItemLayout) -> None:
|
def _changeItemLayout(self, tHandle: str, itemLayout: nwItemLayout) -> None:
|
||||||
"""Set a new item layout value of an item."""
|
"""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 tItem is not None:
|
||||||
if itemLayout == nwItemLayout.DOCUMENT and tItem.documentAllowed():
|
if itemLayout == nwItemLayout.DOCUMENT and tItem.documentAllowed():
|
||||||
tItem.setLayout(nwItemLayout.DOCUMENT)
|
tItem.setLayout(nwItemLayout.DOCUMENT)
|
||||||
@@ -1515,7 +1515,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
|
|
||||||
def _covertFolderToFile(self, tHandle: str, itemLayout: nwItemLayout) -> None:
|
def _covertFolderToFile(self, tHandle: str, itemLayout: nwItemLayout) -> None:
|
||||||
"""Convert a folder to a note or document."""
|
"""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():
|
if tItem is not None and tItem.isFolderType():
|
||||||
msgYes = self.mainGui.askQuestion(self.tr(
|
msgYes = self.mainGui.askQuestion(self.tr(
|
||||||
"Do you want to convert the folder to a {0}? "
|
"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)
|
logger.info("Request to merge items under handle '%s'", tHandle)
|
||||||
itemList = self.getTreeFromHandle(tHandle)
|
itemList = self.getTreeFromHandle(tHandle)
|
||||||
|
|
||||||
tItem = self.mainGui.project.tree[tHandle]
|
tItem = SHARED.project.tree[tHandle]
|
||||||
if tItem is None:
|
if tItem is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -1566,7 +1566,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
self.mainGui.saveDocument()
|
self.mainGui.saveDocument()
|
||||||
|
|
||||||
# Create merge object, and append docs
|
# Create merge object, and append docs
|
||||||
docMerger = DocMerger(self.mainGui.project)
|
docMerger = DocMerger(SHARED.project)
|
||||||
mLabel = self.tr("Merged")
|
mLabel = self.tr("Merged")
|
||||||
|
|
||||||
if newFile:
|
if newFile:
|
||||||
@@ -1588,7 +1588,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self.mainGui.project.index.reIndexHandle(mHandle)
|
SHARED.project.index.reIndexHandle(mHandle)
|
||||||
if newFile:
|
if newFile:
|
||||||
self.revealNewTreeItem(mHandle, nHandle=tHandle, wordCount=True)
|
self.revealNewTreeItem(mHandle, nHandle=tHandle, wordCount=True)
|
||||||
|
|
||||||
@@ -1613,7 +1613,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
"""Split a document into multiple documents."""
|
"""Split a document into multiple documents."""
|
||||||
logger.info("Request to split items with handle '%s'", tHandle)
|
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:
|
if tItem is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -1632,7 +1632,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
intoFolder = splitData.get("intoFolder", False)
|
intoFolder = splitData.get("intoFolder", False)
|
||||||
docHierarchy = splitData.get("docHierarchy", False)
|
docHierarchy = splitData.get("docHierarchy", False)
|
||||||
|
|
||||||
docSplit = DocSplitter(self.mainGui.project, tHandle)
|
docSplit = DocSplitter(SHARED.project, tHandle)
|
||||||
if intoFolder:
|
if intoFolder:
|
||||||
fHandle = docSplit.newParentFolder(tItem.itemParent, tItem.itemName)
|
fHandle = docSplit.newParentFolder(tItem.itemParent, tItem.itemName)
|
||||||
self.revealNewTreeItem(fHandle, nHandle=tHandle)
|
self.revealNewTreeItem(fHandle, nHandle=tHandle)
|
||||||
@@ -1642,7 +1642,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
|
|
||||||
docSplit.splitDocument(headerList, splitText)
|
docSplit.splitDocument(headerList, splitText)
|
||||||
for writeOk, dHandle, nHandle in docSplit.writeDocuments(docHierarchy):
|
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.revealNewTreeItem(dHandle, nHandle=nHandle, wordCount=True)
|
||||||
self._alertTreeChange(dHandle, flush=False)
|
self._alertTreeChange(dHandle, flush=False)
|
||||||
if not writeOk:
|
if not writeOk:
|
||||||
@@ -1676,10 +1676,10 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
if not self.mainGui.askQuestion(question):
|
if not self.mainGui.askQuestion(question):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
docDup = DocDuplicator(self.mainGui.project)
|
docDup = DocDuplicator(SHARED.project)
|
||||||
dupCount = 0
|
dupCount = 0
|
||||||
for dHandle, nHandle in docDup.duplicate(itemTree):
|
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.revealNewTreeItem(dHandle, nHandle=nHandle, wordCount=True)
|
||||||
self._alertTreeChange(dHandle, flush=False)
|
self._alertTreeChange(dHandle, flush=False)
|
||||||
dupCount += 1
|
dupCount += 1
|
||||||
@@ -1699,7 +1699,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
cCount = tItem.childCount()
|
cCount = tItem.childCount()
|
||||||
|
|
||||||
# Update tree-related meta data
|
# Update tree-related meta data
|
||||||
nwItem = self.mainGui.project.tree[tHandle]
|
nwItem = SHARED.project.tree[tHandle]
|
||||||
if nwItem is not None:
|
if nwItem is not None:
|
||||||
nwItem.setExpanded(tItem.isExpanded() and cCount > 0)
|
nwItem.setExpanded(tItem.isExpanded() and cCount > 0)
|
||||||
nwItem.setOrder(tIndex)
|
nwItem.setOrder(tIndex)
|
||||||
@@ -1766,13 +1766,13 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
"""Adds the trash root folder if it doesn't already exist in the
|
"""Adds the trash root folder if it doesn't already exist in the
|
||||||
project tree.
|
project tree.
|
||||||
"""
|
"""
|
||||||
trashHandle = self.mainGui.project.trashFolder()
|
trashHandle = SHARED.project.trashFolder()
|
||||||
if trashHandle is None:
|
if trashHandle is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
trItem = self._getTreeItem(trashHandle)
|
trItem = self._getTreeItem(trashHandle)
|
||||||
if trItem is None:
|
if trItem is None:
|
||||||
trItem = self._addTreeItem(self.mainGui.project.tree[trashHandle])
|
trItem = self._addTreeItem(SHARED.project.tree[trashHandle])
|
||||||
if trItem is not None:
|
if trItem is not None:
|
||||||
trItem.setExpanded(True)
|
trItem.setExpanded(True)
|
||||||
self._alertTreeChange(trashHandle, flush=True)
|
self._alertTreeChange(trashHandle, flush=True)
|
||||||
@@ -1785,14 +1785,14 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
deleted.
|
deleted.
|
||||||
"""
|
"""
|
||||||
self._timeChanged = time()
|
self._timeChanged = time()
|
||||||
self.mainGui.project.setProjectChanged(True)
|
SHARED.project.setProjectChanged(True)
|
||||||
if flush:
|
if flush:
|
||||||
self.saveTreeOrder()
|
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
|
return
|
||||||
|
|
||||||
tItem = self.mainGui.project.tree[tHandle]
|
tItem = SHARED.project.tree[tHandle]
|
||||||
if tItem and tItem.isRootType():
|
if tItem and tItem.isRootType():
|
||||||
self.projView.rootFolderChanged.emit(tHandle)
|
self.projView.rootFolderChanged.emit(tHandle)
|
||||||
|
|
||||||
|
|||||||
+10
-10
@@ -30,7 +30,7 @@ from PyQt5.QtWidgets import (
|
|||||||
QToolBar, QWidget, QSizePolicy, QAction, QMenu, QToolButton
|
QToolBar, QWidget, QSizePolicy, QAction, QMenu, QToolButton
|
||||||
)
|
)
|
||||||
|
|
||||||
from novelwriter import CONFIG
|
from novelwriter import CONFIG, SHARED
|
||||||
from novelwriter.enum import nwView
|
from novelwriter.enum import nwView
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -51,8 +51,8 @@ class GuiSideBar(QToolBar):
|
|||||||
iPx = CONFIG.pxInt(22)
|
iPx = CONFIG.pxInt(22)
|
||||||
mPx = CONFIG.pxInt(60)
|
mPx = CONFIG.pxInt(60)
|
||||||
|
|
||||||
lblFont = CONFIG.theme.guiFont
|
lblFont = SHARED.theme.guiFont
|
||||||
lblFont.setPointSizeF(0.65*CONFIG.theme.fontPointSize)
|
lblFont.setPointSizeF(0.65*SHARED.theme.fontPointSize)
|
||||||
|
|
||||||
self.setMovable(False)
|
self.setMovable(False)
|
||||||
self.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
|
self.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
|
||||||
@@ -130,13 +130,13 @@ class GuiSideBar(QToolBar):
|
|||||||
"""
|
"""
|
||||||
self.setStyleSheet("QToolBar {border: 0px;}")
|
self.setStyleSheet("QToolBar {border: 0px;}")
|
||||||
|
|
||||||
self.aProject.setIcon(CONFIG.theme.getIcon("view_editor"))
|
self.aProject.setIcon(SHARED.theme.getIcon("view_editor"))
|
||||||
self.aNovel.setIcon(CONFIG.theme.getIcon("view_novel"))
|
self.aNovel.setIcon(SHARED.theme.getIcon("view_novel"))
|
||||||
self.aOutline.setIcon(CONFIG.theme.getIcon("view_outline"))
|
self.aOutline.setIcon(SHARED.theme.getIcon("view_outline"))
|
||||||
self.aBuild.setIcon(CONFIG.theme.getIcon("view_build"))
|
self.aBuild.setIcon(SHARED.theme.getIcon("view_build"))
|
||||||
self.aDetails.setIcon(CONFIG.theme.getIcon("proj_details"))
|
self.aDetails.setIcon(SHARED.theme.getIcon("proj_details"))
|
||||||
self.aStats.setIcon(CONFIG.theme.getIcon("proj_stats"))
|
self.aStats.setIcon(SHARED.theme.getIcon("proj_stats"))
|
||||||
self.tbSettings.setIcon(CONFIG.theme.getIcon("settings"))
|
self.tbSettings.setIcon(SHARED.theme.getIcon("settings"))
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ from PyQt5.QtCore import pyqtSlot, QLocale
|
|||||||
from PyQt5.QtGui import QColor
|
from PyQt5.QtGui import QColor
|
||||||
from PyQt5.QtWidgets import qApp, QStatusBar, QLabel
|
from PyQt5.QtWidgets import qApp, QStatusBar, QLabel
|
||||||
|
|
||||||
from novelwriter import CONFIG
|
from novelwriter import CONFIG, SHARED
|
||||||
from novelwriter.common import formatTime
|
from novelwriter.common import formatTime
|
||||||
from novelwriter.extensions.statusled import StatusLED
|
from novelwriter.extensions.statusled import StatusLED
|
||||||
|
|
||||||
@@ -50,11 +50,11 @@ class GuiMainStatus(QStatusBar):
|
|||||||
self.refTime = None
|
self.refTime = None
|
||||||
self.userIdle = False
|
self.userIdle = False
|
||||||
|
|
||||||
colNone = QColor(*CONFIG.theme.statNone)
|
colNone = QColor(*SHARED.theme.statNone)
|
||||||
colSaved = QColor(*CONFIG.theme.statSaved)
|
colSaved = QColor(*SHARED.theme.statSaved)
|
||||||
colUnsaved = QColor(*CONFIG.theme.statUnsaved)
|
colUnsaved = QColor(*SHARED.theme.statUnsaved)
|
||||||
|
|
||||||
iPx = CONFIG.theme.baseIconSize
|
iPx = SHARED.theme.baseIconSize
|
||||||
|
|
||||||
# Permanent Widgets
|
# Permanent Widgets
|
||||||
# =================
|
# =================
|
||||||
@@ -98,7 +98,7 @@ class GuiMainStatus(QStatusBar):
|
|||||||
self.timeIcon = QLabel()
|
self.timeIcon = QLabel()
|
||||||
self.timeText = QLabel("")
|
self.timeText = QLabel("")
|
||||||
self.timeText.setToolTip(self.tr("Session Time"))
|
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.timeIcon.setContentsMargins(0, 0, 0, 0)
|
||||||
self.timeText.setContentsMargins(0, 0, 0, 0)
|
self.timeText.setContentsMargins(0, 0, 0, 0)
|
||||||
self.addPermanentWidget(self.timeIcon)
|
self.addPermanentWidget(self.timeIcon)
|
||||||
@@ -128,13 +128,13 @@ class GuiMainStatus(QStatusBar):
|
|||||||
def updateTheme(self):
|
def updateTheme(self):
|
||||||
"""Update theme elements.
|
"""Update theme elements.
|
||||||
"""
|
"""
|
||||||
iPx = CONFIG.theme.baseIconSize
|
iPx = SHARED.theme.baseIconSize
|
||||||
|
|
||||||
self.langIcon.setPixmap(CONFIG.theme.getPixmap("status_lang", (iPx, iPx)))
|
self.langIcon.setPixmap(SHARED.theme.getPixmap("status_lang", (iPx, iPx)))
|
||||||
self.statsIcon.setPixmap(CONFIG.theme.getPixmap("status_stats", (iPx, iPx)))
|
self.statsIcon.setPixmap(SHARED.theme.getPixmap("status_stats", (iPx, iPx)))
|
||||||
|
|
||||||
self.timePixmap = CONFIG.theme.getPixmap("status_time", (iPx, iPx))
|
self.timePixmap = SHARED.theme.getPixmap("status_time", (iPx, iPx))
|
||||||
self.idlePixmap = CONFIG.theme.getPixmap("status_idle", (iPx, iPx))
|
self.idlePixmap = SHARED.theme.getPixmap("status_idle", (iPx, iPx))
|
||||||
|
|
||||||
self.timeIcon.setPixmap(self.timePixmap)
|
self.timeIcon.setPixmap(self.timePixmap)
|
||||||
|
|
||||||
|
|||||||
+45
-46
@@ -37,7 +37,7 @@ from PyQt5.QtWidgets import (
|
|||||||
QStackedWidget, QVBoxLayout, QWidget
|
QStackedWidget, QVBoxLayout, QWidget
|
||||||
)
|
)
|
||||||
|
|
||||||
from novelwriter import CONFIG, __hexversion__
|
from novelwriter import CONFIG, SHARED, __hexversion__
|
||||||
from novelwriter.gui.theme import GuiTheme
|
from novelwriter.gui.theme import GuiTheme
|
||||||
from novelwriter.gui.sidebar import GuiSideBar
|
from novelwriter.gui.sidebar import GuiSideBar
|
||||||
from novelwriter.gui.outline import GuiOutlineView
|
from novelwriter.gui.outline import GuiOutlineView
|
||||||
@@ -112,9 +112,8 @@ class GuiMain(QMainWindow):
|
|||||||
# Core Classes
|
# Core Classes
|
||||||
# ============
|
# ============
|
||||||
|
|
||||||
# Core Classes
|
# Initialise UserData Instance
|
||||||
CONFIG.setThemeInstance(GuiTheme())
|
SHARED.initSharedData(self, GuiTheme())
|
||||||
self._project = NWProject(self)
|
|
||||||
|
|
||||||
# Core Settings
|
# Core Settings
|
||||||
self.hasProject = False
|
self.hasProject = False
|
||||||
@@ -135,7 +134,7 @@ class GuiMain(QMainWindow):
|
|||||||
# =============
|
# =============
|
||||||
|
|
||||||
# Sizes
|
# Sizes
|
||||||
iPx = CONFIG.theme.fontPixelSize
|
iPx = SHARED.theme.fontPixelSize
|
||||||
mPx = CONFIG.pxInt(4)
|
mPx = CONFIG.pxInt(4)
|
||||||
hWd = CONFIG.pxInt(4)
|
hWd = CONFIG.pxInt(4)
|
||||||
|
|
||||||
@@ -238,7 +237,7 @@ class GuiMain(QMainWindow):
|
|||||||
# Connect Signals
|
# Connect Signals
|
||||||
# ===============
|
# ===============
|
||||||
|
|
||||||
self._project.projectStatusChanged.connect(self.mainStatus.doUpdateProjectStatus)
|
SHARED.project.projectStatusChanged.connect(self.mainStatus.doUpdateProjectStatus)
|
||||||
|
|
||||||
self.viewsBar.viewChangeRequested.connect(self._changeView)
|
self.viewsBar.viewChangeRequested.connect(self._changeView)
|
||||||
|
|
||||||
@@ -307,10 +306,10 @@ class GuiMain(QMainWindow):
|
|||||||
# Cache Alert Pixmaps
|
# Cache Alert Pixmaps
|
||||||
pxSize = (2*iPx, 2*iPx)
|
pxSize = (2*iPx, 2*iPx)
|
||||||
self.alertPix: dict[nwAlert, QPixmap] = {
|
self.alertPix: dict[nwAlert, QPixmap] = {
|
||||||
nwAlert.INFO: CONFIG.theme.getPixmap("alert_info", pxSize),
|
nwAlert.INFO: SHARED.theme.getPixmap("alert_info", pxSize),
|
||||||
nwAlert.WARN: CONFIG.theme.getPixmap("alert_warn", pxSize),
|
nwAlert.WARN: SHARED.theme.getPixmap("alert_warn", pxSize),
|
||||||
nwAlert.ERROR: CONFIG.theme.getPixmap("alert_error", pxSize),
|
nwAlert.ERROR: SHARED.theme.getPixmap("alert_error", pxSize),
|
||||||
nwAlert.ASK: CONFIG.theme.getPixmap("alert_question", pxSize),
|
nwAlert.ASK: SHARED.theme.getPixmap("alert_question", pxSize),
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check that config loaded fine
|
# Check that config loaded fine
|
||||||
@@ -389,7 +388,7 @@ class GuiMain(QMainWindow):
|
|||||||
@property
|
@property
|
||||||
def project(self) -> NWProject:
|
def project(self) -> NWProject:
|
||||||
"""The project instance."""
|
"""The project instance."""
|
||||||
return self._project
|
return SHARED.project
|
||||||
|
|
||||||
##
|
##
|
||||||
# Project Actions
|
# Project Actions
|
||||||
@@ -453,7 +452,7 @@ class GuiMain(QMainWindow):
|
|||||||
|
|
||||||
saveOK = self.saveProject()
|
saveOK = self.saveProject()
|
||||||
doBackup = False
|
doBackup = False
|
||||||
if self._project.data.doBackup and CONFIG.backupOnClose:
|
if SHARED.project.data.doBackup and CONFIG.backupOnClose:
|
||||||
doBackup = True
|
doBackup = True
|
||||||
if CONFIG.askBeforeBackup:
|
if CONFIG.askBeforeBackup:
|
||||||
msgYes = self.askQuestion(self.tr("Backup the current project?"))
|
msgYes = self.askQuestion(self.tr("Backup the current project?"))
|
||||||
@@ -461,7 +460,7 @@ class GuiMain(QMainWindow):
|
|||||||
doBackup = False
|
doBackup = False
|
||||||
|
|
||||||
if doBackup:
|
if doBackup:
|
||||||
self._project.backupProject(False)
|
SHARED.project.backupProject(False)
|
||||||
|
|
||||||
if saveOK:
|
if saveOK:
|
||||||
self.closeDocument()
|
self.closeDocument()
|
||||||
@@ -469,7 +468,7 @@ class GuiMain(QMainWindow):
|
|||||||
self.outlineView.closeProjectTasks()
|
self.outlineView.closeProjectTasks()
|
||||||
self.novelView.closeProjectTasks()
|
self.novelView.closeProjectTasks()
|
||||||
|
|
||||||
self._project.closeProject(self.idleTime)
|
SHARED.project.closeProject(self.idleTime)
|
||||||
self.idleRefTime = time()
|
self.idleRefTime = time()
|
||||||
self.idleTime = 0.0
|
self.idleTime = 0.0
|
||||||
|
|
||||||
@@ -493,9 +492,9 @@ class GuiMain(QMainWindow):
|
|||||||
self._changeView(nwView.PROJECT)
|
self._changeView(nwView.PROJECT)
|
||||||
|
|
||||||
# Try to open the project
|
# Try to open the project
|
||||||
if not self._project.openProject(projFile):
|
if not SHARED.project.openProject(projFile):
|
||||||
# The project open failed.
|
# The project open failed.
|
||||||
lockStatus = self._project.getLockStatus()
|
lockStatus = SHARED.project.getLockStatus()
|
||||||
if lockStatus is None:
|
if lockStatus is None:
|
||||||
# The project is not locked, so failed for some other
|
# The project is not locked, so failed for some other
|
||||||
# reason handled by the project class.
|
# reason handled by the project class.
|
||||||
@@ -525,7 +524,7 @@ class GuiMain(QMainWindow):
|
|||||||
lockDetails = ""
|
lockDetails = ""
|
||||||
|
|
||||||
if self.askQuestion(lockText, info=lockInfo, details=lockDetails, level=nwAlert.WARN):
|
if self.askQuestion(lockText, info=lockInfo, details=lockDetails, level=nwAlert.WARN):
|
||||||
if not self._project.openProject(projFile, overrideLock=True):
|
if not SHARED.project.openProject(projFile, overrideLock=True):
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
@@ -536,11 +535,11 @@ class GuiMain(QMainWindow):
|
|||||||
self.idleTime = 0.0
|
self.idleTime = 0.0
|
||||||
|
|
||||||
# Update GUI
|
# Update GUI
|
||||||
self._updateWindowTitle(self._project.data.name)
|
self._updateWindowTitle(SHARED.project.data.name)
|
||||||
self.rebuildTrees()
|
self.rebuildTrees()
|
||||||
self.docEditor.setDictionaries()
|
self.docEditor.setDictionaries()
|
||||||
self.docEditor.toggleSpellCheck(self._project.data.spellCheck)
|
self.docEditor.toggleSpellCheck(SHARED.project.data.spellCheck)
|
||||||
self.mainStatus.setRefTime(self._project.projOpened)
|
self.mainStatus.setRefTime(SHARED.project.projOpened)
|
||||||
self.projView.openProjectTasks()
|
self.projView.openProjectTasks()
|
||||||
self.novelView.openProjectTasks()
|
self.novelView.openProjectTasks()
|
||||||
self.outlineView.openProjectTasks()
|
self.outlineView.openProjectTasks()
|
||||||
@@ -548,9 +547,9 @@ class GuiMain(QMainWindow):
|
|||||||
|
|
||||||
# Restore previously open documents, if any
|
# Restore previously open documents, if any
|
||||||
# If none was recorded, open the first document found
|
# If none was recorded, open the first document found
|
||||||
lastEdited = self._project.data.getLastHandle("editor")
|
lastEdited = SHARED.project.data.getLastHandle("editor")
|
||||||
if lastEdited is None:
|
if lastEdited is None:
|
||||||
for nwItem in self._project.tree:
|
for nwItem in SHARED.project.tree:
|
||||||
if nwItem and nwItem.isFileType():
|
if nwItem and nwItem.isFileType():
|
||||||
lastEdited = nwItem.itemHandle
|
lastEdited = nwItem.itemHandle
|
||||||
break
|
break
|
||||||
@@ -558,19 +557,19 @@ class GuiMain(QMainWindow):
|
|||||||
if lastEdited is not None:
|
if lastEdited is not None:
|
||||||
self.openDocument(lastEdited, doScroll=True)
|
self.openDocument(lastEdited, doScroll=True)
|
||||||
|
|
||||||
lastViewed = self._project.data.getLastHandle("viewer")
|
lastViewed = SHARED.project.data.getLastHandle("viewer")
|
||||||
if lastViewed is not None:
|
if lastViewed is not None:
|
||||||
self.viewDocument(lastViewed)
|
self.viewDocument(lastViewed)
|
||||||
|
|
||||||
# Check if we need to rebuild the index
|
# Check if we need to rebuild the index
|
||||||
if self._project.index.indexBroken:
|
if SHARED.project.index.indexBroken:
|
||||||
self.makeAlert(self.tr("The project index is outdated or broken. Rebuilding index."))
|
self.makeAlert(self.tr("The project index is outdated or broken. Rebuilding index."))
|
||||||
self.rebuildIndex()
|
self.rebuildIndex()
|
||||||
|
|
||||||
# Make sure the changed status is set to false on things opened
|
# Make sure the changed status is set to false on things opened
|
||||||
qApp.processEvents()
|
qApp.processEvents()
|
||||||
self.docEditor.setDocumentChanged(False)
|
self.docEditor.setDocumentChanged(False)
|
||||||
self._project.setProjectChanged(False)
|
SHARED.project.setProjectChanged(False)
|
||||||
|
|
||||||
logger.debug("Project load complete")
|
logger.debug("Project load complete")
|
||||||
|
|
||||||
@@ -582,7 +581,7 @@ class GuiMain(QMainWindow):
|
|||||||
logger.error("No project open")
|
logger.error("No project open")
|
||||||
return False
|
return False
|
||||||
self.projView.saveProjectTasks()
|
self.projView.saveProjectTasks()
|
||||||
self._project.saveProject(autoSave=autoSave)
|
SHARED.project.saveProject(autoSave=autoSave)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
##
|
##
|
||||||
@@ -615,7 +614,7 @@ class GuiMain(QMainWindow):
|
|||||||
logger.error("No project open")
|
logger.error("No project open")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if not tHandle or not self._project.tree.checkType(tHandle, nwItemType.FILE):
|
if not tHandle or not SHARED.project.tree.checkType(tHandle, nwItemType.FILE):
|
||||||
logger.debug("Requested item '%s' is not a document", tHandle)
|
logger.debug("Requested item '%s' is not a document", tHandle)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -629,7 +628,7 @@ class GuiMain(QMainWindow):
|
|||||||
|
|
||||||
self.closeDocument(beforeOpen=True)
|
self.closeDocument(beforeOpen=True)
|
||||||
if self.docEditor.loadText(tHandle, tLine):
|
if self.docEditor.loadText(tHandle, tLine):
|
||||||
self._project.data.setLastHandle(tHandle, "editor")
|
SHARED.project.data.setLastHandle(tHandle, "editor")
|
||||||
self.projView.setSelectedHandle(tHandle, doScroll=doScroll)
|
self.projView.setSelectedHandle(tHandle, doScroll=doScroll)
|
||||||
self.novelView.setActiveHandle(tHandle)
|
self.novelView.setActiveHandle(tHandle)
|
||||||
if changeFocus:
|
if changeFocus:
|
||||||
@@ -650,7 +649,7 @@ class GuiMain(QMainWindow):
|
|||||||
nHandle = None # The next handle after tHandle
|
nHandle = None # The next handle after tHandle
|
||||||
fHandle = None # The first file handle we encounter
|
fHandle = None # The first file handle we encounter
|
||||||
foundIt = False # We've found tHandle, pick the next we see
|
foundIt = False # We've found tHandle, pick the next we see
|
||||||
for tItem in self._project.tree:
|
for tItem in SHARED.project.tree:
|
||||||
if not tItem.isFileType():
|
if not tItem.isFileType():
|
||||||
continue
|
continue
|
||||||
if fHandle is None:
|
if fHandle is None:
|
||||||
@@ -696,7 +695,7 @@ class GuiMain(QMainWindow):
|
|||||||
tHandle = self.projView.getSelectedHandle()
|
tHandle = self.projView.getSelectedHandle()
|
||||||
|
|
||||||
if tHandle is None:
|
if tHandle is None:
|
||||||
tHandle = self._project.data.getLastHandle("viewer")
|
tHandle = SHARED.project.data.getLastHandle("viewer")
|
||||||
|
|
||||||
if tHandle is None:
|
if tHandle is None:
|
||||||
logger.debug("No document to view, giving up")
|
logger.debug("No document to view, giving up")
|
||||||
@@ -815,7 +814,7 @@ class GuiMain(QMainWindow):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
if tHandle is not None and sTitle is not None:
|
if tHandle is not None and sTitle is not None:
|
||||||
hItem = self._project.index.getItemHeader(tHandle, sTitle)
|
hItem = SHARED.project.index.getItemHeader(tHandle, sTitle)
|
||||||
if hItem is not None:
|
if hItem is not None:
|
||||||
tLine = hItem.line
|
tLine = hItem.line
|
||||||
|
|
||||||
@@ -852,7 +851,7 @@ class GuiMain(QMainWindow):
|
|||||||
tStart = time()
|
tStart = time()
|
||||||
|
|
||||||
self.projView.saveProjectTasks()
|
self.projView.saveProjectTasks()
|
||||||
self._project.index.rebuildIndex()
|
SHARED.project.index.rebuildIndex()
|
||||||
self.projView.populateTree()
|
self.projView.populateTree()
|
||||||
self.novelView.refreshTree()
|
self.novelView.refreshTree()
|
||||||
|
|
||||||
@@ -921,7 +920,7 @@ class GuiMain(QMainWindow):
|
|||||||
if dlgConf.updateTheme:
|
if dlgConf.updateTheme:
|
||||||
# We are doing this manually instead of connecting to
|
# We are doing this manually instead of connecting to
|
||||||
# qApp.paletteChanged since the processing order matters
|
# qApp.paletteChanged since the processing order matters
|
||||||
CONFIG.theme.loadTheme()
|
SHARED.theme.loadTheme()
|
||||||
self.docEditor.updateTheme()
|
self.docEditor.updateTheme()
|
||||||
self.docViewer.updateTheme()
|
self.docViewer.updateTheme()
|
||||||
self.viewsBar.updateTheme()
|
self.viewsBar.updateTheme()
|
||||||
@@ -932,7 +931,7 @@ class GuiMain(QMainWindow):
|
|||||||
self.mainStatus.updateTheme()
|
self.mainStatus.updateTheme()
|
||||||
|
|
||||||
if dlgConf.updateSyntax:
|
if dlgConf.updateSyntax:
|
||||||
CONFIG.theme.loadSyntax()
|
SHARED.theme.loadSyntax()
|
||||||
self.docEditor.updateSyntaxColours()
|
self.docEditor.updateSyntaxColours()
|
||||||
|
|
||||||
self.docEditor.initEditor()
|
self.docEditor.initEditor()
|
||||||
@@ -960,7 +959,7 @@ class GuiMain(QMainWindow):
|
|||||||
if dlgProj.spellChanged:
|
if dlgProj.spellChanged:
|
||||||
self.docEditor.setDictionaries()
|
self.docEditor.setDictionaries()
|
||||||
self.itemDetails.refreshDetails()
|
self.itemDetails.refreshDetails()
|
||||||
self._updateWindowTitle(self._project.data.name)
|
self._updateWindowTitle(SHARED.project.data.name)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -1206,7 +1205,7 @@ class GuiMain(QMainWindow):
|
|||||||
def closeDocEditor(self) -> None:
|
def closeDocEditor(self) -> None:
|
||||||
"""Close the document editor. This does not hide the editor."""
|
"""Close the document editor. This does not hide the editor."""
|
||||||
self.closeDocument()
|
self.closeDocument()
|
||||||
self._project.data.setLastHandle(None, "editor")
|
SHARED.project.data.setLastHandle(None, "editor")
|
||||||
return
|
return
|
||||||
|
|
||||||
def closeDocViewer(self, byUser: bool = True) -> bool:
|
def closeDocViewer(self, byUser: bool = True) -> bool:
|
||||||
@@ -1214,7 +1213,7 @@ class GuiMain(QMainWindow):
|
|||||||
self.docViewer.clearViewer()
|
self.docViewer.clearViewer()
|
||||||
if byUser:
|
if byUser:
|
||||||
# Only reset the last handle if the user called this
|
# Only reset the last handle if the user called this
|
||||||
self._project.data.setLastHandle(None, "viewer")
|
SHARED.project.data.setLastHandle(None, "viewer")
|
||||||
|
|
||||||
# Hide the panel
|
# Hide the panel
|
||||||
bPos = self.splitMain.sizes()
|
bPos = self.splitMain.sizes()
|
||||||
@@ -1400,7 +1399,7 @@ class GuiMain(QMainWindow):
|
|||||||
"""Handle the index lookup of a tag and display an alert if the
|
"""Handle the index lookup of a tag and display an alert if the
|
||||||
tag cannot be found.
|
tag cannot be found.
|
||||||
"""
|
"""
|
||||||
tHandle, sTitle = self._project.index.getTagSource(tag)
|
tHandle, sTitle = SHARED.project.index.getTagSource(tag)
|
||||||
if tHandle is None:
|
if tHandle is None:
|
||||||
self.makeAlert(self.tr(
|
self.makeAlert(self.tr(
|
||||||
"Could not find the reference for tag '{0}'. It either doesn't "
|
"Could not find the reference for tag '{0}'. It either doesn't "
|
||||||
@@ -1447,7 +1446,7 @@ class GuiMain(QMainWindow):
|
|||||||
if tHandle is not None:
|
if tHandle is not None:
|
||||||
if mode == nwDocMode.EDIT:
|
if mode == nwDocMode.EDIT:
|
||||||
tLine = None
|
tLine = None
|
||||||
hItem = self._project.index.getItemHeader(tHandle, sTitle)
|
hItem = SHARED.project.index.getItemHeader(tHandle, sTitle)
|
||||||
if hItem is not None:
|
if hItem is not None:
|
||||||
tLine = hItem.line
|
tLine = hItem.line
|
||||||
self.openDocument(tHandle, tLine=tLine, changeFocus=setFocus)
|
self.openDocument(tHandle, tLine=tLine, changeFocus=setFocus)
|
||||||
@@ -1500,8 +1499,8 @@ class GuiMain(QMainWindow):
|
|||||||
def _autoSaveProject(self) -> None:
|
def _autoSaveProject(self) -> None:
|
||||||
"""Autosave of the project. This is a timer-activated slot."""
|
"""Autosave of the project. This is a timer-activated slot."""
|
||||||
doSave = self.hasProject
|
doSave = self.hasProject
|
||||||
doSave &= self._project.projChanged
|
doSave &= SHARED.project.projChanged
|
||||||
doSave &= self._project.storage.isOpen()
|
doSave &= SHARED.project.storage.isOpen()
|
||||||
if doSave:
|
if doSave:
|
||||||
logger.debug("Autosaving project")
|
logger.debug("Autosaving project")
|
||||||
self.saveProject(autoSave=True)
|
self.saveProject(autoSave=True)
|
||||||
@@ -1521,14 +1520,14 @@ class GuiMain(QMainWindow):
|
|||||||
if not self.hasProject:
|
if not self.hasProject:
|
||||||
self.mainStatus.setProjectStats(0, 0)
|
self.mainStatus.setProjectStats(0, 0)
|
||||||
|
|
||||||
self._project.updateWordCounts()
|
SHARED.project.updateWordCounts()
|
||||||
if CONFIG.incNotesWCount:
|
if CONFIG.incNotesWCount:
|
||||||
iTotal = sum(self._project.data.initCounts)
|
iTotal = sum(SHARED.project.data.initCounts)
|
||||||
cTotal = sum(self._project.data.currCounts)
|
cTotal = sum(SHARED.project.data.currCounts)
|
||||||
self.mainStatus.setProjectStats(cTotal, cTotal - iTotal)
|
self.mainStatus.setProjectStats(cTotal, cTotal - iTotal)
|
||||||
else:
|
else:
|
||||||
iNovel, _ = self._project.data.initCounts
|
iNovel, _ = SHARED.project.data.initCounts
|
||||||
cNovel, _ = self._project.data.currCounts
|
cNovel, _ = SHARED.project.data.currCounts
|
||||||
self.mainStatus.setProjectStats(cNovel, cNovel - iNovel)
|
self.mainStatus.setProjectStats(cNovel, cNovel - iNovel)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ from PyQt5.QtWidgets import (
|
|||||||
QSpinBox
|
QSpinBox
|
||||||
)
|
)
|
||||||
|
|
||||||
from novelwriter import CONFIG
|
from novelwriter import CONFIG, SHARED
|
||||||
from novelwriter.common import readTextFile
|
from novelwriter.common import readTextFile
|
||||||
from novelwriter.extensions.switch import NSwitch
|
from novelwriter.extensions.switch import NSwitch
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ class GuiLipsum(QDialog):
|
|||||||
nPx = CONFIG.pxInt(64)
|
nPx = CONFIG.pxInt(64)
|
||||||
vSp = CONFIG.pxInt(4)
|
vSp = CONFIG.pxInt(4)
|
||||||
self.docIcon = QLabel()
|
self.docIcon = QLabel()
|
||||||
self.docIcon.setPixmap(CONFIG.theme.getPixmap("proj_document", (nPx, nPx)))
|
self.docIcon.setPixmap(SHARED.theme.getPixmap("proj_document", (nPx, nPx)))
|
||||||
|
|
||||||
self.leftBox = QVBoxLayout()
|
self.leftBox = QVBoxLayout()
|
||||||
self.leftBox.setSpacing(vSp)
|
self.leftBox.setSpacing(vSp)
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ from PyQt5.QtWidgets import (
|
|||||||
QPushButton, QSplitter, QVBoxLayout, QWidget
|
QPushButton, QSplitter, QVBoxLayout, QWidget
|
||||||
)
|
)
|
||||||
|
|
||||||
from novelwriter import CONFIG
|
from novelwriter import CONFIG, SHARED
|
||||||
from novelwriter.enum import nwAlert, nwBuildFmt
|
from novelwriter.enum import nwAlert, nwBuildFmt
|
||||||
from novelwriter.common import makeFileNameSafe
|
from novelwriter.common import makeFileNameSafe
|
||||||
from novelwriter.constants import nwLabels
|
from novelwriter.constants import nwLabels
|
||||||
@@ -74,14 +74,14 @@ class GuiManuscriptBuild(QDialog):
|
|||||||
self.setMinimumWidth(CONFIG.pxInt(500))
|
self.setMinimumWidth(CONFIG.pxInt(500))
|
||||||
self.setMinimumHeight(CONFIG.pxInt(300))
|
self.setMinimumHeight(CONFIG.pxInt(300))
|
||||||
|
|
||||||
iPx = CONFIG.theme.baseIconSize
|
iPx = SHARED.theme.baseIconSize
|
||||||
sp4 = CONFIG.pxInt(4)
|
sp4 = CONFIG.pxInt(4)
|
||||||
sp8 = CONFIG.pxInt(8)
|
sp8 = CONFIG.pxInt(8)
|
||||||
sp16 = CONFIG.pxInt(16)
|
sp16 = CONFIG.pxInt(16)
|
||||||
wWin = CONFIG.pxInt(620)
|
wWin = CONFIG.pxInt(620)
|
||||||
hWin = CONFIG.pxInt(360)
|
hWin = CONFIG.pxInt(360)
|
||||||
|
|
||||||
pOptions = self.mainGui.project.options
|
pOptions = SHARED.project.options
|
||||||
self.resize(
|
self.resize(
|
||||||
CONFIG.pxInt(pOptions.getInt("GuiManuscriptBuild", "winWidth", wWin)),
|
CONFIG.pxInt(pOptions.getInt("GuiManuscriptBuild", "winWidth", wWin)),
|
||||||
CONFIG.pxInt(pOptions.getInt("GuiManuscriptBuild", "winHeight", hWin))
|
CONFIG.pxInt(pOptions.getInt("GuiManuscriptBuild", "winHeight", hWin))
|
||||||
@@ -146,7 +146,7 @@ class GuiManuscriptBuild(QDialog):
|
|||||||
# Build Path
|
# Build Path
|
||||||
self.lblPath = QLabel(self.tr("Path"))
|
self.lblPath = QLabel(self.tr("Path"))
|
||||||
self.buildPath = QLineEdit(self)
|
self.buildPath = QLineEdit(self)
|
||||||
self.btnBrowse = QPushButton(CONFIG.theme.getIcon("browse"), "")
|
self.btnBrowse = QPushButton(SHARED.theme.getIcon("browse"), "")
|
||||||
|
|
||||||
self.pathBox = QHBoxLayout()
|
self.pathBox = QHBoxLayout()
|
||||||
self.pathBox.addWidget(self.buildPath)
|
self.pathBox.addWidget(self.buildPath)
|
||||||
@@ -156,7 +156,7 @@ class GuiManuscriptBuild(QDialog):
|
|||||||
# Build Name
|
# Build Name
|
||||||
self.lblName = QLabel(self.tr("File Name"))
|
self.lblName = QLabel(self.tr("File Name"))
|
||||||
self.buildName = QLineEdit(self)
|
self.buildName = QLineEdit(self)
|
||||||
self.btnReset = QPushButton(CONFIG.theme.getIcon("revert"), "")
|
self.btnReset = QPushButton(SHARED.theme.getIcon("revert"), "")
|
||||||
self.btnReset.setToolTip(self.tr("Reset file name to default"))
|
self.btnReset.setToolTip(self.tr("Reset file name to default"))
|
||||||
|
|
||||||
self.nameBox = QHBoxLayout()
|
self.nameBox = QHBoxLayout()
|
||||||
@@ -181,7 +181,7 @@ class GuiManuscriptBuild(QDialog):
|
|||||||
self.buildBox.setVerticalSpacing(sp4)
|
self.buildBox.setVerticalSpacing(sp4)
|
||||||
|
|
||||||
# Dialog Buttons
|
# Dialog Buttons
|
||||||
self.btnBuild = QPushButton(CONFIG.theme.getIcon("export"), self.tr("&Build"))
|
self.btnBuild = QPushButton(SHARED.theme.getIcon("export"), self.tr("&Build"))
|
||||||
self.dlgButtons = QDialogButtonBox(QDialogButtonBox.Close)
|
self.dlgButtons = QDialogButtonBox(QDialogButtonBox.Close)
|
||||||
self.dlgButtons.addButton(self.btnBuild, QDialogButtonBox.ActionRole)
|
self.dlgButtons.addButton(self.btnBuild, QDialogButtonBox.ActionRole)
|
||||||
|
|
||||||
@@ -279,7 +279,7 @@ class GuiManuscriptBuild(QDialog):
|
|||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def _doResetBuildName(self):
|
def _doResetBuildName(self):
|
||||||
"""Generate a default build name."""
|
"""Generate a default build name."""
|
||||||
bName = f"{self.mainGui.project.data.name} - {self._build.name}"
|
bName = f"{SHARED.project.data.name} - {self._build.name}"
|
||||||
self.buildName.setText(bName)
|
self.buildName.setText(bName)
|
||||||
self._build.setLastBuildName(bName)
|
self._build.setLastBuildName(bName)
|
||||||
return
|
return
|
||||||
@@ -320,7 +320,7 @@ class GuiManuscriptBuild(QDialog):
|
|||||||
):
|
):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
docBuild = NWBuildDocument(self.mainGui.project, self._build)
|
docBuild = NWBuildDocument(SHARED.project, self._build)
|
||||||
docBuild.queueAll()
|
docBuild.queueAll()
|
||||||
|
|
||||||
self.buildProgress.setMaximum(len(docBuild))
|
self.buildProgress.setMaximum(len(docBuild))
|
||||||
@@ -353,7 +353,7 @@ class GuiManuscriptBuild(QDialog):
|
|||||||
fmtWidth = CONFIG.rpxInt(mainSplit[0])
|
fmtWidth = CONFIG.rpxInt(mainSplit[0])
|
||||||
sumWidth = CONFIG.rpxInt(mainSplit[1])
|
sumWidth = CONFIG.rpxInt(mainSplit[1])
|
||||||
|
|
||||||
pOptions = self.mainGui.project.options
|
pOptions = SHARED.project.options
|
||||||
pOptions.setValue("GuiManuscriptBuild", "winWidth", winWidth)
|
pOptions.setValue("GuiManuscriptBuild", "winWidth", winWidth)
|
||||||
pOptions.setValue("GuiManuscriptBuild", "winHeight", winHeight)
|
pOptions.setValue("GuiManuscriptBuild", "winHeight", winHeight)
|
||||||
pOptions.setValue("GuiManuscriptBuild", "fmtWidth", fmtWidth)
|
pOptions.setValue("GuiManuscriptBuild", "fmtWidth", fmtWidth)
|
||||||
@@ -365,9 +365,9 @@ class GuiManuscriptBuild(QDialog):
|
|||||||
def _populateContentList(self):
|
def _populateContentList(self):
|
||||||
"""Build the content list."""
|
"""Build the content list."""
|
||||||
rootMap = {}
|
rootMap = {}
|
||||||
filtered = self._build.buildItemFilter(self.mainGui.project)
|
filtered = self._build.buildItemFilter(SHARED.project)
|
||||||
self.listContent.clear()
|
self.listContent.clear()
|
||||||
for nwItem in self.mainGui.project.tree:
|
for nwItem in SHARED.project.tree:
|
||||||
tHandle = nwItem.itemHandle
|
tHandle = nwItem.itemHandle
|
||||||
rHandle = nwItem.itemRoot
|
rHandle = nwItem.itemRoot
|
||||||
|
|
||||||
@@ -376,11 +376,11 @@ class GuiManuscriptBuild(QDialog):
|
|||||||
|
|
||||||
if filtered.get(tHandle, (False, 0))[0]:
|
if filtered.get(tHandle, (False, 0))[0]:
|
||||||
if rHandle not in rootMap:
|
if rHandle not in rootMap:
|
||||||
rItem = self.mainGui.project.tree[rHandle]
|
rItem = SHARED.project.tree[rHandle]
|
||||||
if isinstance(rItem, NWItem):
|
if isinstance(rItem, NWItem):
|
||||||
rootMap[rHandle] = rItem.itemName
|
rootMap[rHandle] = rItem.itemName
|
||||||
|
|
||||||
itemIcon = CONFIG.theme.getItemIcon(
|
itemIcon = SHARED.theme.getItemIcon(
|
||||||
nwItem.itemType, nwItem.itemClass,
|
nwItem.itemType, nwItem.itemClass,
|
||||||
nwItem.itemLayout, nwItem.mainHeading
|
nwItem.itemLayout, nwItem.mainHeading
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ from PyQt5.QtWidgets import (
|
|||||||
)
|
)
|
||||||
from PyQt5.QtPrintSupport import QPrintPreviewDialog, QPrinter
|
from PyQt5.QtPrintSupport import QPrintPreviewDialog, QPrinter
|
||||||
|
|
||||||
from novelwriter import CONFIG
|
from novelwriter import CONFIG, SHARED
|
||||||
from novelwriter.error import logException
|
from novelwriter.error import logException
|
||||||
from novelwriter.common import checkInt, fuzzyTime
|
from novelwriter.common import checkInt, fuzzyTime
|
||||||
from novelwriter.core.tohtml import ToHtml
|
from novelwriter.core.tohtml import ToHtml
|
||||||
@@ -74,18 +74,18 @@ class GuiManuscript(QDialog):
|
|||||||
|
|
||||||
self.mainGui = mainGui
|
self.mainGui = mainGui
|
||||||
|
|
||||||
self._builds = BuildCollection(self.mainGui.project)
|
self._builds = BuildCollection(SHARED.project)
|
||||||
self._buildMap: dict[str, QListWidgetItem] = {}
|
self._buildMap: dict[str, QListWidgetItem] = {}
|
||||||
|
|
||||||
self.setWindowTitle(self.tr("Build Manuscript"))
|
self.setWindowTitle(self.tr("Build Manuscript"))
|
||||||
self.setMinimumWidth(CONFIG.pxInt(600))
|
self.setMinimumWidth(CONFIG.pxInt(600))
|
||||||
self.setMinimumHeight(CONFIG.pxInt(500))
|
self.setMinimumHeight(CONFIG.pxInt(500))
|
||||||
|
|
||||||
iPx = CONFIG.theme.baseIconSize
|
iPx = SHARED.theme.baseIconSize
|
||||||
wWin = CONFIG.pxInt(900)
|
wWin = CONFIG.pxInt(900)
|
||||||
hWin = CONFIG.pxInt(600)
|
hWin = CONFIG.pxInt(600)
|
||||||
|
|
||||||
pOptions = self.mainGui.project.options
|
pOptions = SHARED.project.options
|
||||||
self.resize(
|
self.resize(
|
||||||
CONFIG.pxInt(pOptions.getInt("GuiManuscript", "winWidth", wWin)),
|
CONFIG.pxInt(pOptions.getInt("GuiManuscript", "winWidth", wWin)),
|
||||||
CONFIG.pxInt(pOptions.getInt("GuiManuscript", "winHeight", hWin))
|
CONFIG.pxInt(pOptions.getInt("GuiManuscript", "winHeight", hWin))
|
||||||
@@ -105,21 +105,21 @@ class GuiManuscript(QDialog):
|
|||||||
).format(CONFIG.pxInt(2), fadeCol.red(), fadeCol.green(), fadeCol.blue())
|
).format(CONFIG.pxInt(2), fadeCol.red(), fadeCol.green(), fadeCol.blue())
|
||||||
|
|
||||||
self.tbAdd = QToolButton(self)
|
self.tbAdd = QToolButton(self)
|
||||||
self.tbAdd.setIcon(CONFIG.theme.getIcon("add"))
|
self.tbAdd.setIcon(SHARED.theme.getIcon("add"))
|
||||||
self.tbAdd.setIconSize(QSize(iPx, iPx))
|
self.tbAdd.setIconSize(QSize(iPx, iPx))
|
||||||
self.tbAdd.setToolTip(self.tr("Add New Build"))
|
self.tbAdd.setToolTip(self.tr("Add New Build"))
|
||||||
self.tbAdd.setStyleSheet(buttonStyle)
|
self.tbAdd.setStyleSheet(buttonStyle)
|
||||||
self.tbAdd.clicked.connect(self._createNewBuild)
|
self.tbAdd.clicked.connect(self._createNewBuild)
|
||||||
|
|
||||||
self.tbDel = QToolButton(self)
|
self.tbDel = QToolButton(self)
|
||||||
self.tbDel.setIcon(CONFIG.theme.getIcon("remove"))
|
self.tbDel.setIcon(SHARED.theme.getIcon("remove"))
|
||||||
self.tbDel.setIconSize(QSize(iPx, iPx))
|
self.tbDel.setIconSize(QSize(iPx, iPx))
|
||||||
self.tbDel.setToolTip(self.tr("Delete Selected Build"))
|
self.tbDel.setToolTip(self.tr("Delete Selected Build"))
|
||||||
self.tbDel.setStyleSheet(buttonStyle)
|
self.tbDel.setStyleSheet(buttonStyle)
|
||||||
self.tbDel.clicked.connect(self._deleteSelectedBuild)
|
self.tbDel.clicked.connect(self._deleteSelectedBuild)
|
||||||
|
|
||||||
self.tbEdit = QToolButton(self)
|
self.tbEdit = QToolButton(self)
|
||||||
self.tbEdit.setIcon(CONFIG.theme.getIcon("edit"))
|
self.tbEdit.setIcon(SHARED.theme.getIcon("edit"))
|
||||||
self.tbEdit.setIconSize(QSize(iPx, iPx))
|
self.tbEdit.setIconSize(QSize(iPx, iPx))
|
||||||
self.tbEdit.setToolTip(self.tr("Edit Selected Build"))
|
self.tbEdit.setToolTip(self.tr("Edit Selected Build"))
|
||||||
self.tbEdit.setStyleSheet(buttonStyle)
|
self.tbEdit.setStyleSheet(buttonStyle)
|
||||||
@@ -163,7 +163,7 @@ class GuiManuscript(QDialog):
|
|||||||
# Assemble GUI
|
# Assemble GUI
|
||||||
# ============
|
# ============
|
||||||
|
|
||||||
self.docPreview = _PreviewWidget(self.mainGui)
|
self.docPreview = _PreviewWidget(self)
|
||||||
|
|
||||||
self.controlBox = QVBoxLayout()
|
self.controlBox = QVBoxLayout()
|
||||||
self.controlBox.addLayout(self.listToolBox, 0)
|
self.controlBox.addLayout(self.listToolBox, 0)
|
||||||
@@ -210,7 +210,7 @@ class GuiManuscript(QDialog):
|
|||||||
self._updateBuildsList()
|
self._updateBuildsList()
|
||||||
|
|
||||||
logger.debug("Loading build cache")
|
logger.debug("Loading build cache")
|
||||||
cache = CONFIG.dataPath("cache") / f"build_{self.mainGui.project.data.uuid}.json"
|
cache = CONFIG.dataPath("cache") / f"build_{SHARED.project.data.uuid}.json"
|
||||||
if cache.is_file():
|
if cache.is_file():
|
||||||
try:
|
try:
|
||||||
with open(cache, mode="r", encoding="utf-8") as fObj:
|
with open(cache, mode="r", encoding="utf-8") as fObj:
|
||||||
@@ -289,7 +289,7 @@ class GuiManuscript(QDialog):
|
|||||||
if build is None:
|
if build is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
docBuild = NWBuildDocument(self.mainGui.project, build)
|
docBuild = NWBuildDocument(SHARED.project, build)
|
||||||
docBuild.queueAll()
|
docBuild.queueAll()
|
||||||
|
|
||||||
self.docPreview.beginNewBuild(len(docBuild))
|
self.docPreview.beginNewBuild(len(docBuild))
|
||||||
@@ -309,7 +309,7 @@ class GuiManuscript(QDialog):
|
|||||||
self._updatePreview(result, build)
|
self._updatePreview(result, build)
|
||||||
|
|
||||||
logger.debug("Saving build cache")
|
logger.debug("Saving build cache")
|
||||||
cache = CONFIG.dataPath("cache") / f"build_{self.mainGui.project.data.uuid}.json"
|
cache = CONFIG.dataPath("cache") / f"build_{SHARED.project.data.uuid}.json"
|
||||||
try:
|
try:
|
||||||
with open(cache, mode="w+", encoding="utf-8") as outFile:
|
with open(cache, mode="w+", encoding="utf-8") as outFile:
|
||||||
outFile.write(json.dumps(result, indent=2))
|
outFile.write(json.dumps(result, indent=2))
|
||||||
@@ -390,7 +390,7 @@ class GuiManuscript(QDialog):
|
|||||||
optsWidth = CONFIG.rpxInt(mainSplit[0])
|
optsWidth = CONFIG.rpxInt(mainSplit[0])
|
||||||
viewWidth = CONFIG.rpxInt(mainSplit[1])
|
viewWidth = CONFIG.rpxInt(mainSplit[1])
|
||||||
|
|
||||||
pOptions = self.mainGui.project.options
|
pOptions = SHARED.project.options
|
||||||
pOptions.setValue("GuiManuscript", "winWidth", winWidth)
|
pOptions.setValue("GuiManuscript", "winWidth", winWidth)
|
||||||
pOptions.setValue("GuiManuscript", "winHeight", winHeight)
|
pOptions.setValue("GuiManuscript", "winHeight", winHeight)
|
||||||
pOptions.setValue("GuiManuscript", "optsWidth", optsWidth)
|
pOptions.setValue("GuiManuscript", "optsWidth", optsWidth)
|
||||||
@@ -426,7 +426,7 @@ class GuiManuscript(QDialog):
|
|||||||
for key, name in self._builds.builds():
|
for key, name in self._builds.builds():
|
||||||
bItem = QListWidgetItem()
|
bItem = QListWidgetItem()
|
||||||
bItem.setText(name)
|
bItem.setText(name)
|
||||||
bItem.setIcon(CONFIG.theme.getIcon("export"))
|
bItem.setIcon(SHARED.theme.getIcon("export"))
|
||||||
bItem.setData(self.D_KEY, key)
|
bItem.setData(self.D_KEY, key)
|
||||||
self.buildList.addItem(bItem)
|
self.buildList.addItem(bItem)
|
||||||
self._buildMap[key] = bItem
|
self._buildMap[key] = bItem
|
||||||
@@ -446,10 +446,8 @@ class GuiManuscript(QDialog):
|
|||||||
|
|
||||||
class _PreviewWidget(QTextBrowser):
|
class _PreviewWidget(QTextBrowser):
|
||||||
|
|
||||||
def __init__(self, mainGui: GuiMain):
|
def __init__(self, parent: QWidget):
|
||||||
super().__init__(parent=mainGui)
|
super().__init__(parent=parent)
|
||||||
|
|
||||||
self.mainGui = mainGui
|
|
||||||
|
|
||||||
self._docTime = 0
|
self._docTime = 0
|
||||||
self._buildName = ""
|
self._buildName = ""
|
||||||
@@ -460,7 +458,7 @@ class _PreviewWidget(QTextBrowser):
|
|||||||
dPalette.setColor(QPalette.Text, QColor(0, 0, 0))
|
dPalette.setColor(QPalette.Text, QColor(0, 0, 0))
|
||||||
self.setPalette(dPalette)
|
self.setPalette(dPalette)
|
||||||
|
|
||||||
self.setMinimumWidth(40*CONFIG.theme.textNWidth)
|
self.setMinimumWidth(40*SHARED.theme.textNWidth)
|
||||||
self.setTextFont(CONFIG.textFont, CONFIG.textSize)
|
self.setTextFont(CONFIG.textFont, CONFIG.textSize)
|
||||||
self.setTabStopDistance(CONFIG.getTabWidth())
|
self.setTabStopDistance(CONFIG.getTabWidth())
|
||||||
self.setOpenExternalLinks(False)
|
self.setOpenExternalLinks(False)
|
||||||
@@ -478,7 +476,7 @@ class _PreviewWidget(QTextBrowser):
|
|||||||
aPalette.setColor(QPalette.Foreground, aPalette.toolTipText().color())
|
aPalette.setColor(QPalette.Foreground, aPalette.toolTipText().color())
|
||||||
|
|
||||||
aFont = self.font()
|
aFont = self.font()
|
||||||
aFont.setPointSizeF(0.9*CONFIG.theme.fontPointSize)
|
aFont.setPointSizeF(0.9*SHARED.theme.fontPointSize)
|
||||||
|
|
||||||
self.ageLabel = QLabel("", self)
|
self.ageLabel = QLabel("", self)
|
||||||
self.ageLabel.setIndent(0)
|
self.ageLabel.setIndent(0)
|
||||||
@@ -486,7 +484,7 @@ class _PreviewWidget(QTextBrowser):
|
|||||||
self.ageLabel.setPalette(aPalette)
|
self.ageLabel.setPalette(aPalette)
|
||||||
self.ageLabel.setAutoFillBackground(True)
|
self.ageLabel.setAutoFillBackground(True)
|
||||||
self.ageLabel.setAlignment(Qt.AlignCenter)
|
self.ageLabel.setAlignment(Qt.AlignCenter)
|
||||||
self.ageLabel.setFixedHeight(int(2.1*CONFIG.theme.fontPixelSize))
|
self.ageLabel.setFixedHeight(int(2.1*SHARED.theme.fontPixelSize))
|
||||||
|
|
||||||
# Progress
|
# Progress
|
||||||
self.buildProgress = NProgressCircle(self, CONFIG.pxInt(160), CONFIG.pxInt(16))
|
self.buildProgress = NProgressCircle(self, CONFIG.pxInt(160), CONFIG.pxInt(16))
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ from PyQt5.QtWidgets import (
|
|||||||
QWidget
|
QWidget
|
||||||
)
|
)
|
||||||
|
|
||||||
from novelwriter import CONFIG
|
from novelwriter import CONFIG, SHARED
|
||||||
from novelwriter.constants import nwHeadFmt, nwLabels, trConst
|
from novelwriter.constants import nwHeadFmt, nwLabels, trConst
|
||||||
from novelwriter.core.buildsettings import BuildSettings, FilterMode
|
from novelwriter.core.buildsettings import BuildSettings, FilterMode
|
||||||
from novelwriter.extensions.switch import NSwitch
|
from novelwriter.extensions.switch import NSwitch
|
||||||
@@ -88,7 +88,7 @@ class GuiBuildSettings(QDialog):
|
|||||||
wWin = CONFIG.pxInt(750)
|
wWin = CONFIG.pxInt(750)
|
||||||
hWin = CONFIG.pxInt(550)
|
hWin = CONFIG.pxInt(550)
|
||||||
|
|
||||||
pOptions = self.mainGui.project.options
|
pOptions = SHARED.project.options
|
||||||
self.resize(
|
self.resize(
|
||||||
CONFIG.pxInt(pOptions.getInt("GuiBuildSettings", "winWidth", wWin)),
|
CONFIG.pxInt(pOptions.getInt("GuiBuildSettings", "winWidth", wWin)),
|
||||||
CONFIG.pxInt(pOptions.getInt("GuiBuildSettings", "winHeight", hWin))
|
CONFIG.pxInt(pOptions.getInt("GuiBuildSettings", "winHeight", hWin))
|
||||||
@@ -100,7 +100,7 @@ class GuiBuildSettings(QDialog):
|
|||||||
self.optSideBar = NPagedSideBar(self)
|
self.optSideBar = NPagedSideBar(self)
|
||||||
self.optSideBar.setMinimumWidth(mPx)
|
self.optSideBar.setMinimumWidth(mPx)
|
||||||
self.optSideBar.setMaximumWidth(mPx)
|
self.optSideBar.setMaximumWidth(mPx)
|
||||||
self.optSideBar.setLabelColor(CONFIG.theme.helpText)
|
self.optSideBar.setLabelColor(SHARED.theme.helpText)
|
||||||
|
|
||||||
self.optSideBar.addLabel(self.tr("Options"))
|
self.optSideBar.addLabel(self.tr("Options"))
|
||||||
self.optSideBar.addButton(self.tr("Selection"), self.OPT_FILTERS)
|
self.optSideBar.addButton(self.tr("Selection"), self.OPT_FILTERS)
|
||||||
@@ -262,7 +262,7 @@ class GuiBuildSettings(QDialog):
|
|||||||
|
|
||||||
treeWidth, filterWidth = self.optTabSelect.mainSplitSizes()
|
treeWidth, filterWidth = self.optTabSelect.mainSplitSizes()
|
||||||
|
|
||||||
pOptions = self.mainGui.project.options
|
pOptions = SHARED.project.options
|
||||||
pOptions.setValue("GuiBuildSettings", "winWidth", winWidth)
|
pOptions.setValue("GuiBuildSettings", "winWidth", winWidth)
|
||||||
pOptions.setValue("GuiBuildSettings", "winHeight", winHeight)
|
pOptions.setValue("GuiBuildSettings", "winHeight", winHeight)
|
||||||
pOptions.setValue("GuiBuildSettings", "treeWidth", treeWidth)
|
pOptions.setValue("GuiBuildSettings", "treeWidth", treeWidth)
|
||||||
@@ -303,16 +303,14 @@ class _FilterTab(QWidget):
|
|||||||
def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings) -> None:
|
def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings) -> None:
|
||||||
super().__init__(parent=buildMain)
|
super().__init__(parent=buildMain)
|
||||||
|
|
||||||
self.mainGui = buildMain.mainGui
|
|
||||||
|
|
||||||
self._treeMap: dict[str, QTreeWidgetItem] = {}
|
self._treeMap: dict[str, QTreeWidgetItem] = {}
|
||||||
self._build = build
|
self._build = build
|
||||||
|
|
||||||
self._statusFlags: dict[int, QIcon] = {
|
self._statusFlags: dict[int, QIcon] = {
|
||||||
self.F_NONE: QIcon(),
|
self.F_NONE: QIcon(),
|
||||||
self.F_FILTERED: CONFIG.theme.getIcon("build_filtered"),
|
self.F_FILTERED: SHARED.theme.getIcon("build_filtered"),
|
||||||
self.F_INCLUDED: CONFIG.theme.getIcon("build_included"),
|
self.F_INCLUDED: SHARED.theme.getIcon("build_included"),
|
||||||
self.F_EXCLUDED: CONFIG.theme.getIcon("build_excluded"),
|
self.F_EXCLUDED: SHARED.theme.getIcon("build_excluded"),
|
||||||
}
|
}
|
||||||
|
|
||||||
self._trIncluded = self.tr("Included in manuscript")
|
self._trIncluded = self.tr("Included in manuscript")
|
||||||
@@ -322,7 +320,7 @@ class _FilterTab(QWidget):
|
|||||||
# ============
|
# ============
|
||||||
|
|
||||||
# Tree Settings
|
# Tree Settings
|
||||||
iPx = CONFIG.theme.baseIconSize
|
iPx = SHARED.theme.baseIconSize
|
||||||
cMg = CONFIG.pxInt(6)
|
cMg = CONFIG.pxInt(6)
|
||||||
|
|
||||||
# Tree Widget
|
# Tree Widget
|
||||||
@@ -360,7 +358,7 @@ class _FilterTab(QWidget):
|
|||||||
|
|
||||||
self.resetButton = QToolButton(self)
|
self.resetButton = QToolButton(self)
|
||||||
self.resetButton.setToolTip(self.tr("Reset to default"))
|
self.resetButton.setToolTip(self.tr("Reset to default"))
|
||||||
self.resetButton.setIcon(CONFIG.theme.getIcon("revert"))
|
self.resetButton.setIcon(SHARED.theme.getIcon("revert"))
|
||||||
self.resetButton.clicked.connect(lambda: self._setSelectedMode(self.F_FILTERED))
|
self.resetButton.clicked.connect(lambda: self._setSelectedMode(self.F_FILTERED))
|
||||||
|
|
||||||
self.modeBox = QHBoxLayout()
|
self.modeBox = QHBoxLayout()
|
||||||
@@ -379,7 +377,7 @@ class _FilterTab(QWidget):
|
|||||||
# Assemble GUI
|
# Assemble GUI
|
||||||
# ============
|
# ============
|
||||||
|
|
||||||
pOptions = self.mainGui.project.options
|
pOptions = SHARED.project.options
|
||||||
|
|
||||||
self.selectionBox = QVBoxLayout()
|
self.selectionBox = QVBoxLayout()
|
||||||
self.selectionBox.addWidget(self.optTree)
|
self.selectionBox.addWidget(self.optTree)
|
||||||
@@ -445,7 +443,7 @@ class _FilterTab(QWidget):
|
|||||||
logger.debug("Building project tree")
|
logger.debug("Building project tree")
|
||||||
self._treeMap = {}
|
self._treeMap = {}
|
||||||
self.optTree.clear()
|
self.optTree.clear()
|
||||||
for nwItem in self.mainGui.project.getProjectItems():
|
for nwItem in SHARED.project.getProjectItems():
|
||||||
|
|
||||||
tHandle = nwItem.itemHandle
|
tHandle = nwItem.itemHandle
|
||||||
pHandle = nwItem.itemParent
|
pHandle = nwItem.itemParent
|
||||||
@@ -461,7 +459,7 @@ class _FilterTab(QWidget):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
hLevel = nwItem.mainHeading
|
hLevel = nwItem.mainHeading
|
||||||
itemIcon = CONFIG.theme.getItemIcon(
|
itemIcon = SHARED.theme.getItemIcon(
|
||||||
nwItem.itemType, nwItem.itemClass, nwItem.itemLayout, hLevel
|
nwItem.itemType, nwItem.itemClass, nwItem.itemLayout, hLevel
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -475,7 +473,7 @@ class _FilterTab(QWidget):
|
|||||||
trItem.setText(self.C_NAME, nwItem.itemName)
|
trItem.setText(self.C_NAME, nwItem.itemName)
|
||||||
trItem.setData(self.C_DATA, self.D_HANDLE, tHandle)
|
trItem.setData(self.C_DATA, self.D_HANDLE, tHandle)
|
||||||
trItem.setData(self.C_DATA, self.D_FILE, isFile)
|
trItem.setData(self.C_DATA, self.D_FILE, isFile)
|
||||||
trItem.setIcon(self.C_ACTIVE, CONFIG.theme.getIcon(iconName))
|
trItem.setIcon(self.C_ACTIVE, SHARED.theme.getIcon(iconName))
|
||||||
|
|
||||||
trItem.setTextAlignment(self.C_NAME, Qt.AlignLeft)
|
trItem.setTextAlignment(self.C_NAME, Qt.AlignLeft)
|
||||||
|
|
||||||
@@ -499,19 +497,19 @@ class _FilterTab(QWidget):
|
|||||||
self.filterOpt.clear()
|
self.filterOpt.clear()
|
||||||
self.filterOpt.addLabel(self._build.getLabel("filter"))
|
self.filterOpt.addLabel(self._build.getLabel("filter"))
|
||||||
self.filterOpt.addItem(
|
self.filterOpt.addItem(
|
||||||
CONFIG.theme.getIcon("proj_scene"),
|
SHARED.theme.getIcon("proj_scene"),
|
||||||
self._build.getLabel("filter.includeNovel"),
|
self._build.getLabel("filter.includeNovel"),
|
||||||
"doc:filter.includeNovel",
|
"doc:filter.includeNovel",
|
||||||
default=self._build.getBool("filter.includeNovel")
|
default=self._build.getBool("filter.includeNovel")
|
||||||
)
|
)
|
||||||
self.filterOpt.addItem(
|
self.filterOpt.addItem(
|
||||||
CONFIG.theme.getIcon("proj_note"),
|
SHARED.theme.getIcon("proj_note"),
|
||||||
self._build.getLabel("filter.includeNotes"),
|
self._build.getLabel("filter.includeNotes"),
|
||||||
"doc:filter.includeNotes",
|
"doc:filter.includeNotes",
|
||||||
default=self._build.getBool("filter.includeNotes")
|
default=self._build.getBool("filter.includeNotes")
|
||||||
)
|
)
|
||||||
self.filterOpt.addItem(
|
self.filterOpt.addItem(
|
||||||
CONFIG.theme.getIcon("unchecked"),
|
SHARED.theme.getIcon("unchecked"),
|
||||||
self._build.getLabel("filter.includeInactive"),
|
self._build.getLabel("filter.includeInactive"),
|
||||||
"doc:filter.includeInactive",
|
"doc:filter.includeInactive",
|
||||||
default=self._build.getBool("filter.includeInactive")
|
default=self._build.getBool("filter.includeInactive")
|
||||||
@@ -521,9 +519,9 @@ class _FilterTab(QWidget):
|
|||||||
|
|
||||||
# Root Classes
|
# Root Classes
|
||||||
self.filterOpt.addLabel(self.tr("Select Root Folders"))
|
self.filterOpt.addLabel(self.tr("Select Root Folders"))
|
||||||
for tHandle, nwItem in self.mainGui.project.tree.iterRoots(None):
|
for tHandle, nwItem in SHARED.project.tree.iterRoots(None):
|
||||||
if not nwItem.isInactiveClass():
|
if not nwItem.isInactiveClass():
|
||||||
itemIcon = CONFIG.theme.getItemIcon(
|
itemIcon = SHARED.theme.getItemIcon(
|
||||||
nwItem.itemType, nwItem.itemClass, nwItem.itemLayout
|
nwItem.itemType, nwItem.itemClass, nwItem.itemLayout
|
||||||
)
|
)
|
||||||
self.filterOpt.addItem(
|
self.filterOpt.addItem(
|
||||||
@@ -557,7 +555,7 @@ class _FilterTab(QWidget):
|
|||||||
|
|
||||||
def _setTreeItemMode(self) -> None:
|
def _setTreeItemMode(self) -> None:
|
||||||
"""Update the filtered mode icon on all items."""
|
"""Update the filtered mode icon on all items."""
|
||||||
filtered = self._build.buildItemFilter(self.mainGui.project)
|
filtered = self._build.buildItemFilter(SHARED.project)
|
||||||
for tHandle, item in self._treeMap.items():
|
for tHandle, item in self._treeMap.items():
|
||||||
allow, mode = filtered.get(tHandle, (False, FilterMode.UNKNOWN))
|
allow, mode = filtered.get(tHandle, (False, FilterMode.UNKNOWN))
|
||||||
if mode == FilterMode.INCLUDED:
|
if mode == FilterMode.INCLUDED:
|
||||||
@@ -597,12 +595,10 @@ class _HeadingsTab(QWidget):
|
|||||||
def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings) -> None:
|
def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings) -> None:
|
||||||
super().__init__(parent=buildMain)
|
super().__init__(parent=buildMain)
|
||||||
|
|
||||||
self.mainGui = buildMain.mainGui
|
|
||||||
|
|
||||||
self._build = build
|
self._build = build
|
||||||
self._editing = 0
|
self._editing = 0
|
||||||
|
|
||||||
iPx = CONFIG.theme.baseIconSize
|
iPx = SHARED.theme.baseIconSize
|
||||||
vSp = CONFIG.pxInt(12)
|
vSp = CONFIG.pxInt(12)
|
||||||
bSp = CONFIG.pxInt(6)
|
bSp = CONFIG.pxInt(6)
|
||||||
|
|
||||||
@@ -616,7 +612,7 @@ class _HeadingsTab(QWidget):
|
|||||||
self.fmtTitle = QLineEdit("")
|
self.fmtTitle = QLineEdit("")
|
||||||
self.fmtTitle.setReadOnly(True)
|
self.fmtTitle.setReadOnly(True)
|
||||||
self.btnTitle = QToolButton()
|
self.btnTitle = QToolButton()
|
||||||
self.btnTitle.setIcon(CONFIG.theme.getIcon("edit"))
|
self.btnTitle.setIcon(SHARED.theme.getIcon("edit"))
|
||||||
self.btnTitle.clicked.connect(lambda: self._editHeading(self.EDIT_TITLE))
|
self.btnTitle.clicked.connect(lambda: self._editHeading(self.EDIT_TITLE))
|
||||||
|
|
||||||
wrapTitle = QHBoxLayout()
|
wrapTitle = QHBoxLayout()
|
||||||
@@ -632,7 +628,7 @@ class _HeadingsTab(QWidget):
|
|||||||
self.fmtChapter = QLineEdit("")
|
self.fmtChapter = QLineEdit("")
|
||||||
self.fmtChapter.setReadOnly(True)
|
self.fmtChapter.setReadOnly(True)
|
||||||
self.btnChapter = QToolButton()
|
self.btnChapter = QToolButton()
|
||||||
self.btnChapter.setIcon(CONFIG.theme.getIcon("edit"))
|
self.btnChapter.setIcon(SHARED.theme.getIcon("edit"))
|
||||||
self.btnChapter.clicked.connect(lambda: self._editHeading(self.EDIT_CHAPTER))
|
self.btnChapter.clicked.connect(lambda: self._editHeading(self.EDIT_CHAPTER))
|
||||||
|
|
||||||
wrapChapter = QHBoxLayout()
|
wrapChapter = QHBoxLayout()
|
||||||
@@ -648,7 +644,7 @@ class _HeadingsTab(QWidget):
|
|||||||
self.fmtUnnumbered = QLineEdit("")
|
self.fmtUnnumbered = QLineEdit("")
|
||||||
self.fmtUnnumbered.setReadOnly(True)
|
self.fmtUnnumbered.setReadOnly(True)
|
||||||
self.btnUnnumbered = QToolButton()
|
self.btnUnnumbered = QToolButton()
|
||||||
self.btnUnnumbered.setIcon(CONFIG.theme.getIcon("edit"))
|
self.btnUnnumbered.setIcon(SHARED.theme.getIcon("edit"))
|
||||||
self.btnUnnumbered.clicked.connect(lambda: self._editHeading(self.EDIT_UNNUM))
|
self.btnUnnumbered.clicked.connect(lambda: self._editHeading(self.EDIT_UNNUM))
|
||||||
|
|
||||||
wrapUnnumbered = QHBoxLayout()
|
wrapUnnumbered = QHBoxLayout()
|
||||||
@@ -665,7 +661,7 @@ class _HeadingsTab(QWidget):
|
|||||||
self.fmtScene = QLineEdit("")
|
self.fmtScene = QLineEdit("")
|
||||||
self.fmtScene.setReadOnly(True)
|
self.fmtScene.setReadOnly(True)
|
||||||
self.btnScene = QToolButton()
|
self.btnScene = QToolButton()
|
||||||
self.btnScene.setIcon(CONFIG.theme.getIcon("edit"))
|
self.btnScene.setIcon(SHARED.theme.getIcon("edit"))
|
||||||
self.btnScene.clicked.connect(lambda: self._editHeading(self.EDIT_SCENE))
|
self.btnScene.clicked.connect(lambda: self._editHeading(self.EDIT_SCENE))
|
||||||
self.hdeScene = QLabel(self.tr("Hide"))
|
self.hdeScene = QLabel(self.tr("Hide"))
|
||||||
self.hdeScene.setToolTip(sceneHideTip)
|
self.hdeScene.setToolTip(sceneHideTip)
|
||||||
@@ -692,7 +688,7 @@ class _HeadingsTab(QWidget):
|
|||||||
self.fmtSection = QLineEdit("")
|
self.fmtSection = QLineEdit("")
|
||||||
self.fmtSection.setReadOnly(True)
|
self.fmtSection.setReadOnly(True)
|
||||||
self.btnSection = QToolButton()
|
self.btnSection = QToolButton()
|
||||||
self.btnSection.setIcon(CONFIG.theme.getIcon("edit"))
|
self.btnSection.setIcon(SHARED.theme.getIcon("edit"))
|
||||||
self.btnSection.clicked.connect(lambda: self._editHeading(self.EDIT_SECTION))
|
self.btnSection.clicked.connect(lambda: self._editHeading(self.EDIT_SECTION))
|
||||||
self.hdeSection = QLabel(self.tr("Hide"))
|
self.hdeSection = QLabel(self.tr("Hide"))
|
||||||
self.hdeSection.setToolTip(sectionHideTip)
|
self.hdeSection.setToolTip(sectionHideTip)
|
||||||
@@ -868,9 +864,9 @@ class _HeadingSyntaxHighlighter(QSyntaxHighlighter):
|
|||||||
def __init__(self, document: QTextDocument) -> None:
|
def __init__(self, document: QTextDocument) -> None:
|
||||||
super().__init__(document)
|
super().__init__(document)
|
||||||
self._fmtSymbol = QTextCharFormat()
|
self._fmtSymbol = QTextCharFormat()
|
||||||
self._fmtSymbol.setForeground(QColor(*CONFIG.theme.colHead))
|
self._fmtSymbol.setForeground(QColor(*SHARED.theme.colHead))
|
||||||
self._fmtFormat = QTextCharFormat()
|
self._fmtFormat = QTextCharFormat()
|
||||||
self._fmtFormat.setForeground(QColor(*CONFIG.theme.colEmph))
|
self._fmtFormat.setForeground(QColor(*SHARED.theme.colEmph))
|
||||||
return
|
return
|
||||||
|
|
||||||
def highlightBlock(self, text: str) -> None:
|
def highlightBlock(self, text: str) -> None:
|
||||||
@@ -896,7 +892,7 @@ class _ContentTab(QWidget):
|
|||||||
|
|
||||||
self._build = build
|
self._build = build
|
||||||
|
|
||||||
iPx = CONFIG.theme.baseIconSize
|
iPx = SHARED.theme.baseIconSize
|
||||||
|
|
||||||
# Left Form
|
# Left Form
|
||||||
# =========
|
# =========
|
||||||
@@ -964,14 +960,13 @@ class _FormatTab(QWidget):
|
|||||||
super().__init__(parent=buildMain)
|
super().__init__(parent=buildMain)
|
||||||
|
|
||||||
self.buildMain = buildMain
|
self.buildMain = buildMain
|
||||||
self.mainGui = buildMain.mainGui
|
|
||||||
|
|
||||||
self._build = build
|
self._build = build
|
||||||
self._unitScale = 1.0
|
self._unitScale = 1.0
|
||||||
|
|
||||||
iPx = CONFIG.theme.baseIconSize
|
iPx = SHARED.theme.baseIconSize
|
||||||
spW = 6*CONFIG.theme.textNWidth
|
spW = 6*SHARED.theme.textNWidth
|
||||||
dbW = 8*CONFIG.theme.textNWidth
|
dbW = 8*SHARED.theme.textNWidth
|
||||||
|
|
||||||
# Text Format Form
|
# Text Format Form
|
||||||
# ================
|
# ================
|
||||||
@@ -992,7 +987,7 @@ class _FormatTab(QWidget):
|
|||||||
self.textFont = QLineEdit()
|
self.textFont = QLineEdit()
|
||||||
self.textFont.setReadOnly(True)
|
self.textFont.setReadOnly(True)
|
||||||
self.btnTextFont = QPushButton("...")
|
self.btnTextFont = QPushButton("...")
|
||||||
self.btnTextFont.setMaximumWidth(int(2.5*CONFIG.theme.getTextWidth("...")))
|
self.btnTextFont.setMaximumWidth(int(2.5*SHARED.theme.getTextWidth("...")))
|
||||||
self.btnTextFont.clicked.connect(self._selectFont)
|
self.btnTextFont.clicked.connect(self._selectFont)
|
||||||
self.formFormat.addRow(
|
self.formFormat.addRow(
|
||||||
self._build.getLabel("format.textFont"), self.textFont, button=self.btnTextFont
|
self._build.getLabel("format.textFont"), self.textFont, button=self.btnTextFont
|
||||||
@@ -1278,7 +1273,7 @@ class _OutputTab(QWidget):
|
|||||||
|
|
||||||
self._build = build
|
self._build = build
|
||||||
|
|
||||||
iPx = CONFIG.theme.baseIconSize
|
iPx = SHARED.theme.baseIconSize
|
||||||
|
|
||||||
# Left Form
|
# Left Form
|
||||||
# =========
|
# =========
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ from PyQt5.QtWidgets import (
|
|||||||
QPushButton, QRadioButton, QSpinBox, QVBoxLayout, QWizard, QWizardPage
|
QPushButton, QRadioButton, QSpinBox, QVBoxLayout, QWizard, QWizardPage
|
||||||
)
|
)
|
||||||
|
|
||||||
from novelwriter import CONFIG
|
from novelwriter import CONFIG, SHARED
|
||||||
from novelwriter.common import makeFileNameSafe
|
from novelwriter.common import makeFileNameSafe
|
||||||
from novelwriter.extensions.switch import NSwitch
|
from novelwriter.extensions.switch import NSwitch
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ class GuiProjectWizard(QWizard):
|
|||||||
|
|
||||||
self.mainGui = mainGui
|
self.mainGui = mainGui
|
||||||
|
|
||||||
self.sideImage = CONFIG.theme.loadDecoration(
|
self.sideImage = SHARED.theme.loadDecoration(
|
||||||
"wiz-back", None, CONFIG.pxInt(370)
|
"wiz-back", None, CONFIG.pxInt(370)
|
||||||
)
|
)
|
||||||
self.setWizardStyle(QWizard.ModernStyle)
|
self.setWizardStyle(QWizard.ModernStyle)
|
||||||
@@ -104,7 +104,7 @@ class ProjWizardIntroPage(QWizardPage):
|
|||||||
"Peter Mitterhofer", "CC BY-SA 4.0"
|
"Peter Mitterhofer", "CC BY-SA 4.0"
|
||||||
))
|
))
|
||||||
lblFont = self.imgCredit.font()
|
lblFont = self.imgCredit.font()
|
||||||
lblFont.setPointSizeF(0.6*CONFIG.theme.fontPointSize)
|
lblFont.setPointSizeF(0.6*SHARED.theme.fontPointSize)
|
||||||
self.imgCredit.setFont(lblFont)
|
self.imgCredit.setFont(lblFont)
|
||||||
|
|
||||||
xW = CONFIG.pxInt(300)
|
xW = CONFIG.pxInt(300)
|
||||||
@@ -172,7 +172,7 @@ class ProjWizardFolderPage(QWizardPage):
|
|||||||
self.projPath.setPlaceholderText(self.tr("Required"))
|
self.projPath.setPlaceholderText(self.tr("Required"))
|
||||||
|
|
||||||
self.browseButton = QPushButton("...")
|
self.browseButton = QPushButton("...")
|
||||||
self.browseButton.setMaximumWidth(int(2.5*CONFIG.theme.getTextWidth("...")))
|
self.browseButton.setMaximumWidth(int(2.5*SHARED.theme.getTextWidth("...")))
|
||||||
self.browseButton.clicked.connect(self._doBrowse)
|
self.browseButton.clicked.connect(self._doBrowse)
|
||||||
|
|
||||||
self.errLabel = QLabel("")
|
self.errLabel = QLabel("")
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ from PyQt5.QtWidgets import (
|
|||||||
QLabel, QGroupBox, QMenu, QAction, QFileDialog, QSpinBox, QHBoxLayout
|
QLabel, QGroupBox, QMenu, QAction, QFileDialog, QSpinBox, QHBoxLayout
|
||||||
)
|
)
|
||||||
|
|
||||||
from novelwriter import CONFIG
|
from novelwriter import CONFIG, SHARED
|
||||||
from novelwriter.enum import nwAlert
|
from novelwriter.enum import nwAlert
|
||||||
from novelwriter.error import formatException
|
from novelwriter.error import formatException
|
||||||
from novelwriter.common import formatTime, checkInt, checkIntTuple, minmax
|
from novelwriter.common import formatTime, checkInt, checkIntTuple, minmax
|
||||||
@@ -79,7 +79,7 @@ class GuiWritingStats(QDialog):
|
|||||||
self.timeFilter = 0.0
|
self.timeFilter = 0.0
|
||||||
self.wordOffset = 0
|
self.wordOffset = 0
|
||||||
|
|
||||||
pOptions = self.mainGui.project.options
|
pOptions = SHARED.project.options
|
||||||
|
|
||||||
self.setWindowTitle(self.tr("Writing Statistics"))
|
self.setWindowTitle(self.tr("Writing Statistics"))
|
||||||
self.setMinimumWidth(CONFIG.pxInt(420))
|
self.setMinimumWidth(CONFIG.pxInt(420))
|
||||||
@@ -132,7 +132,7 @@ class GuiWritingStats(QDialog):
|
|||||||
self.listBox.setSortingEnabled(True)
|
self.listBox.setSortingEnabled(True)
|
||||||
|
|
||||||
# Word Bar
|
# Word Bar
|
||||||
self.barHeight = int(round(0.5*CONFIG.theme.fontPixelSize))
|
self.barHeight = int(round(0.5*SHARED.theme.fontPixelSize))
|
||||||
self.barWidth = CONFIG.pxInt(200)
|
self.barWidth = CONFIG.pxInt(200)
|
||||||
self.barImage = QPixmap(self.barHeight, self.barHeight)
|
self.barImage = QPixmap(self.barHeight, self.barHeight)
|
||||||
self.barImage.fill(self.palette().highlight().color())
|
self.barImage.fill(self.palette().highlight().color())
|
||||||
@@ -143,27 +143,27 @@ class GuiWritingStats(QDialog):
|
|||||||
self.infoBox.setLayout(self.infoForm)
|
self.infoBox.setLayout(self.infoForm)
|
||||||
|
|
||||||
self.labelTotal = QLabel(formatTime(0))
|
self.labelTotal = QLabel(formatTime(0))
|
||||||
self.labelTotal.setFont(CONFIG.theme.guiFontFixed)
|
self.labelTotal.setFont(SHARED.theme.guiFontFixed)
|
||||||
self.labelTotal.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
|
self.labelTotal.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
|
||||||
|
|
||||||
self.labelIdleT = QLabel(formatTime(0))
|
self.labelIdleT = QLabel(formatTime(0))
|
||||||
self.labelIdleT.setFont(CONFIG.theme.guiFontFixed)
|
self.labelIdleT.setFont(SHARED.theme.guiFontFixed)
|
||||||
self.labelIdleT.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
|
self.labelIdleT.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
|
||||||
|
|
||||||
self.labelFilter = QLabel(formatTime(0))
|
self.labelFilter = QLabel(formatTime(0))
|
||||||
self.labelFilter.setFont(CONFIG.theme.guiFontFixed)
|
self.labelFilter.setFont(SHARED.theme.guiFontFixed)
|
||||||
self.labelFilter.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
|
self.labelFilter.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
|
||||||
|
|
||||||
self.novelWords = QLabel("0")
|
self.novelWords = QLabel("0")
|
||||||
self.novelWords.setFont(CONFIG.theme.guiFontFixed)
|
self.novelWords.setFont(SHARED.theme.guiFontFixed)
|
||||||
self.novelWords.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
|
self.novelWords.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
|
||||||
|
|
||||||
self.notesWords = QLabel("0")
|
self.notesWords = QLabel("0")
|
||||||
self.notesWords.setFont(CONFIG.theme.guiFontFixed)
|
self.notesWords.setFont(SHARED.theme.guiFontFixed)
|
||||||
self.notesWords.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
|
self.notesWords.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
|
||||||
|
|
||||||
self.totalWords = QLabel("0")
|
self.totalWords = QLabel("0")
|
||||||
self.totalWords.setFont(CONFIG.theme.guiFontFixed)
|
self.totalWords.setFont(SHARED.theme.guiFontFixed)
|
||||||
self.totalWords.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
|
self.totalWords.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
|
||||||
|
|
||||||
lblTTime = QLabel(self.tr("Total Time:"))
|
lblTTime = QLabel(self.tr("Total Time:"))
|
||||||
@@ -190,7 +190,7 @@ class GuiWritingStats(QDialog):
|
|||||||
self.infoForm.setRowStretch(6, 1)
|
self.infoForm.setRowStretch(6, 1)
|
||||||
|
|
||||||
# Filter Options
|
# Filter Options
|
||||||
sPx = CONFIG.theme.baseIconSize
|
sPx = SHARED.theme.baseIconSize
|
||||||
|
|
||||||
self.filterBox = QGroupBox(self.tr("Filters"), self)
|
self.filterBox = QGroupBox(self.tr("Filters"), self)
|
||||||
self.filterForm = QGridLayout(self)
|
self.filterForm = QGridLayout(self)
|
||||||
@@ -333,7 +333,7 @@ class GuiWritingStats(QDialog):
|
|||||||
showIdleTime = self.showIdleTime.isChecked()
|
showIdleTime = self.showIdleTime.isChecked()
|
||||||
histMax = self.histMax.value()
|
histMax = self.histMax.value()
|
||||||
|
|
||||||
pOptions = self.mainGui.project.options
|
pOptions = SHARED.project.options
|
||||||
pOptions.setValue("GuiWritingStats", "winWidth", winWidth)
|
pOptions.setValue("GuiWritingStats", "winWidth", winWidth)
|
||||||
pOptions.setValue("GuiWritingStats", "winHeight", winHeight)
|
pOptions.setValue("GuiWritingStats", "winHeight", winHeight)
|
||||||
pOptions.setValue("GuiWritingStats", "widthCol0", widthCol0)
|
pOptions.setValue("GuiWritingStats", "widthCol0", widthCol0)
|
||||||
@@ -441,7 +441,7 @@ class GuiWritingStats(QDialog):
|
|||||||
ttTime = 0
|
ttTime = 0
|
||||||
ttIdle = 0
|
ttIdle = 0
|
||||||
|
|
||||||
for record in self.mainGui.project.session.iterRecords():
|
for record in SHARED.project.session.iterRecords():
|
||||||
rType = record.get("type")
|
rType = record.get("type")
|
||||||
if rType == "initial":
|
if rType == "initial":
|
||||||
self.wordOffset = checkInt(record.get("offset"), 0)
|
self.wordOffset = checkInt(record.get("offset"), 0)
|
||||||
@@ -587,13 +587,13 @@ class GuiWritingStats(QDialog):
|
|||||||
newItem.setTextAlignment(self.C_COUNT, Qt.AlignRight)
|
newItem.setTextAlignment(self.C_COUNT, Qt.AlignRight)
|
||||||
newItem.setTextAlignment(self.C_BAR, Qt.AlignLeft | Qt.AlignVCenter)
|
newItem.setTextAlignment(self.C_BAR, Qt.AlignLeft | Qt.AlignVCenter)
|
||||||
|
|
||||||
newItem.setFont(self.C_TIME, CONFIG.theme.guiFontFixed)
|
newItem.setFont(self.C_TIME, SHARED.theme.guiFontFixed)
|
||||||
newItem.setFont(self.C_LENGTH, CONFIG.theme.guiFontFixed)
|
newItem.setFont(self.C_LENGTH, SHARED.theme.guiFontFixed)
|
||||||
newItem.setFont(self.C_COUNT, CONFIG.theme.guiFontFixed)
|
newItem.setFont(self.C_COUNT, SHARED.theme.guiFontFixed)
|
||||||
if showIdleTime:
|
if showIdleTime:
|
||||||
newItem.setFont(self.C_IDLE, CONFIG.theme.guiFontFixed)
|
newItem.setFont(self.C_IDLE, SHARED.theme.guiFontFixed)
|
||||||
else:
|
else:
|
||||||
newItem.setFont(self.C_IDLE, CONFIG.theme.guiFont)
|
newItem.setFont(self.C_IDLE, SHARED.theme.guiFont)
|
||||||
|
|
||||||
self.listBox.addTopLevelItem(newItem)
|
self.listBox.addTopLevelItem(newItem)
|
||||||
self.timeFilter += sDiff
|
self.timeFilter += sDiff
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ from tools import writeFile
|
|||||||
from PyQt5.QtGui import QIcon, QPalette, QPixmap
|
from PyQt5.QtGui import QIcon, QPalette, QPixmap
|
||||||
from PyQt5.QtWidgets import QApplication
|
from PyQt5.QtWidgets import QApplication
|
||||||
|
|
||||||
from novelwriter import CONFIG
|
from novelwriter import CONFIG, SHARED
|
||||||
from novelwriter.enum import nwItemClass, nwItemLayout, nwItemType
|
from novelwriter.enum import nwItemClass, nwItemLayout, nwItemType
|
||||||
from novelwriter.constants import nwLabels
|
from novelwriter.constants import nwLabels
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ from novelwriter.constants import nwLabels
|
|||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testGuiTheme_Main(qtbot, nwGUI, tstPaths):
|
def testGuiTheme_Main(qtbot, nwGUI, tstPaths):
|
||||||
"""Test the theme class init."""
|
"""Test the theme class init."""
|
||||||
mainTheme = CONFIG.theme
|
mainTheme = SHARED.theme
|
||||||
|
|
||||||
# Methods
|
# Methods
|
||||||
# =======
|
# =======
|
||||||
@@ -121,7 +121,7 @@ def testGuiTheme_Main(qtbot, nwGUI, tstPaths):
|
|||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testGuiTheme_Theme(qtbot, monkeypatch, nwGUI):
|
def testGuiTheme_Theme(qtbot, monkeypatch, nwGUI):
|
||||||
"""Test the theme part of the class."""
|
"""Test the theme part of the class."""
|
||||||
mainTheme = CONFIG.theme
|
mainTheme = SHARED.theme
|
||||||
|
|
||||||
# List Themes
|
# List Themes
|
||||||
# ===========
|
# ===========
|
||||||
@@ -199,7 +199,7 @@ def testGuiTheme_Theme(qtbot, monkeypatch, nwGUI):
|
|||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testGuiTheme_Syntax(qtbot, monkeypatch, nwGUI):
|
def testGuiTheme_Syntax(qtbot, monkeypatch, nwGUI):
|
||||||
"""Test the syntax part of the class."""
|
"""Test the syntax part of the class."""
|
||||||
mainTheme = CONFIG.theme
|
mainTheme = SHARED.theme
|
||||||
|
|
||||||
# List Themes
|
# List Themes
|
||||||
# ===========
|
# ===========
|
||||||
@@ -264,7 +264,7 @@ def testGuiTheme_Syntax(qtbot, monkeypatch, nwGUI):
|
|||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testGuiTheme_Icons(qtbot, caplog, monkeypatch, nwGUI, tstPaths):
|
def testGuiTheme_Icons(qtbot, caplog, monkeypatch, nwGUI, tstPaths):
|
||||||
"""Test the icon cache class."""
|
"""Test the icon cache class."""
|
||||||
iconCache = CONFIG.theme.iconCache
|
iconCache = SHARED.theme.iconCache
|
||||||
|
|
||||||
# Load Theme
|
# Load Theme
|
||||||
# ==========
|
# ==========
|
||||||
|
|||||||
Reference in New Issue
Block a user