* Read the file contents and return it wrapped in a <style> HTML element. * * @return The <style> HTML element or an empty string in case of error. * * @note Referencing a local file via absolute path or file:// URL inside a <link> * HTML element does not work because Qt WebEngine forbids such file system access. * A comment under QTBUG-5
| 65 | * during back/forward web history navigation, so such navigation loads unstyled pages. |
| 66 | */ |
| 67 | static QString readStyleSheet(const QString& fileName) |
| 68 | { |
| 69 | QFile file(fileName); |
| 70 | if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { |
| 71 | qCWarning(MANPAGE) << "cannot read CSS file" << fileName << ':' << file.error() << file.errorString(); |
| 72 | return QString(); |
| 73 | } |
| 74 | const auto cssCode = file.readAll(); |
| 75 | return styleElementWithCode(cssCode, fileName); |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Get the URL contents and return it wrapped in a <style> HTML element. |
nothing calls this directly
no test coverage detected