Move theme and project instances to new shared data class

This commit is contained in:
Veronica Berglyd Olsen
2023-08-10 21:13:10 +02:00
parent a2f183f147
commit 863dcf8b37
30 changed files with 530 additions and 578 deletions
+3 -18
View File
@@ -3,7 +3,8 @@ novelWriter Config Class
==========================
File History:
Created: 2018-09-22 [0.0.1] Config
Created: 2018-09-22 [0.0.1] Config
Created: 2022-11-09 [2.0rc2] RecentProjects
This file is a part of novelWriter
Copyright 20182023, Veronica Berglyd Olsen
@@ -28,7 +29,6 @@ import json
import logging
from time import time
from typing import TYPE_CHECKING
from pathlib import Path
from PyQt5.QtGui import QFontDatabase
@@ -42,9 +42,6 @@ from novelwriter.error import formatException, logException
from novelwriter.common import NWConfigParser, checkInt, checkPath, formatTimeStamp
from novelwriter.constants import nwFiles, nwUnicode
if TYPE_CHECKING: # pragma: no cover
from novelwriter.gui.theme import GuiTheme
logger = logging.getLogger(__name__)
@@ -96,7 +93,6 @@ class Config:
# User Settings
# =============
self._themeObj = None
self._recentObj = RecentProjects(self)
# General GUI Settings
@@ -244,12 +240,6 @@ class Config:
def recentProjects(self) -> RecentProjects:
return self._recentObj
@property
def theme(self) -> GuiTheme:
if self._themeObj is None:
raise Exception("Cannot access GUI theme before it is initialised")
return self._themeObj
@property
def mainWinSize(self) -> list[int]:
return [int(x*self.guiScale) for x in self._mainWinSize]
@@ -297,11 +287,6 @@ class Config:
# Setters
##
def setThemeInstance(self, theme: GuiTheme) -> None:
"""Set the applications theme instance."""
self._themeObj = theme
return
def setMainWinSize(self, width: int, height: int) -> None:
"""Set the size of the main window, but only if the change is
larger than 5 pixels. The OS window manager will sometimes
@@ -499,7 +484,7 @@ class Config:
self._recentObj.loadCache()
self._checkOptionalPackages()
logger.debug("Config initialisation complete")
logger.debug("Config instance initialised")
return