Added spoiler support to system notifications.
This commit is contained in:
parent
baca36e715
commit
938aa5d577
|
@ -47,6 +47,32 @@ constexpr auto kSystemAlertDuration = crl::time(1000);
|
||||||
constexpr auto kSystemAlertDuration = crl::time(0);
|
constexpr auto kSystemAlertDuration = crl::time(0);
|
||||||
#endif // Q_OS_MAC
|
#endif // Q_OS_MAC
|
||||||
|
|
||||||
|
QString TextWithPermanentSpoiler(QString textWithCommands) {
|
||||||
|
const auto start = textcmdStartSpoiler();
|
||||||
|
const auto stop = textcmdStopSpoiler();
|
||||||
|
while (true) {
|
||||||
|
const auto startIndex = textWithCommands.indexOf(start);
|
||||||
|
if (startIndex == -1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
const auto stopIndex = textWithCommands.indexOf(stop);
|
||||||
|
if (stopIndex == -1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (stopIndex < startIndex) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
const auto length = stopIndex - startIndex - start.size();
|
||||||
|
textWithCommands.remove(stopIndex, stop.size());
|
||||||
|
textWithCommands.remove(startIndex, start.size());
|
||||||
|
textWithCommands.replace(
|
||||||
|
startIndex,
|
||||||
|
length,
|
||||||
|
QString(QChar(0x259A)).repeated(length));
|
||||||
|
}
|
||||||
|
return textWithCommands;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
System::System()
|
System::System()
|
||||||
|
@ -739,7 +765,7 @@ void NativeManager::doShowNotification(
|
||||||
: (forwardedCount < 2
|
: (forwardedCount < 2
|
||||||
? (item->groupId()
|
? (item->groupId()
|
||||||
? tr::lng_in_dlg_album(tr::now)
|
? tr::lng_in_dlg_album(tr::now)
|
||||||
: item->notificationText())
|
: TextWithPermanentSpoiler(item->notificationText()))
|
||||||
: tr::lng_forward_messages(tr::now, lt_count, forwardedCount));
|
: tr::lng_forward_messages(tr::now, lt_count, forwardedCount));
|
||||||
|
|
||||||
// #TODO optimize
|
// #TODO optimize
|
||||||
|
|
Loading…
Reference in New Issue