2 #include <QSyntaxStyle>
6 #include <QXmlStreamReader>
20 QXmlStreamReader
reader(fl);
24 auto token =
reader.readNext();
26 if(token == QXmlStreamReader::StartElement)
28 if (
reader.name() ==
"style-scheme")
30 if (
reader.attributes().hasAttribute(
"name"))
35 else if (
reader.name() ==
"style")
37 auto attributes =
reader.attributes();
39 auto name = attributes.value(
"name");
43 if (attributes.hasAttribute(
"background"))
45 format.setBackground(QColor(attributes.value(
"background").toString()));
48 if (attributes.hasAttribute(
"foreground"))
50 format.setForeground(QColor(attributes.value(
"foreground").toString()));
53 if (attributes.hasAttribute(
"bold") &&
54 attributes.value(
"bold") ==
"true")
56 format.setFontWeight(QFont::Weight::Bold);
59 if (attributes.hasAttribute(
"italic") &&
60 attributes.value(
"italic") ==
"true")
62 format.setFontItalic(
true);
65 if (attributes.hasAttribute(
"underlineStyle"))
67 auto underline = attributes.value(
"underlineStyle");
69 auto s = QTextCharFormat::UnderlineStyle::NoUnderline;
73 s = QTextCharFormat::UnderlineStyle::SingleUnderline;
77 s = QTextCharFormat::UnderlineStyle::DashUnderline;
81 s = QTextCharFormat::UnderlineStyle::DotLine;
85 s = QTextCharFormat::DashDotLine;
89 s = QTextCharFormat::DashDotDotLine;
93 s = QTextCharFormat::WaveUnderline;
95 else if (
underline ==
"SpellCheckUnderline")
97 s = QTextCharFormat::SpellCheckUnderline;
101 qDebug() <<
"Unknown underline value " <<
underline;
126 if (result ==
m_data.end())
128 return QTextCharFormat();
131 return result.value();
145 Q_INIT_RESOURCE(qcodeeditor_resources);
146 QFile fl(
":/default_style.xml");
148 if (!fl.open(QIODevice::ReadOnly))
153 if (!style.
load(fl.readAll()))
155 qDebug() <<
"Can't load default style.";