added emote loading

This commit is contained in:
fourtf
2017-01-13 18:59:11 +01:00
parent 0fbc40a52a
commit 4dbe2b0254
18 changed files with 402 additions and 181 deletions
+13 -6
View File
@@ -32,7 +32,8 @@ ChatWidgetView::resizeEvent(QResizeEvent *)
auto messages = c->getMessagesClone();
for (std::shared_ptr<Message> &message : messages) {
message.get()->layout(width(), true);
qInfo(QString::number(width()).toStdString().c_str());
message.get()->layout(this->width(), true);
}
}
@@ -48,18 +49,22 @@ ChatWidgetView::paintEvent(QPaintEvent *)
auto messages = c->getMessagesClone();
int y = 0;
int y = 32;
for (std::shared_ptr<Message> const &message : messages) {
for (WordPart const &wordPart : message.get()->wordParts()) {
painter.setPen(QColor(255, 0, 0));
painter.drawRect(wordPart.x(), wordPart.y() + y, wordPart.width(),
wordPart.height());
// image
if (wordPart.word().isImage()) {
LazyLoadedImage &lli = wordPart.word().getImage();
const QImage *image = lli.image();
const QPixmap *image = lli.pixmap();
if (image != NULL) {
painter.drawImage(
painter.drawPixmap(
QRect(wordPart.x(), wordPart.y() + y, wordPart.width(),
wordPart.height()),
*image);
@@ -70,8 +75,10 @@ ChatWidgetView::paintEvent(QPaintEvent *)
painter.setPen(wordPart.word().color());
painter.setFont(wordPart.word().getFont());
painter.drawText(wordPart.x(), wordPart.y() + y,
wordPart.getText());
painter.drawText(
QRectF(wordPart.x(), wordPart.y() + y, 10000, 10000),
wordPart.getText(),
QTextOption(Qt::AlignLeft | Qt::AlignTop));
}
}