FIRST QuasselTopia version that actually has a chatwidget that _looks_ like
authorManuel Nickschas <sputnick@quassel-irc.org>
Mon, 5 Nov 2007 00:40:48 +0000 (00:40 +0000)
committerManuel Nickschas <sputnick@quassel-irc.org>
Mon, 5 Nov 2007 00:40:48 +0000 (00:40 +0000)
a chatwidget, including colors and stuff...

Quassel.kdevelop.filelist
src/qtopia/chatline.cpp
src/qtopia/chatline.h
src/qtopia/chatwidget.cpp
src/qtopia/chatwidget.h
src/qtopia/qtopiamainwin.cpp
src/qtopia/qtopiaui.cpp
src/qtopia/qtopiaui.h
src/qtopia/qtopiauistyle.cpp

index 61b69b0..a8958f7 100644 (file)
@@ -455,6 +455,10 @@ src/qtopia/qtopiamainwin.cpp
 src/qtopia/qtopiamainwin.h
 src/qtopia/qtopiastyle.cpp
 src/qtopia/qtopiastyle.h
+src/qtopia/qtopiaui.cpp
+src/qtopia/qtopiaui.h
+src/qtopia/qtopiauistyle.cpp
+src/qtopia/qtopiauistyle.h
 src/qtopia/topicbar.cpp
 src/qtopia/topicbar.h
 src/qtopia/ui
index 3f447d2..d0fbf6e 100644 (file)
 
 #include "chatline.h"
 #include "qtopiaui.h"
