Deuglify channel state icons
[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    * These are Oxygen palette colors
87    */
88   addSenderAutoColor(SenderCol01, "#989a95");
89   addSenderAutoColor(SenderCol02, "#ef8440");
90   addSenderAutoColor(SenderCol03, "#ffe200");
91   addSenderAutoColor(SenderCol04, "#49b13b");
92   addSenderAutoColor(SenderCol05, "#00a778");
93   addSenderAutoColor(SenderCol06, "#008b90");
94   addSenderAutoColor(SenderCol07, "#0069ba");
95   addSenderAutoColor(SenderCol08, "#563696");
96   addSenderAutoColor(SenderCol09, "#ad3597");
97   addSenderAutoColor(SenderCol10, "#e70083");
98   addSenderAutoColor(SenderCol11, "#e70f00");
99   addSenderAutoColor(SenderCol12, "#866127");
100
101   QTextCharFormat nick;
102   nick.setAnchor(true);
103   nick.setFontWeight(QFont::Bold);
104   setFormat(Nick, nick, Settings::Default);
105
106   QTextCharFormat hostmask;
107   hostmask.setFontItalic(true);
108   setFormat(Hostmask, hostmask, Settings::Default);
109
110   QTextCharFormat channel;
111   channel.setAnchor(true);
112   channel.setFontWeight(QFont::Bold);
113   setFormat(ChannelName, channel, Settings::Default);
114
115   QTextCharFormat flags;
116   flags.setFontWeight(QFont::Bold);
117   setFormat(ModeFlags, flags, Settings::Default);
118
119   QTextCharFormat url;
120   url.setFontUnderline(true);
121   url.setAnchor(true);
122   setFormat(Url, url, Settings::Default);
123
124   QtUiStyleSettings s;
125   _highlightColor = s.highlightColor();
126   if(!_highlightColor.isValid()) _highlightColor = QColor("lightcoral");
127 }
128
129 QtUiStyle::~QtUiStyle() {}
130
131 void QtUiStyle::setHighlightColor(const QColor &col) {
132   _highlightColor = col;
133   QtUiStyleSettings s;
134   s.setHighlightColor(col);
135 }
136
137 void QtUiStyle::addSenderAutoColor(FormatType type, const QString name) {
138   QTextCharFormat autoColor;
139   autoColor.setAnchor(true);
140   autoColor.setForeground(QBrush(QColor(name)));
141   setFormat(type, autoColor, Settings::Default);
142 }