mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-23 03:18:49 +03:00
Fix bug with emoji font setting and clean linting
This commit is contained in:
parent
778921be8a
commit
86888ee713
8 changed files with 42 additions and 41 deletions
|
@ -159,7 +159,8 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
|
||||||
1000,
|
1000,
|
||||||
"",
|
"",
|
||||||
"highlight",
|
"highlight",
|
||||||
[this, mentionsPos](const mtx::responses::Notifications &res, mtx::http::RequestErr err) {
|
[this, mentionsPos](const mtx::responses::Notifications &res,
|
||||||
|
mtx::http::RequestErr err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
nhlog::net()->warn("failed to retrieve notifications: {} ({})",
|
nhlog::net()->warn("failed to retrieve notifications: {} ({})",
|
||||||
err->matrix_error.error,
|
err->matrix_error.error,
|
||||||
|
@ -218,8 +219,6 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
connect(room_list_, &RoomList::roomChanged, this, [this](const QString &roomid) {
|
connect(room_list_, &RoomList::roomChanged, this, [this](const QString &roomid) {
|
||||||
QStringList users;
|
QStringList users;
|
||||||
|
|
||||||
|
@ -1007,7 +1006,8 @@ ChatPage::showNotificationsDialog(const mtx::responses::Notifications &res, cons
|
||||||
nhlog::db()->warn("error while sending desktop notification: {}", e.what());
|
nhlog::db()->warn("error while sending desktop notification: {}", e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
notifDialog->setGeometry(widgetPos.x() - (width() / 10), widgetPos.y() + 25, width() / 5, height() / 2);
|
notifDialog->setGeometry(
|
||||||
|
widgetPos.x() - (width() / 10), widgetPos.y() + 25, width() / 5, height() / 2);
|
||||||
// notifDialog->move(widgetPos.x(), widgetPos.y());
|
// notifDialog->move(widgetPos.x(), widgetPos.y());
|
||||||
// notifDialog->setFixedWidth(width() / 10);
|
// notifDialog->setFixedWidth(width() / 10);
|
||||||
// notifDialog->setFixedHeight(height() / 2);
|
// notifDialog->setFixedHeight(height() / 2);
|
||||||
|
|
|
@ -89,7 +89,8 @@ signals:
|
||||||
void messageReply(const RelatedInfo &related);
|
void messageReply(const RelatedInfo &related);
|
||||||
|
|
||||||
void notificationsRetrieved(const mtx::responses::Notifications &);
|
void notificationsRetrieved(const mtx::responses::Notifications &);
|
||||||
void highlightedNotifsRetrieved(const mtx::responses::Notifications &, const QPoint widgetPos);
|
void highlightedNotifsRetrieved(const mtx::responses::Notifications &,
|
||||||
|
const QPoint widgetPos);
|
||||||
|
|
||||||
void uploadFailed(const QString &msg);
|
void uploadFailed(const QString &msg);
|
||||||
void imageUploaded(const QString &roomid,
|
void imageUploaded(const QString &roomid,
|
||||||
|
|
|
@ -96,7 +96,6 @@ public:
|
||||||
QString font() const { return font_; }
|
QString font() const { return font_; }
|
||||||
QString emojiFont() const { return emojiFont_; }
|
QString emojiFont() const { return emojiFont_; }
|
||||||
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void groupViewStateChanged(bool state);
|
void groupViewStateChanged(bool state);
|
||||||
|
|
||||||
|
@ -111,7 +110,6 @@ private:
|
||||||
double baseFontSize_;
|
double baseFontSize_;
|
||||||
QString font_;
|
QString font_;
|
||||||
QString emojiFont_;
|
QString emojiFont_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class HorizontalLine : public QFrame
|
class HorizontalLine : public QFrame
|
||||||
|
|
|
@ -26,6 +26,29 @@ utils::localUser()
|
||||||
return settings.value("auth/user_id").toString();
|
return settings.value("auth/user_id").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
utils::replaceEmoji(const QString &body)
|
||||||
|
{
|
||||||
|
QString fmtBody = "";
|
||||||
|
|
||||||
|
QVector<uint> utf32_string = body.toUcs4();
|
||||||
|
|
||||||
|
QSettings settings;
|
||||||
|
QString userFontFamily = settings.value("user/emoji_font_family", "emoji").toString();
|
||||||
|
|
||||||
|
for (auto &code : utf32_string) {
|
||||||
|
// TODO: Be more precise here.
|
||||||
|
if (code > 9000)
|
||||||
|
fmtBody +=
|
||||||
|
QString("<span style=\"font-family: " + userFontFamily + ";\">") +
|
||||||
|
QString::fromUcs4(&code, 1) + "</span>";
|
||||||
|
else
|
||||||
|
fmtBody += QString::fromUcs4(&code, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmtBody;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
utils::setScaleFactor(float factor)
|
utils::setScaleFactor(float factor)
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,6 +34,9 @@ namespace utils {
|
||||||
|
|
||||||
using TimelineEvent = mtx::events::collections::TimelineEvents;
|
using TimelineEvent = mtx::events::collections::TimelineEvents;
|
||||||
|
|
||||||
|
QString
|
||||||
|
replaceEmoji(const QString &body);
|
||||||
|
|
||||||
QString
|
QString
|
||||||
localUser();
|
localUser();
|
||||||
|
|
||||||
|
|
|
@ -650,7 +650,7 @@ TimelineItem::markReceived(bool isEncrypted)
|
||||||
void
|
void
|
||||||
TimelineItem::generateBody(const QString &body)
|
TimelineItem::generateBody(const QString &body)
|
||||||
{
|
{
|
||||||
body_ = new TextLabel(replaceEmoji(body), this);
|
body_ = new TextLabel(utils::replaceEmoji(body), this);
|
||||||
body_->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextBrowserInteraction);
|
body_->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextBrowserInteraction);
|
||||||
|
|
||||||
connect(body_, &TextLabel::userProfileTriggered, this, [](const QString &user_id) {
|
connect(body_, &TextLabel::userProfileTriggered, this, [](const QString &user_id) {
|
||||||
|
@ -727,7 +727,7 @@ TimelineItem::generateUserName(const QString &user_id, const QString &displaynam
|
||||||
|
|
||||||
userName_ = new QLabel(this);
|
userName_ = new QLabel(this);
|
||||||
userName_->setFont(usernameFont);
|
userName_->setFont(usernameFont);
|
||||||
userName_->setText(replaceEmoji(fm.elidedText(sender, Qt::ElideRight, 500)));
|
userName_->setText(utils::replaceEmoji(fm.elidedText(sender, Qt::ElideRight, 500)));
|
||||||
userName_->setToolTip(user_id);
|
userName_->setToolTip(user_id);
|
||||||
userName_->setToolTipDuration(1500);
|
userName_->setToolTipDuration(1500);
|
||||||
userName_->setAttribute(Qt::WA_Hover);
|
userName_->setAttribute(Qt::WA_Hover);
|
||||||
|
@ -773,29 +773,6 @@ TimelineItem::generateTimestamp(const QDateTime &time)
|
||||||
QString("<span style=\"color: #999\"> %1 </span>").arg(time.toString("HH:mm")));
|
QString("<span style=\"color: #999\"> %1 </span>").arg(time.toString("HH:mm")));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString
|
|
||||||
TimelineItem::replaceEmoji(const QString &body)
|
|
||||||
{
|
|
||||||
QString fmtBody = "";
|
|
||||||
|
|
||||||
QVector<uint> utf32_string = body.toUcs4();
|
|
||||||
|
|
||||||
QSettings settings;
|
|
||||||
QString userFontFamily = settings.value("user/emoji_font_family", "emoji").toString();
|
|
||||||
|
|
||||||
for (auto &code : utf32_string) {
|
|
||||||
// TODO: Be more precise here.
|
|
||||||
if (code > 9000)
|
|
||||||
fmtBody +=
|
|
||||||
QString("<span style=\"font-family: " + userFontFamily + ";\">") +
|
|
||||||
QString::fromUcs4(&code, 1) + "</span>";
|
|
||||||
else
|
|
||||||
fmtBody += QString::fromUcs4(&code, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return fmtBody;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TimelineItem::setupAvatarLayout(const QString &userName)
|
TimelineItem::setupAvatarLayout(const QString &userName)
|
||||||
{
|
{
|
||||||
|
|
|
@ -276,7 +276,6 @@ private:
|
||||||
|
|
||||||
QFutureWatcher<QString> *colorGenerating_;
|
QFutureWatcher<QString> *colorGenerating_;
|
||||||
|
|
||||||
QString replaceEmoji(const QString &body);
|
|
||||||
QString event_id_;
|
QString event_id_;
|
||||||
mtx::events::MessageType message_type_;
|
mtx::events::MessageType message_type_;
|
||||||
QString room_id_;
|
QString room_id_;
|
||||||
|
|
Loading…
Reference in a new issue