+#include "qtopiauistyle.h"
 
 ChatLine::ChatLine(Message msg) {
-  //_styledSender = QtopiaUi::style()->styleString(msg.formattedSender());
-  //_styledText = QtopiaUi::style()->styleString(msg.formattedText());
+  _styledSender = QtopiaUi::style()->styleString(msg.formattedSender());
+  _styledText = QtopiaUi::style()->styleString(msg.formattedText());
   _timestamp = msg.timestamp();
   _msgId = msg.msgId();
   _bufferInfo = msg.buffer();
@@ -53,17 +54,14 @@ QDateTime ChatLine::timestamp() const {
   return _timestamp;
 }
 
-QString ChatLine::htmlSender() const {
-  return _htmlSender;
+UiStyle::StyledText ChatLine::styledSender() const {
+  return _styledSender;
 }
 
-QString ChatLine::htmlText() const {
-  return _htmlText;
+UiStyle::StyledText ChatLine::styledText() const {
+  return _styledText;
 }
 
-QString ChatLine::htmlTimestamp() const {
-  return _htmlTimestamp;
-}
 
 
 QString ChatLine::formattedToHtml(const QString &f) {
index 61865c4..a25a056 100644 (file)
@@ -34,9 +34,8 @@ class ChatLine : public AbstractUiMsg {
     BufferInfo bufferInfo() const;
     QDateTime timestamp() const;
 
-    QString htmlSender() const;
-    QString htmlText() const;
-    QString htmlTimestamp() const;
+    UiStyle::StyledText styledSender() const;
+    UiStyle::StyledText styledText() const;
 
   private:
     QString _sender, _text, _htmlSender, _htmlText, _htmlTimestamp;
index 6c3ffe2..8c81f44 100644 (file)
@@ -23,7 +23,7 @@
 #include "chatwidget.h"
 
 ChatWidget::ChatWidget(QWidget *parent) : QTextEdit(parent) {
-
+  setStyleSheet("background-color: rgba(255, 255, 255, 60%)");
 }
 
 void ChatWidget::setContents(QList<ChatLine *> lines) {
@@ -45,7 +45,10 @@ void ChatWidget::appendMsg(AbstractUiMsg *msg) {
 }
 
 void ChatWidget::appendChatLine(ChatLine *line) {
-  append(line->text()); qDebug() << "appending";
+  QTextCursor cursor = textCursor();
+  moveCursor(QTextCursor::End);
+  insertChatLine(line);
+  setTextCursor(cursor);
 }
 
 void ChatWidget::appendChatLines(QList<ChatLine *> list) {
@@ -55,24 +58,30 @@ void ChatWidget::appendChatLines(QList<ChatLine *> list) {
 }
 
 void ChatWidget::prependChatLine(ChatLine *line) {
-  qDebug() << "prepending"; return;
   QTextCursor cursor = textCursor();
   moveCursor(QTextCursor::Start);
-  insertHtml(line->text());
+  insertChatLine(line);
   setTextCursor(cursor);
-  QTextCharFormat fmt;
-  fmt.setForeground(QBrush("#eeff33"));
-  QFont font("Courier", 8);
-  font.setFixedPitch(true); qDebug() << font.family();
-  fmt.setFont(font);
-  //fmt.setBackground(QBrush("#112233"));
-  QTextCursor crsor(document());
-  crsor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
-  crsor.select(QTextCursor::Document);
-  crsor.setCharFormat(fmt);
 }
 
 void ChatWidget::prependChatLines(QList<ChatLine *> list) {
+  foreach(ChatLine *line, list) {
+    prependChatLine(line);
+  }
+}
 
+void ChatWidget::insertChatLine(ChatLine *line) {
+  insertStyledText(line->styledSender());
+  insertPlainText(" ");
+  insertStyledText(line->styledText());
+  insertPlainText("\n");
+}
 
+void ChatWidget::insertStyledText(const QtopiaUiStyle::StyledText &stext) {
+  QTextCursor cursor = textCursor();
+  foreach(QTextLayout::FormatRange format, stext.formats) {
+    cursor.setCharFormat(format.format);
+    setTextCursor(cursor);
+    insertPlainText(stext.text.mid(format.start, format.length));
+  }
 }
index 07de94f..faa14c0 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <QTextEdit>
 #include "chatline.h"
+#include "qtopiauistyle.h"
 #include "quasselui.h"
 
 class ChatWidget : public QTextEdit {
@@ -41,6 +42,8 @@ class ChatWidget : public QTextEdit {
     void appendChatLines(QList<ChatLine *>);
 
   private:
+    void insertChatLine(ChatLine *);
+    void insertStyledText(const QtopiaUiStyle::StyledText &);
 
 
 
index 1f60969..fc98f61 100644 (file)
@@ -87,8 +87,8 @@ void QtopiaMainWin::connectedToCore() {
     emit requestBacklog(id, 100, -1);
   }
   // FIXME just for testing: select first available buffer
-  if(Client::allBufferInfos().count() > 1) {
-    Buffer *b = Client::buffer(Client::allBufferInfos()[1]);
+  if(Client::allBufferInfos().count() > 2) {
+    Buffer *b = Client::buffer(Client::allBufferInfos()[2]);
     Client::bufferModel()->selectBuffer(b);
   }
 }
index e41fb9b..c34317b 100644 (file)
@@ -22,6 +22,8 @@
 #include "qtopiamainwin.h"
 #include "qtopiauistyle.h"
 
+QtopiaUiStyle *QtopiaUi::_style;
+
 QtopiaUi::QtopiaUi(QtopiaMainWin *mw) : AbstractUi(), mainWin(mw) {
   _style = new QtopiaUiStyle();
   connect(mainWin, SIGNAL(connectToCore(const QVariantMap &)), this, SIGNAL(connectToCore(const QVariantMap &)));
@@ -40,7 +42,7 @@ void QtopiaUi::init() {
 
 }
 
-QtopiaUiStyle *QtopiaUi::style() const {
+QtopiaUiStyle *QtopiaUi::style() {
   return _style;
 }
 
index 66ee17f..716a011 100644 (file)
@@ -36,7 +36,7 @@ class QtopiaUi : public AbstractUi {
     void init();
     AbstractUiMsg *layoutMsg(const Message &);
 
-    QtopiaUiStyle *style() const;
+    static QtopiaUiStyle *style();
 
   protected slots:
     void connectedToCore();
@@ -44,7 +44,7 @@ class QtopiaUi : public AbstractUi {
 
   private:
     QtopiaMainWin *mainWin;
-    QtopiaUiStyle *_style;
+    static QtopiaUiStyle *_style;
 };
 
 
index 2716b22..5168ee4 100644 (file)
@@ -23,7 +23,7 @@
 QtopiaUiStyle::QtopiaUiStyle() : UiStyle() {
 
   QTextCharFormat def;
-  def.setFont(QFont("Verdana",6));
+  def.setFont(QFont("Verdana",5));
   setFormat(None, def);
 
   // We need to just set our internal formats; everything else is done by the base class...
@@ -51,15 +51,15 @@ QtopiaUiStyle::QtopiaUiStyle() : UiStyle() {
   setFormat(JoinMsg, join);
 
   QTextCharFormat part;
-  part.setForeground(QBrush("#cd5c5c"));
+  part.setForeground(QBrush("#ff0000"));
   setFormat(PartMsg, part);
 
   QTextCharFormat quit;
-  quit.setForeground(QBrush("#cd5c5c"));
+  quit.setForeground(QBrush("#ff0000"));
   setFormat(QuitMsg, quit);
 
   QTextCharFormat kick;
-  kick.setForeground(QBrush("#cd5c5c"));
+  kick.setForeground(QBrush("#ff0000"));
   setFormat(KickMsg, kick);
 
   QTextCharFormat nren;