mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-29 14:18:49 +03:00
Merge pull request #227 from christarazi/fix-text-wrap-checkmark
Create space for checkmark beforehand fixes #217
This commit is contained in:
commit
54582cab3a
2 changed files with 20 additions and 5 deletions
|
@ -137,6 +137,7 @@ private:
|
|||
QFont font_;
|
||||
|
||||
QLabel *timestamp_;
|
||||
QLabel *checkmark_;
|
||||
QLabel *userName_;
|
||||
QLabel *body_;
|
||||
};
|
||||
|
@ -181,6 +182,7 @@ TimelineItem::setupLocalWidgetLayout(Widget *widget,
|
|||
messageLayout_->addLayout(widgetLayout, 1);
|
||||
}
|
||||
|
||||
messageLayout_->addWidget(checkmark_);
|
||||
messageLayout_->addWidget(timestamp_);
|
||||
mainLayout_->addLayout(messageLayout_);
|
||||
}
|
||||
|
@ -231,6 +233,7 @@ TimelineItem::setupWidgetLayout(Widget *widget,
|
|||
messageLayout_->addLayout(widgetLayout, 1);
|
||||
}
|
||||
|
||||
messageLayout_->addWidget(checkmark_);
|
||||
messageLayout_->addWidget(timestamp_);
|
||||
mainLayout_->addLayout(messageLayout_);
|
||||
}
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
#include "timeline/widgets/ImageItem.h"
|
||||
#include "timeline/widgets/VideoItem.h"
|
||||
|
||||
constexpr const static char *CHECKMARK = "✓";
|
||||
|
||||
void
|
||||
TimelineItem::init()
|
||||
{
|
||||
|
@ -61,6 +63,15 @@ TimelineItem::init()
|
|||
|
||||
mainLayout_->setContentsMargins(conf::timeline::headerLeftMargin, 0, 0, 0);
|
||||
mainLayout_->setSpacing(0);
|
||||
|
||||
QFont checkmarkFont;
|
||||
checkmarkFont.setPixelSize(conf::timeline::fonts::timestamp);
|
||||
|
||||
// Setting fixed width for checkmark because systems may have a differing width for a
|
||||
// space and the Unicode checkmark.
|
||||
checkmark_ = new QLabel(" ", this);
|
||||
checkmark_->setFont(checkmarkFont);
|
||||
checkmark_->setFixedWidth(QFontMetrics{checkmarkFont}.width(CHECKMARK));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -108,6 +119,7 @@ TimelineItem::TimelineItem(mtx::events::MessageType ty,
|
|||
messageLayout_->addWidget(body_, 1);
|
||||
}
|
||||
|
||||
messageLayout_->addWidget(checkmark_);
|
||||
messageLayout_->addWidget(timestamp_);
|
||||
mainLayout_->addLayout(messageLayout_);
|
||||
}
|
||||
|
@ -239,6 +251,7 @@ TimelineItem::TimelineItem(const mtx::events::RoomEvent<mtx::events::msg::Notice
|
|||
messageLayout_->addWidget(body_, 1);
|
||||
}
|
||||
|
||||
messageLayout_->addWidget(checkmark_);
|
||||
messageLayout_->addWidget(timestamp_);
|
||||
mainLayout_->addLayout(messageLayout_);
|
||||
}
|
||||
|
@ -285,6 +298,7 @@ TimelineItem::TimelineItem(const mtx::events::RoomEvent<mtx::events::msg::Emote>
|
|||
messageLayout_->addWidget(body_, 1);
|
||||
}
|
||||
|
||||
messageLayout_->addWidget(checkmark_);
|
||||
messageLayout_->addWidget(timestamp_);
|
||||
mainLayout_->addLayout(messageLayout_);
|
||||
}
|
||||
|
@ -336,6 +350,7 @@ TimelineItem::TimelineItem(const mtx::events::RoomEvent<mtx::events::msg::Text>
|
|||
messageLayout_->addWidget(body_, 1);
|
||||
}
|
||||
|
||||
messageLayout_->addWidget(checkmark_);
|
||||
messageLayout_->addWidget(timestamp_);
|
||||
mainLayout_->addLayout(messageLayout_);
|
||||
}
|
||||
|
@ -343,11 +358,8 @@ TimelineItem::TimelineItem(const mtx::events::RoomEvent<mtx::events::msg::Text>
|
|||
void
|
||||
TimelineItem::markReceived()
|
||||
{
|
||||
auto checkmark = new QLabel("✓", this);
|
||||
checkmark->setStyleSheet(QString("font-size: %1px;").arg(conf::timeline::fonts::timestamp));
|
||||
checkmark->setAlignment(Qt::AlignTop);
|
||||
|
||||
messageLayout_->insertWidget(1, checkmark);
|
||||
checkmark_->setText(CHECKMARK);
|
||||
checkmark_->setAlignment(Qt::AlignTop);
|
||||
}
|
||||
|
||||
// Only the body is displayed.
|
||||
|
|
Loading…
Reference in a new issue