diff options
author | Loren Burkholder <computersemiexpert@outlook.com> | 2024-01-17 08:25:07 -0500 |
---|---|---|
committer | Loren Burkholder <computersemiexpert@outlook.com> | 2024-01-17 08:25:17 -0500 |
commit | c7e1c554bb62d4c51bbf17faef49f4beb3e1c8b9 (patch) | |
tree | e0d639c7a3d60fad29335f7b21e37674a6504625 | |
parent | 8ca0f61cadcf469264c05792b3d7d5dd8c252ee9 (diff) |
Use a better spoiler display methodspoilers
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.
-rw-r--r-- | resources/qml/delegates/TextMessage.qml | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/resources/qml/delegates/TextMessage.qml b/resources/qml/delegates/TextMessage.qml index 3625aea1..91047e2c 100644 --- a/resources/qml/delegates/TextMessage.qml +++ b/resources/qml/delegates/TextMessage.qml @@ -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 + } } |