root/trunk/qt4-gui/src/config/emoticons.h

Revision 5837, 3.0 kB (checked in by eugene, 12 months ago)

P.S. Happy recompiling ;-)

  • Property svn:eol-style set to native
Line 
1/*
2 * This file is part of Licq, an instant messaging client for UNIX.
3 * Copyright (C) 2003-2006 Licq developers
4 *
5 * Licq 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 2 of the License, or
8 * (at your option) any later version.
9 *
10 * Licq 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 Licq; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18 */
19
20#ifndef EMOTICONS_H
21#define EMOTICONS_H
22
23#include <QMap>
24#include <QObject>
25
26namespace LicqQtGui
27{
28class Emoticons : public QObject
29{
30  Q_OBJECT;
31
32public:
33  /// Theme name constants (not translated).
34  static const QString DEFAULT_THEME;
35  static const QString NO_THEME;
36
37  /// Helper functions so that when we save the theme name we can save
38  /// it untranslated, and later when we load it we can translate it again before
39  /// setting the theme.
40  static QString translateThemeName(const QString& name);
41  static QString untranslateThemeName(const QString& name);
42
43  Emoticons();
44  virtual ~Emoticons();
45
46  /// Get singleton instance
47  static Emoticons* self();
48
49  /// Set dirs to search themes in to @a basedirs
50  void setBasedirs(const QStringList& basedirs);
51
52  /// @returns the list of available (translated) theme names
53  QStringList themes() const;
54
55  /// @returns the list of files of the current emoticon theme
56  QStringList fileList() const;
57
58  /// @param theme is the translated name of the theme
59  /// @returns the list of files for @a theme
60  QStringList fileList(const QString& theme) const;
61
62  /// Loads @a theme and returns true; or false if @a theme could not be loaded.
63  /// @param theme is the translated name of the theme
64  bool setTheme(const QString& theme);
65
66  /// @returns the current theme name (translated)
67  QString theme() const;
68
69  /// @returns a mapping of files to smileys
70  QMap<QString, QString> emoticonsKeys() const;
71
72  /**
73   * In no mode is any replacing done within "<a ...</a>" or "<...>".
74   * StrictMode: Require a blank (space) before and after the smiley.
75   * NormalMode: Require a blank (space) before and a blank or punctuation after the smiley.
76   * RelaxedMode: Anything matching a smiley is replaced.
77   */
78  enum ParseMode { StrictMode, NormalMode, RelaxedMode };
79
80  /// Replaces all smileys in @a message with their icon.
81  void parseMessage(QString& message, ParseMode mode) const;
82
83  /// Replace all emoticons with their smiley
84  static void unparseMessage(QString& message);
85
86signals:
87  void themeChanged();
88
89private:
90  Emoticons(const Emoticons&);
91  Emoticons& operator=(const Emoticons&);
92
93  static Emoticons* m_self;
94
95  class Impl;
96  Impl* pimpl;
97};
98
99} // namespace LicqQtGui
100
101#endif // EMOTICONS_H
Note: See TracBrowser for help on using the browser.