- Implemented: Sender auto coloring based on the tango colorscheme
[quassel.git] / src / qtui / qtuistyle.cpp
1 /***************************************************************************
2  *   Copyright (C) 2005-09 by the Quassel Project                          *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
5  *   This program 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) version 3.                                           *
9  *                                                                         *
10  *   This program 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, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20
21 #include "qtuistyle.h"
22 #include "qtuisettings.h"
23
24 QtUiStyle::QtUiStyle() : UiStyle("QtUiStyle") {
25   // We need to just set our internal formats; everything else is done by the base class...
26
27   // Internal message formats
28   QTextCharFormat plainMsg;
29   plainMsg.setForeground(QBrush("black"));
30   setFormat(PlainMsg, plainMsg, Settings::Default);
31
32   QTextCharFormat notice;
33   notice.setForeground(QBrush("navy"));
34   setFormat(NoticeMsg, notice, Settings::Default);
35
36   QTextCharFormat server;
37   server.setForeground(QBrush("navy"));
38   setFormat(ServerMsg, server, Settings::Default);
39
40   QTextCharFormat error;
41   error.setForeground(QBrush("red"));
42   setFormat(ErrorMsg, error, Settings::Default);
43
44   QTextCharFormat join;
45   join.setForeground(QBrush("green"));
46   setFormat(JoinMsg, join, Settings::Default);
47
48   QTextCharFormat part;
49   part.setForeground(QBrush("indianred"));
50   setFormat(PartMsg, part, Settings::Default);
51
52   QTextCharFormat quit;
53   quit.setForeground(QBrush("indianred"));
54   setFormat(QuitMsg, quit, Settings::Default);
55
56   QTextCharFormat kick;
57   kick.setForeground(QBrush("indianred"));
58   setFormat(KickMsg, kick, Settings::Default);
59
60   QTextCharFormat nren;
61   nren.setForeground(QBrush("magenta"));
62   setFormat(RenameMsg, nren, Settings::Default);
63
64   QTextCharFormat mode;
65   mode.setForeground(QBrush("steelblue"));
66   setFormat(ModeMsg, mode, Settings::Default);
67
68   QTextCharFormat action;
69   action.setFontItalic(true);
70   action.setForeground(QBrush("darkmagenta"));
71   setFormat(ActionMsg, action, Settings::Default);
72
73   // Internal message element formats
74   QTextCharFormat ts;
75   ts.setForeground(QBrush("grey"));
76   setFormat(Timestamp, ts, Settings::Default);
77
78   // Set the default sender color
79   QTextCharFormat sender;
80   sender.setAnchor(true);
81   sender.setForeground(QBrush("navy"));
82   setFormat(Sender, sender, Settings::Default);
83
84   /*
85    * Fillup the list of colors used for sender auto coloring In this case
86    * this are all tango colors without the grey tones 
87    * See "http://tango.freedesktop.org/Tango_Icon_Theme_Guidelines" for details
88    */
89   // Butter
90   addSenderAutoColor(SenderCol01, "#fce94f");
91   addSenderAutoColor(SenderCol02, "#edd400");
92   addSenderAutoColor(SenderCol03,  "#c4a000");
93   // Orange
94   addSenderAutoColor(SenderCol04,  "#fcaf3e");
95   addSenderAutoColor(SenderCol05,  "#f57900");
96   addSenderAutoColor(SenderCol06,  "#ce5c00");
97   // Chocolate
98   addSenderAutoColor(SenderCol07, "#e9b96e");
99   addSenderAutoColor(SenderCol08, "#c17d11");
100   addSenderAutoColor(SenderCol09, "#8f5902");
101   // Chameleon
102   addSenderAutoColor(SenderCol10, "#8ae234");
103   addSenderAutoColor(SenderCol11, "#73d216");
104   addSenderAutoColor(SenderCol12, "#4e9a06");
105   // Sky Blue
106   addSenderAutoColor(SenderCol13, "#729fcf");
107   addSenderAutoColor(SenderCol14, "#3465a4");
108   addSenderAutoColor(SenderCol15, "#204a87");
109   // Plum
110   addSenderAutoColor(SenderCol16, "#ad7fa8");
111   addSenderAutoColor(SenderCol17, "#75507b");
112   addSenderAutoColor(SenderCol18, "#5c3566");
113   // Scarlet Red
114   addSenderAutoColor(SenderCol19, "#ef2929");
115   addSenderAutoColor(SenderCol20, "#cc0000");
116   addSenderAutoColor(SenderCol21, "#a40000");
117
118   QTextCharFormat nick;
119   nick.setAnchor(true);
120   nick.setFontWeight(QFont::Bold);
121   setFormat(Nick, nick, Settings::Default);
122
123   QTextCharFormat hostmask;
124   hostmask.setFontItalic(true);
125   setFormat(Hostmask, hostmask, Settings::Default);
126
127   QTextCharFormat channel;
128   channel.setAnchor(true);
129   channel.setFontWeight(QFont::Bold);
130   setFormat(ChannelName, channel, Settings::Default);
131
132   QTextCharFormat flags;
133   flags.setFontWeight(QFont::Bold);
134   setFormat(ModeFlags, flags, Settings::Default);
135
136   QTextCharFormat url;
137   url.setFontUnderline(true);
138   url.setAnchor(true);
139   setFormat(Url, url, Settings::Default);
140
141   QtUiStyleSettings s;
142   _highlightColor = s.highlightColor();
143   if(!_highlightColor.isValid()) _highlightColor = QColor("lightcoral");
144 }
145
146 QtUiStyle::~QtUiStyle() {}
147
148 void QtUiStyle::setHighlightColor(const QColor &col) {
149   _highlightColor = col;
150   QtUiStyleSettings s;
151   s.setHighlightColor(col);
152 }
153
154 void QtUiStyle::addSenderAutoColor(FormatType type, const QString name) 
155 {
156   QTextCharFormat autoColor;
157   autoColor.setAnchor(true);
158   autoColor.setForeground(QBrush(QColor(name)));
159   setFormat(type, autoColor, Settings::Default);
160 }