Merge branch 'main' into dev
This commit is contained in:
@@ -23,7 +23,6 @@ link = 44, 152, 247
|
|||||||
linkvisited = 44, 152, 247
|
linkvisited = 44, 152, 247
|
||||||
|
|
||||||
[GUI]
|
[GUI]
|
||||||
treewordcount = 197, 200, 198
|
|
||||||
statusnone = 150, 152, 150
|
statusnone = 150, 152, 150
|
||||||
statussaved = 39, 135, 78
|
statussaved = 39, 135, 78
|
||||||
statusunsaved = 138, 32, 32
|
statusunsaved = 138, 32, 32
|
||||||
|
|||||||
+3
-5
@@ -76,11 +76,10 @@ class GuiTheme:
|
|||||||
self.themeLicenseUrl = ""
|
self.themeLicenseUrl = ""
|
||||||
|
|
||||||
## GUI
|
## GUI
|
||||||
self.treeWCount = [0, 0, 0]
|
|
||||||
self.statNone = [120, 120, 120]
|
self.statNone = [120, 120, 120]
|
||||||
self.statUnsaved = [120, 120, 40]
|
self.statUnsaved = [200, 15, 39]
|
||||||
self.statSaved = [40, 120, 0]
|
self.statSaved = [2, 133, 37]
|
||||||
self.helpText = [0, 0, 0]
|
self.helpText = [0, 0, 0]
|
||||||
|
|
||||||
# Loaded Syntax Settings
|
# Loaded Syntax Settings
|
||||||
|
|
||||||
@@ -309,7 +308,6 @@ class GuiTheme:
|
|||||||
## GUI
|
## GUI
|
||||||
cnfSec = "GUI"
|
cnfSec = "GUI"
|
||||||
if confParser.has_section(cnfSec):
|
if confParser.has_section(cnfSec):
|
||||||
self.treeWCount = self._loadColour(confParser, cnfSec, "treewordcount")
|
|
||||||
self.statNone = self._loadColour(confParser, cnfSec, "statusnone")
|
self.statNone = self._loadColour(confParser, cnfSec, "statusnone")
|
||||||
self.statUnsaved = self._loadColour(confParser, cnfSec, "statusunsaved")
|
self.statUnsaved = self._loadColour(confParser, cnfSec, "statusunsaved")
|
||||||
self.statSaved = self._loadColour(confParser, cnfSec, "statussaved")
|
self.statSaved = self._loadColour(confParser, cnfSec, "statussaved")
|
||||||
|
|||||||
+19
-11
@@ -90,7 +90,7 @@ class GuiMain(QMainWindow):
|
|||||||
|
|
||||||
# Prepare Main Window
|
# Prepare Main Window
|
||||||
self.resize(*self.mainConf.getWinSize())
|
self.resize(*self.mainConf.getWinSize())
|
||||||
self._setWindowTitle()
|
self._updateWindowTitle()
|
||||||
self.setWindowIcon(QIcon(self.mainConf.appIcon))
|
self.setWindowIcon(QIcon(self.mainConf.appIcon))
|
||||||
|
|
||||||
# Build the GUI
|
# Build the GUI
|
||||||
@@ -300,10 +300,13 @@ class GuiMain(QMainWindow):
|
|||||||
|
|
||||||
# Work Area
|
# Work Area
|
||||||
self.docEditor.clearEditor()
|
self.docEditor.clearEditor()
|
||||||
|
self.docEditor.setDictionaries()
|
||||||
self.closeDocViewer()
|
self.closeDocViewer()
|
||||||
|
self.projMeta.clearDetails()
|
||||||
|
|
||||||
# General
|
# General
|
||||||
self.statusBar.clearStatus()
|
self.statusBar.clearStatus()
|
||||||
|
self._updateWindowTitle()
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -322,11 +325,12 @@ class GuiMain(QMainWindow):
|
|||||||
"""Create new project via the new project wizard.
|
"""Create new project via the new project wizard.
|
||||||
"""
|
"""
|
||||||
if self.hasProject:
|
if self.hasProject:
|
||||||
self.makeAlert(
|
if not self.closeProject():
|
||||||
"Please close the current project before making a new one.",
|
self.makeAlert(
|
||||||
nwAlert.ERROR
|
"Cannot create new project when another project is open.",
|
||||||
)
|
nwAlert.ERROR
|
||||||
return False
|
)
|
||||||
|
return False
|
||||||
|
|
||||||
if projData is None:
|
if projData is None:
|
||||||
projData = self.showNewProjectDialog()
|
projData = self.showNewProjectDialog()
|
||||||
@@ -351,8 +355,13 @@ class GuiMain(QMainWindow):
|
|||||||
self.rebuildTrees()
|
self.rebuildTrees()
|
||||||
self.saveProject()
|
self.saveProject()
|
||||||
self.hasProject = True
|
self.hasProject = True
|
||||||
self.statusBar.setRefTime(self.theProject.projOpened)
|
self.docEditor.setDictionaries()
|
||||||
self.rebuildIndex(beQuiet=True)
|
self.rebuildIndex(beQuiet=True)
|
||||||
|
self.statusBar.setRefTime(self.theProject.projOpened)
|
||||||
|
self.statusBar.setProjectStatus(True)
|
||||||
|
self.statusBar.setDocumentStatus(None)
|
||||||
|
self.statusBar.setStatus("New project created ...")
|
||||||
|
self._updateWindowTitle(self.theProject.projName)
|
||||||
else:
|
else:
|
||||||
self.theProject.clearProject()
|
self.theProject.clearProject()
|
||||||
return False
|
return False
|
||||||
@@ -399,7 +408,6 @@ class GuiMain(QMainWindow):
|
|||||||
self.closeDocument()
|
self.closeDocument()
|
||||||
self.docViewer.clearNavHistory()
|
self.docViewer.clearNavHistory()
|
||||||
self.projView.closeOutline()
|
self.projView.closeOutline()
|
||||||
self.projMeta.clearDetails()
|
|
||||||
self.theProject.closeProject()
|
self.theProject.closeProject()
|
||||||
self.theIndex.clearIndex()
|
self.theIndex.clearIndex()
|
||||||
self.clearGUI()
|
self.clearGUI()
|
||||||
@@ -471,7 +479,7 @@ class GuiMain(QMainWindow):
|
|||||||
self.theIndex.loadIndex()
|
self.theIndex.loadIndex()
|
||||||
|
|
||||||
# Update GUI
|
# Update GUI
|
||||||
self._setWindowTitle(self.theProject.projName)
|
self._updateWindowTitle(self.theProject.projName)
|
||||||
self.rebuildTrees()
|
self.rebuildTrees()
|
||||||
self.docEditor.setDictionaries()
|
self.docEditor.setDictionaries()
|
||||||
self.docEditor.setSpellCheck(self.theProject.spellCheck)
|
self.docEditor.setSpellCheck(self.theProject.spellCheck)
|
||||||
@@ -942,7 +950,7 @@ class GuiMain(QMainWindow):
|
|||||||
if dlgProj.result() == QDialog.Accepted:
|
if dlgProj.result() == QDialog.Accepted:
|
||||||
logger.debug("Applying new project settings")
|
logger.debug("Applying new project settings")
|
||||||
self.docEditor.setDictionaries()
|
self.docEditor.setDictionaries()
|
||||||
self._setWindowTitle(self.theProject.projName)
|
self._updateWindowTitle(self.theProject.projName)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -1265,7 +1273,7 @@ class GuiMain(QMainWindow):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _setWindowTitle(self, projName=None):
|
def _updateWindowTitle(self, projName=None):
|
||||||
"""Set the window title and add the project's working title.
|
"""Set the window title and add the project's working title.
|
||||||
"""
|
"""
|
||||||
winTitle = self.mainConf.appName
|
winTitle = self.mainConf.appName
|
||||||
|
|||||||
+44
-40
@@ -8,6 +8,7 @@ import shutil
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from dummy import DummyMain
|
from dummy import DummyMain
|
||||||
|
from tools import cleanProject
|
||||||
|
|
||||||
sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)))
|
sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)))
|
||||||
|
|
||||||
@@ -129,21 +130,20 @@ def nwGUI(qtbot, fncDir):
|
|||||||
def nwMinimal(tmpDir):
|
def nwMinimal(tmpDir):
|
||||||
"""A minimal novelWriter example project.
|
"""A minimal novelWriter example project.
|
||||||
"""
|
"""
|
||||||
testDir = os.path.dirname(__file__)
|
tstDir = os.path.dirname(__file__)
|
||||||
minimalStore = os.path.join(testDir, "minimal")
|
srcDir = os.path.join(tstDir, "minimal")
|
||||||
minimalDir = os.path.join(tmpDir, "minimal")
|
dstDir = os.path.join(tmpDir, "minimal")
|
||||||
if os.path.isdir(minimalDir):
|
if os.path.isdir(dstDir):
|
||||||
shutil.rmtree(minimalDir)
|
shutil.rmtree(dstDir)
|
||||||
shutil.copytree(minimalStore, minimalDir)
|
|
||||||
cacheDir = os.path.join(minimalDir, "cache")
|
shutil.copytree(srcDir, dstDir)
|
||||||
if os.path.isdir(cacheDir):
|
cleanProject(dstDir)
|
||||||
shutil.rmtree(cacheDir)
|
|
||||||
metaDir = os.path.join(minimalDir, "meta")
|
yield dstDir
|
||||||
if os.path.isdir(metaDir):
|
|
||||||
shutil.rmtree(metaDir)
|
if os.path.isdir(dstDir):
|
||||||
yield minimalDir
|
shutil.rmtree(dstDir)
|
||||||
if os.path.isdir(minimalDir):
|
|
||||||
shutil.rmtree(minimalDir)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@pytest.fixture(scope="function")
|
@pytest.fixture(scope="function")
|
||||||
@@ -151,34 +151,38 @@ def nwLipsum(tmpDir):
|
|||||||
"""A medium sized novelWriter example project with a lot of Lorem
|
"""A medium sized novelWriter example project with a lot of Lorem
|
||||||
Ipsum dummy text.
|
Ipsum dummy text.
|
||||||
"""
|
"""
|
||||||
testDir = os.path.dirname(__file__)
|
tstDir = os.path.dirname(__file__)
|
||||||
lipsumStore = os.path.join(testDir, "lipsum")
|
srcDir = os.path.join(tstDir, "lipsum")
|
||||||
lipsumDir = os.path.join(tmpDir, "lipsum")
|
dstDir = os.path.join(tmpDir, "lipsum")
|
||||||
if os.path.isdir(lipsumDir):
|
if os.path.isdir(dstDir):
|
||||||
shutil.rmtree(lipsumDir)
|
shutil.rmtree(dstDir)
|
||||||
shutil.copytree(lipsumStore, lipsumDir)
|
|
||||||
cacheDir = os.path.join(lipsumDir, "cache")
|
shutil.copytree(srcDir, dstDir)
|
||||||
if os.path.isdir(cacheDir):
|
cleanProject(dstDir)
|
||||||
shutil.rmtree(cacheDir)
|
|
||||||
metaDir = os.path.join(lipsumDir, "meta")
|
yield dstDir
|
||||||
if os.path.isdir(metaDir):
|
|
||||||
shutil.rmtree(metaDir)
|
if os.path.isdir(dstDir):
|
||||||
yield lipsumDir
|
shutil.rmtree(dstDir)
|
||||||
if os.path.isdir(lipsumDir):
|
|
||||||
shutil.rmtree(lipsumDir)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@pytest.fixture(scope="function")
|
@pytest.fixture(scope="function")
|
||||||
def nwOldProj(tmpDir):
|
def nwOldProj(tmpDir):
|
||||||
"""A minimal movelWriter project using the old folder structure.
|
"""A minimal movelWriter project using the old folder structure used
|
||||||
|
for storage versions < 1.2.
|
||||||
"""
|
"""
|
||||||
testDir = os.path.dirname(__file__)
|
tstDir = os.path.dirname(__file__)
|
||||||
oldProjStore = os.path.join(testDir, "oldproj")
|
srcDir = os.path.join(tstDir, "oldproj")
|
||||||
oldProjDir = os.path.join(tmpDir, "oldproj")
|
dstDir = os.path.join(tmpDir, "oldproj")
|
||||||
if os.path.isdir(oldProjDir):
|
if os.path.isdir(dstDir):
|
||||||
shutil.rmtree(oldProjDir)
|
shutil.rmtree(dstDir)
|
||||||
shutil.copytree(oldProjStore, oldProjDir)
|
|
||||||
yield oldProjDir
|
shutil.copytree(srcDir, dstDir)
|
||||||
if os.path.isdir(oldProjDir):
|
|
||||||
shutil.rmtree(oldProjDir)
|
yield dstDir
|
||||||
|
|
||||||
|
if os.path.isdir(dstDir):
|
||||||
|
shutil.rmtree(dstDir)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -73,7 +73,6 @@ def testGuiTheme_Main(qtbot, monkeypatch, nwMinimal, tmpDir):
|
|||||||
assert thePalette.link().color() == QColor(44, 152, 247)
|
assert thePalette.link().color() == QColor(44, 152, 247)
|
||||||
assert thePalette.linkVisited().color() == QColor(44, 152, 247)
|
assert thePalette.linkVisited().color() == QColor(44, 152, 247)
|
||||||
|
|
||||||
assert nwGUI.theTheme.treeWCount == [197, 200, 198]
|
|
||||||
assert nwGUI.theTheme.statNone == [150, 152, 150]
|
assert nwGUI.theTheme.statNone == [150, 152, 150]
|
||||||
assert nwGUI.theTheme.statSaved == [39, 135, 78]
|
assert nwGUI.theTheme.statSaved == [39, 135, 78]
|
||||||
assert nwGUI.theTheme.statUnsaved == [138, 32, 32]
|
assert nwGUI.theTheme.statUnsaved == [138, 32, 32]
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
"""novelWriter Test Tools
|
"""novelWriter Test Tools
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
|
|
||||||
from PyQt5.QtWidgets import qApp
|
from PyQt5.QtWidgets import qApp
|
||||||
@@ -82,3 +85,24 @@ def writeFile(fileName, fileData):
|
|||||||
"""
|
"""
|
||||||
with open(fileName, mode="w", encoding="utf8") as outFile:
|
with open(fileName, mode="w", encoding="utf8") as outFile:
|
||||||
outFile.write(fileData)
|
outFile.write(fileData)
|
||||||
|
|
||||||
|
def cleanProject(projPath):
|
||||||
|
"""Delete all generated files in a project.
|
||||||
|
"""
|
||||||
|
cacheDir = os.path.join(projPath, "cache")
|
||||||
|
if os.path.isdir(cacheDir):
|
||||||
|
shutil.rmtree(cacheDir)
|
||||||
|
|
||||||
|
metaDir = os.path.join(projPath, "meta")
|
||||||
|
if os.path.isdir(metaDir):
|
||||||
|
shutil.rmtree(metaDir)
|
||||||
|
|
||||||
|
bakFile = os.path.join(projPath, "nwProject.bak")
|
||||||
|
if os.path.isfile(bakFile):
|
||||||
|
os.unlink(bakFile)
|
||||||
|
|
||||||
|
tocFile = os.path.join(projPath, "ToC.txt")
|
||||||
|
if os.path.isfile(tocFile):
|
||||||
|
os.unlink(tocFile)
|
||||||
|
|
||||||
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user