Communi  3.5.0
A cross-platform IRC framework written with Qt
ircpalette.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008-2016 The Communi Project
3 
4  You may use this file under the terms of BSD license as follows:
5 
6  Redistribution and use in source and binary forms, with or without
7  modification, are permitted provided that the following conditions are met:
8  * Redistributions of source code must retain the above copyright
9  notice, this list of conditions and the following disclaimer.
10  * Redistributions in binary form must reproduce the above copyright
11  notice, this list of conditions and the following disclaimer in the
12  documentation and/or other materials provided with the distribution.
13  * Neither the name of the copyright holder nor the names of its
14  contributors may be used to endorse or promote products derived
15  from this software without specific prior written permission.
16 
17  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR
21  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28 
29 #ifndef IRCPALETTE_H
30 #define IRCPALETTE_H
31 
32 #include <IrcGlobal>
33 #include <QtCore/qmap.h>
34 #include <QtCore/qobject.h>
35 #include <QtCore/qstring.h>
36 #include <QtCore/qmetatype.h>
37 #include <QtCore/qscopedpointer.h>
38 
39 IRC_BEGIN_NAMESPACE
40 
41 class IrcPalettePrivate;
42 
43 class IRC_UTIL_EXPORT IrcPalette : public QObject
44 {
45  Q_OBJECT
46  Q_PROPERTY(QString white READ white WRITE setWhite)
47  Q_PROPERTY(QString black READ black WRITE setBlack)
48  Q_PROPERTY(QString blue READ blue WRITE setBlue)
49  Q_PROPERTY(QString green READ green WRITE setGreen)
50  Q_PROPERTY(QString red READ red WRITE setRed)
51  Q_PROPERTY(QString brown READ brown WRITE setBrown)
52  Q_PROPERTY(QString purple READ purple WRITE setPurple)
53  Q_PROPERTY(QString orange READ orange WRITE setOrange)
54  Q_PROPERTY(QString yellow READ yellow WRITE setYellow)
55  Q_PROPERTY(QString lightGreen READ lightGreen WRITE setLightGreen)
56  Q_PROPERTY(QString cyan READ cyan WRITE setCyan)
57  Q_PROPERTY(QString lightCyan READ lightCyan WRITE setLightCyan)
58  Q_PROPERTY(QString lightBlue READ lightBlue WRITE setLightBlue)
59  Q_PROPERTY(QString pink READ pink WRITE setPink)
60  Q_PROPERTY(QString gray READ gray WRITE setGray)
61  Q_PROPERTY(QString lightGray READ lightGray WRITE setLightGray)
62 
63 public:
64  ~IrcPalette();
65 
66  QMap<int, QString> colorNames() const;
67  void setColorNames(const QMap<int, QString>& names);
68 
69  QString colorName(int color, const QString& fallback = QLatin1String("black")) const;
70  void setColorName(int color, const QString& name);
71 
72  QString white() const;
73  void setWhite(const QString& color);
74 
75  QString black() const;
76  void setBlack(const QString& color);
77 
78  QString blue() const;
79  void setBlue(const QString& color);
80 
81  QString green() const;
82  void setGreen(const QString& color);
83 
84  QString red() const;
85  void setRed(const QString& color);
86 
87  QString brown() const;
88  void setBrown(const QString& color);
89 
90  QString purple() const;
91  void setPurple(const QString& color);
92 
93  QString orange() const;
94  void setOrange(const QString& color);
95 
96  QString yellow() const;
97  void setYellow(const QString& color);
98 
99  QString lightGreen() const;
100  void setLightGreen(const QString& color);
101 
102  QString cyan() const;
103  void setCyan(const QString& color);
104 
105  QString lightCyan() const;
106  void setLightCyan(const QString& color);
107 
108  QString lightBlue() const;
109  void setLightBlue(const QString& color);
110 
111  QString pink() const;
112  void setPink(const QString& color);
113 
114  QString gray() const;
115  void setGray(const QString& color);
116 
117  QString lightGray() const;
118  void setLightGray(const QString& color);
119 
120 private:
121  friend class IrcTextFormat;
122  explicit IrcPalette(QObject* parent);
123 
124  QScopedPointer<IrcPalettePrivate> d_ptr;
125  Q_DECLARE_PRIVATE(IrcPalette)
126  Q_DISABLE_COPY(IrcPalette)
127 };
128 
129 IRC_END_NAMESPACE
130 
131 Q_DECLARE_METATYPE(IRC_PREPEND_NAMESPACE(IrcPalette*))
132 
133 #endif // IRCPALETTE_H
Specifies a palette of IRC colors.
Definition: ircpalette.h:43
Provides methods for text formatting.
Definition: irctextformat.h:45