Added option to highlight your own messages (#3833)
* Removed magic numbers when checking rowIndex * Swap from static ints to enum * Referred enum members by enum name * Fixed formatting * Added highlight option for self messages * Update CHANGELOG.md * Made disabled by default * Moved setting from Messages tab to Users tab * Moved checks to HighlightController * Set row index to 0 sillE silly me * Update CHANGELOG.md * Moved check outside of loop * Improved naming and documentation on variables * Fixed formatting * Fix compile errors * Update ColorProvider self message highlight color when it's changed Use the ColorProvider self message highlight color instead of rolling our own non-updating color * Update changelog entry * Remove unused `customColor` from user highlights builder * Use explicit lambda capture * Update comment for the color provider color * HighlightModelHpp: Future-proof custom row enum B) * Document UserHighlightModel color changes * Update colorprovider comment * Update enabled, show in mentions & color setting paths * Rename settings from `selfMessagesHighlight` to `selfMessageHighlight` --------- Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -3,7 +3,9 @@
|
||||
#include "Application.hpp"
|
||||
#include "controllers/highlights/HighlightModel.hpp"
|
||||
#include "controllers/highlights/HighlightPhrase.hpp"
|
||||
#include "providers/colors/ColorProvider.hpp"
|
||||
#include "singletons/Settings.hpp"
|
||||
#include "singletons/WindowManager.hpp"
|
||||
#include "util/StandardItemHelper.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
@@ -37,6 +39,86 @@ HighlightPhrase UserHighlightModel::getItemFromRow(
|
||||
highlightColor};
|
||||
}
|
||||
|
||||
void UserHighlightModel::afterInit()
|
||||
{
|
||||
// User highlight settings for your own messages
|
||||
std::vector<QStandardItem *> messagesRow = this->createRow();
|
||||
setBoolItem(messagesRow[Column::Pattern],
|
||||
getSettings()->enableSelfMessageHighlight.getValue(), true,
|
||||
false);
|
||||
messagesRow[Column::Pattern]->setData("Your messages (automatic)",
|
||||
Qt::DisplayRole);
|
||||
setBoolItem(messagesRow[Column::ShowInMentions],
|
||||
getSettings()->showSelfMessageHighlightInMentions.getValue(),
|
||||
true, false);
|
||||
messagesRow[Column::FlashTaskbar]->setFlags({});
|
||||
messagesRow[Column::PlaySound]->setFlags({});
|
||||
messagesRow[Column::UseRegex]->setFlags({});
|
||||
messagesRow[Column::CaseSensitive]->setFlags({});
|
||||
messagesRow[Column::SoundPath]->setFlags({});
|
||||
|
||||
auto selfColor =
|
||||
ColorProvider::instance().color(ColorType::SelfMessageHighlight);
|
||||
setColorItem(messagesRow[Column::Color], *selfColor, false);
|
||||
|
||||
this->insertCustomRow(
|
||||
messagesRow, HighlightModel::UserHighlightRowIndexes::SelfMessageRow);
|
||||
}
|
||||
|
||||
void UserHighlightModel::customRowSetData(
|
||||
const std::vector<QStandardItem *> &row, int column, const QVariant &value,
|
||||
int role, int rowIndex)
|
||||
{
|
||||
switch (column)
|
||||
{
|
||||
case Column::Pattern: {
|
||||
if (role == Qt::CheckStateRole)
|
||||
{
|
||||
if (rowIndex ==
|
||||
HighlightModel::UserHighlightRowIndexes::SelfMessageRow)
|
||||
{
|
||||
getSettings()->enableSelfMessageHighlight.setValue(
|
||||
value.toBool());
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Column::ShowInMentions: {
|
||||
if (role == Qt::CheckStateRole)
|
||||
{
|
||||
if (rowIndex ==
|
||||
HighlightModel::UserHighlightRowIndexes::SelfMessageRow)
|
||||
{
|
||||
getSettings()->showSelfMessageHighlightInMentions.setValue(
|
||||
value.toBool());
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Column::Color: {
|
||||
// Custom color
|
||||
if (role == Qt::DecorationRole)
|
||||
{
|
||||
auto colorName = value.value<QColor>().name(QColor::HexArgb);
|
||||
if (rowIndex ==
|
||||
HighlightModel::UserHighlightRowIndexes::SelfMessageRow)
|
||||
{
|
||||
// Update the setting with the new value
|
||||
getSettings()->selfMessageHighlightColor.setValue(
|
||||
colorName);
|
||||
// Update the color provider with the new color to be used for future
|
||||
const_cast<ColorProvider &>(ColorProvider::instance())
|
||||
.updateColor(ColorType::SelfMessageHighlight,
|
||||
QColor(colorName));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
getApp()->windows->forceLayoutChannelViews();
|
||||
}
|
||||
|
||||
// row into vector item
|
||||
void UserHighlightModel::getRowFromItem(const HighlightPhrase &item,
|
||||
std::vector<QStandardItem *> &row)
|
||||
|
||||
Reference in New Issue
Block a user