| 15 | } |
| 16 | |
| 17 | bool QSyntaxStyle::load(QString fl) |
| 18 | { |
| 19 | QXmlStreamReader reader(fl); |
| 20 | |
| 21 | while (!reader.atEnd() && !reader.hasError()) |
| 22 | { |
| 23 | auto token = reader.readNext(); |
| 24 | |
| 25 | if (token == QXmlStreamReader::StartElement) |
| 26 | { |
| 27 | if (reader.name() == "style-scheme") |
| 28 | { |
| 29 | if (reader.attributes().hasAttribute("name")) |
| 30 | { |
| 31 | m_name = reader.attributes().value("name").toString(); |
| 32 | } |
| 33 | } |
| 34 | else if (reader.name() == "style") |
| 35 | { |
| 36 | auto attributes = reader.attributes(); |
| 37 | |
| 38 | auto name = attributes.value("name"); |
| 39 | |
| 40 | QTextCharFormat format; |
| 41 | |
| 42 | if (attributes.hasAttribute("background")) |
| 43 | { |
| 44 | format.setBackground( |
| 45 | QColor(attributes.value("background").toString())); |
| 46 | } |
| 47 | |
| 48 | if (attributes.hasAttribute("foreground")) |
| 49 | { |
| 50 | format.setForeground( |
| 51 | QColor(attributes.value("foreground").toString())); |
| 52 | } |
| 53 | |
| 54 | if (attributes.hasAttribute("bold") |
| 55 | && attributes.value("bold") == "true") |
| 56 | { |
| 57 | format.setFontWeight(QFont::Weight::Bold); |
| 58 | } |
| 59 | |
| 60 | if (attributes.hasAttribute("italic") |
| 61 | && attributes.value("italic") == "true") |
| 62 | { |
| 63 | format.setFontItalic(true); |
| 64 | } |
| 65 | |
| 66 | if (attributes.hasAttribute("underlineStyle")) |
| 67 | { |
| 68 | auto underline = attributes.value("underlineStyle"); |
| 69 | |
| 70 | auto s = QTextCharFormat::UnderlineStyle::NoUnderline; |
| 71 | |
| 72 | if (underline == "SingleUnderline") |
| 73 | { |
| 74 | s = QTextCharFormat::UnderlineStyle::SingleUnderline; |
no test coverage detected