Clean up setters and getters in Config

This commit is contained in:
Veronica Berglyd Olsen
2022-11-10 09:29:00 +01:00
parent e2f3a44d96
commit 15fec91358
11 changed files with 220 additions and 206 deletions
+16
View File
@@ -124,6 +124,17 @@ def checkUuid(value, default):
return default
def checkPath(value, default):
"""Check if a value is a valid path. Non-empty strings are accepted.
"""
if isinstance(value, Path):
return value
elif isinstance(value, str):
if value.strip():
return Path(value)
return default
# =============================================================================================== #
# Validator Functions
# =============================================================================================== #
@@ -552,6 +563,11 @@ class NWConfigParser(ConfigParser):
logger.error("Could not read '%s':'%s' from config", section, option)
return default
def rdPath(self, section, option, default):
"""Read a path value.
"""
return checkPath(self.get(section, option, fallback=default), default)
def rdStrList(self, section, option, default):
"""Read string list.
"""
+136 -137
View File
@@ -37,7 +37,7 @@ from PyQt5.QtCore import (
)
from novelwriter.error import logException, formatException
from novelwriter.common import splitVersionNumber, formatTimeStamp, NWConfigParser
from novelwriter.common import checkPath, splitVersionNumber, formatTimeStamp, NWConfigParser
from novelwriter.constants import nwFiles, nwUnicode
logger = logging.getLogger(__name__)
@@ -73,10 +73,10 @@ class Config:
self._appPath = self._appRoot
# Runtime Settings and Variables
self._hasError = False # True if the config class encountered an error
self._errData = [] # List of error messages
self.confChanged = False # True whenever the config has chenged, false after save
self.cmdOpen = None # Path from command line for project to be opened on launch
self._hasError = False # True if the config class encountered an error
self._errData = [] # List of error messages
self._confChanged = False # True whenever the config has chenged, false after save
self.cmdOpen = None # Path from command line for project to be opened on launch
# Localisation Info
self._qLocal = QLocale.system()
@@ -106,14 +106,13 @@ class Config:
self.setDefaultSyntaxTheme()
# Size Settings
self.winGeometry = [1200, 650]
self.prefGeometry = [700, 615]
self.projColWidth = [200, 60, 140]
self.mainPanePos = [300, 800]
self.docPanePos = [400, 400]
self.viewPanePos = [500, 150]
self.outlnPanePos = [500, 150]
self.isFullScreen = False
self._winGeometry = [1200, 650]
self._prefGeometry = [700, 615]
self._projColWidth = [200, 60, 140]
self._mainPanePos = [300, 800]
self._viewPanePos = [500, 150]
self._outlnPanePos = [500, 150]
self.isFullScreen = False
# Feature Settings
self.hideVScroll = False # Hide vertical scroll bars on main widgets
@@ -258,6 +257,109 @@ class Config:
def recentProjects(self):
return self._recentProj
@property
def mainWinSize(self):
return [int(x*self.guiScale) for x in self._winGeometry]
@property
def preferencesWinSize(self):
return [int(x*self.guiScale) for x in self._prefGeometry]
@property
def projLoadColWidths(self):
return [int(x*self.guiScale) for x in self._projColWidth]
@property
def mainPanePos(self):
return [int(x*self.guiScale) for x in self._mainPanePos]
@property
def viewPanePos(self):
return [int(x*self.guiScale) for x in self._viewPanePos]
@property
def outlinePanePos(self):
return [int(x*self.guiScale) for x in self._outlnPanePos]
##
# Setters
##
def setMainWinSize(self, newWidth, newHeight):
"""Set the size of the main window, but only if the change is
larger than 5 pixels. The OS window manager will sometimes
adjust it a bit, and we don't want the main window to shrink or
grow each time the app is opened.
"""
newWidth = int(newWidth/self.guiScale)
newHeight = int(newHeight/self.guiScale)
if abs(self._winGeometry[0] - newWidth) > 5:
self._winGeometry[0] = newWidth
self._confChanged = True
if abs(self._winGeometry[1] - newHeight) > 5:
self._winGeometry[1] = newHeight
self._confChanged = True
return
def setPreferencesWinSize(self, newWidth, newHeight):
"""Sat the size of the Preferences dialog window.
"""
self._prefGeometry[0] = int(newWidth/self.guiScale)
self._prefGeometry[1] = int(newHeight/self.guiScale)
self._confChanged = True
return
def setProjLoadColWidths(self, colWidths):
"""Set the column widths of the Load Project dialog.
"""
self._projColWidth = [int(x/self.guiScale) for x in colWidths]
self._confChanged = True
return
def setMainPanePos(self, panePos):
"""Set the position of the main GUI splitter.
"""
self._mainPanePos = [int(x/self.guiScale) for x in panePos]
self._confChanged = True
return
def setViewPanePos(self, panePos):
"""Set the position of the viewer meta data splitter.
"""
self._viewPanePos = [int(x/self.guiScale) for x in panePos]
self._confChanged = True
return
def setOutlinePanePos(self, panePos):
"""Set the position of the outline details splitter.
"""
self._outlnPanePos = [int(x/self.guiScale) for x in panePos]
self._confChanged = True
return
def setLastPath(self, lastPath):
"""Set the last used path. Only the folder is saved, so if the
path is not a folder, the parent of the path is used instead.
"""
if isinstance(lastPath, (str, Path)):
lastPath = Path(lastPath)
if not lastPath.is_dir():
lastPath = lastPath.parent
if lastPath.is_dir():
self._lastPath = lastPath
logger.debug("Last path updated: %s" % self._lastPath)
return
def setBackupPath(self, backupPath):
"""Set the current backup path.
"""
self._backupPath = checkPath(backupPath, None)
return
def setConfigChanged(self, value):
self._confChanged = bool(value)
return
##
# Methods
##
@@ -291,8 +393,9 @@ class Config:
def lastPath(self):
"""Return the last path used by the user, but ensure it exists.
"""
if self._lastPath.is_dir():
return self._lastPath
if isinstance(self._lastPath, Path):
if self._lastPath.is_dir():
return self._lastPath
return Path.home().absolute()
def backupPath(self):
@@ -440,13 +543,12 @@ class Config:
# Sizes
cnfSec = "Sizes"
self.winGeometry = theConf.rdIntList(cnfSec, "geometry", self.winGeometry)
self.prefGeometry = theConf.rdIntList(cnfSec, "preferences", self.prefGeometry)
self.projColWidth = theConf.rdIntList(cnfSec, "projcols", self.projColWidth)
self.mainPanePos = theConf.rdIntList(cnfSec, "mainpane", self.mainPanePos)
self.docPanePos = theConf.rdIntList(cnfSec, "docpane", self.docPanePos)
self.viewPanePos = theConf.rdIntList(cnfSec, "viewpane", self.viewPanePos)
self.outlnPanePos = theConf.rdIntList(cnfSec, "outlinepane", self.outlnPanePos)
self._winGeometry = theConf.rdIntList(cnfSec, "geometry", self._winGeometry)
self._prefGeometry = theConf.rdIntList(cnfSec, "preferences", self._prefGeometry)
self._projColWidth = theConf.rdIntList(cnfSec, "projcols", self._projColWidth)
self._mainPanePos = theConf.rdIntList(cnfSec, "mainpane", self._mainPanePos)
self._viewPanePos = theConf.rdIntList(cnfSec, "viewpane", self._viewPanePos)
self._outlnPanePos = theConf.rdIntList(cnfSec, "outlinepane", self._outlnPanePos)
self.isFullScreen = theConf.rdBool(cnfSec, "fullscreen", self.isFullScreen)
# Project
@@ -496,10 +598,9 @@ class Config:
# Backup
cnfSec = "Backup"
backupPath = theConf.rdStr(cnfSec, "backuppath", None)
self._backupPath = theConf.rdPath(cnfSec, "backuppath", self._backupPath)
self.backupOnClose = theConf.rdBool(cnfSec, "backuponclose", self.backupOnClose)
self.askBeforeBackup = theConf.rdBool(cnfSec, "askbeforebackup", self.askBeforeBackup)
self.setBackupPath(backupPath)
# State
cnfSec = "State"
@@ -515,7 +616,7 @@ class Config:
# Path
cnfSec = "Path"
self._lastPath = Path(theConf.rdStr(cnfSec, "lastpath", self._lastPath))
self._lastPath = theConf.rdPath(cnfSec, "lastpath", self._lastPath)
# Check Certain Values for None
self.spellLanguage = self._checkNone(self.spellLanguage)
@@ -551,13 +652,12 @@ class Config:
}
theConf["Sizes"] = {
"geometry": self._packList(self.winGeometry),
"preferences": self._packList(self.prefGeometry),
"projcols": self._packList(self.projColWidth),
"mainpane": self._packList(self.mainPanePos),
"docpane": self._packList(self.docPanePos),
"viewpane": self._packList(self.viewPanePos),
"outlinepane": self._packList(self.outlnPanePos),
"geometry": self._packList(self._winGeometry),
"preferences": self._packList(self._prefGeometry),
"projcols": self._packList(self._projColWidth),
"mainpane": self._packList(self._mainPanePos),
"viewpane": self._packList(self._viewPanePos),
"outlinepane": self._packList(self._outlnPanePos),
"fullscreen": str(self.isFullScreen),
}
@@ -633,7 +733,7 @@ class Config:
try:
with open(cnfPath, mode="w", encoding="utf-8") as outFile:
theConf.write(outFile)
self.confChanged = False
self._confChanged = False
except Exception as exc:
logger.error("Could not save config file")
logException()
@@ -648,105 +748,25 @@ class Config:
# Setters
##
def setLastPath(self, lastPath):
"""Set the last used path. Only the folder is saved, so if the
path is not a folder, the parent of the path is used instead.
"""
if isinstance(lastPath, (str, Path)):
lastPath = Path(lastPath)
if not lastPath.is_dir():
lastPath = lastPath.parent
if lastPath.is_dir():
self._lastPath = lastPath
logger.debug("Last path updated: %s" % self._lastPath)
return
def setBackupPath(self, backupPath):
"""Set the current backup path.
"""
self._backupPath = None
if isinstance(backupPath, (str, Path)):
self._backupPath = Path(backupPath)
return
def setWinSize(self, newWidth, newHeight):
"""Set the size of the main window, but only if the change is
larger than 5 pixels. The OS window manager will sometimes
adjust it a bit, and we don't want the main window to shrink or
grow each time the app is opened.
"""
newWidth = int(newWidth/self.guiScale)
newHeight = int(newHeight/self.guiScale)
if abs(self.winGeometry[0] - newWidth) > 5:
self.winGeometry[0] = newWidth
self.confChanged = True
if abs(self.winGeometry[1] - newHeight) > 5:
self.winGeometry[1] = newHeight
self.confChanged = True
return
def setPreferencesSize(self, newWidth, newHeight):
"""Sat the size of the Preferences dialog window.
"""
self.prefGeometry[0] = int(newWidth/self.guiScale)
self.prefGeometry[1] = int(newHeight/self.guiScale)
self.confChanged = True
return
def setProjColWidths(self, colWidths):
"""Set the column widths of the Load Project dialog.
"""
self.projColWidth = [int(x/self.guiScale) for x in colWidths]
self.confChanged = True
return
def setMainPanePos(self, panePos):
"""Set the position of the main GUI splitter.
"""
self.mainPanePos = [int(x/self.guiScale) for x in panePos]
self.confChanged = True
return
def setDocPanePos(self, panePos):
"""Set the position of the main editor/viewer splitter.
"""
self.docPanePos = [int(x/self.guiScale) for x in panePos]
self.confChanged = True
return
def setViewPanePos(self, panePos):
"""Set the position of the viewer meta data splitter.
"""
self.viewPanePos = [int(x/self.guiScale) for x in panePos]
self.confChanged = True
return
def setOutlinePanePos(self, panePos):
"""Set the position of the outline details splitter.
"""
self.outlnPanePos = [int(x/self.guiScale) for x in panePos]
self.confChanged = True
return
def setShowRefPanel(self, checkState):
"""Set the visibility state of the reference panel.
"""
self.showRefPanel = checkState
self.confChanged = True
self._confChanged = True
return
def setViewComments(self, viewState):
"""Set the visibility state of comments in the viewer.
"""
self.viewComments = viewState
self.confChanged = True
self._confChanged = True
return
def setViewSynopsis(self, viewState):
"""Set the visibility state of synopsis comments in the viewer.
"""
self.viewSynopsis = viewState
self.confChanged = True
self._confChanged = True
return
##
@@ -767,27 +787,6 @@ class Config:
# Getters
##
def getWinSize(self):
return [int(x*self.guiScale) for x in self.winGeometry]
def getPreferencesSize(self):
return [int(x*self.guiScale) for x in self.prefGeometry]
def getProjColWidths(self):
return [int(x*self.guiScale) for x in self.projColWidth]
def getMainPanePos(self):
return [int(x*self.guiScale) for x in self.mainPanePos]
def getDocPanePos(self):
return [int(x*self.guiScale) for x in self.docPanePos]
def getViewPanePos(self):
return [int(x*self.guiScale) for x in self.viewPanePos]
def getOutlinePanePos(self):
return [int(x*self.guiScale) for x in self.outlnPanePos]
def getTextWidth(self, focusMode=False):
if focusMode:
return self.pxInt(max(self.focusWidth, 200))
+9 -9
View File
@@ -74,7 +74,7 @@ class GuiPreferences(PagedDialog):
self.buttonBox.rejected.connect(self._doClose)
self.addControls(self.buttonBox)
self.resize(*self.mainConf.getPreferencesSize())
self.resize(*self.mainConf.preferencesWinSize)
# Settings
self._updateTheme = False
@@ -143,7 +143,7 @@ class GuiPreferences(PagedDialog):
def _saveWindowSize(self):
"""Save the dialog window size.
"""
self.mainConf.setPreferencesSize(self.width(), self.height())
self.mainConf.setPreferencesWinSize(self.width(), self.height())
return
# END Class GuiPreferences
@@ -311,7 +311,7 @@ class GuiPreferencesGeneral(QWidget):
self.mainConf.hideVScroll = self.hideVScroll.isChecked()
self.mainConf.hideHScroll = self.hideHScroll.isChecked()
self.mainConf.confChanged = True
self.mainConf.setConfigChanged(True)
return
@@ -458,7 +458,7 @@ class GuiPreferencesProjects(QWidget):
self.mainConf.stopWhenIdle = self.stopWhenIdle.isChecked()
self.mainConf.userIdleTime = round(self.userIdleTime.value() * 60)
self.mainConf.confChanged = True
self.mainConf.setConfigChanged(True)
return
@@ -629,7 +629,7 @@ class GuiPreferencesDocuments(QWidget):
self.mainConf.textMargin = self.textMargin.value()
self.mainConf.tabWidth = self.tabWidth.value()
self.mainConf.confChanged = True
self.mainConf.setConfigChanged(True)
return
@@ -820,7 +820,7 @@ class GuiPreferencesEditor(QWidget):
self.mainConf.autoScroll = self.autoScroll.isChecked()
self.mainConf.autoScrollPos = self.autoScrollPos.value()
self.mainConf.confChanged = True
self.mainConf.setConfigChanged(True)
return
@@ -911,7 +911,7 @@ class GuiPreferencesSyntax(QWidget):
# Text Errors
self.mainConf.showMultiSpaces = self.showMultiSpaces.isChecked()
self.mainConf.confChanged = True
self.mainConf.setConfigChanged(True)
return
@@ -1065,7 +1065,7 @@ class GuiPreferencesAutomation(QWidget):
self.mainConf.fmtPadAfter = self.fmtPadAfter.text().strip()
self.mainConf.fmtPadThin = self.fmtPadThin.isChecked()
self.mainConf.confChanged = True
self.mainConf.setConfigChanged(True)
return
@@ -1186,7 +1186,7 @@ class GuiPreferencesQuotes(QWidget):
self.mainConf.fmtDoubleQuotes[0] = self.quoteSym["DO"].text()
self.mainConf.fmtDoubleQuotes[1] = self.quoteSym["DC"].text()
self.mainConf.confChanged = True
self.mainConf.setConfigChanged(True)
return
+2 -2
View File
@@ -258,7 +258,7 @@ class GuiProjectLoad(QDialog):
colWidths[self.C_NAME] = self.listBox.columnWidth(self.C_NAME)
colWidths[self.C_COUNT] = self.listBox.columnWidth(self.C_COUNT)
colWidths[self.C_TIME] = self.listBox.columnWidth(self.C_TIME)
self.mainConf.setProjColWidths(colWidths)
self.mainConf.setProjLoadColWidths(colWidths)
return
def _populateList(self):
@@ -284,7 +284,7 @@ class GuiProjectLoad(QDialog):
if self.listBox.topLevelItemCount() > 0:
self.listBox.topLevelItem(0).setSelected(True)
projColWidth = self.mainConf.getProjColWidths()
projColWidth = self.mainConf.projLoadColWidths
if len(projColWidth) == 3:
self.listBox.setColumnWidth(self.C_NAME, projColWidth[self.C_NAME])
self.listBox.setColumnWidth(self.C_COUNT, projColWidth[self.C_COUNT])
+1 -1
View File
@@ -71,7 +71,7 @@ class GuiOutlineView(QWidget):
self.splitOutline = QSplitter(Qt.Vertical)
self.splitOutline.addWidget(self.outlineTree)
self.splitOutline.addWidget(self.outlineData)
self.splitOutline.setSizes(self.mainConf.getOutlinePanePos())
self.splitOutline.setSizes(self.mainConf.outlinePanePos)
# Assemble
self.outerBox = QVBoxLayout()
+4 -5
View File
@@ -93,7 +93,7 @@ class GuiMain(QMainWindow):
self.idleTime = 0.0
# Prepare Main Window
self.resize(*self.mainConf.getWinSize())
self.resize(*self.mainConf.mainWinSize)
self._updateWindowTitle()
nwIcon = self.mainConf.assetPath("icons") / "novelwriter.svg"
@@ -140,7 +140,7 @@ class GuiMain(QMainWindow):
self.splitView.addWidget(self.docViewer)
self.splitView.addWidget(self.viewMeta)
self.splitView.setHandleWidth(hWd)
self.splitView.setSizes(self.mainConf.getViewPanePos())
self.splitView.setSizes(self.mainConf.viewPanePos)
# Splitter : Document Editor / Document Viewer
self.splitDocs = QSplitter(Qt.Horizontal)
@@ -154,7 +154,7 @@ class GuiMain(QMainWindow):
self.splitMain.addWidget(self.treePane)
self.splitMain.addWidget(self.splitDocs)
self.splitMain.setHandleWidth(hWd)
self.splitMain.setSizes(self.mainConf.getMainPanePos())
self.splitMain.setSizes(self.mainConf.mainPanePos)
# Main Stack : Editor / Outline
self.mainStack = QStackedWidget()
@@ -1169,14 +1169,13 @@ class GuiMain(QMainWindow):
if not self.isFocusMode:
self.mainConf.setMainPanePos(self.splitMain.sizes())
self.mainConf.setDocPanePos(self.splitDocs.sizes())
self.mainConf.setOutlinePanePos(self.outlineView.splitSizes())
if self.viewMeta.isVisible():
self.mainConf.setViewPanePos(self.splitView.sizes())
self.mainConf.setShowRefPanel(self.viewMeta.isVisible())
if not self.mainConf.isFullScreen:
self.mainConf.setWinSize(self.width(), self.height())
self.mainConf.setMainWinSize(self.width(), self.height())
if self.hasProject:
self.closeProject(True)
@@ -14,7 +14,6 @@ geometry = 1200, 650
preferences = 700, 615
projcols = 200, 60, 140
mainpane = 300, 800
docpane = 400, 400
viewpane = 500, 150
outlinepane = 500, 150
fullscreen = False
@@ -14,7 +14,6 @@ geometry = 1200, 650
preferences = 699, 614
projcols = 200, 60, 140
mainpane = 300, 800
docpane = 400, 400
viewpane = 500, 150
outlinepane = 500, 150
fullscreen = False
+18 -3
View File
@@ -23,15 +23,17 @@ import time
import pytest
import hashlib
from pathlib import Path
from mock import causeOSError
from tools import writeFile
from novelwriter.guimain import GuiMain
from novelwriter.common import (
checkStringNone, checkString, checkInt, checkFloat, checkBool, checkHandle,
checkUuid, isHandle, isTitleTag, isItemClass, isItemType, isItemLayout,
hexToInt, minmax, checkIntTuple, formatInt, formatTimeStamp, formatTime,
simplified, yesNo, splitVersionNumber, transferCase, fuzzyTime,
checkUuid, checkPath, isHandle, isTitleTag, isItemClass, isItemType,
isItemLayout, hexToInt, minmax, checkIntTuple, formatInt, formatTimeStamp,
formatTime, simplified, yesNo, splitVersionNumber, transferCase, fuzzyTime,
numberToRoman, jsonEncode, readTextFile, makeFileNameSafe, sha256sum,
getGuiItem, NWConfigParser
)
@@ -175,6 +177,19 @@ def testBaseCommon_CheckUuid():
# END Test testBaseCommon_CheckUuid
@pytest.mark.base
def testBaseCommon_CheckPath():
"""Test the checkPath function.
"""
assert checkPath(Path("test"), None) == Path("test")
assert checkPath("test", None) == Path("test")
assert checkPath(None, None) is None
assert checkPath("", None) is None
assert checkPath(" ", None) is None
# END Test testBaseCommon_CheckPath
@pytest.mark.base
def testBaseCommon_IsHandle():
"""Test the isHandle function.
+33 -46
View File
@@ -253,96 +253,83 @@ def testBaseConfig_SettersGetters(tmpConf):
# Window Size
tmpConf.guiScale = 1.0
tmpConf.setWinSize(1205, 655)
assert tmpConf.confChanged is False
tmpConf.setMainWinSize(1205, 655)
assert tmpConf._confChanged is False
tmpConf.guiScale = 2.0
tmpConf.setWinSize(70, 70)
assert tmpConf.getWinSize() == [70, 70]
assert tmpConf.winGeometry == [35, 35]
tmpConf.setMainWinSize(70, 70)
assert tmpConf.mainWinSize == [70, 70]
assert tmpConf._winGeometry == [35, 35]
tmpConf.guiScale = 1.0
tmpConf.setWinSize(70, 70)
assert tmpConf.getWinSize() == [70, 70]
assert tmpConf.winGeometry == [70, 70]
tmpConf.setMainWinSize(70, 70)
assert tmpConf.mainWinSize == [70, 70]
assert tmpConf._winGeometry == [70, 70]
tmpConf.setWinSize(1200, 650)
tmpConf.setMainWinSize(1200, 650)
# Preferences Size
tmpConf.guiScale = 2.0
tmpConf.setPreferencesSize(70, 70)
assert tmpConf.getPreferencesSize() == [70, 70]
assert tmpConf.prefGeometry == [35, 35]
tmpConf.setPreferencesWinSize(70, 70)
assert tmpConf.preferencesWinSize == [70, 70]
assert tmpConf._prefGeometry == [35, 35]
tmpConf.guiScale = 1.0
tmpConf.setPreferencesSize(70, 70)
assert tmpConf.getPreferencesSize() == [70, 70]
assert tmpConf.prefGeometry == [70, 70]
tmpConf.setPreferencesWinSize(70, 70)
assert tmpConf.preferencesWinSize == [70, 70]
assert tmpConf._prefGeometry == [70, 70]
tmpConf.setPreferencesSize(700, 615)
tmpConf.setPreferencesWinSize(700, 615)
# Project Settings Tree Columns
tmpConf.guiScale = 2.0
tmpConf.setProjColWidths([10, 20, 30])
assert tmpConf.getProjColWidths() == [10, 20, 30]
assert tmpConf.projColWidth == [5, 10, 15]
tmpConf.setProjLoadColWidths([10, 20, 30])
assert tmpConf.projLoadColWidths == [10, 20, 30]
assert tmpConf._projColWidth == [5, 10, 15]
tmpConf.guiScale = 1.0
tmpConf.setProjColWidths([10, 20, 30])
assert tmpConf.getProjColWidths() == [10, 20, 30]
assert tmpConf.projColWidth == [10, 20, 30]
tmpConf.setProjLoadColWidths([10, 20, 30])
assert tmpConf.projLoadColWidths == [10, 20, 30]
assert tmpConf._projColWidth == [10, 20, 30]
tmpConf.setProjColWidths([200, 60, 140])
tmpConf.setProjLoadColWidths([200, 60, 140])
# Main Pane Splitter
tmpConf.guiScale = 2.0
tmpConf.setMainPanePos([200, 700])
assert tmpConf.getMainPanePos() == [200, 700]
assert tmpConf.mainPanePos == [100, 350]
assert tmpConf.mainPanePos == [200, 700]
assert tmpConf._mainPanePos == [100, 350]
tmpConf.guiScale = 1.0
tmpConf.setMainPanePos([200, 700])
assert tmpConf.getMainPanePos() == [200, 700]
assert tmpConf.mainPanePos == [200, 700]
assert tmpConf._mainPanePos == [200, 700]
tmpConf.setMainPanePos([300, 800])
# Doc Pane Splitter
tmpConf.guiScale = 2.0
tmpConf.setDocPanePos([300, 300])
assert tmpConf.getDocPanePos() == [300, 300]
assert tmpConf.docPanePos == [150, 150]
tmpConf.guiScale = 1.0
tmpConf.setDocPanePos([300, 300])
assert tmpConf.getDocPanePos() == [300, 300]
assert tmpConf.docPanePos == [300, 300]
tmpConf.setDocPanePos([400, 400])
# View Pane Splitter
tmpConf.guiScale = 2.0
tmpConf.setViewPanePos([400, 250])
assert tmpConf.getViewPanePos() == [400, 250]
assert tmpConf.viewPanePos == [200, 125]
assert tmpConf.viewPanePos == [400, 250]
assert tmpConf._viewPanePos == [200, 125]
tmpConf.guiScale = 1.0
tmpConf.setViewPanePos([400, 250])
assert tmpConf.getViewPanePos() == [400, 250]
assert tmpConf.viewPanePos == [400, 250]
assert tmpConf._viewPanePos == [400, 250]
tmpConf.setViewPanePos([500, 150])
# Outline Pane Splitter
tmpConf.guiScale = 2.0
tmpConf.setOutlinePanePos([400, 250])
assert tmpConf.getOutlinePanePos() == [400, 250]
assert tmpConf.outlnPanePos == [200, 125]
assert tmpConf.outlinePanePos == [400, 250]
assert tmpConf._outlnPanePos == [200, 125]
tmpConf.guiScale = 1.0
tmpConf.setOutlinePanePos([400, 250])
assert tmpConf.getOutlinePanePos() == [400, 250]
assert tmpConf.outlnPanePos == [400, 250]
assert tmpConf.outlinePanePos == [400, 250]
assert tmpConf._outlnPanePos == [400, 250]
tmpConf.setOutlinePanePos([500, 150])
+1 -1
View File
@@ -215,7 +215,7 @@ def testDlgPreferences_Main(qtbot, monkeypatch, nwGUI, fncPath, tstPaths):
qtbot.mouseClick(nwPrefs.buttonBox.button(QDialogButtonBox.Ok), Qt.LeftButton)
nwPrefs._doClose()
assert theConf.confChanged
assert theConf._confChanged is True
assert nwGUI.mainConf.saveConfig()
projFile = fncPath / "novelwriter.conf"