mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
cleanup
This commit is contained in:
parent
57a7324d41
commit
133ff15154
|
@ -84,10 +84,9 @@ bool SmileyPack::load(const QString& filename)
|
|||
return true;
|
||||
}
|
||||
|
||||
QString SmileyPack::replaceEmoticons(const QString &msg)
|
||||
QString SmileyPack::replaceEmoticons(QString msg)
|
||||
{
|
||||
QString out = msg;
|
||||
QRegExp exp("\\S*"); // matches words
|
||||
QRegExp exp("\\S+"); // matches words
|
||||
|
||||
int index = msg.indexOf(exp);
|
||||
int offset = 0;
|
||||
|
@ -105,19 +104,19 @@ QString SmileyPack::replaceEmoticons(const QString &msg)
|
|||
|
||||
QString imgRichText = "<img src=\"data:image/png;base64," % cache[file] % "\">";
|
||||
|
||||
out.replace(index + offset, key.length(), imgRichText);
|
||||
offset += imgRichText.length() - key.length();
|
||||
msg.replace(index + offset, key.length(), imgRichText);
|
||||
index += imgRichText.length() - key.length();
|
||||
}
|
||||
index = msg.indexOf(exp, index + exp.matchedLength() + 1);
|
||||
index = msg.indexOf(exp, index + key.length());
|
||||
}
|
||||
|
||||
return out;
|
||||
return msg;
|
||||
}
|
||||
|
||||
void SmileyPack::loadSmiley(const QString &name)
|
||||
{
|
||||
QSize size(16, 16); // TODO: adapt to text size
|
||||
QString filename = path % "/" % name;
|
||||
QString filename = path % '/' % name;
|
||||
QImage img(filename);
|
||||
|
||||
if (!img.isNull())
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
static SmileyPack& getInstance();
|
||||
|
||||
bool load(const QString &filename);
|
||||
QString replaceEmoticons(const QString& msg);
|
||||
QString replaceEmoticons(QString msg);
|
||||
|
||||
private slots:
|
||||
void onSmileyPackChanged();
|
||||
|
@ -42,7 +42,7 @@ private:
|
|||
void loadSmiley(const QString& name);
|
||||
|
||||
QHash<QString, QString> assignmentTable; // matches an emoticon to its corresponding smiley
|
||||
QHash<QString, QString> cache;
|
||||
QHash<QString, QString> cache; // base64 representation of a smiley
|
||||
QString path; // directory containing the cfg file
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user