Add a function to convert QColor to CSS rgba format

This commit is contained in:
Veronica Berglyd Olsen
2024-03-27 13:11:37 +01:00
parent 3e66968387
commit 2d9b57b534
6 changed files with 67 additions and 62 deletions
+15 -6
View File
@@ -29,16 +29,16 @@ from xml.etree import ElementTree as ET
from tools import writeFile
from mocked import causeOSError
from PyQt5.QtGui import QDesktopServices
from PyQt5.QtGui import QColor, QDesktopServices
from PyQt5.QtCore import QUrl
from novelwriter.common import (
checkBool, checkFloat, checkInt, checkIntTuple, checkPath, checkString,
checkStringNone, checkUuid, formatFileFilter, formatInt, formatTime,
formatTimeStamp, formatVersion, fuzzyTime, getFileSize, hexToInt, isHandle,
isItemClass, isItemLayout, isItemType, isTitleTag, jsonEncode,
makeFileNameSafe, minmax, numberToRoman, NWConfigParser, openExternalPath,
readTextFile, simplified, transferCase, xmlIndent, yesNo
checkStringNone, checkUuid, cssCol, formatFileFilter, formatInt,
formatTime, formatTimeStamp, formatVersion, fuzzyTime, getFileSize,
hexToInt, isHandle, isItemClass, isItemLayout, isItemType, isTitleTag,
jsonEncode, makeFileNameSafe, minmax, numberToRoman, NWConfigParser,
openExternalPath, readTextFile, simplified, transferCase, xmlIndent, yesNo
)
@@ -494,6 +494,15 @@ def testBaseCommon_numberToRoman():
# END Test testBaseCommon_numberToRoman
@pytest.mark.base
def testBaseCommon_cssCol():
"""Test the cssCol function."""
assert cssCol(QColor(0, 0, 0, 0)) == "rgba(0, 0, 0, 0)"
assert cssCol(QColor(10, 20, 30, 40)) == "rgba(10, 20, 30, 40)"
# END Test testBaseCommon_cssCol
@pytest.mark.base
def testBaseCommon_jsonEncode():
"""Test the jsonEncode function."""