Add a more obvious placeholder icon (#1780)
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="24" height="24" version="1.2" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="m0 0v4l8 8-8 8v4h4l8-8 8 8h4v-4l-8-8 8-8v-4h-4l-8 8-8-8h-4z" fill="#f00" stroke-width=".70711"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 251 B |
@@ -544,6 +544,9 @@ class GuiIcons:
|
||||
self._confName = "icons.conf"
|
||||
self._iconPath = CONFIG.assetPath("icons")
|
||||
|
||||
# None Icon
|
||||
self._noIcon = QIcon(str(self._iconPath / "none.svg"))
|
||||
|
||||
# Icon Theme Meta
|
||||
self.themeName = ""
|
||||
self.themeDescription = ""
|
||||
@@ -680,7 +683,7 @@ class GuiIcons:
|
||||
icon.addPixmap(pOne, QIcon.Mode.Normal, QIcon.State.On)
|
||||
icon.addPixmap(pTwo, QIcon.Mode.Normal, QIcon.State.Off)
|
||||
return icon
|
||||
return QIcon()
|
||||
return self._noIcon
|
||||
|
||||
def getPixmap(self, name: str, size: tuple[int, int]) -> QPixmap:
|
||||
"""Return an icon from the icon buffer as a QPixmap. If it
|
||||
@@ -712,7 +715,7 @@ class GuiIcons:
|
||||
elif tLayout == nwItemLayout.NOTE:
|
||||
iconName = "proj_note"
|
||||
if iconName is None:
|
||||
return QIcon()
|
||||
return self._noIcon
|
||||
|
||||
return self.getIcon(iconName)
|
||||
|
||||
@@ -753,7 +756,7 @@ class GuiIcons:
|
||||
"""
|
||||
if name not in self.ICON_KEYS:
|
||||
logger.error("Requested unknown icon name '%s'", name)
|
||||
return QIcon()
|
||||
return self._noIcon
|
||||
|
||||
# If we just want the app icons, return right away
|
||||
if name == "novelwriter":
|
||||
@@ -769,7 +772,7 @@ class GuiIcons:
|
||||
# If we didn't find one, give up and return an empty icon
|
||||
logger.warning("Did not load an icon for '%s'", name)
|
||||
|
||||
return QIcon()
|
||||
return self._noIcon
|
||||
|
||||
# END Class GuiIcons
|
||||
|
||||
|
||||
@@ -332,7 +332,7 @@ def testGuiTheme_LoadIcons(qtbot):
|
||||
# Load an unknown icon
|
||||
qIcon = iconCache.getIcon("stuff")
|
||||
assert isinstance(qIcon, QIcon)
|
||||
assert qIcon.isNull() is True
|
||||
assert qIcon == iconCache._noIcon
|
||||
|
||||
# Load an icon, it is likely already cached
|
||||
qIcon = iconCache.getIcon("add")
|
||||
@@ -349,17 +349,17 @@ def testGuiTheme_LoadIcons(qtbot):
|
||||
# Load app icon
|
||||
qIcon = iconCache.getIcon("novelwriter")
|
||||
assert isinstance(qIcon, QIcon)
|
||||
assert qIcon.isNull() is False
|
||||
assert qIcon != iconCache._noIcon
|
||||
|
||||
# Load mime icon
|
||||
qIcon = iconCache.getIcon("proj_nwx")
|
||||
assert isinstance(qIcon, QIcon)
|
||||
assert qIcon.isNull() is False
|
||||
assert qIcon != iconCache._noIcon
|
||||
|
||||
# Toggle icon
|
||||
qIcon = iconCache.getToggleIcon("bullet", (24, 24))
|
||||
assert isinstance(qIcon, QIcon)
|
||||
assert qIcon.isNull() is False
|
||||
assert qIcon != iconCache._noIcon
|
||||
pOn = qIcon.pixmap(24, 24, QIcon.Mode.Normal, QIcon.State.On)
|
||||
pOff = qIcon.pixmap(24, 24, QIcon.Mode.Normal, QIcon.State.Off)
|
||||
assert pOn != pOff
|
||||
@@ -367,7 +367,7 @@ def testGuiTheme_LoadIcons(qtbot):
|
||||
# Unknown toggle icon
|
||||
qIcon = iconCache.getToggleIcon("stuff", (24, 24))
|
||||
assert isinstance(qIcon, QIcon)
|
||||
assert qIcon.isNull() is True
|
||||
assert qIcon == iconCache._noIcon
|
||||
|
||||
# Load Item Icons
|
||||
# ===============
|
||||
@@ -420,7 +420,7 @@ def testGuiTheme_LoadIcons(qtbot):
|
||||
# No Type -> Null
|
||||
assert iconCache.getItemIcon(
|
||||
nwItemType.NO_TYPE, nwItemClass.NOVEL, nwItemLayout.DOCUMENT, hLevel="H0"
|
||||
).isNull() is True
|
||||
) == iconCache._noIcon
|
||||
|
||||
# qtbot.stop()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user