1 | /********************************************************************************** |
2 | * Copyright (C) 2008 by Carlo Segato <brandon.ml@gmail.com> * |
3 | * * |
4 | * This library is free software; you can redistribute it and/or * |
5 | * modify it under the terms of the GNU Lesser General Public * |
6 | * License as published by the Free Software Foundation; either * |
7 | * version 2.1 of the License, or (at your option) any later version. * |
8 | * * |
9 | * This library is distributed in the hope that it will be useful, * |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * |
12 | * Lesser General Public License for more details. * |
13 | * * |
14 | * You should have received a copy of the GNU Lesser General Public * |
15 | * License along with this library. If not, see <http://www.gnu.org/licenses/>.* |
16 | * * |
17 | **********************************************************************************/ |
18 | |
19 | #ifndef KEMOTICONS_H |
20 | #define KEMOTICONS_H |
21 | |
22 | #include "kemoticons_export.h" |
23 | #include "kemoticonstheme.h" |
24 | |
25 | #include <QtCore/QObject> |
26 | #include <QtCore/QHash> |
27 | |
28 | #include <kservicetypetrader.h> |
29 | |
30 | class KEmoticonsPrivate; |
31 | |
32 | /** |
33 | * This class can be used to retrieve, install, create emoticons theme. |
34 | * For example if you want to get the current emoticon theme |
35 | * @code |
36 | * KEmoticons ke; |
37 | * KEmoticonsTheme et = ke.theme(); |
38 | * //do whatever you want with the theme |
39 | * @endcode |
40 | * it can also be used to set the emoticon theme and the parse mode in the config file |
41 | * @author Carlo Segato (brandon.ml@gmail.com) |
42 | */ |
43 | |
44 | class KEMOTICONS_EXPORT KEmoticons : public QObject |
45 | { |
46 | Q_OBJECT |
47 | public: |
48 | |
49 | /** |
50 | * Default constructor |
51 | */ |
52 | KEmoticons(); |
53 | |
54 | /** |
55 | * Destruct the object |
56 | */ |
57 | ~KEmoticons(); |
58 | |
59 | /** |
60 | * Retrieve the current emoticons theme |
61 | * @return the current KEmoticonsTheme |
62 | */ |
63 | KEmoticonsTheme theme(); |
64 | |
65 | /** |
66 | * Retrieve the theme with name @p name |
67 | * @param name name of the theme |
68 | * @return the KEmoticonsTheme @p name |
69 | */ |
70 | KEmoticonsTheme theme(const QString &name); |
71 | |
72 | /** |
73 | * Retrieve the current emoticon theme name |
74 | */ |
75 | static QString currentThemeName(); |
76 | |
77 | /** |
78 | * Returns a list of installed theme |
79 | */ |
80 | static QStringList themeList(); |
81 | |
82 | /** |
83 | * Set @p theme as the current theme |
84 | * @param theme a pointer to a KEmoticonsTheme object |
85 | */ |
86 | static void setTheme(const KEmoticonsTheme &theme); |
87 | |
88 | /** |
89 | * Set @p theme as the current theme |
90 | * @param theme the name of a theme |
91 | */ |
92 | static void setTheme(const QString &theme); |
93 | |
94 | /** |
95 | * Create a new emoticons theme |
96 | * @code |
97 | * KEmoticonsTheme theme; |
98 | * KService::List srv = KServiceTypeTrader::self()->query("KEmoticons"); |
99 | * for (int i = 0; i < srv.size(); ++i) { |
100 | * // we want to create a kde emoticons theme |
101 | * if (srv.at(i)->property("X-KDE-EmoticonsFileName").toString() == "emoticons.xml") { |
102 | * theme = KEmoticons().newTheme("test", srv.at(i)); |
103 | * } |
104 | * } |
105 | * @endcode |
106 | * @param name the name of the new emoticons theme |
107 | * @param service the kind of emoticon theme to create |
108 | */ |
109 | KEmoticonsTheme newTheme(const QString &name, const KService::Ptr &service); |
110 | |
111 | /** |
112 | * Install all themes inside the archive @p archiveName |
113 | * @param archiveName path to the archive |
114 | * @return a list of installed themes |
115 | */ |
116 | QStringList installTheme(const QString &archiveName); |
117 | |
118 | /** |
119 | * Set the parse mode to @p mode |
120 | */ |
121 | static void setParseMode(KEmoticonsTheme::ParseMode mode); |
122 | |
123 | /** |
124 | * Returns the current parse mode |
125 | */ |
126 | static KEmoticonsTheme::ParseMode parseMode(); |
127 | |
128 | private: |
129 | /** |
130 | * Private class |
131 | */ |
132 | KEmoticonsPrivate * const d; |
133 | |
134 | Q_PRIVATE_SLOT(d, void themeChanged(const QString &path)) |
135 | }; |
136 | |
137 | #endif /* KEMOTICONS_H */ |
138 | |
139 | // kate: space-indent on; indent-width 4; replace-tabs on; |
140 | |