Use longer rainbow while executing "/rainbow".

This commit is contained in:
Black Hat 2018-08-06 05:00:06 +08:00
parent 6f8cd14e38
commit 640e3712a2
2 changed files with 8 additions and 7 deletions

View File

@ -269,9 +269,9 @@ Item {
text = text.substr(PREFIX_RAINBOW.length)
var parsedText = ""
var rainbowColor = ["#ee0000", "#ff7700", "#eeee00", "#00bb00", "#0000ee", "#dd00dd", "#880088"]
var rainbowColor = ["#ff2b00", "#ff5500", "#ff8000", "#ffaa00", "#ffd500", "#ffff00", "#d4ff00", "#aaff00", "#80ff00", "#55ff00", "#2bff00", "#00ff00", "#00ff2b", "#00ff55", "#00ff80", "#00ffaa", "#00ffd5", "#00ffff", "#00d4ff", "#00aaff", "#007fff", "#0055ff", "#002bff", "#0000ff", "#2a00ff", "#5500ff", "#7f00ff", "#aa00ff", "#d400ff", "#ff00ff", "#ff00d4", "#ff00aa", "#ff0080", "#ff0055", "#ff002b", "#ff0000"]
for (var i = 0; i < text.length; i++) {
parsedText = parsedText + "<font color='" + rainbowColor[i % 7] + "'>" + text.charAt(i) + "</font>"
parsedText = parsedText + "<font color='" + rainbowColor[i % rainbowColor.length] + "'>" + text.charAt(i) + "</font>"
}
currentRoom.postHtmlMessage(text, parsedText, RoomMessageEvent.Text)
return

View File

@ -338,8 +338,7 @@ QVariant MessageEventModel::data(const QModelIndex& idx, int role) const {
if (e.hasFileContent()) {
auto fileCaption = e.content()->fileInfo()->originalName;
if (fileCaption.isEmpty())
fileCaption = e.plainBody();
if (fileCaption.isEmpty()) fileCaption = e.plainBody();
if (fileCaption.isEmpty()) return tr("a file");
}
return e.plainBody();
@ -423,7 +422,6 @@ QVariant MessageEventModel::data(const QModelIndex& idx, int role) const {
tr("Unknown Event"));
}
if (role == Qt::ToolTipRole) {
return evt.originalJson();
}
@ -515,11 +513,14 @@ QVariant MessageEventModel::data(const QModelIndex& idx, int role) const {
return role == TimeRole ? QVariant(ts) : renderDate(ts);
}
if (role == AboveSectionRole || role == AboveAuthorRole || role == AboveTimeRole)
if (role == AboveSectionRole || role == AboveAuthorRole ||
role == AboveTimeRole)
for (auto r = row + 1; r < rowCount(); ++r) {
auto i = index(r);
if (data(i, SpecialMarksRole) != EventStatus::Hidden)
return data(i, role == AboveSectionRole ? SectionRole : role == AboveAuthorRole ? AuthorRole : TimeRole);
return data(i, role == AboveSectionRole
? SectionRole
: role == AboveAuthorRole ? AuthorRole : TimeRole);
}
return {};