Merge branch 'dev' into feature/build_gui
This commit is contained in:
@@ -31,7 +31,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import bisect
|
||||
import logging
|
||||
import novelwriter
|
||||
|
||||
from enum import Enum
|
||||
from time import time
|
||||
@@ -50,6 +49,7 @@ from PyQt5.QtWidgets import (
|
||||
QFrame
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter.enum import nwAlert, nwDocAction, nwDocInsert, nwDocMode, nwItemClass
|
||||
from novelwriter.common import minmax, transferCase
|
||||
from novelwriter.constants import nwConst, nwFiles, nwKeyWords, nwUnicode
|
||||
@@ -81,7 +81,6 @@ class GuiDocEditor(QTextEdit):
|
||||
logger.debug("Initialising GuiDocEditor ...")
|
||||
|
||||
# Class Variables
|
||||
self.mainConf = novelwriter.CONFIG
|
||||
self.mainGui = mainGui
|
||||
self.mainTheme = mainGui.mainTheme
|
||||
self.theProject = mainGui.theProject
|
||||
@@ -140,7 +139,7 @@ class GuiDocEditor(QTextEdit):
|
||||
self.customContextMenuRequested.connect(self._openContextMenu)
|
||||
|
||||
# Editor Settings
|
||||
self.setMinimumWidth(self.mainConf.pxInt(300))
|
||||
self.setMinimumWidth(CONFIG.pxInt(300))
|
||||
self.setAcceptRichText(False)
|
||||
self.setAutoFillBackground(True)
|
||||
self.setFrameStyle(QFrame.NoFrame)
|
||||
@@ -169,7 +168,7 @@ class GuiDocEditor(QTextEdit):
|
||||
self.wCounterDoc.setAutoDelete(False)
|
||||
self.wCounterDoc.signals.countsReady.connect(self._updateDocCounts)
|
||||
|
||||
self.wcInterval = self.mainConf.wordCountTimer
|
||||
self.wcInterval = CONFIG.wordCountTimer
|
||||
|
||||
# Set Up Selection Word Counter
|
||||
self.wcTimerSel = QTimer()
|
||||
@@ -252,26 +251,26 @@ class GuiDocEditor(QTextEdit):
|
||||
# Some Constants
|
||||
self._nonWord = (
|
||||
"\"'"
|
||||
f"{self.mainConf.fmtSQuoteOpen}{self.mainConf.fmtSQuoteClose}"
|
||||
f"{self.mainConf.fmtDQuoteOpen}{self.mainConf.fmtDQuoteClose}"
|
||||
f"{CONFIG.fmtSQuoteOpen}{CONFIG.fmtSQuoteClose}"
|
||||
f"{CONFIG.fmtDQuoteOpen}{CONFIG.fmtDQuoteClose}"
|
||||
)
|
||||
|
||||
# Typography
|
||||
if self.mainConf.fmtPadThin:
|
||||
if CONFIG.fmtPadThin:
|
||||
self._typPadChar = nwUnicode.U_THNBSP
|
||||
else:
|
||||
self._typPadChar = nwUnicode.U_NBSP
|
||||
|
||||
self._typSQuoteO = self.mainConf.fmtSQuoteOpen
|
||||
self._typSQuoteC = self.mainConf.fmtSQuoteClose
|
||||
self._typDQuoteO = self.mainConf.fmtDQuoteOpen
|
||||
self._typDQuoteC = self.mainConf.fmtDQuoteClose
|
||||
self._typRepDQuote = self.mainConf.doReplaceDQuote
|
||||
self._typRepSQuote = self.mainConf.doReplaceSQuote
|
||||
self._typRepDash = self.mainConf.doReplaceDash
|
||||
self._typRepDots = self.mainConf.doReplaceDots
|
||||
self._typPadBefore = self.mainConf.fmtPadBefore
|
||||
self._typPadAfter = self.mainConf.fmtPadAfter
|
||||
self._typSQuoteO = CONFIG.fmtSQuoteOpen
|
||||
self._typSQuoteC = CONFIG.fmtSQuoteClose
|
||||
self._typDQuoteO = CONFIG.fmtDQuoteOpen
|
||||
self._typDQuoteC = CONFIG.fmtDQuoteClose
|
||||
self._typRepDQuote = CONFIG.doReplaceDQuote
|
||||
self._typRepSQuote = CONFIG.doReplaceSQuote
|
||||
self._typRepDash = CONFIG.doReplaceDash
|
||||
self._typRepDots = CONFIG.doReplaceDots
|
||||
self._typPadBefore = CONFIG.fmtPadBefore
|
||||
self._typPadAfter = CONFIG.fmtPadAfter
|
||||
|
||||
# Reload spell check and dictionaries
|
||||
self.setDictionaries()
|
||||
@@ -279,23 +278,23 @@ class GuiDocEditor(QTextEdit):
|
||||
# Set font
|
||||
theFont = QFont()
|
||||
qDoc = self.document()
|
||||
if self.mainConf.textFont is None:
|
||||
if CONFIG.textFont is None:
|
||||
# If none is defined, set a default font
|
||||
theFont = QFont()
|
||||
if self.mainConf.osWindows and "Arial" in self.mainTheme.guiFontDB.families():
|
||||
if CONFIG.osWindows and "Arial" in self.mainTheme.guiFontDB.families():
|
||||
theFont.setFamily("Arial")
|
||||
theFont.setPointSize(12)
|
||||
elif self.mainConf.osDarwin and "Courier" in self.mainTheme.guiFontDB.families():
|
||||
elif CONFIG.osDarwin and "Courier" in self.mainTheme.guiFontDB.families():
|
||||
theFont.setFamily("Courier")
|
||||
theFont.setPointSize(12)
|
||||
else:
|
||||
theFont = qDoc.defaultFont()
|
||||
|
||||
self.mainConf.textFont = theFont.family()
|
||||
self.mainConf.textSize = theFont.pointSize()
|
||||
CONFIG.textFont = theFont.family()
|
||||
CONFIG.textSize = theFont.pointSize()
|
||||
|
||||
theFont.setFamily(self.mainConf.textFont)
|
||||
theFont.setPointSize(self.mainConf.textSize)
|
||||
theFont.setFamily(CONFIG.textFont)
|
||||
theFont.setPointSize(CONFIG.textSize)
|
||||
self.setFont(theFont)
|
||||
|
||||
# Set default text margins
|
||||
@@ -303,37 +302,37 @@ class GuiDocEditor(QTextEdit):
|
||||
# allocated to the document itself. See issue #1112.
|
||||
cW = self.cursorWidth()
|
||||
qDoc.setDocumentMargin(cW)
|
||||
self._vpMargin = max(self.mainConf.getTextMargin() - cW, 0)
|
||||
self._vpMargin = max(CONFIG.getTextMargin() - cW, 0)
|
||||
self.setViewportMargins(self._vpMargin, self._vpMargin, self._vpMargin, self._vpMargin)
|
||||
|
||||
# Also set the document text options for the document text flow
|
||||
theOpt = QTextOption()
|
||||
|
||||
if self.mainConf.doJustify:
|
||||
if CONFIG.doJustify:
|
||||
theOpt.setAlignment(Qt.AlignJustify)
|
||||
if self.mainConf.showTabsNSpaces:
|
||||
if CONFIG.showTabsNSpaces:
|
||||
theOpt.setFlags(theOpt.flags() | QTextOption.ShowTabsAndSpaces)
|
||||
if self.mainConf.showLineEndings:
|
||||
if CONFIG.showLineEndings:
|
||||
theOpt.setFlags(theOpt.flags() | QTextOption.ShowLineAndParagraphSeparators)
|
||||
|
||||
qDoc.setDefaultTextOption(theOpt)
|
||||
|
||||
# Scroll bars
|
||||
if self.mainConf.hideVScroll:
|
||||
if CONFIG.hideVScroll:
|
||||
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
else:
|
||||
self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
|
||||
|
||||
if self.mainConf.hideHScroll:
|
||||
if CONFIG.hideHScroll:
|
||||
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
else:
|
||||
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
|
||||
|
||||
# Refresh the tab stops
|
||||
self.setTabStopDistance(self.mainConf.getTabWidth())
|
||||
self.setTabStopDistance(CONFIG.getTabWidth())
|
||||
|
||||
# Configure word count timer
|
||||
self.wcInterval = self.mainConf.wordCountTimer
|
||||
self.wcInterval = CONFIG.wordCountTimer
|
||||
self.wcTimerDoc.setInterval(int(self.wcInterval*1000))
|
||||
|
||||
# If we have a document open, we should reload it in case the
|
||||
@@ -420,10 +419,10 @@ class GuiDocEditor(QTextEdit):
|
||||
elif isinstance(tLine, int):
|
||||
self.setCursorLine(tLine)
|
||||
|
||||
if self.mainConf.scrollPastEnd > 0:
|
||||
if CONFIG.scrollPastEnd > 0:
|
||||
fSize = QFontMetrics(self.font()).lineSpacing()
|
||||
docFrame = self.document().rootFrame().frameFormat()
|
||||
docFrame.setBottomMargin(round(self.mainConf.scrollPastEnd * fSize))
|
||||
docFrame.setBottomMargin(round(CONFIG.scrollPastEnd * fSize))
|
||||
self.document().rootFrame().setFrameFormat(docFrame)
|
||||
|
||||
self.docFooter.updateLineCount()
|
||||
@@ -571,8 +570,8 @@ class GuiDocEditor(QTextEdit):
|
||||
sH = hBar.height() if hBar.isVisible() else 0
|
||||
|
||||
tM = self._vpMargin
|
||||
if self.mainConf.textWidth > 0 or self.mainGui.isFocusMode:
|
||||
tW = self.mainConf.getTextWidth(self.mainGui.isFocusMode)
|
||||
if CONFIG.textWidth > 0 or self.mainGui.isFocusMode:
|
||||
tW = CONFIG.getTextWidth(self.mainGui.isFocusMode)
|
||||
tM = max((wW - sW - tW)//2, self._vpMargin)
|
||||
|
||||
tB = self.frameWidth()
|
||||
@@ -674,7 +673,7 @@ class GuiDocEditor(QTextEdit):
|
||||
# when it is enabled. By default, it's 30% of viewport.
|
||||
vPos = self.verticalScrollBar().value()
|
||||
cPos = self.cursorRect().topLeft().y()
|
||||
mPos = int(self.mainConf.autoScrollPos*0.01 * self.viewport().height())
|
||||
mPos = int(CONFIG.autoScrollPos*0.01 * self.viewport().height())
|
||||
if cPos > mPos:
|
||||
# Only scroll if the cursor is past the auto-scroll limit
|
||||
self.verticalScrollBar().setValue(max(0, vPos + cPos - mPos))
|
||||
@@ -715,7 +714,7 @@ class GuiDocEditor(QTextEdit):
|
||||
dictionary changed signal.
|
||||
"""
|
||||
if self.theProject.data.spellLang is None:
|
||||
theLang = self.mainConf.spellLanguage
|
||||
theLang = CONFIG.spellLanguage
|
||||
else:
|
||||
theLang = self.theProject.data.spellLang
|
||||
|
||||
@@ -738,7 +737,7 @@ class GuiDocEditor(QTextEdit):
|
||||
if theMode is None:
|
||||
theMode = not self._spellCheck
|
||||
|
||||
if not self.mainConf.hasEnchant:
|
||||
if not CONFIG.hasEnchant:
|
||||
if theMode:
|
||||
self.mainGui.makeAlert(self.tr(
|
||||
"Spell checking requires the package PyEnchant. "
|
||||
@@ -1038,7 +1037,7 @@ class GuiDocEditor(QTextEdit):
|
||||
self.docAction(nwDocAction.SEL_ALL)
|
||||
return
|
||||
|
||||
if self.mainConf.autoScroll:
|
||||
if CONFIG.autoScroll:
|
||||
|
||||
cOld = self.cursorRect().center().y()
|
||||
super().keyPressEvent(keyEvent)
|
||||
@@ -1049,7 +1048,7 @@ class GuiDocEditor(QTextEdit):
|
||||
if okMod and okKey:
|
||||
cNew = self.cursorRect().center().y()
|
||||
cMov = cNew - cOld
|
||||
mPos = self.mainConf.autoScrollPos*0.01 * self.viewport().height()
|
||||
mPos = CONFIG.autoScrollPos*0.01 * self.viewport().height()
|
||||
if abs(cMov) > 0 and cOld > mPos:
|
||||
# Move the scroll bar
|
||||
vBar = self.verticalScrollBar()
|
||||
@@ -2090,7 +2089,7 @@ class GuiDocEditor(QTextEdit):
|
||||
"""Check if document size crosses the big document limit set in
|
||||
config. If so, we will set the big document flag to True.
|
||||
"""
|
||||
bigLim = round(self.mainConf.bigDocLimit*1000)
|
||||
bigLim = round(CONFIG.bigDocLimit*1000)
|
||||
newState = theSize > bigLim
|
||||
|
||||
if newState != self._bigDoc:
|
||||
@@ -2114,7 +2113,7 @@ class GuiDocEditor(QTextEdit):
|
||||
on user settings and document action.
|
||||
"""
|
||||
theCursor = self.textCursor()
|
||||
if self.mainConf.autoSelect and not theCursor.hasSelection():
|
||||
if CONFIG.autoSelect and not theCursor.hasSelection():
|
||||
theCursor.select(QTextCursor.WordUnderCursor)
|
||||
posS = theCursor.selectionStart()
|
||||
posE = theCursor.selectionEnd()
|
||||
@@ -2175,7 +2174,7 @@ class GuiDocEditor(QTextEdit):
|
||||
"""Enable/disable the auto-replace feature temporarily.
|
||||
"""
|
||||
if theState:
|
||||
self._doReplace = self.mainConf.doReplace
|
||||
self._doReplace = CONFIG.doReplace
|
||||
else:
|
||||
self._doReplace = False
|
||||
return
|
||||
@@ -2245,21 +2244,20 @@ class GuiDocEditSearch(QFrame):
|
||||
|
||||
logger.debug("Initialising GuiDocEditSearch ...")
|
||||
|
||||
self.mainConf = novelwriter.CONFIG
|
||||
self.docEditor = docEditor
|
||||
self.mainGui = docEditor.mainGui
|
||||
self.theProject = docEditor.theProject
|
||||
self.mainTheme = docEditor.mainTheme
|
||||
|
||||
self.repVisible = False
|
||||
self.isCaseSense = self.mainConf.searchCase
|
||||
self.isWholeWord = self.mainConf.searchWord
|
||||
self.isRegEx = self.mainConf.searchRegEx
|
||||
self.doLoop = self.mainConf.searchLoop
|
||||
self.doNextFile = self.mainConf.searchNextFile
|
||||
self.doMatchCap = self.mainConf.searchMatchCap
|
||||
self.isCaseSense = CONFIG.searchCase
|
||||
self.isWholeWord = CONFIG.searchWord
|
||||
self.isRegEx = CONFIG.searchRegEx
|
||||
self.doLoop = CONFIG.searchLoop
|
||||
self.doNextFile = CONFIG.searchNextFile
|
||||
self.doMatchCap = CONFIG.searchMatchCap
|
||||
|
||||
mPx = self.mainConf.pxInt(6)
|
||||
mPx = CONFIG.pxInt(6)
|
||||
tPx = int(0.8*self.mainTheme.fontPixelSize)
|
||||
self.boxFont = self.mainTheme.guiFont
|
||||
self.boxFont.setPointSizeF(0.9*self.mainTheme.fontPointSize)
|
||||
@@ -2291,7 +2289,7 @@ class GuiDocEditSearch(QFrame):
|
||||
|
||||
self.searchLabel = QLabel(self.tr("Search"))
|
||||
self.searchLabel.setFont(self.boxFont)
|
||||
self.searchLabel.setIndent(self.mainConf.pxInt(6))
|
||||
self.searchLabel.setIndent(CONFIG.pxInt(6))
|
||||
|
||||
self.resultLabel = QLabel("?/?")
|
||||
self.resultLabel.setFont(self.boxFont)
|
||||
@@ -2376,10 +2374,10 @@ class GuiDocEditSearch(QFrame):
|
||||
self.mainBox.setColumnStretch(3, 0)
|
||||
self.mainBox.setColumnStretch(4, 0)
|
||||
self.mainBox.setColumnStretch(5, 0)
|
||||
self.mainBox.setSpacing(self.mainConf.pxInt(2))
|
||||
self.mainBox.setSpacing(CONFIG.pxInt(2))
|
||||
self.mainBox.setContentsMargins(mPx, mPx, mPx, mPx)
|
||||
|
||||
boxWidth = self.mainConf.pxInt(200)
|
||||
boxWidth = CONFIG.pxInt(200)
|
||||
self.searchBox.setFixedWidth(boxWidth)
|
||||
self.replaceBox.setFixedWidth(boxWidth)
|
||||
self.replaceBox.setVisible(False)
|
||||
@@ -2438,12 +2436,12 @@ class GuiDocEditSearch(QFrame):
|
||||
def closeSearch(self):
|
||||
"""Close the search box.
|
||||
"""
|
||||
self.mainConf.searchCase = self.isCaseSense
|
||||
self.mainConf.searchWord = self.isWholeWord
|
||||
self.mainConf.searchRegEx = self.isRegEx
|
||||
self.mainConf.searchLoop = self.doLoop
|
||||
self.mainConf.searchNextFile = self.doNextFile
|
||||
self.mainConf.searchMatchCap = self.doMatchCap
|
||||
CONFIG.searchCase = self.isCaseSense
|
||||
CONFIG.searchWord = self.isWholeWord
|
||||
CONFIG.searchRegEx = self.isRegEx
|
||||
CONFIG.searchLoop = self.doLoop
|
||||
CONFIG.searchNextFile = self.doNextFile
|
||||
CONFIG.searchMatchCap = self.doMatchCap
|
||||
|
||||
self.showReplace.setChecked(False)
|
||||
self.setVisible(False)
|
||||
@@ -2517,7 +2515,7 @@ class GuiDocEditSearch(QFrame):
|
||||
# Using the Unicode-capable QRegularExpression class was
|
||||
# only added in Qt 5.13. Otherwise, 5.3 and up supports
|
||||
# only the QRegExp class.
|
||||
if self.mainConf.verQtValue >= 0x050d00:
|
||||
if CONFIG.verQtValue >= 0x050d00:
|
||||
rxOpt = QRegularExpression.UseUnicodePropertiesOption
|
||||
if not self.isCaseSense:
|
||||
rxOpt |= QRegularExpression.CaseInsensitiveOption
|
||||
@@ -2661,7 +2659,6 @@ class GuiDocEditHeader(QWidget):
|
||||
|
||||
logger.debug("Initialising GuiDocEditHeader ...")
|
||||
|
||||
self.mainConf = novelwriter.CONFIG
|
||||
self.docEditor = docEditor
|
||||
self.mainGui = docEditor.mainGui
|
||||
self.theProject = docEditor.theProject
|
||||
@@ -2670,7 +2667,7 @@ class GuiDocEditHeader(QWidget):
|
||||
self._docHandle = None
|
||||
|
||||
fPx = int(0.9*self.mainTheme.fontPixelSize)
|
||||
hSp = self.mainConf.pxInt(6)
|
||||
hSp = CONFIG.pxInt(6)
|
||||
|
||||
# Main Widget Settings
|
||||
self.setAutoFillBackground(True)
|
||||
@@ -2738,7 +2735,7 @@ class GuiDocEditHeader(QWidget):
|
||||
|
||||
# Fix Margins and Size
|
||||
# This is needed for high DPI systems. See issue #499.
|
||||
cM = self.mainConf.pxInt(8)
|
||||
cM = CONFIG.pxInt(8)
|
||||
self.setContentsMargins(0, 0, 0, 0)
|
||||
self.outerBox.setContentsMargins(cM, cM, cM, cM)
|
||||
self.setMinimumHeight(fPx + 2*cM)
|
||||
@@ -2802,7 +2799,7 @@ class GuiDocEditHeader(QWidget):
|
||||
self.minmaxButton.setVisible(False)
|
||||
return True
|
||||
|
||||
if self.mainConf.showFullPath:
|
||||
if CONFIG.showFullPath:
|
||||
tTitle = []
|
||||
tTree = self.theProject.tree.getItemPath(tHandle)
|
||||
for aHandle in reversed(tTree):
|
||||
@@ -2897,7 +2894,6 @@ class GuiDocEditFooter(QWidget):
|
||||
|
||||
logger.debug("Initialising GuiDocEditFooter ...")
|
||||
|
||||
self.mainConf = novelwriter.CONFIG
|
||||
self.docEditor = docEditor
|
||||
self.mainGui = docEditor.mainGui
|
||||
self.theProject = docEditor.theProject
|
||||
@@ -2910,8 +2906,8 @@ class GuiDocEditFooter(QWidget):
|
||||
|
||||
self.sPx = int(round(0.9*self.mainTheme.baseIconSize))
|
||||
fPx = int(0.9*self.mainTheme.fontPixelSize)
|
||||
bSp = self.mainConf.pxInt(4)
|
||||
hSp = self.mainConf.pxInt(6)
|
||||
bSp = CONFIG.pxInt(4)
|
||||
hSp = CONFIG.pxInt(6)
|
||||
|
||||
lblFont = self.font()
|
||||
lblFont.setPointSizeF(0.9*self.mainTheme.fontPointSize)
|
||||
@@ -2980,7 +2976,7 @@ class GuiDocEditFooter(QWidget):
|
||||
|
||||
# Fix Margins and Size
|
||||
# This is needed for high DPI systems. See issue #499.
|
||||
cM = self.mainConf.pxInt(8)
|
||||
cM = CONFIG.pxInt(8)
|
||||
self.setContentsMargins(0, 0, 0, 0)
|
||||
self.outerBox.setContentsMargins(cM, cM, cM, cM)
|
||||
self.setMinimumHeight(fPx + 2*cM)
|
||||
|
||||
@@ -24,7 +24,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import novelwriter
|
||||
|
||||
from time import time
|
||||
|
||||
@@ -33,6 +32,7 @@ from PyQt5.QtGui import (
|
||||
QColor, QTextCharFormat, QFont, QSyntaxHighlighter, QBrush
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter.common import checkInt
|
||||
from novelwriter.constants import nwRegEx, nwUnicode
|
||||
|
||||
@@ -50,7 +50,6 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
super().__init__(theDoc)
|
||||
|
||||
logger.debug("Initialising GuiDocHighlighter ...")
|
||||
self.mainConf = novelwriter.CONFIG
|
||||
self.theDoc = theDoc
|
||||
self.spEnchant = spEnchant
|
||||
self.mainGui = mainGui
|
||||
@@ -103,7 +102,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
self.colBreak.setAlpha(64)
|
||||
|
||||
self.colEmph = None
|
||||
if self.mainConf.highlightEmph:
|
||||
if CONFIG.highlightEmph:
|
||||
self.colEmph = QColor(*self.mainTheme.colEmph)
|
||||
|
||||
self.hStyles = {
|
||||
@@ -135,7 +134,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
self.hRules = []
|
||||
|
||||
# Multiple or Trailing Spaces
|
||||
if self.mainConf.showMultiSpaces:
|
||||
if CONFIG.showMultiSpaces:
|
||||
self.hRules.append((
|
||||
r"[ ]{2,}|[ ]*$", {
|
||||
0: self.hStyles["mspaces"],
|
||||
@@ -150,11 +149,11 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
))
|
||||
|
||||
# Quoted Strings
|
||||
if self.mainConf.highlightQuotes:
|
||||
fmtDblO = self.mainConf.fmtDQuoteOpen
|
||||
fmtDblC = self.mainConf.fmtDQuoteClose
|
||||
fmtSngO = self.mainConf.fmtSQuoteOpen
|
||||
fmtSngC = self.mainConf.fmtSQuoteClose
|
||||
if CONFIG.highlightQuotes:
|
||||
fmtDblO = CONFIG.fmtDQuoteOpen
|
||||
fmtDblC = CONFIG.fmtDQuoteClose
|
||||
fmtSngO = CONFIG.fmtSQuoteOpen
|
||||
fmtSngC = CONFIG.fmtSQuoteClose
|
||||
|
||||
# Straight Quotes
|
||||
if not (fmtDblO == fmtDblC == "\""):
|
||||
@@ -165,7 +164,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
))
|
||||
|
||||
# Double Quotes
|
||||
dblEnd = "|$" if self.mainConf.allowOpenDQuote else ""
|
||||
dblEnd = "|$" if CONFIG.allowOpenDQuote else ""
|
||||
self.hRules.append((
|
||||
f"(\\B{fmtDblO})(.*?)({fmtDblC}\\B{dblEnd})", {
|
||||
0: self.hStyles["dialogue2"],
|
||||
@@ -173,7 +172,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
))
|
||||
|
||||
# Single Quotes
|
||||
sngEnd = "|$" if self.mainConf.allowOpenSQuote else ""
|
||||
sngEnd = "|$" if CONFIG.allowOpenSQuote else ""
|
||||
self.hRules.append((
|
||||
f"(\\B{fmtSngO})(.*?)({fmtSngC}\\B{sngEnd})", {
|
||||
0: self.hStyles["dialogue3"],
|
||||
@@ -432,7 +431,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
theFormat.setBackground(QBrush(fmtCol, Qt.SolidPattern))
|
||||
|
||||
if fmtSize is not None:
|
||||
theFormat.setFontPointSize(int(round(fmtSize*self.mainConf.textSize)))
|
||||
theFormat.setFontPointSize(int(round(fmtSize*CONFIG.textSize)))
|
||||
|
||||
return theFormat
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import novelwriter
|
||||
|
||||
from enum import Enum
|
||||
|
||||
@@ -41,6 +40,7 @@ from PyQt5.QtWidgets import (
|
||||
QAction, QMenu, QFrame
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter.enum import nwItemType, nwDocAction, nwDocMode
|
||||
from novelwriter.error import logException
|
||||
from novelwriter.constants import nwUnicode
|
||||
@@ -59,7 +59,6 @@ class GuiDocViewer(QTextBrowser):
|
||||
logger.debug("Initialising GuiDocViewer ...")
|
||||
|
||||
# Class Variables
|
||||
self.mainConf = novelwriter.CONFIG
|
||||
self.mainGui = mainGui
|
||||
self.mainTheme = mainGui.mainTheme
|
||||
self.theProject = mainGui.theProject
|
||||
@@ -68,7 +67,7 @@ class GuiDocViewer(QTextBrowser):
|
||||
self._docHandle = None
|
||||
|
||||
# Settings
|
||||
self.setMinimumWidth(self.mainConf.pxInt(300))
|
||||
self.setMinimumWidth(CONFIG.pxInt(300))
|
||||
self.setAutoFillBackground(True)
|
||||
self.setOpenExternalLinks(False)
|
||||
self.setFocusPolicy(Qt.StrongFocus)
|
||||
@@ -116,11 +115,11 @@ class GuiDocViewer(QTextBrowser):
|
||||
|
||||
# Set Font
|
||||
theFont = QFont()
|
||||
if self.mainConf.textFont is None:
|
||||
if CONFIG.textFont is None:
|
||||
# If none is defined, set the default back to config
|
||||
self.mainConf.textFont = self.document().defaultFont().family()
|
||||
theFont.setFamily(self.mainConf.textFont)
|
||||
theFont.setPointSize(self.mainConf.textSize)
|
||||
CONFIG.textFont = self.document().defaultFont().family()
|
||||
theFont.setFamily(CONFIG.textFont)
|
||||
theFont.setPointSize(CONFIG.textSize)
|
||||
self.setFont(theFont)
|
||||
|
||||
# Set the widget colours to match syntax theme
|
||||
@@ -141,23 +140,23 @@ class GuiDocViewer(QTextBrowser):
|
||||
# Set default text margins
|
||||
self.document().setDocumentMargin(0)
|
||||
theOpt = QTextOption()
|
||||
if self.mainConf.doJustify:
|
||||
if CONFIG.doJustify:
|
||||
theOpt.setAlignment(Qt.AlignJustify)
|
||||
self.document().setDefaultTextOption(theOpt)
|
||||
|
||||
# Scroll bars
|
||||
if self.mainConf.hideVScroll:
|
||||
if CONFIG.hideVScroll:
|
||||
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
else:
|
||||
self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
|
||||
|
||||
if self.mainConf.hideHScroll:
|
||||
if CONFIG.hideHScroll:
|
||||
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
else:
|
||||
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
|
||||
|
||||
# Refresh the tab stops
|
||||
self.setTabStopDistance(self.mainConf.getTabWidth())
|
||||
self.setTabStopDistance(CONFIG.getTabWidth())
|
||||
|
||||
# If we have a document open, we should reload it in case the font changed
|
||||
if self._docHandle is not None:
|
||||
@@ -177,7 +176,7 @@ class GuiDocViewer(QTextBrowser):
|
||||
|
||||
sPos = self.verticalScrollBar().value()
|
||||
aDoc = ToHtml(self.theProject)
|
||||
aDoc.setPreview(self.mainConf.viewComments, self.mainConf.viewSynopsis)
|
||||
aDoc.setPreview(CONFIG.viewComments, CONFIG.viewSynopsis)
|
||||
aDoc.setLinkHeaders(True)
|
||||
|
||||
# Be extra careful here to prevent crashes when first opening a
|
||||
@@ -196,7 +195,7 @@ class GuiDocViewer(QTextBrowser):
|
||||
return False
|
||||
|
||||
# Refresh the tab stops
|
||||
self.setTabStopDistance(self.mainConf.getTabWidth())
|
||||
self.setTabStopDistance(CONFIG.getTabWidth())
|
||||
|
||||
# Must be before setHtml
|
||||
if updateHistory:
|
||||
@@ -297,7 +296,7 @@ class GuiDocViewer(QTextBrowser):
|
||||
"""
|
||||
wW = self.width()
|
||||
wH = self.height()
|
||||
cM = self.mainConf.getTextMargin()
|
||||
cM = CONFIG.getTextMargin()
|
||||
|
||||
vBar = self.verticalScrollBar()
|
||||
sW = vBar.width() if vBar.isVisible() else 0
|
||||
@@ -306,8 +305,8 @@ class GuiDocViewer(QTextBrowser):
|
||||
sH = hBar.height() if hBar.isVisible() else 0
|
||||
|
||||
tM = cM
|
||||
if self.mainConf.textWidth > 0:
|
||||
tW = self.mainConf.getTextWidth()
|
||||
if CONFIG.textWidth > 0:
|
||||
tW = CONFIG.getTextWidth()
|
||||
tM = max((wW - sW - tW)//2, cM)
|
||||
|
||||
tB = self.frameWidth()
|
||||
@@ -685,7 +684,6 @@ class GuiDocViewHeader(QWidget):
|
||||
|
||||
logger.debug("Initialising GuiDocViewHeader ...")
|
||||
|
||||
self.mainConf = novelwriter.CONFIG
|
||||
self.docViewer = docViewer
|
||||
self.mainGui = docViewer.mainGui
|
||||
self.theProject = docViewer.theProject
|
||||
@@ -695,7 +693,7 @@ class GuiDocViewHeader(QWidget):
|
||||
self._docHandle = None
|
||||
|
||||
fPx = int(0.9*self.mainTheme.fontPixelSize)
|
||||
hSp = self.mainConf.pxInt(6)
|
||||
hSp = CONFIG.pxInt(6)
|
||||
|
||||
# Main Widget Settings
|
||||
self.setAutoFillBackground(True)
|
||||
@@ -763,7 +761,7 @@ class GuiDocViewHeader(QWidget):
|
||||
|
||||
# Fix Margins and Size
|
||||
# This is needed for high DPI systems. See issue #499.
|
||||
cM = self.mainConf.pxInt(8)
|
||||
cM = CONFIG.pxInt(8)
|
||||
self.setContentsMargins(0, 0, 0, 0)
|
||||
self.outerBox.setContentsMargins(cM, cM, cM, cM)
|
||||
self.setMinimumHeight(fPx + 2*cM)
|
||||
@@ -828,7 +826,7 @@ class GuiDocViewHeader(QWidget):
|
||||
self.refreshButton.setVisible(False)
|
||||
return True
|
||||
|
||||
if self.mainConf.showFullPath:
|
||||
if CONFIG.showFullPath:
|
||||
tTitle = []
|
||||
tTree = self.theProject.tree.getItemPath(tHandle)
|
||||
for aHandle in reversed(tTree):
|
||||
@@ -903,7 +901,6 @@ class GuiDocViewFooter(QWidget):
|
||||
|
||||
logger.debug("Initialising GuiDocViewFooter ...")
|
||||
|
||||
self.mainConf = novelwriter.CONFIG
|
||||
self.docViewer = docViewer
|
||||
self.mainGui = docViewer.mainGui
|
||||
self.mainTheme = docViewer.mainTheme
|
||||
@@ -913,8 +910,8 @@ class GuiDocViewFooter(QWidget):
|
||||
self._docHandle = None
|
||||
|
||||
fPx = int(0.9*self.mainTheme.fontPixelSize)
|
||||
bSp = self.mainConf.pxInt(2)
|
||||
hSp = self.mainConf.pxInt(8)
|
||||
bSp = CONFIG.pxInt(2)
|
||||
hSp = CONFIG.pxInt(8)
|
||||
|
||||
# Main Widget Settings
|
||||
self.setContentsMargins(0, 0, 0, 0)
|
||||
@@ -942,7 +939,7 @@ class GuiDocViewFooter(QWidget):
|
||||
# Show Comments
|
||||
self.showComments = QToolButton(self)
|
||||
self.showComments.setCheckable(True)
|
||||
self.showComments.setChecked(self.mainConf.viewComments)
|
||||
self.showComments.setChecked(CONFIG.viewComments)
|
||||
self.showComments.setToolButtonStyle(Qt.ToolButtonIconOnly)
|
||||
self.showComments.setIconSize(QSize(fPx, fPx))
|
||||
self.showComments.setFixedSize(QSize(fPx, fPx))
|
||||
@@ -952,7 +949,7 @@ class GuiDocViewFooter(QWidget):
|
||||
# Show Synopsis
|
||||
self.showSynopsis = QToolButton(self)
|
||||
self.showSynopsis.setCheckable(True)
|
||||
self.showSynopsis.setChecked(self.mainConf.viewSynopsis)
|
||||
self.showSynopsis.setChecked(CONFIG.viewSynopsis)
|
||||
self.showSynopsis.setToolButtonStyle(Qt.ToolButtonIconOnly)
|
||||
self.showSynopsis.setIconSize(QSize(fPx, fPx))
|
||||
self.showSynopsis.setFixedSize(QSize(fPx, fPx))
|
||||
@@ -1021,7 +1018,7 @@ class GuiDocViewFooter(QWidget):
|
||||
|
||||
# Fix Margins and Size
|
||||
# This is needed for high DPI systems. See issue #499.
|
||||
cM = self.mainConf.pxInt(8)
|
||||
cM = CONFIG.pxInt(8)
|
||||
self.setContentsMargins(0, 0, 0, 0)
|
||||
self.outerBox.setContentsMargins(cM, cM, cM, cM)
|
||||
self.setMinimumHeight(fPx + 2*cM)
|
||||
@@ -1120,7 +1117,7 @@ class GuiDocViewFooter(QWidget):
|
||||
def _doToggleComments(self, theState):
|
||||
"""Toggle the view comment button and reload the document.
|
||||
"""
|
||||
self.mainConf.viewComments = theState
|
||||
CONFIG.viewComments = theState
|
||||
self.docViewer.reloadText()
|
||||
return
|
||||
|
||||
@@ -1128,7 +1125,7 @@ class GuiDocViewFooter(QWidget):
|
||||
def _doToggleSynopsis(self, theState):
|
||||
"""Toggle the view synopsis button and reload the document.
|
||||
"""
|
||||
self.mainConf.viewSynopsis = theState
|
||||
CONFIG.viewSynopsis = theState
|
||||
self.docViewer.reloadText()
|
||||
return
|
||||
|
||||
@@ -1146,7 +1143,6 @@ class GuiDocViewDetails(QScrollArea):
|
||||
super().__init__(parent=mainGui)
|
||||
|
||||
logger.debug("Initialising GuiDocViewDetails ...")
|
||||
self.mainConf = novelwriter.CONFIG
|
||||
self.mainGui = mainGui
|
||||
self.theProject = mainGui.theProject
|
||||
self.mainTheme = mainGui.mainTheme
|
||||
@@ -1172,7 +1168,7 @@ class GuiDocViewDetails(QScrollArea):
|
||||
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
|
||||
self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
|
||||
self.setWidgetResizable(True)
|
||||
self.setMinimumHeight(self.mainConf.pxInt(50))
|
||||
self.setMinimumHeight(CONFIG.pxInt(50))
|
||||
self.setFrameStyle(QFrame.NoFrame)
|
||||
|
||||
logger.debug("GuiDocViewDetails initialisation complete")
|
||||
|
||||
@@ -24,12 +24,12 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import novelwriter
|
||||
|
||||
from PyQt5.QtCore import Qt, pyqtSlot
|
||||
from PyQt5.QtGui import QFont, QPixmap
|
||||
from PyQt5.QtWidgets import QWidget, QGridLayout, QLabel
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter.constants import trConst, nwLabels
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -41,7 +41,6 @@ class GuiItemDetails(QWidget):
|
||||
super().__init__(parent=mainGui)
|
||||
|
||||
logger.debug("Initialising GuiItemDetails ...")
|
||||
self.mainConf = novelwriter.CONFIG
|
||||
self.mainGui = mainGui
|
||||
self.theProject = mainGui.theProject
|
||||
self.mainTheme = mainGui.mainTheme
|
||||
@@ -50,9 +49,9 @@ class GuiItemDetails(QWidget):
|
||||
self._itemHandle = None
|
||||
|
||||
# Sizes
|
||||
hSp = self.mainConf.pxInt(6)
|
||||
vSp = self.mainConf.pxInt(1)
|
||||
mPx = self.mainConf.pxInt(6)
|
||||
hSp = CONFIG.pxInt(6)
|
||||
vSp = CONFIG.pxInt(1)
|
||||
mPx = CONFIG.pxInt(6)
|
||||
fPt = self.mainTheme.fontPointSize
|
||||
|
||||
fntLabel = QFont()
|
||||
|
||||
+16
-22
@@ -24,7 +24,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import novelwriter
|
||||
|
||||
from pathlib import Path
|
||||
from urllib.parse import urljoin
|
||||
@@ -34,8 +33,9 @@ from PyQt5.QtCore import QUrl
|
||||
from PyQt5.QtGui import QDesktopServices
|
||||
from PyQt5.QtWidgets import QMenuBar, QAction
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter.enum import nwDocAction, nwDocInsert, nwWidget
|
||||
from novelwriter.constants import trConst, nwKeyWords, nwLabels, nwUnicode
|
||||
from novelwriter.constants import nwConst, trConst, nwKeyWords, nwLabels, nwUnicode
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -50,7 +50,6 @@ class GuiMainMenu(QMenuBar):
|
||||
super().__init__(parent=mainGui)
|
||||
|
||||
logger.debug("Initialising GuiMainMenu ...")
|
||||
self.mainConf = novelwriter.CONFIG
|
||||
self.mainGui = mainGui
|
||||
self.theProject = mainGui.theProject
|
||||
|
||||
@@ -105,9 +104,9 @@ class GuiMainMenu(QMenuBar):
|
||||
def _openUserManualFile(self):
|
||||
"""Open the documentation in PDF format.
|
||||
"""
|
||||
if isinstance(self.mainConf.pdfDocs, Path):
|
||||
if isinstance(CONFIG.pdfDocs, Path):
|
||||
QDesktopServices.openUrl(
|
||||
QUrl(urljoin("file:", pathname2url(str(self.mainConf.pdfDocs))))
|
||||
QUrl(urljoin("file:", pathname2url(str(CONFIG.pdfDocs))))
|
||||
)
|
||||
return
|
||||
|
||||
@@ -310,7 +309,7 @@ class GuiMainMenu(QMenuBar):
|
||||
|
||||
# View > TreeView
|
||||
self.aFocusTree = QAction(self.tr("Go to Project Tree"), self)
|
||||
if self.mainConf.osWindows:
|
||||
if CONFIG.osWindows:
|
||||
self.aFocusTree.setShortcut("Ctrl+Alt+1")
|
||||
else:
|
||||
self.aFocusTree.setShortcut("Alt+1")
|
||||
@@ -319,7 +318,7 @@ class GuiMainMenu(QMenuBar):
|
||||
|
||||
# View > Document Pane 1
|
||||
self.aFocusEditor = QAction(self.tr("Go to Document Editor"), self)
|
||||
if self.mainConf.osWindows:
|
||||
if CONFIG.osWindows:
|
||||
self.aFocusEditor.setShortcut("Ctrl+Alt+2")
|
||||
else:
|
||||
self.aFocusEditor.setShortcut("Alt+2")
|
||||
@@ -328,7 +327,7 @@ class GuiMainMenu(QMenuBar):
|
||||
|
||||
# View > Document Pane 2
|
||||
self.aFocusView = QAction(self.tr("Go to Document Viewer"), self)
|
||||
if self.mainConf.osWindows:
|
||||
if CONFIG.osWindows:
|
||||
self.aFocusView.setShortcut("Ctrl+Alt+3")
|
||||
else:
|
||||
self.aFocusView.setShortcut("Alt+3")
|
||||
@@ -337,7 +336,7 @@ class GuiMainMenu(QMenuBar):
|
||||
|
||||
# View > Outline
|
||||
self.aFocusOutline = QAction(self.tr("Go to Outline"), self)
|
||||
if self.mainConf.osWindows:
|
||||
if CONFIG.osWindows:
|
||||
self.aFocusOutline.setShortcut("Ctrl+Alt+4")
|
||||
else:
|
||||
self.aFocusOutline.setShortcut("Alt+4")
|
||||
@@ -754,7 +753,7 @@ class GuiMainMenu(QMenuBar):
|
||||
|
||||
# Search > Replace
|
||||
self.aReplace = QAction(self.tr("Replace"), self)
|
||||
if self.mainConf.osDarwin:
|
||||
if CONFIG.osDarwin:
|
||||
self.aReplace.setShortcut("Ctrl+=")
|
||||
else:
|
||||
self.aReplace.setShortcut("Ctrl+H")
|
||||
@@ -763,7 +762,7 @@ class GuiMainMenu(QMenuBar):
|
||||
|
||||
# Search > Find Next
|
||||
self.aFindNext = QAction(self.tr("Find Next"), self)
|
||||
if self.mainConf.osDarwin:
|
||||
if CONFIG.osDarwin:
|
||||
self.aFindNext.setShortcuts(["Ctrl+G", "F3"])
|
||||
else:
|
||||
self.aFindNext.setShortcuts(["F3", "Ctrl+G"])
|
||||
@@ -772,7 +771,7 @@ class GuiMainMenu(QMenuBar):
|
||||
|
||||
# Search > Find Prev
|
||||
self.aFindPrev = QAction(self.tr("Find Previous"), self)
|
||||
if self.mainConf.osDarwin:
|
||||
if CONFIG.osDarwin:
|
||||
self.aFindPrev.setShortcuts(["Ctrl+Shift+G", "Shift+F3"])
|
||||
else:
|
||||
self.aFindPrev.setShortcuts(["Shift+F3", "Ctrl+Shift+G"])
|
||||
@@ -877,18 +876,13 @@ class GuiMainMenu(QMenuBar):
|
||||
self.helpMenu.addSeparator()
|
||||
|
||||
# Help > User Manual (Online)
|
||||
if novelwriter.__version__[-2] == "f":
|
||||
docUrl = f"{novelwriter.__docurl__}/en/stable/"
|
||||
else:
|
||||
docUrl = f"{novelwriter.__docurl__}/en/latest/"
|
||||
|
||||
self.aHelpDocs = QAction(self.tr("User Manual (Online)"), self)
|
||||
self.aHelpDocs.setShortcut("F1")
|
||||
self.aHelpDocs.triggered.connect(lambda: self._openWebsite(docUrl))
|
||||
self.aHelpDocs.triggered.connect(lambda: self._openWebsite(nwConst.URL_DOCS))
|
||||
self.helpMenu.addAction(self.aHelpDocs)
|
||||
|
||||
# Help > User Manual (PDF)
|
||||
if isinstance(self.mainConf.pdfDocs, Path):
|
||||
if isinstance(CONFIG.pdfDocs, Path):
|
||||
self.aPdfDocs = QAction(self.tr("User Manual (PDF)"), self)
|
||||
self.aPdfDocs.setShortcut("Shift+F1")
|
||||
self.aPdfDocs.triggered.connect(self._openUserManualFile)
|
||||
@@ -899,17 +893,17 @@ class GuiMainMenu(QMenuBar):
|
||||
|
||||
# Document > Report an Issue
|
||||
self.aIssue = QAction(self.tr("Report an Issue (GitHub)"), self)
|
||||
self.aIssue.triggered.connect(lambda: self._openWebsite(novelwriter.__issuesurl__))
|
||||
self.aIssue.triggered.connect(lambda: self._openWebsite(nwConst.URL_REPORT))
|
||||
self.helpMenu.addAction(self.aIssue)
|
||||
|
||||
# Document > Ask a Question
|
||||
self.aQuestion = QAction(self.tr("Ask a Question (GitHub)"), self)
|
||||
self.aQuestion.triggered.connect(lambda: self._openWebsite(novelwriter.__helpurl__))
|
||||
self.aQuestion.triggered.connect(lambda: self._openWebsite(nwConst.URL_HELP))
|
||||
self.helpMenu.addAction(self.aQuestion)
|
||||
|
||||
# Document > Main Website
|
||||
self.aWebsite = QAction(self.tr("The novelWriter Website"), self)
|
||||
self.aWebsite.triggered.connect(lambda: self._openWebsite(novelwriter.__url__))
|
||||
self.aWebsite.triggered.connect(lambda: self._openWebsite(nwConst.URL_WEB))
|
||||
self.helpMenu.addAction(self.aWebsite)
|
||||
|
||||
# Help > Separator
|
||||
|
||||
@@ -26,7 +26,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import novelwriter
|
||||
|
||||
from enum import Enum
|
||||
from time import time
|
||||
@@ -39,6 +38,7 @@ from PyQt5.QtWidgets import (
|
||||
QTreeWidgetItem, QVBoxLayout, QWidget
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter.enum import nwDocMode, nwItemClass, nwOutline
|
||||
from novelwriter.common import minmax
|
||||
from novelwriter.constants import nwHeaders, nwKeyWords, nwLabels, trConst
|
||||
@@ -198,14 +198,13 @@ class GuiNovelToolBar(QWidget):
|
||||
|
||||
logger.debug("Initialising GuiNovelToolBar ...")
|
||||
|
||||
self.mainConf = novelwriter.CONFIG
|
||||
self.novelView = novelView
|
||||
self.mainGui = novelView.mainGui
|
||||
self.theProject = novelView.mainGui.theProject
|
||||
self.mainTheme = novelView.mainGui.mainTheme
|
||||
|
||||
iPx = self.mainTheme.baseIconSize
|
||||
mPx = self.mainConf.pxInt(2)
|
||||
mPx = CONFIG.pxInt(2)
|
||||
|
||||
self.setContentsMargins(0, 0, 0, 0)
|
||||
self.setAutoFillBackground(True)
|
||||
@@ -216,7 +215,7 @@ class GuiNovelToolBar(QWidget):
|
||||
self.novelPrefix = self.tr("Outline of {0}")
|
||||
self.novelValue = NovelSelector(self, self.theProject, self.mainGui)
|
||||
self.novelValue.setFont(selFont)
|
||||
self.novelValue.setMinimumWidth(self.mainConf.pxInt(150))
|
||||
self.novelValue.setMinimumWidth(CONFIG.pxInt(150))
|
||||
self.novelValue.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
||||
self.novelValue.novelSelectionChanged.connect(self.setCurrentRoot)
|
||||
|
||||
@@ -290,7 +289,7 @@ class GuiNovelToolBar(QWidget):
|
||||
buttonStyle = (
|
||||
"QToolButton {{padding: {0}px; border: none; background: transparent;}} "
|
||||
"QToolButton:hover {{border: none; background: rgba({1},{2},{3},0.2);}}"
|
||||
).format(self.mainConf.pxInt(2), fadeCol.red(), fadeCol.green(), fadeCol.blue())
|
||||
).format(CONFIG.pxInt(2), fadeCol.red(), fadeCol.green(), fadeCol.blue())
|
||||
|
||||
self.tbNovel.setStyleSheet(buttonStyle)
|
||||
self.tbRefresh.setStyleSheet(buttonStyle)
|
||||
@@ -398,7 +397,6 @@ class GuiNovelTree(QTreeWidget):
|
||||
|
||||
logger.debug("Initialising GuiNovelTree ...")
|
||||
|
||||
self.mainConf = novelwriter.CONFIG
|
||||
self.novelView = novelView
|
||||
self.mainGui = novelView.mainGui
|
||||
self.mainTheme = novelView.mainGui.mainTheme
|
||||
@@ -420,7 +418,7 @@ class GuiNovelTree(QTreeWidget):
|
||||
# =========
|
||||
|
||||
iPx = self.mainTheme.baseIconSize
|
||||
cMg = self.mainConf.pxInt(6)
|
||||
cMg = CONFIG.pxInt(6)
|
||||
|
||||
self.setIconSize(QSize(iPx, iPx))
|
||||
self.setFrameStyle(QFrame.NoFrame)
|
||||
@@ -470,12 +468,12 @@ class GuiNovelTree(QTreeWidget):
|
||||
"""Set or update tree widget settings.
|
||||
"""
|
||||
# Scroll bars
|
||||
if self.mainConf.hideVScroll:
|
||||
if CONFIG.hideVScroll:
|
||||
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
else:
|
||||
self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
|
||||
|
||||
if self.mainConf.hideHScroll:
|
||||
if CONFIG.hideHScroll:
|
||||
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
else:
|
||||
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
|
||||
|
||||
+14
-18
@@ -28,7 +28,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import novelwriter
|
||||
|
||||
from time import time
|
||||
from enum import Enum
|
||||
@@ -42,6 +41,7 @@ from PyQt5.QtWidgets import (
|
||||
QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter.enum import (
|
||||
nwDocMode, nwItemClass, nwItemLayout, nwItemType, nwOutline
|
||||
)
|
||||
@@ -61,7 +61,6 @@ class GuiOutlineView(QWidget):
|
||||
def __init__(self, mainGui):
|
||||
super().__init__(parent=mainGui)
|
||||
|
||||
self.mainConf = novelwriter.CONFIG
|
||||
self.mainGui = mainGui
|
||||
self.theProject = mainGui.theProject
|
||||
|
||||
@@ -75,7 +74,7 @@ class GuiOutlineView(QWidget):
|
||||
self.splitOutline.addWidget(self.outlineTree)
|
||||
self.splitOutline.addWidget(self.outlineData)
|
||||
self.splitOutline.setOpaqueResize(False)
|
||||
self.splitOutline.setSizes(self.mainConf.outlinePanePos)
|
||||
self.splitOutline.setSizes(CONFIG.outlinePanePos)
|
||||
|
||||
# Assemble
|
||||
self.outerBox = QVBoxLayout()
|
||||
@@ -215,13 +214,12 @@ class GuiOutlineToolBar(QToolBar):
|
||||
|
||||
logger.debug("Initialising GuiOutlineToolBar ...")
|
||||
|
||||
self.mainConf = novelwriter.CONFIG
|
||||
self.mainGui = theOutline.mainGui
|
||||
self.theProject = theOutline.mainGui.theProject
|
||||
self.mainTheme = theOutline.mainGui.mainTheme
|
||||
|
||||
iPx = self.mainConf.pxInt(22)
|
||||
mPx = self.mainConf.pxInt(12)
|
||||
iPx = CONFIG.pxInt(22)
|
||||
mPx = CONFIG.pxInt(12)
|
||||
|
||||
self.setMovable(False)
|
||||
self.setIconSize(QSize(iPx, iPx))
|
||||
@@ -235,7 +233,7 @@ class GuiOutlineToolBar(QToolBar):
|
||||
self.novelLabel.setContentsMargins(0, 0, mPx, 0)
|
||||
|
||||
self.novelValue = NovelSelector(self, self.theProject, self.mainGui)
|
||||
self.novelValue.setMinimumWidth(self.mainConf.pxInt(200))
|
||||
self.novelValue.setMinimumWidth(CONFIG.pxInt(200))
|
||||
self.novelValue.novelSelectionChanged.connect(self._novelValueChanged)
|
||||
|
||||
# Actions
|
||||
@@ -373,7 +371,6 @@ class GuiOutlineTree(QTreeWidget):
|
||||
|
||||
logger.debug("Initialising GuiOutlineTree ...")
|
||||
|
||||
self.mainConf = novelwriter.CONFIG
|
||||
self.outlineView = outlineView
|
||||
self.mainGui = outlineView.mainGui
|
||||
self.theProject = outlineView.mainGui.theProject
|
||||
@@ -446,12 +443,12 @@ class GuiOutlineTree(QTreeWidget):
|
||||
"""Set or update outline settings.
|
||||
"""
|
||||
# Scroll bars
|
||||
if self.mainConf.hideVScroll:
|
||||
if CONFIG.hideVScroll:
|
||||
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
else:
|
||||
self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
|
||||
|
||||
if self.mainConf.hideHScroll:
|
||||
if CONFIG.hideHScroll:
|
||||
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
else:
|
||||
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
|
||||
@@ -610,7 +607,7 @@ class GuiOutlineTree(QTreeWidget):
|
||||
tmpWidth = pOptions.getValue("GuiOutline", "columnWidth", {})
|
||||
for hName in tmpWidth:
|
||||
try:
|
||||
self._colWidth[nwOutline[hName]] = self.mainConf.pxInt(tmpWidth[hName])
|
||||
self._colWidth[nwOutline[hName]] = CONFIG.pxInt(tmpWidth[hName])
|
||||
except Exception:
|
||||
logger.warning("Ignored unknown outline column '%s'", str(hName))
|
||||
|
||||
@@ -640,7 +637,7 @@ class GuiOutlineTree(QTreeWidget):
|
||||
colHidden = {}
|
||||
|
||||
for hItem in nwOutline:
|
||||
colWidth[hItem.name] = self.mainConf.rpxInt(self._colWidth[hItem])
|
||||
colWidth[hItem.name] = CONFIG.rpxInt(self._colWidth[hItem])
|
||||
colHidden[hItem.name] = self._colHidden[hItem]
|
||||
|
||||
for iCol in range(self.columnCount()):
|
||||
@@ -648,7 +645,7 @@ class GuiOutlineTree(QTreeWidget):
|
||||
treeOrder.append(hName)
|
||||
|
||||
iLog = self.treeHead.logicalIndex(iCol)
|
||||
logWidth = self.mainConf.rpxInt(self.columnWidth(iLog))
|
||||
logWidth = CONFIG.rpxInt(self.columnWidth(iLog))
|
||||
logHidden = self.isColumnHidden(iLog)
|
||||
|
||||
colHidden[hName] = logHidden
|
||||
@@ -801,7 +798,6 @@ class GuiOutlineDetails(QScrollArea):
|
||||
|
||||
logger.debug("Initialising GuiOutlineDetails ...")
|
||||
|
||||
self.mainConf = novelwriter.CONFIG
|
||||
self.theOutline = theOutline
|
||||
self.mainGui = theOutline.mainGui
|
||||
self.theProject = theOutline.mainGui.theProject
|
||||
@@ -811,8 +807,8 @@ class GuiOutlineDetails(QScrollArea):
|
||||
minTitle = 30*self.mainTheme.textNWidth
|
||||
maxTitle = 40*self.mainTheme.textNWidth
|
||||
wCount = self.mainTheme.getTextWidth("999,999")
|
||||
hSpace = int(self.mainConf.pxInt(10))
|
||||
vSpace = int(self.mainConf.pxInt(4))
|
||||
hSpace = int(CONFIG.pxInt(10))
|
||||
vSpace = int(CONFIG.pxInt(4))
|
||||
|
||||
# Details Area
|
||||
self.titleLabel = QLabel("<b>%s</b>" % self.tr("Title"))
|
||||
@@ -994,12 +990,12 @@ class GuiOutlineDetails(QScrollArea):
|
||||
"""Set or update outline settings.
|
||||
"""
|
||||
# Scroll bars
|
||||
if self.mainConf.hideVScroll:
|
||||
if CONFIG.hideVScroll:
|
||||
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
else:
|
||||
self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
|
||||
|
||||
if self.mainConf.hideHScroll:
|
||||
if CONFIG.hideHScroll:
|
||||
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
else:
|
||||
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
|
||||
|
||||
@@ -26,7 +26,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import novelwriter
|
||||
|
||||
from enum import Enum
|
||||
from time import time
|
||||
@@ -38,10 +37,11 @@ from PyQt5.QtWidgets import (
|
||||
QMenu, QShortcut, QSizePolicy, QToolButton, QTreeWidget, QTreeWidgetItem,
|
||||
QVBoxLayout, QWidget
|
||||
)
|
||||
from novelwriter.core.item import NWItem
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter.enum import nwDocMode, nwItemType, nwItemClass, nwItemLayout, nwAlert, nwWidget
|
||||
from novelwriter.constants import nwHeaders, nwUnicode, trConst, nwLabels
|
||||
from novelwriter.core.item import NWItem
|
||||
from novelwriter.core.coretools import DocMerger, DocSplitter
|
||||
from novelwriter.dialogs.docmerge import GuiDocMerge
|
||||
from novelwriter.dialogs.docsplit import GuiDocSplit
|
||||
@@ -217,7 +217,6 @@ class GuiProjectToolBar(QWidget):
|
||||
|
||||
logger.debug("Initialising GuiProjectToolBar ...")
|
||||
|
||||
self.mainConf = novelwriter.CONFIG
|
||||
self.projView = projView
|
||||
self.projTree = projView.projTree
|
||||
self.mainGui = projView.mainGui
|
||||
@@ -225,7 +224,7 @@ class GuiProjectToolBar(QWidget):
|
||||
self.mainTheme = projView.mainGui.mainTheme
|
||||
|
||||
iPx = self.mainTheme.baseIconSize
|
||||
mPx = self.mainConf.pxInt(2)
|
||||
mPx = CONFIG.pxInt(2)
|
||||
|
||||
self.setContentsMargins(0, 0, 0, 0)
|
||||
self.setAutoFillBackground(True)
|
||||
@@ -348,7 +347,7 @@ class GuiProjectToolBar(QWidget):
|
||||
buttonStyle = (
|
||||
"QToolButton {{padding: {0}px; border: none; background: transparent;}} "
|
||||
"QToolButton:hover {{border: none; background: rgba({1},{2},{3},0.2);}}"
|
||||
).format(self.mainConf.pxInt(2), fadeCol.red(), fadeCol.green(), fadeCol.blue())
|
||||
).format(CONFIG.pxInt(2), fadeCol.red(), fadeCol.green(), fadeCol.blue())
|
||||
|
||||
self.tbQuick.setStyleSheet(buttonStyle)
|
||||
self.tbMoveU.setStyleSheet(buttonStyle)
|
||||
@@ -458,7 +457,6 @@ class GuiProjectTree(QTreeWidget):
|
||||
|
||||
logger.debug("Initialising GuiProjectTree ...")
|
||||
|
||||
self.mainConf = novelwriter.CONFIG
|
||||
self.projView = projView
|
||||
self.mainGui = projView.mainGui
|
||||
self.mainTheme = projView.mainGui.mainTheme
|
||||
@@ -478,7 +476,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
|
||||
# Tree Settings
|
||||
iPx = self.mainTheme.baseIconSize
|
||||
cMg = self.mainConf.pxInt(6)
|
||||
cMg = CONFIG.pxInt(6)
|
||||
|
||||
self.setIconSize(QSize(iPx, iPx))
|
||||
self.setFrameStyle(QFrame.NoFrame)
|
||||
@@ -532,12 +530,12 @@ class GuiProjectTree(QTreeWidget):
|
||||
"""Set or update tree widget settings.
|
||||
"""
|
||||
# Scroll bars
|
||||
if self.mainConf.hideVScroll:
|
||||
if CONFIG.hideVScroll:
|
||||
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
else:
|
||||
self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
|
||||
|
||||
if self.mainConf.hideHScroll:
|
||||
if CONFIG.hideHScroll:
|
||||
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
else:
|
||||
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
|
||||
@@ -987,7 +985,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
|
||||
trItem.setIcon(self.C_ACTIVE, self.mainTheme.getIcon(iconName))
|
||||
|
||||
if self.mainConf.emphLabels and nwItem.isDocumentLayout():
|
||||
if CONFIG.emphLabels and nwItem.isDocumentLayout():
|
||||
trFont = trItem.font(self.C_NAME)
|
||||
trFont.setBold(hLevel == "H1" or hLevel == "H2")
|
||||
trFont.setUnderline(hLevel == "H1")
|
||||
|
||||
@@ -24,13 +24,13 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import novelwriter
|
||||
|
||||
from PyQt5.QtCore import Qt, QSize, pyqtSignal
|
||||
from PyQt5.QtWidgets import (
|
||||
QToolBar, QWidget, QSizePolicy, QAction, QMenu, QToolButton
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter.enum import nwView
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -45,13 +45,12 @@ class GuiSideBar(QToolBar):
|
||||
|
||||
logger.debug("Initialising GuiSideBar ...")
|
||||
|
||||
self.mainConf = novelwriter.CONFIG
|
||||
self.mainGui = mainGui
|
||||
self.mainTheme = mainGui.mainTheme
|
||||
|
||||
# Style
|
||||
iPx = self.mainConf.pxInt(22)
|
||||
mPx = self.mainConf.pxInt(60)
|
||||
iPx = CONFIG.pxInt(22)
|
||||
mPx = CONFIG.pxInt(60)
|
||||
|
||||
lblFont = self.mainTheme.guiFont
|
||||
lblFont.setPointSizeF(0.65*self.mainTheme.fontPointSize)
|
||||
|
||||
@@ -25,7 +25,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import novelwriter
|
||||
|
||||
from time import time
|
||||
|
||||
@@ -33,6 +32,7 @@ from PyQt5.QtCore import pyqtSlot, QLocale
|
||||
from PyQt5.QtGui import QColor
|
||||
from PyQt5.QtWidgets import qApp, QStatusBar, QLabel
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter.common import formatTime
|
||||
from novelwriter.gui.components import StatusLED
|
||||
|
||||
@@ -46,7 +46,6 @@ class GuiMainStatus(QStatusBar):
|
||||
|
||||
logger.debug("Initialising GuiMainStatus ...")
|
||||
|
||||
self.mainConf = novelwriter.CONFIG
|
||||
self.mainGui = mainGui
|
||||
self.mainTheme = mainGui.mainTheme
|
||||
self.refTime = None
|
||||
@@ -61,7 +60,7 @@ class GuiMainStatus(QStatusBar):
|
||||
# Permanent Widgets
|
||||
# =================
|
||||
|
||||
xM = self.mainConf.pxInt(8)
|
||||
xM = CONFIG.pxInt(8)
|
||||
|
||||
# The Spell Checker Language
|
||||
self.langIcon = QLabel("")
|
||||
@@ -174,7 +173,7 @@ class GuiMainStatus(QStatusBar):
|
||||
def setUserIdle(self, userIdle):
|
||||
"""Change the idle status icon.
|
||||
"""
|
||||
if not self.mainConf.stopWhenIdle:
|
||||
if not CONFIG.stopWhenIdle:
|
||||
userIdle = False
|
||||
|
||||
if self.userIdle != userIdle:
|
||||
@@ -191,7 +190,7 @@ class GuiMainStatus(QStatusBar):
|
||||
"""Update the current project statistics.
|
||||
"""
|
||||
self.statsText.setText(self.tr("Words: {0} ({1})").format(f"{pWC:n}", f"{sWC:+n}"))
|
||||
if self.mainConf.incNotesWCount:
|
||||
if CONFIG.incNotesWCount:
|
||||
self.statsText.setToolTip(self.tr("Project word count (session change)"))
|
||||
else:
|
||||
self.statsText.setToolTip(self.tr("Novel word count (session change)"))
|
||||
@@ -203,7 +202,7 @@ class GuiMainStatus(QStatusBar):
|
||||
if self.refTime is None:
|
||||
self.timeText.setText("00:00:00")
|
||||
else:
|
||||
if self.mainConf.stopWhenIdle:
|
||||
if CONFIG.stopWhenIdle:
|
||||
sessTime = round(time() - self.refTime - idleTime)
|
||||
else:
|
||||
sessTime = round(time() - self.refTime)
|
||||
|
||||
+19
-21
@@ -25,7 +25,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import novelwriter
|
||||
|
||||
from math import ceil
|
||||
|
||||
@@ -35,6 +34,7 @@ from PyQt5.QtGui import (
|
||||
QPalette, QColor, QIcon, QFont, QFontMetrics, QFontDatabase, QPixmap
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter.enum import nwItemLayout, nwItemType
|
||||
from novelwriter.error import logException
|
||||
from novelwriter.common import NWConfigParser, minmax
|
||||
@@ -52,7 +52,6 @@ class GuiTheme:
|
||||
|
||||
def __init__(self):
|
||||
|
||||
self.mainConf = novelwriter.CONFIG
|
||||
self.iconCache = GuiIcons(self)
|
||||
|
||||
# Loaded Theme Settings
|
||||
@@ -118,10 +117,10 @@ class GuiTheme:
|
||||
self._availThemes = {}
|
||||
self._availSyntax = {}
|
||||
|
||||
self._listConf(self._availSyntax, self.mainConf.assetPath("syntax"))
|
||||
self._listConf(self._availThemes, self.mainConf.assetPath("themes"))
|
||||
self._listConf(self._availSyntax, self.mainConf.dataPath("syntax"))
|
||||
self._listConf(self._availThemes, self.mainConf.dataPath("themes"))
|
||||
self._listConf(self._availSyntax, CONFIG.assetPath("syntax"))
|
||||
self._listConf(self._availThemes, CONFIG.assetPath("themes"))
|
||||
self._listConf(self._availSyntax, CONFIG.dataPath("syntax"))
|
||||
self._listConf(self._availThemes, CONFIG.dataPath("themes"))
|
||||
|
||||
self.loadTheme()
|
||||
self.loadSyntax()
|
||||
@@ -136,7 +135,7 @@ class GuiTheme:
|
||||
# Extract Other Info
|
||||
self.guiDPI = qApp.primaryScreen().logicalDotsPerInchX()
|
||||
self.guiScale = qApp.primaryScreen().logicalDotsPerInchX()/96.0
|
||||
self.mainConf.guiScale = self.guiScale
|
||||
CONFIG.guiScale = self.guiScale
|
||||
logger.debug("GUI DPI: %.1f", self.guiDPI)
|
||||
logger.debug("GUI Scale: %.2f", self.guiScale)
|
||||
|
||||
@@ -184,11 +183,11 @@ class GuiTheme:
|
||||
def loadTheme(self):
|
||||
"""Load the currently specified GUI theme.
|
||||
"""
|
||||
guiTheme = self.mainConf.guiTheme
|
||||
guiTheme = CONFIG.guiTheme
|
||||
if guiTheme not in self._availThemes:
|
||||
logger.error("Could not find GUI theme '%s'", guiTheme)
|
||||
guiTheme = "default"
|
||||
self.mainConf.guiTheme = guiTheme
|
||||
CONFIG.guiTheme = guiTheme
|
||||
|
||||
themeFile = self._availThemes.get(guiTheme, None)
|
||||
if themeFile is None:
|
||||
@@ -270,11 +269,11 @@ class GuiTheme:
|
||||
def loadSyntax(self):
|
||||
"""Load the currently specified syntax highlighter theme.
|
||||
"""
|
||||
guiSyntax = self.mainConf.guiSyntax
|
||||
guiSyntax = CONFIG.guiSyntax
|
||||
if guiSyntax not in self._availSyntax:
|
||||
logger.error("Could not find syntax theme '%s'", guiSyntax)
|
||||
guiSyntax = "default_light"
|
||||
self.mainConf.guiSyntax = guiSyntax
|
||||
CONFIG.guiSyntax = guiSyntax
|
||||
|
||||
syntaxFile = self._availSyntax.get(guiSyntax, None)
|
||||
if syntaxFile is None:
|
||||
@@ -367,18 +366,18 @@ class GuiTheme:
|
||||
"""Update the GUI's font style from settings.
|
||||
"""
|
||||
theFont = QFont()
|
||||
if self.mainConf.guiFont not in self.guiFontDB.families():
|
||||
if self.mainConf.osWindows and "Arial" in self.guiFontDB.families():
|
||||
if CONFIG.guiFont not in self.guiFontDB.families():
|
||||
if CONFIG.osWindows and "Arial" in self.guiFontDB.families():
|
||||
# On Windows we default to Arial if possible
|
||||
theFont.setFamily("Arial")
|
||||
theFont.setPointSize(10)
|
||||
else:
|
||||
theFont = self.guiFontDB.systemFont(QFontDatabase.GeneralFont)
|
||||
self.mainConf.guiFont = theFont.family()
|
||||
self.mainConf.guiFontSize = theFont.pointSize()
|
||||
CONFIG.guiFont = theFont.family()
|
||||
CONFIG.guiFontSize = theFont.pointSize()
|
||||
else:
|
||||
theFont.setFamily(self.mainConf.guiFont)
|
||||
theFont.setPointSize(self.mainConf.guiFontSize)
|
||||
theFont.setFamily(CONFIG.guiFont)
|
||||
theFont.setPointSize(CONFIG.guiFontSize)
|
||||
|
||||
qApp.setFont(theFont)
|
||||
|
||||
@@ -473,7 +472,6 @@ class GuiIcons:
|
||||
|
||||
def __init__(self, mainTheme):
|
||||
|
||||
self.mainConf = novelwriter.CONFIG
|
||||
self.mainTheme = mainTheme
|
||||
|
||||
# Storage
|
||||
@@ -483,7 +481,7 @@ class GuiIcons:
|
||||
self._confName = "icons.conf"
|
||||
|
||||
# Icon Theme Path
|
||||
self._iconPath = self.mainConf.assetPath("icons")
|
||||
self._iconPath = CONFIG.assetPath("icons")
|
||||
|
||||
# Icon Theme Meta
|
||||
self.themeName = ""
|
||||
@@ -508,7 +506,7 @@ class GuiIcons:
|
||||
self._themeMap = {}
|
||||
themePath = self._iconPath / iconTheme
|
||||
if not themePath.is_dir():
|
||||
themePath = self.mainConf.dataPath("icons") / iconTheme
|
||||
themePath = CONFIG.dataPath("icons") / iconTheme
|
||||
if not themePath.is_dir():
|
||||
logger.warning("No icons loaded for '%s'", iconTheme)
|
||||
return False
|
||||
@@ -581,7 +579,7 @@ class GuiIcons:
|
||||
if decoKey in self._themeMap:
|
||||
imgPath = self._themeMap[decoKey]
|
||||
elif decoKey in self.IMAGE_MAP:
|
||||
imgPath = self.mainConf.assetPath("images") / self.IMAGE_MAP[decoKey]
|
||||
imgPath = CONFIG.assetPath("images") / self.IMAGE_MAP[decoKey]
|
||||
else:
|
||||
logger.error("Decoration with name '%s' does not exist", decoKey)
|
||||
return QPixmap()
|
||||
|
||||
Reference in New Issue
Block a user