1 /***************************************************************************
2 * Copyright (C) 2005-09 by the Quassel Project *
3 * devel@quassel-irc.org *
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. *
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. *
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 ***************************************************************************/
21 #include "qtuistyle.h"
22 #include "qtuisettings.h"
24 QtUiStyle::QtUiStyle() : UiStyle("QtUiStyle") {
25 // We need to just set our internal formats; everything else is done by the base class...
27 // Internal message formats
28 QTextCharFormat plainMsg;
29 plainMsg.setForeground(QBrush("black"));
30 setFormat(PlainMsg, plainMsg, Settings::Default);
32 QTextCharFormat notice;
33 notice.setForeground(QBrush("navy"));
34 setFormat(NoticeMsg, notice, Settings::Default);
36 QTextCharFormat server;
37 server.setForeground(QBrush("navy"));
38 setFormat(ServerMsg, server, Settings::Default);
40 QTextCharFormat error;
41 error.setForeground(QBrush("red"));
42 setFormat(ErrorMsg, error, Settings::Default);
45 join.setForeground(QBrush("green"));
46 setFormat(JoinMsg, join, Settings::Default);
49 part.setForeground(QBrush("indianred"));
50 setFormat(PartMsg, part, Settings::Default);
53 quit.setForeground(QBrush("indianred"));
54 setFormat(QuitMsg, quit, Settings::Default);
57 kick.setForeground(QBrush("indianred"));
58 setFormat(KickMsg, kick, Settings::Default);
61 nren.setForeground(QBrush("magenta"));
62 setFormat(RenameMsg, nren, Settings::Default);
65 mode.setForeground(QBrush("steelblue"));
66 setFormat(ModeMsg, mode, Settings::Default);
68 QTextCharFormat action;
69 action.setFontItalic(true);
70 action.setForeground(QBrush("darkmagenta"));
71 setFormat(ActionMsg, action, Settings::Default);
73 // Internal message element formats
75 ts.setForeground(QBrush("grey"));
76 setFormat(Timestamp, ts, Settings::Default);
78 // Set the default sender color
79 QTextCharFormat sender;
80 sender.setAnchor(true);
81 sender.setForeground(QBrush("navy"));
82 setFormat(Sender, sender, Settings::Default);
85 * Fillup the list of colors used for sender auto coloring In this case
86 * These are Oxygen palette colors
88 addSenderAutoColor(SenderCol01, "#989a95");
89 addSenderAutoColor(SenderCol02, "#ef8440");
90 addSenderAutoColor(SenderCol03, "#ffbf00");
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");
101 QTextCharFormat nick;
102 nick.setAnchor(true);
103 nick.setFontWeight(QFont::Bold);
104 setFormat(Nick, nick, Settings::Default);
106 QTextCharFormat hostmask;
107 hostmask.setFontItalic(true);
108 setFormat(Hostmask, hostmask, Settings::Default);
110 QTextCharFormat channel;
111 channel.setAnchor(true);
112 channel.setFontWeight(QFont::Bold);
113 setFormat(ChannelName, channel, Settings::Default);
115 QTextCharFormat flags;
116 flags.setFontWeight(QFont::Bold);
117 setFormat(ModeFlags, flags, Settings::Default);
120 url.setFontUnderline(true);
122 setFormat(Url, url, Settings::Default);
125 _highlightColor = s.highlightColor();
126 if(!_highlightColor.isValid()) _highlightColor = QColor("lightcoral");
129 QtUiStyle::~QtUiStyle() {}
131 void QtUiStyle::setHighlightColor(const QColor &col) {
132 _highlightColor = col;
134 s.setHighlightColor(col);
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);