Compare commits

...

4 commits

Author SHA1 Message Date
Loren Burkholder
f6fb1b0fe1
Merge c7e1c554bb into 1a00d91316 2024-11-03 21:47:40 +00:00
DeepBlueV7.X
1a00d91316
Merge pull request #1833 from Integral-Tech/refactor-string-conversion
refactor: use fmt lib to avoid back-and-forth conversion
2024-10-30 01:10:07 +00:00
Integral
b7a5d714c6
refactor: use fmt lib to avoid back-and-forth conversion 2024-10-19 16:49:12 +08:00
Loren Burkholder
c7e1c554bb
Use a better spoiler display method
I've taken this method from how Neochat implements spoilers. The
only downside is that all spoilers are displayed and hidden at the
same time; however, it solves the mobile problem.
2024-01-17 08:25:17 -05:00
2 changed files with 13 additions and 6 deletions

View file

@ -2,6 +2,7 @@
//
// SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick
import ".."
import im.nheko
@ -15,6 +16,7 @@ MatrixText {
property string copyText: selectedText ? getText(selectionStart, selectionEnd) : body
property int metadataWidth: 100
property bool fitsMetadata: false //positionAt(width,height-4) == positionAt(width-metadataWidth-10, height-4)
property bool showSpoilers: false
// table border-collapse doesn't seem to work
text: `
@ -33,11 +35,12 @@ MatrixText {
padding: ` + Math.ceil(fontMetrics.lineSpacing/2) + `px;
}
blockquote { margin-left: 1em; }
` + (!Settings.mobileMode ? `span[data-mx-spoiler] {
span[data-mx-spoiler] {` + (!showSpoilers ? `
color: transparent;
background-color: ` + palette.text + `;
}` : "") + // TODO(Nico): Figure out how to support mobile
`</style>
background-color: ` + palette.text + `;` : `
background-color: ` + palette.alternateBase + ';') + `
}
</style>
` + formatted.replace(/<del>/g, "<s>").replace(/<\/del>/g, "</s>").replace(/<strike>/g, "<s>").replace(/<\/strike>/g, "</s>")
enabled: !isReply
@ -49,4 +52,7 @@ MatrixText {
cursorShape: Qt.PointingHandCursor
}
TapHandler {
onTapped: showSpoilers = !showSpoilers
}
}

View file

@ -20,6 +20,8 @@
#include <QVideoFrame>
#include <QVideoSink>
#include <fmt/format.h>
#include <nlohmann/json.hpp>
#include <mtx/responses/common.hpp>
@ -578,8 +580,7 @@ InputBar::message(const QString &msg, MarkdownOverride useMarkdown, bool rainbow
}
}
text.body =
QStringLiteral("%1\n%2").arg(body, QString::fromStdString(text.body)).toStdString();
text.body = fmt::format("{}\n{}", body.toStdString(), text.body);
// NOTE(Nico): rich replies always need a formatted_body!
text.format = "org.matrix.custom.html";