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 14:52:14 +02:00
/*
2014-08-02 16:53:18 +02:00
Copyright (C) 2014 by Project Tox <https://tox.im>
2014-07-25 14:52:14 +02:00
2014-08-02 16:53:18 +02:00
This file is part of qTox, a Qt-based graphical interface for Tox.
2014-07-25 14:52:14 +02:00
2014-08-02 16:53:18 +02:00
This program is libre software: you can redistribute it and/or modify
2014-07-25 14:52:14 +02: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-30 22:07:26 +02:00
#include <QString>
#include <QStringList>
2014-07-25 14:52:14 +02:00
#define SMILEYPACK_SEARCH_PATHS \
{ \
"./smileys", "/usr/share/qtox/smileys", "/usr/share/emoticons", "~/.kde4/share/emoticons", "~/.kde/share/emoticons" \
}
2014-08-10 19:01:53 +02:00
2014-07-26 10:05:32 +02:00
//maps emoticons to smileys
2014-07-25 14:52:14 +02: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-10 18:50:40 +02:00
static bool isValid(const QString& filename);
2014-07-25 14:52:14 +02:00
bool load(const QString& filename);
2014-07-31 17:36:55 +02:00
QString smileyfied(QString msg);
2014-07-30 22:07:26 +02:00
QList<QStringList> getEmoticons() const;
2014-07-31 17:36:55 +02:00
QString getAsRichText(const QString& key);
QIcon getAsIcon(const QString& key);
2014-07-30 09:18:41 +02:00
2014-07-25 14:52:14 +02:00
private slots:
void onSmileyPackChanged();
2014-07-26 10:28:57 +02:00
private:
SmileyPack();
SmileyPack(SmileyPack&) = delete;
SmileyPack& operator=(const SmileyPack&) = delete;
2014-07-31 16:08:44 +02:00
void cacheSmiley(const QString& name);
QByteArray getCachedSmiley(const QString& key);
2014-07-29 10:50:39 +02:00
2014-07-31 16:08:44 +02:00
QHash<QString, QString> filenameTable; // matches an emoticon to its corresponding smiley ie. ":)" -> "happy.png"
2014-07-31 17:36:55 +02:00
QHash<QString, QByteArray> imgCache; // (scaled) representation of a smiley ie. "happy.png" -> data
QList<QStringList> emoticons; // {{ ":)", ":-)" }, {":(", ...}, ... }
2014-07-31 16:08:44 +02:00
QString path; // directory containing the cfg and image files
2014-07-25 14:52:14 +02:00
};
#endif // SMILEYPACK_H