21 #include <QtCore/QFile>
22 #include <QtCore/QFileInfo>
42 for (
int i = 0; i < m_text.size(); ++i) {
45 if (line.startsWith(
'#') || line.isEmpty()) {
49 QRegExp re(
"^\\[(.*)\\]$");
50 int pos = re.indexIn(line.trimmed());
52 if (!re.cap(1).compare(
"default", Qt::CaseInsensitive)) {
67 if (splitted.at(0) ==
"!") {
68 emoName = splitted.at(1);
70 emoName = splitted.at(0);
73 if (emoName == emoticon) {
88 int i = m_text.indexOf(QRegExp(
"^\\[default\\]$", Qt::CaseInsensitive));
95 m_text.insert(i + 1, emoticon);
107 kWarning() << fp.fileName() <<
"doesn't exist!";
111 if (!fp.open(QIODevice::WriteOnly)) {
112 kWarning() << fp.fileName() <<
"can't open WriteOnly!";
116 QTextStream emoStream(&fp);
118 if (m_text.indexOf(QRegExp(
"^Icon=.*", Qt::CaseInsensitive)) == -1) {
119 int i = m_text.indexOf(QRegExp(
"^Description=.*", Qt::CaseInsensitive));
121 m_text.insert(i + 1,
"Icon=" + file);
124 emoStream << m_text.join(
"\n");
135 kWarning() << path <<
"doesn't exist!";
139 if (!fp.open(QIODevice::ReadOnly)) {
140 kWarning() << fp.fileName() <<
"can't open ReadOnly!";
144 QTextStream str(&fp);
147 while (!str.atEnd()) {
151 if (line.startsWith(
'#') || line.isEmpty()) {
155 QRegExp re(
"^\\[(.*)\\]$");
156 int pos = re.indexIn(line.trimmed());
158 if (!re.cap(1).compare(
"default", Qt::CaseInsensitive)) {
170 QStringList splitted = line.split(QRegExp(
"\\s+"));
173 if (splitted.at(0) ==
"!") {
175 emo = KGlobal::dirs()->findResource(
"emoticons",
themeName() +
'/' + splitted.at(1));
177 emo = KGlobal::dirs()->findResource(
"emoticons",
themeName() +
'/' + splitted.at(0));
181 for (; i < splitted.size(); ++i) {
182 if (!splitted.at(i).isEmpty() && splitted.at(i) !=
" ") {
183 sl << splitted.at(i);
200 QFile fp(path +
'/' +
"theme");
202 if (!fp.open(QIODevice::WriteOnly)) {
203 kWarning() << fp.fileName() <<
"can't open WriteOnly!";
207 QTextStream out(&fp);
208 out.setCodec(
"UTF-8" );
211 out <<
"Description=" +
themeName() << endl;
212 out <<
"Author=" << endl;
214 out <<
"[default]" << endl;