Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a better spoiler display method #1662

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions resources/qml/delegates/TextMessage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//
// SPDX-License-Identifier: GPL-3.0-or-later

import QtQuick
import ".."
import im.nheko

Expand All @@ -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: `
Expand All @@ -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 + ';') + `
Comment on lines +40 to +41
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you setting the background twice?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not. That's a ternary operator statement.

}
</style>
` + formatted.replace(/<del>/g, "<s>").replace(/<\/del>/g, "</s>").replace(/<strike>/g, "<s>").replace(/<\/strike>/g, "</s>")

enabled: !isReply
Expand All @@ -49,4 +52,7 @@ MatrixText {
cursorShape: Qt.PointingHandCursor
}

TapHandler {
onTapped: showSpoilers = !showSpoilers
}
}