Update and reorganise themes (#893)
* Drop the subfolders for GUI themes * Remove bundled font support * Add safe file read function * Allow loading themes from multiple locations * Clean up unused variables * Clean up icons class * Merge icon theme icons * Update icon theme class * Remove guiDark config setting * Fix tests * Fix handling of default theme * Update icon readmes * Add test for getGuiItem common function
This commit is contained in:
committed by
GitHub
parent
be3376272e
commit
15ec1496c5
@@ -23,7 +23,7 @@ import pytest
|
||||
import novelwriter
|
||||
|
||||
from PyQt5.QtGui import QColor, QPixmap, QIcon
|
||||
from PyQt5.QtWidgets import QStyle, QMessageBox
|
||||
from PyQt5.QtWidgets import QMessageBox
|
||||
|
||||
keyDelay = 2
|
||||
typeDelay = 1
|
||||
@@ -50,7 +50,6 @@ def testGuiTheme_Main(qtbot, monkeypatch, nwMinimal, tmpDir):
|
||||
novelwriter.CONFIG.guiTheme = "default_dark"
|
||||
novelwriter.CONFIG.guiSyntax = "tomorrow_night_eighties"
|
||||
novelwriter.CONFIG.guiIcons = "typicons_colour_dark"
|
||||
novelwriter.CONFIG.guiDark = True
|
||||
novelwriter.CONFIG.guiFont = "Cantarell"
|
||||
novelwriter.CONFIG.guiFontSize = 11
|
||||
novelwriter.CONFIG.confChanged = True
|
||||
@@ -73,9 +72,8 @@ def testGuiTheme_Main(qtbot, monkeypatch, nwMinimal, tmpDir):
|
||||
assert novelwriter.CONFIG.guiTheme == "default_dark"
|
||||
assert novelwriter.CONFIG.guiSyntax == "tomorrow_night_eighties"
|
||||
assert novelwriter.CONFIG.guiIcons == "typicons_dark"
|
||||
assert novelwriter.CONFIG.guiDark is True
|
||||
assert novelwriter.CONFIG.guiFont == "Cantarell"
|
||||
assert novelwriter.CONFIG.guiFontSize == 11
|
||||
assert novelwriter.CONFIG.guiFont != ""
|
||||
assert novelwriter.CONFIG.guiFontSize > 0
|
||||
|
||||
# Check GUI Colours
|
||||
thePalette = nwGUI.palette()
|
||||
@@ -119,9 +117,8 @@ def testGuiTheme_Main(qtbot, monkeypatch, nwMinimal, tmpDir):
|
||||
# Test Icon class
|
||||
theIcons = nwGUI.theTheme.theIcons
|
||||
novelwriter.CONFIG.guiIcons = "invalid"
|
||||
assert not theIcons.updateTheme()
|
||||
novelwriter.CONFIG.guiIcons = "typicons_dark"
|
||||
assert theIcons.updateTheme()
|
||||
assert theIcons.updateTheme() is True
|
||||
assert novelwriter.CONFIG.guiIcons == "typicons_light"
|
||||
|
||||
# Ask for a non-existent key
|
||||
anImg = theIcons.loadDecoration("nonsense", 20, 20)
|
||||
@@ -168,17 +165,8 @@ def testGuiTheme_Main(qtbot, monkeypatch, nwMinimal, tmpDir):
|
||||
assert isinstance(anIcon, QIcon)
|
||||
assert not anIcon.isNull()
|
||||
|
||||
# Add test icons and test alternative load paths
|
||||
theIcons.ICON_MAP["testicon1"] = (QStyle.SP_DriveHDIcon, None)
|
||||
anIcon = theIcons.getIcon("testicon1")
|
||||
assert isinstance(anIcon, QIcon)
|
||||
assert not anIcon.isNull()
|
||||
|
||||
theIcons.ICON_MAP["testicon2"] = (None, "folder")
|
||||
anIcon = theIcons.getIcon("testicon2")
|
||||
assert isinstance(anIcon, QIcon)
|
||||
|
||||
theIcons.ICON_MAP["testicon3"] = (None, None)
|
||||
# Check return empty icon if file not found
|
||||
theIcons.ICON_KEYS.add("testicon3")
|
||||
anIcon = theIcons.getIcon("testicon3")
|
||||
assert isinstance(anIcon, QIcon)
|
||||
assert anIcon.isNull()
|
||||
|
||||
Reference in New Issue
Block a user