Merge branch 'dev' into feature/build_gui

This commit is contained in:
Veronica Berglyd Olsen
2023-05-16 23:45:22 +02:00
69 changed files with 960 additions and 1037 deletions
+27 -29
View File
@@ -25,7 +25,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
import json
import logging
import novelwriter
from time import time
from pathlib import Path
@@ -43,6 +42,7 @@ from PyQt5.QtWidgets import (
)
from PyQt5.QtPrintSupport import QPrinter, QPrintPreviewDialog
from novelwriter import CONFIG
from novelwriter.enum import nwAlert, nwItemType, nwItemLayout, nwItemClass
from novelwriter.error import formatException, logException
from novelwriter.common import fuzzyTime, makeFileNameSafe
@@ -73,7 +73,6 @@ class GuiBuildNovel(QDialog):
logger.debug("Initialising GuiBuildNovel ...")
self.setObjectName("GuiBuildNovel")
self.mainConf = novelwriter.CONFIG
self.mainGui = mainGui
self.mainTheme = mainGui.mainTheme
self.theProject = mainGui.theProject
@@ -84,13 +83,13 @@ class GuiBuildNovel(QDialog):
self.buildTime = 0 # The timestamp of the last build
self.setWindowTitle(self.tr("Build Novel Project"))
self.setMinimumWidth(self.mainConf.pxInt(700))
self.setMinimumHeight(self.mainConf.pxInt(600))
self.setMinimumWidth(CONFIG.pxInt(700))
self.setMinimumHeight(CONFIG.pxInt(600))
pOptions = self.theProject.options
self.resize(
self.mainConf.pxInt(pOptions.getInt("GuiBuildNovel", "winWidth", 900)),
self.mainConf.pxInt(pOptions.getInt("GuiBuildNovel", "winHeight", 800))
CONFIG.pxInt(pOptions.getInt("GuiBuildNovel", "winWidth", 900)),
CONFIG.pxInt(pOptions.getInt("GuiBuildNovel", "winHeight", 800))
)
self.docView = GuiBuildNovelDocView(self, self.theProject)
@@ -121,7 +120,7 @@ class GuiBuildNovel(QDialog):
"be centred automatically and only appear between sections of "
"the same type."
).format("* * *")
xFmt = self.mainConf.pxInt(100)
xFmt = CONFIG.pxInt(100)
self.fmtTitle = QLineEdit()
self.fmtTitle.setMaxLength(200)
@@ -165,7 +164,7 @@ class GuiBuildNovel(QDialog):
self.buildLang = QComboBox()
self.buildLang.setMinimumWidth(xFmt)
theLangs = self.mainConf.listLanguages(self.mainConf.LANG_PROJ)
theLangs = CONFIG.listLanguages(CONFIG.LANG_PROJ)
self.buildLang.addItem("[%s]" % self.tr("Not Set"), "None")
for langID, langName in theLangs:
self.buildLang.addItem(langName, langID)
@@ -237,7 +236,7 @@ class GuiBuildNovel(QDialog):
self.textFont.setReadOnly(True)
self.textFont.setMinimumWidth(xFmt)
self.textFont.setText(
pOptions.getString("GuiBuildNovel", "textFont", self.mainConf.textFont)
pOptions.getString("GuiBuildNovel", "textFont", CONFIG.textFont)
)
self.fontButton = QPushButton("...")
self.fontButton.setMaximumWidth(int(2.5*self.mainTheme.getTextWidth("...")))
@@ -249,7 +248,7 @@ class GuiBuildNovel(QDialog):
self.textSize.setMaximum(72)
self.textSize.setSingleStep(1)
self.textSize.setValue(
pOptions.getInt("GuiBuildNovel", "textSize", self.mainConf.textSize)
pOptions.getInt("GuiBuildNovel", "textSize", CONFIG.textSize)
)
self.lineHeight = QDoubleSpinBox(self)
@@ -518,13 +517,13 @@ class GuiBuildNovel(QDialog):
self.buttonBox.addWidget(self.btnSave)
self.buttonBox.addWidget(self.btnPrint)
self.buttonBox.addWidget(self.btnClose)
self.buttonBox.setSpacing(self.mainConf.pxInt(4))
self.buttonBox.setSpacing(CONFIG.pxInt(4))
# Assemble GUI
# ============
# Splitter Position
boxWidth = self.mainConf.pxInt(350)
boxWidth = CONFIG.pxInt(350)
boxWidth = pOptions.getInt("GuiBuildNovel", "boxWidth", boxWidth)
docWidth = max(self.width() - boxWidth, 100)
docWidth = pOptions.getInt("GuiBuildNovel", "docWidth", docWidth)
@@ -547,22 +546,22 @@ class GuiBuildNovel(QDialog):
# Tool Box Scroll Area
self.toolsArea = QScrollArea()
self.toolsArea.setMinimumWidth(self.mainConf.pxInt(250))
self.toolsArea.setMinimumWidth(CONFIG.pxInt(250))
self.toolsArea.setWidgetResizable(True)
self.toolsArea.setWidget(self.toolsWidget)
if self.mainConf.hideVScroll:
if CONFIG.hideVScroll:
self.toolsArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
else:
self.toolsArea.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
if self.mainConf.hideHScroll:
if CONFIG.hideHScroll:
self.toolsArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
else:
self.toolsArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
# Tools and Buttons Layout
tSp = self.mainConf.pxInt(8)
tSp = CONFIG.pxInt(8)
self.innerBox = QVBoxLayout()
self.innerBox.addWidget(self.toolsArea)
self.innerBox.addSpacing(tSp)
@@ -891,14 +890,14 @@ class GuiBuildNovel(QDialog):
cleanName = makeFileNameSafe(self.theProject.data.name)
fileName = "%s.%s" % (cleanName, fileExt)
savePath = self.mainConf.lastPath() / fileName
savePath = CONFIG.lastPath() / fileName
savePath, _ = QFileDialog.getSaveFileName(
self, self.tr("Save Document As"), str(savePath)
)
if not savePath:
return False
self.mainConf.setLastPath(savePath)
CONFIG.setLastPath(savePath)
# Build and Write
# ===============
@@ -1173,8 +1172,8 @@ class GuiBuildNovel(QDialog):
buildLang = self.buildLang.currentData()
hideScene = self.hideScene.isChecked()
hideSection = self.hideSection.isChecked()
winWidth = self.mainConf.rpxInt(self.width())
winHeight = self.mainConf.rpxInt(self.height())
winWidth = CONFIG.rpxInt(self.width())
winHeight = CONFIG.rpxInt(self.height())
justifyText = self.justifyText.isChecked()
noStyling = self.noStyling.isChecked()
textFont = self.textFont.text()
@@ -1192,8 +1191,8 @@ class GuiBuildNovel(QDialog):
rootFilter = self._generateRootFilter()
mainSplit = self.mainSplit.sizes()
boxWidth = self.mainConf.rpxInt(mainSplit[0])
docWidth = self.mainConf.rpxInt(mainSplit[1])
boxWidth = CONFIG.rpxInt(mainSplit[0])
docWidth = CONFIG.rpxInt(mainSplit[1])
self.theProject.setProjectLang(buildLang)
@@ -1243,7 +1242,6 @@ class GuiBuildNovelDocView(QTextBrowser):
logger.debug("Initialising GuiBuildNovelDocView ...")
self.mainConf = novelwriter.CONFIG
self.theProject = theProject
self.mainGui = mainGui
self.mainTheme = mainGui.mainTheme
@@ -1252,7 +1250,7 @@ class GuiBuildNovelDocView(QTextBrowser):
self.setMinimumWidth(40*self.mainGui.mainTheme.textNWidth)
self.setOpenExternalLinks(False)
self.document().setDocumentMargin(self.mainConf.getTextMargin())
self.document().setDocumentMargin(CONFIG.getTextMargin())
self.setPlaceholderText(self.tr(
"This area will show the content of the document to be "
"exported or printed. Press the \"Build Preview\" button "
@@ -1260,15 +1258,15 @@ class GuiBuildNovelDocView(QTextBrowser):
))
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 tab stops
self.setTabStopDistance(self.mainConf.getTabWidth())
self.setTabStopDistance(CONFIG.getTabWidth())
docPalette = self.palette()
docPalette.setColor(QPalette.Base, QColor(255, 255, 255))
+6 -7
View File
@@ -25,7 +25,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
import random
import logging
import novelwriter
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import (
@@ -33,6 +32,7 @@ from PyQt5.QtWidgets import (
QSpinBox
)
from novelwriter import CONFIG
from novelwriter.common import readTextFile
from novelwriter.extensions.switch import NSwitch
@@ -47,18 +47,17 @@ class GuiLipsum(QDialog):
logger.debug("Initialising GuiLipsum ...")
self.setObjectName("GuiLipsum")
self.mainConf = novelwriter.CONFIG
self.mainGui = mainGui
self.mainTheme = mainGui.mainTheme
self.setWindowTitle(self.tr("Insert Placeholder Text"))
self.innerBox = QHBoxLayout()
self.innerBox.setSpacing(self.mainConf.pxInt(16))
self.innerBox.setSpacing(CONFIG.pxInt(16))
# Icon
nPx = self.mainConf.pxInt(64)
vSp = self.mainConf.pxInt(4)
nPx = CONFIG.pxInt(64)
vSp = CONFIG.pxInt(4)
self.docIcon = QLabel()
self.docIcon.setPixmap(self.mainTheme.getPixmap("proj_document", (nPx, nPx)))
@@ -105,7 +104,7 @@ class GuiLipsum(QDialog):
self.outerBox = QVBoxLayout()
self.outerBox.addLayout(self.innerBox)
self.outerBox.addWidget(self.buttonBox)
self.outerBox.setSpacing(self.mainConf.pxInt(16))
self.outerBox.setSpacing(CONFIG.pxInt(16))
self.setLayout(self.outerBox)
logger.debug("GuiLipsum initialisation complete")
@@ -119,7 +118,7 @@ class GuiLipsum(QDialog):
def _doInsert(self):
"""Load the text and insert it in the open document.
"""
lipsumFile = self.mainConf.assetPath("text") / "lipsum.txt"
lipsumFile = CONFIG.assetPath("text") / "lipsum.txt"
lipsumText = readTextFile(lipsumFile).splitlines()
if self.randSwitch.isChecked():
+11 -13
View File
@@ -24,13 +24,13 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
import novelwriter
from PyQt5.QtWidgets import (
QDialog, QGridLayout, QPushButton, QSplitter, QTextBrowser, QVBoxLayout,
QWidget, qApp
)
from novelwriter import CONFIG
from novelwriter.tools.manussettings import GuiBuildSettings
logger = logging.getLogger(__name__)
@@ -41,22 +41,21 @@ class GuiBuildManuscript(QDialog):
def __init__(self, mainGui):
super().__init__(parent=mainGui)
self.mainConf = novelwriter.CONFIG
self.mainGui = mainGui
self.mainTheme = mainGui.mainTheme
self.theProject = mainGui.theProject
self.setWindowTitle(self.tr("Build Manuscript"))
self.setMinimumWidth(self.mainConf.pxInt(600))
self.setMinimumHeight(self.mainConf.pxInt(500))
self.setMinimumWidth(CONFIG.pxInt(600))
self.setMinimumHeight(CONFIG.pxInt(500))
wWin = self.mainConf.pxInt(900)
hWin = self.mainConf.pxInt(600)
wWin = CONFIG.pxInt(900)
hWin = CONFIG.pxInt(600)
pOptions = self.theProject.options
self.resize(
self.mainConf.pxInt(pOptions.getInt("GuiBuildManuscript", "winWidth", wWin)),
self.mainConf.pxInt(pOptions.getInt("GuiBuildManuscript", "winHeight", hWin))
CONFIG.pxInt(pOptions.getInt("GuiBuildManuscript", "winWidth", wWin)),
CONFIG.pxInt(pOptions.getInt("GuiBuildManuscript", "winHeight", hWin))
)
# Controls
@@ -80,8 +79,8 @@ class GuiBuildManuscript(QDialog):
self.mainSplit.addWidget(self.optsWidget)
self.mainSplit.addWidget(self.manPreview)
self.mainSplit.setSizes([
self.mainConf.pxInt(pOptions.getInt("GuiBuildManuscript", "optsWidth", wWin//3)),
self.mainConf.pxInt(pOptions.getInt("GuiBuildManuscript", "viewWidth", 2*wWin//3)),
CONFIG.pxInt(pOptions.getInt("GuiBuildManuscript", "optsWidth", wWin//3)),
CONFIG.pxInt(pOptions.getInt("GuiBuildManuscript", "viewWidth", 2*wWin//3)),
])
self.outerBox = QVBoxLayout()
@@ -134,8 +133,8 @@ class GuiBuildManuscript(QDialog):
"""
logger.debug("Saving GuiBuildManuscript settings")
winWidth = self.mainConf.rpxInt(self.width())
winHeight = self.mainConf.rpxInt(self.height())
winWidth = CONFIG.rpxInt(self.width())
winHeight = CONFIG.rpxInt(self.height())
mainSplit = self.mainSplit.sizes()
optsWidth = mainSplit[0]
@@ -158,7 +157,6 @@ class GuiManuscriptPreview(QTextBrowser):
def __init__(self, mainGui):
super().__init__(parent=mainGui)
self.mainConf = novelwriter.CONFIG
self.mainGui = mainGui
self.mainTheme = mainGui.mainTheme
self.theProject = mainGui.theProject
+15 -18
View File
@@ -25,7 +25,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
from __future__ import annotations
import logging
import novelwriter
from typing import TYPE_CHECKING
@@ -37,6 +36,7 @@ from PyQt5.QtWidgets import (
QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget
)
from novelwriter import CONFIG
from novelwriter.core.buildsettings import BuildSettings, FilterMode
from novelwriter.extensions.switch import NSwitch
from novelwriter.extensions.switchbox import NSwitchBox
@@ -64,7 +64,6 @@ class GuiBuildSettings(QDialog):
logger.debug("Initialising GuiBuildSettings ...")
self.setObjectName("GuiBuildSettings")
self.mainConf = novelwriter.CONFIG
self.mainGui = mainGui
self.mainTheme = mainGui.mainTheme
self.theProject = mainGui.theProject
@@ -73,17 +72,17 @@ class GuiBuildSettings(QDialog):
self._build.unpack(buildData)
self.setWindowTitle(self.tr("Manuscript Build Settings"))
self.setMinimumWidth(self.mainConf.pxInt(700))
self.setMinimumHeight(self.mainConf.pxInt(400))
self.setMinimumWidth(CONFIG.pxInt(700))
self.setMinimumHeight(CONFIG.pxInt(400))
mPx = self.mainConf.pxInt(150)
wWin = self.mainConf.pxInt(900)
hWin = self.mainConf.pxInt(600)
mPx = CONFIG.pxInt(150)
wWin = CONFIG.pxInt(900)
hWin = CONFIG.pxInt(600)
pOptions = self.theProject.options
self.resize(
self.mainConf.pxInt(pOptions.getInt("GuiBuildSettings", "winWidth", wWin)),
self.mainConf.pxInt(pOptions.getInt("GuiBuildSettings", "winHeight", hWin))
CONFIG.pxInt(pOptions.getInt("GuiBuildSettings", "winWidth", wWin)),
CONFIG.pxInt(pOptions.getInt("GuiBuildSettings", "winHeight", hWin))
)
# Options SideBar
@@ -204,8 +203,8 @@ class GuiBuildSettings(QDialog):
"""
logger.debug("Saving GuiBuildSettings settings")
winWidth = self.mainConf.rpxInt(self.width())
winHeight = self.mainConf.rpxInt(self.height())
winWidth = CONFIG.rpxInt(self.width())
winHeight = CONFIG.rpxInt(self.height())
treeWidth, filterWidth = self.optTabSelect.mainSplitSizes()
@@ -239,7 +238,6 @@ class GuiBuildFilterTab(QWidget):
def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings):
super().__init__(parent=buildMain)
self.mainConf = novelwriter.CONFIG
self.mainGui = buildMain.mainGui
self.mainTheme = buildMain.mainGui.mainTheme
self.theProject = buildMain.mainGui.theProject
@@ -259,7 +257,7 @@ class GuiBuildFilterTab(QWidget):
# Tree Settings
iPx = self.mainTheme.baseIconSize
cMg = self.mainConf.pxInt(6)
cMg = CONFIG.pxInt(6)
# Tree Widget
self.optTree = QTreeWidget(self)
@@ -312,8 +310,8 @@ class GuiBuildFilterTab(QWidget):
# ========
pOptions = self.theProject.options
wTree = self.mainConf.pxInt(pOptions.getInt("GuiBuildSettings", "treeWidth", 0))
fTree = self.mainConf.pxInt(pOptions.getInt("GuiBuildSettings", "filterWidth", 0))
wTree = CONFIG.pxInt(pOptions.getInt("GuiBuildSettings", "treeWidth", 0))
fTree = CONFIG.pxInt(pOptions.getInt("GuiBuildSettings", "filterWidth", 0))
self.selectionBox = QVBoxLayout()
self.selectionBox.addLayout(self.modeBox)
@@ -511,7 +509,6 @@ class GuiBuildHeadingsTab(QWidget):
def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings):
super().__init__(parent=buildMain)
self.mainConf = novelwriter.CONFIG
self.mainGui = buildMain.mainGui
self.mainTheme = buildMain.mainGui.mainTheme
self.theProject = buildMain.mainGui.theProject
@@ -519,8 +516,8 @@ class GuiBuildHeadingsTab(QWidget):
self._build = build
iPx = self.mainTheme.baseIconSize
vSp = self.mainConf.pxInt(12)
bSp = self.mainConf.pxInt(6)
vSp = CONFIG.pxInt(12)
bSp = CONFIG.pxInt(6)
# Format Boxes
# ============
+16 -22
View File
@@ -25,7 +25,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
import os
import logging
import novelwriter
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import (
@@ -33,6 +32,7 @@ from PyQt5.QtWidgets import (
QPushButton, QRadioButton, QSpinBox, QVBoxLayout, QWizard, QWizardPage
)
from novelwriter import CONFIG
from novelwriter.common import makeFileNameSafe
from novelwriter.extensions.switch import NSwitch
@@ -53,12 +53,11 @@ class GuiProjectWizard(QWizard):
logger.debug("Initialising GuiProjectWizard ...")
self.setObjectName("GuiProjectWizard")
self.mainConf = novelwriter.CONFIG
self.mainGui = mainGui
self.mainTheme = mainGui.mainTheme
self.sideImage = self.mainTheme.loadDecoration(
"wiz-back", None, self.mainConf.pxInt(370)
"wiz-back", None, CONFIG.pxInt(370)
)
self.setWizardStyle(QWizard.ModernStyle)
self.setPixmap(QWizard.WatermarkPixmap, self.sideImage)
@@ -89,7 +88,6 @@ class ProjWizardIntroPage(QWizardPage):
def __init__(self, theWizard):
super().__init__()
self.mainConf = novelwriter.CONFIG
self.theWizard = theWizard
self.mainTheme = theWizard.mainTheme
@@ -109,9 +107,9 @@ class ProjWizardIntroPage(QWizardPage):
lblFont.setPointSizeF(0.6*self.mainTheme.fontPointSize)
self.imgCredit.setFont(lblFont)
xW = self.mainConf.pxInt(300)
vS = self.mainConf.pxInt(12)
fS = self.mainConf.pxInt(4)
xW = CONFIG.pxInt(300)
vS = CONFIG.pxInt(12)
fS = CONFIG.pxInt(4)
# The Page Form
self.projName = QLineEdit()
@@ -158,7 +156,6 @@ class ProjWizardFolderPage(QWizardPage):
def __init__(self, theWizard):
super().__init__()
self.mainConf = novelwriter.CONFIG
self.theWizard = theWizard
self.mainTheme = theWizard.mainTheme
@@ -169,9 +166,9 @@ class ProjWizardFolderPage(QWizardPage):
))
self.theText.setWordWrap(True)
xW = self.mainConf.pxInt(300)
vS = self.mainConf.pxInt(12)
fS = self.mainConf.pxInt(8)
xW = CONFIG.pxInt(300)
vS = CONFIG.pxInt(12)
fS = CONFIG.pxInt(8)
self.projPath = QLineEdit("")
self.projPath.setFixedWidth(xW)
@@ -234,7 +231,7 @@ class ProjWizardFolderPage(QWizardPage):
def _doBrowse(self):
"""Select a project folder.
"""
lastPath = self.mainConf.lastPath()
lastPath = CONFIG.lastPath()
projDir = QFileDialog.getExistingDirectory(
self, self.tr("Select Project Folder"), str(lastPath), options=QFileDialog.ShowDirsOnly
)
@@ -256,7 +253,6 @@ class ProjWizardPopulatePage(QWizardPage):
def __init__(self, theWizard):
super().__init__()
self.mainConf = novelwriter.CONFIG
self.theWizard = theWizard
self.setTitle(self.tr("Populate Project"))
@@ -267,8 +263,8 @@ class ProjWizardPopulatePage(QWizardPage):
))
self.theText.setWordWrap(True)
vS = self.mainConf.pxInt(12)
fS = self.mainConf.pxInt(4)
vS = CONFIG.pxInt(12)
fS = CONFIG.pxInt(4)
self.popMinimal = QRadioButton(self.tr("Fill the project with a minimal set of items"))
self.popSample = QRadioButton(self.tr("Fill the project with example files"))
@@ -312,7 +308,6 @@ class ProjWizardCustomPage(QWizardPage):
def __init__(self, theWizard):
super().__init__()
self.mainConf = novelwriter.CONFIG
self.theWizard = theWizard
self.setTitle(self.tr("Custom Project Options"))
@@ -323,9 +318,9 @@ class ProjWizardCustomPage(QWizardPage):
))
self.theText.setWordWrap(True)
cM = self.mainConf.pxInt(12)
mH = self.mainConf.pxInt(26)
fS = self.mainConf.pxInt(4)
cM = CONFIG.pxInt(12)
mH = CONFIG.pxInt(26)
fS = CONFIG.pxInt(4)
# Root Folders
self.addPlot = NSwitch()
@@ -413,7 +408,6 @@ class ProjWizardFinalPage(QWizardPage):
def __init__(self, theWizard):
super().__init__()
self.mainConf = novelwriter.CONFIG
self.theWizard = theWizard
self.setTitle(self.tr("Summary"))
@@ -422,7 +416,7 @@ class ProjWizardFinalPage(QWizardPage):
# Assemble
self.outerBox = QVBoxLayout()
self.outerBox.setSpacing(self.mainConf.pxInt(12))
self.outerBox.setSpacing(CONFIG.pxInt(12))
self.outerBox.addWidget(self.theText)
self.outerBox.addStretch(1)
self.setLayout(self.outerBox)
@@ -470,7 +464,7 @@ class ProjWizardFinalPage(QWizardPage):
self.tr("You have selected the following:"),
"<br>&nbsp;&bull;&nbsp;".join(sumList),
self.tr("Press '{0}' to create the new project.").format(
self.tr("Done") if self.mainConf.osDarwin else self.tr("Finish")
self.tr("Done") if CONFIG.osDarwin else self.tr("Finish")
)
)
)
+18 -19
View File
@@ -25,7 +25,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
import json
import logging
import novelwriter
from pathlib import Path
from datetime import datetime
@@ -37,6 +36,7 @@ from PyQt5.QtWidgets import (
QLabel, QGroupBox, QMenu, QAction, QFileDialog, QSpinBox, QHBoxLayout
)
from novelwriter import CONFIG
from novelwriter.enum import nwAlert
from novelwriter.error import formatException
from novelwriter.common import formatTime, checkInt, checkIntTuple, minmax
@@ -63,7 +63,6 @@ class GuiWritingStats(QDialog):
logger.debug("Initialising GuiWritingStats ...")
self.setObjectName("GuiWritingStats")
self.mainConf = novelwriter.CONFIG
self.mainGui = mainGui
self.mainTheme = mainGui.mainTheme
self.theProject = mainGui.theProject
@@ -76,24 +75,24 @@ class GuiWritingStats(QDialog):
pOptions = self.theProject.options
self.setWindowTitle(self.tr("Writing Statistics"))
self.setMinimumWidth(self.mainConf.pxInt(420))
self.setMinimumHeight(self.mainConf.pxInt(400))
self.setMinimumWidth(CONFIG.pxInt(420))
self.setMinimumHeight(CONFIG.pxInt(400))
self.resize(
self.mainConf.pxInt(pOptions.getInt("GuiWritingStats", "winWidth", 550)),
self.mainConf.pxInt(pOptions.getInt("GuiWritingStats", "winHeight", 500))
CONFIG.pxInt(pOptions.getInt("GuiWritingStats", "winWidth", 550)),
CONFIG.pxInt(pOptions.getInt("GuiWritingStats", "winHeight", 500))
)
# List Box
wCol0 = self.mainConf.pxInt(
wCol0 = CONFIG.pxInt(
pOptions.getInt("GuiWritingStats", "widthCol0", 180)
)
wCol1 = self.mainConf.pxInt(
wCol1 = CONFIG.pxInt(
pOptions.getInt("GuiWritingStats", "widthCol1", 80)
)
wCol2 = self.mainConf.pxInt(
wCol2 = CONFIG.pxInt(
pOptions.getInt("GuiWritingStats", "widthCol2", 80)
)
wCol3 = self.mainConf.pxInt(
wCol3 = CONFIG.pxInt(
pOptions.getInt("GuiWritingStats", "widthCol3", 80)
)
@@ -127,7 +126,7 @@ class GuiWritingStats(QDialog):
# Word Bar
self.barHeight = int(round(0.5*self.mainTheme.fontPixelSize))
self.barWidth = self.mainConf.pxInt(200)
self.barWidth = CONFIG.pxInt(200)
self.barImage = QPixmap(self.barHeight, self.barHeight)
self.barImage.fill(self.palette().highlight().color())
@@ -309,12 +308,12 @@ class GuiWritingStats(QDialog):
"""
self.logData = []
winWidth = self.mainConf.rpxInt(self.width())
winHeight = self.mainConf.rpxInt(self.height())
widthCol0 = self.mainConf.rpxInt(self.listBox.columnWidth(0))
widthCol1 = self.mainConf.rpxInt(self.listBox.columnWidth(1))
widthCol2 = self.mainConf.rpxInt(self.listBox.columnWidth(2))
widthCol3 = self.mainConf.rpxInt(self.listBox.columnWidth(3))
winWidth = CONFIG.rpxInt(self.width())
winHeight = CONFIG.rpxInt(self.height())
widthCol0 = CONFIG.rpxInt(self.listBox.columnWidth(0))
widthCol1 = CONFIG.rpxInt(self.listBox.columnWidth(1))
widthCol2 = CONFIG.rpxInt(self.listBox.columnWidth(2))
widthCol3 = CONFIG.rpxInt(self.listBox.columnWidth(3))
sortCol = self.listBox.sortColumn()
sortOrder = self.listBox.header().sortIndicatorOrder()
incNovel = self.incNovel.isChecked()
@@ -362,14 +361,14 @@ class GuiWritingStats(QDialog):
return False
# Generate the file name
savePath = self.mainConf.lastPath() / f"sessionStats.{fileExt}"
savePath = CONFIG.lastPath() / f"sessionStats.{fileExt}"
savePath, _ = QFileDialog.getSaveFileName(
self, self.tr("Save Data As"), str(savePath), "%s (*.%s)" % (textFmt, fileExt)
)
if not savePath:
return False
self.mainConf.setLastPath(savePath)
CONFIG.setLastPath(savePath)
# Do the actual writing
wSuccess = False