1 /*
2     Copyright (C) 2014 Aseman
3     http://aseman.co
4 
5     Cutegram is free software: you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation, either version 3 of the License, or
8     (at your option) any later version.
9 
10     Cutegram is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14 
15     You should have received a copy of the GNU General Public License
16     along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #ifndef EMOJIS_H
20 #define EMOJIS_H
21 
22 #include <QObject>
23 #include <QList>
24 #include <QVariantMap>
25 #include <QColor>
26 
27 class UserData;
28 class EmojisPrivate;
29 class Emojis : public QObject
30 {
31     Q_PROPERTY( QString currentTheme READ currentTheme WRITE setCurrentTheme NOTIFY currentThemeChanged)
32     Q_PROPERTY( UserData* userData READ userData WRITE setUserData NOTIFY userDataChanged)
33     Q_PROPERTY( QVariantMap replacements READ replacements WRITE setReplacements NOTIFY replacementsChanged)
34     Q_PROPERTY( bool autoEmojis READ autoEmojis WRITE setAutoEmojis NOTIFY autoEmojisChanged)
35     Q_PROPERTY(QColor linkColor READ linkColor WRITE setLinkColor NOTIFY linkColorChanged)
36     Q_PROPERTY(QColor linkVisitedColor READ linkVisitedColor WRITE setLinkVisitedColor NOTIFY linkVisitedColorChanged)
37 
38     Q_OBJECT
39 public:
40     Emojis(QObject *parent = 0);
41     ~Emojis();
42 
43     void setCurrentTheme( const QString & theme );
44     QString currentTheme() const;
45 
46     UserData *userData() const;
47     void setUserData(UserData *userData);
48 
49     void setReplacements(const QVariantMap &map);
50     QVariantMap replacements() const;
51 
52     void setLinkColor(const QColor &color);
53     QColor linkColor() const;
54 
55     void setLinkVisitedColor(const QColor &color);
56     QColor linkVisitedColor() const;
57 
58     bool autoEmojis() const;
59     void setAutoEmojis(bool stt);
60 
61     Q_INVOKABLE QString convertSmiliesToEmoji(const QString &text);
62 
63     Q_INVOKABLE QString textToEmojiText(const QString & txt , int size = 16, bool skipLinks = false, bool localLinks = false);
64     Q_INVOKABLE QString bodyTextToEmojiText( const QString & txt );
65 
66     Q_INVOKABLE QList<QString> keys() const;
67     Q_INVOKABLE QString pathOf( const QString & key ) const;
68 
69     Q_INVOKABLE bool contains(const QString &key) const;
70 
71     const QHash<QString,QString> &emojis() const;
72 
73 signals:
74     void currentThemeChanged();
75     void userDataChanged();
76     void replacementsChanged();
77     void autoEmojisChanged();
78     void linkColorChanged();
79     void linkVisitedColorChanged();
80 
81 private:
82     EmojisPrivate *p;
83 };
84 
85 #endif // EMOJIS_H
86