1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00
qTox/smileypack.h

63 lines
2.2 KiB
C
Raw Normal View History

2014-07-25 20:52:14 +08:00
/*
2014-08-02 22:53:18 +08:00
Copyright (C) 2014 by Project Tox <https://tox.im>
2014-07-25 20:52:14 +08:00
2014-08-02 22:53:18 +08:00
This file is part of qTox, a Qt-based graphical interface for Tox.
2014-07-25 20:52:14 +08:00
2014-08-02 22:53:18 +08:00
This program is libre software: you can redistribute it and/or modify
2014-07-25 20:52:14 +08:00
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the COPYING file for more details.
*/
#ifndef SMILEYPACK_H
#define SMILEYPACK_H
#include <QHash>
#include <QObject>
2014-07-31 04:07:26 +08:00
#include <QString>
#include <QStringList>
2014-07-25 20:52:14 +08:00
#define SMILEYPACK_SEARCH_PATHS \
{ \
"./smileys", "/usr/share/qtox/smileys", "/usr/share/emoticons", "~/.kde4/share/emoticons", "~/.kde/share/emoticons" \
}
2014-08-11 01:01:53 +08:00
2014-07-26 16:05:32 +08:00
//maps emoticons to smileys
2014-07-25 20:52:14 +08:00
class SmileyPack : public QObject
{
Q_OBJECT
public:
static SmileyPack& getInstance();
static QList<QPair<QString, QString> > listSmileyPacks(const QStringList& paths = SMILEYPACK_SEARCH_PATHS);
2014-08-11 00:50:40 +08:00
static bool isValid(const QString& filename);
2014-07-25 20:52:14 +08:00
bool load(const QString& filename);
2014-07-31 23:36:55 +08:00
QString smileyfied(QString msg);
2014-07-31 04:07:26 +08:00
QList<QStringList> getEmoticons() const;
2014-07-31 23:36:55 +08:00
QString getAsRichText(const QString& key);
QIcon getAsIcon(const QString& key);
2014-07-30 15:18:41 +08:00
2014-07-25 20:52:14 +08:00
private slots:
void onSmileyPackChanged();
2014-07-26 16:28:57 +08:00
private:
SmileyPack();
SmileyPack(SmileyPack&) = delete;
SmileyPack& operator=(const SmileyPack&) = delete;
2014-07-31 22:08:44 +08:00
void cacheSmiley(const QString& name);
QByteArray getCachedSmiley(const QString& key);
2014-07-29 16:50:39 +08:00
2014-07-31 22:08:44 +08:00
QHash<QString, QString> filenameTable; // matches an emoticon to its corresponding smiley ie. ":)" -> "happy.png"
2014-07-31 23:36:55 +08:00
QHash<QString, QByteArray> imgCache; // (scaled) representation of a smiley ie. "happy.png" -> data
QList<QStringList> emoticons; // {{ ":)", ":-)" }, {":(", ...}, ... }
2014-07-31 22:08:44 +08:00
QString path; // directory containing the cfg and image files
2014-07-25 20:52:14 +08:00
};
#endif // SMILEYPACK_H