Colored emoji support.

Also, this approach seems to have a memory leak while converting
QStringList to QVariant.
This commit is contained in:
Black Hat
2018-08-11 20:48:44 +08:00
parent e30c412637
commit 4dbd0e2dcd
9 changed files with 1552 additions and 1127 deletions

1460
src/emojimodel.cpp Normal file

File diff suppressed because it is too large Load Diff

43
src/emojimodel.h Normal file
View File

@@ -0,0 +1,43 @@
#ifndef EMOJIMODEL_H
#define EMOJIMODEL_H
#include <QObject>
#include <QVariant>
class EmojiModel : public QObject {
Q_OBJECT
Q_PROPERTY(QVariant model READ getModel NOTIFY categoryChanged)
Q_PROPERTY(QString category READ getCategory WRITE setCategory NOTIFY
categoryChanged)
public:
explicit EmojiModel(QObject *parent = nullptr);
QVariant getModel();
QString getCategory() { return m_category; }
void setCategory(QString category) {
if (category != m_category) {
m_category = category;
emit categoryChanged();
}
}
private:
static const QStringList people;
static const QStringList nature;
static const QStringList food;
static const QStringList activity;
static const QStringList travel;
static const QStringList objects;
static const QStringList symbols;
static const QStringList flags;
QString m_category = "people";
signals:
void categoryChanged();
public slots:
};
#endif // EMOJIMODEL_H

View File

@@ -8,6 +8,7 @@
#include "messageeventmodel.h"
#include "room.h"
#include "roomlistmodel.h"
#include "emojimodel.h"
#include "csapi/joining.h"
#include "csapi/leaving.h"
@@ -28,6 +29,7 @@ int main(int argc, char *argv[]) {
qmlRegisterType<Controller>("Matrique", 0, 1, "Controller");
qmlRegisterType<RoomListModel>("Matrique", 0, 1, "RoomListModel");
qmlRegisterType<MessageEventModel>("Matrique", 0, 1, "MessageEventModel");
qmlRegisterType<EmojiModel>("Matrique", 0, 1, "EmojiModel");
qmlRegisterUncreatableType<RoomMessageEvent>("Matrique", 0, 1, "RoomMessageEvent", "ENUM");
QQmlApplicationEngine engine;