+ //ui.chatWidget->setStyleSheet("div { color: #777777; }");
+ //ui.chatWidget->setHtml("<style type=\"text/css\">.foo { color: #777777; } .bar { font-style: italic }</style>"
+ // "<div class=\"foo\">foo</div> <div class=\"bar\">bar</div> baz");
+ //ui.chatWidget->moveCursor(QTextCursor::End);
+ //ui.chatWidget->insertHtml("<div class=\"foo\"> brumm</div>");
+
+ ChatWidget *chatWidget;
+ if(!chatWidgets.contains(buf)) {
+ chatWidget = new ChatWidget(this);
+ QList<ChatLine *> lines;
+ QList<AbstractUiMsg *> msgs = buf->contents();
+ foreach(AbstractUiMsg *msg, msgs) {
+ lines.append((ChatLine*)(msg));
+ }
+ chatWidget->setContents(lines);
+ connect(buf, SIGNAL(msgAppended(AbstractUiMsg *)), chatWidget, SLOT(appendMsg(AbstractUiMsg *)));
+ connect(buf, SIGNAL(msgPrepended(AbstractUiMsg *)), chatWidget, SLOT(prependMsg(AbstractUiMsg *)));
+ connect(buf, SIGNAL(topicSet(QString)), this, SLOT(setTopic(QString)));
+ //connect(buf, SIGNAL(ownNickSet(QString)), this, SLOT(setOwnNick(QString)));
+ ui.stack->addWidget(chatWidget);
+ chatWidgets.insert(buf, chatWidget);
+ chatWidget->setFocusProxy(ui.inputLine);
+ } else chatWidget = chatWidgets[buf];
+ ui.inputLine->show(); ui.topicBar->show();
+ ui.stack->setCurrentWidget(chatWidget);
+ ui.inputLine->setFocus();
+ currentBuffer = buf;
+}
+
+void MainWidget::enterPressed() {
+ QStringList lines = ui.inputLine->text().split('\n', QString::SkipEmptyParts);
+ foreach(QString msg, lines) {
+ if(msg.isEmpty()) continue;
+ if(currentBuffer) currentBuffer->processUserInput(msg);
+ }
+ ui.inputLine->clear();
+}
+
+// FIXME make this more elegant, we don't need to send a string around...
+void MainWidget::setTopic(QString topic) {
+ Q_UNUSED(topic);
+ if(currentBuffer) {
+ QString title = QString("%1 (%2): \"%3\"").arg(currentBuffer->name()).arg(currentBuffer->networkName()).arg(currentBuffer->topic());
+ ui.topicBar->setContents(title);
+ }