94 } |
94 } |
95 |
95 |
96 return firstIsShorter; |
96 return firstIsShorter; |
97 } |
97 } |
98 |
98 |
99 const char* HWChatWidget::STYLE = |
|
100 "\ |
|
101 a { color:#c8c8ff; }\ |
|
102 .nick { text-decoration: none; }\ |
|
103 .UserChat .nick { color:#ffec20; }\ |
|
104 .FriendChat { color: #08e008; }\ |
|
105 .FriendChat .nick { color: #20ff20; }\ |
|
106 .UserJoin { color: #c0c0c0; }\ |
|
107 .UserJoin .nick { color: #d0d0d0; }\ |
|
108 .FriendJoin { color: #c0e0c0; }\ |
|
109 .FriendJoin .nick { color: #d0f0d0; }\ |
|
110 .UserAction { color: #ff80ff; }\ |
|
111 .UserAction .nick { color: #ffa0ff; }\ |
|
112 .FriendAction { color: #ff00ff; }\ |
|
113 .FriendAction .nick { color: #ff30ff; }\ |
|
114 .Error { color: #ff0000 }\ |
|
115 .Warning { color: #ff8000 }\ |
|
116 .Notice { color: #fefefe }\ |
|
117 "; |
|
118 |
99 |
119 HWChatWidget::HWChatWidget(QWidget* parent, QSettings * gameSettings, bool notify) : |
100 HWChatWidget::HWChatWidget(QWidget* parent, QSettings * gameSettings, bool notify) : |
120 QWidget(parent), |
101 QWidget(parent), |
121 mainLayout(this) |
102 mainLayout(this) |
122 { |
103 { |
139 |
120 |
140 mainLayout.addWidget(chatEditLine, 2, 0); |
121 mainLayout.addWidget(chatEditLine, 2, 0); |
141 |
122 |
142 chatText = new QTextBrowser(this); |
123 chatText = new QTextBrowser(this); |
143 |
124 |
|
125 QString style; |
|
126 |
144 // load external stylesheet if there is any |
127 // load external stylesheet if there is any |
145 QFile * file = |
128 QFile extFile(HWDataManager::instance().findFileForRead("css/chat.css")); |
146 new QFile(HWDataManager::instance().findFileForRead("css/chat.css")); |
129 |
147 |
130 QFile resFile(":/res/css/chat.css"); |
148 if (file->exists() && file->open(QIODevice::ReadOnly | QIODevice::Text)) |
131 |
149 { |
132 QFile & file = (extFile.exists()?extFile:resFile); |
150 QString style = ""; |
133 |
151 QTextStream in(file); |
134 if (file.open(QIODevice::ReadOnly | QIODevice::Text)) |
|
135 { |
|
136 QTextStream in(&file); |
152 while (!in.atEnd()) |
137 while (!in.atEnd()) |
153 { |
138 { |
154 QString line = in.readLine(); |
139 QString line = in.readLine(); |
155 if(!line.isEmpty()) |
140 if(!line.isEmpty()) |
156 style.append(line); |
141 style.append(line); |
157 } |
142 } |
158 chatText->document()->setDefaultStyleSheet(style); |
143 } |
159 } |
144 |
160 else |
145 chatText->document()->setDefaultStyleSheet(style); |
161 chatText->document()->setDefaultStyleSheet(STYLE); |
|
162 |
146 |
163 chatText->setMinimumHeight(20); |
147 chatText->setMinimumHeight(20); |
164 chatText->setMinimumWidth(10); |
148 chatText->setMinimumWidth(10); |
165 chatText->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
149 chatText->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
166 chatText->setOpenLinks(false); |
150 chatText->setOpenLinks(false); |