Allow highlights to be excluded from /mentions (#2036)

This commit is contained in:
Leon Richardt
2020-10-24 14:33:15 +02:00
committed by GitHub
parent 0049a5ebb2
commit ec94869480
12 changed files with 99 additions and 40 deletions
+20 -1
View File
@@ -9,7 +9,7 @@ namespace chatterino {
// commandmodel
HighlightModel::HighlightModel(QObject *parent)
: SignalVectorModel<HighlightPhrase>(7, parent)
: SignalVectorModel<HighlightPhrase>(Column::COUNT, parent)
{
}
@@ -25,6 +25,7 @@ HighlightPhrase HighlightModel::getItemFromRow(
return HighlightPhrase{
row[Column::Pattern]->data(Qt::DisplayRole).toString(),
row[Column::ShowInMentions]->data(Qt::DisplayRole).toBool(),
row[Column::FlashTaskbar]->data(Qt::CheckStateRole).toBool(),
row[Column::PlaySound]->data(Qt::CheckStateRole).toBool(),
row[Column::UseRegex]->data(Qt::CheckStateRole).toBool(),
@@ -38,6 +39,7 @@ void HighlightModel::getRowFromItem(const HighlightPhrase &item,
std::vector<QStandardItem *> &row)
{
setStringItem(row[Column::Pattern], item.getPattern());
setBoolItem(row[Column::ShowInMentions], item.showInMentions());
setBoolItem(row[Column::FlashTaskbar], item.hasAlert());
setBoolItem(row[Column::PlaySound], item.hasSound());
setBoolItem(row[Column::UseRegex], item.isRegex());
@@ -54,6 +56,9 @@ void HighlightModel::afterInit()
getSettings()->enableSelfHighlight.getValue(), true, false);
usernameRow[Column::Pattern]->setData("Your username (automatic)",
Qt::DisplayRole);
setBoolItem(usernameRow[Column::ShowInMentions],
getSettings()->showSelfHighlightInMentions.getValue(), true,
false);
setBoolItem(usernameRow[Column::FlashTaskbar],
getSettings()->enableSelfHighlightTaskbar.getValue(), true,
false);
@@ -76,6 +81,7 @@ void HighlightModel::afterInit()
setBoolItem(whisperRow[Column::Pattern],
getSettings()->enableWhisperHighlight.getValue(), true, false);
whisperRow[Column::Pattern]->setData("Whispers", Qt::DisplayRole);
whisperRow[Column::ShowInMentions]->setFlags(0); // We have /whispers
setBoolItem(whisperRow[Column::FlashTaskbar],
getSettings()->enableWhisperHighlightTaskbar.getValue(), true,
false);
@@ -100,6 +106,7 @@ void HighlightModel::afterInit()
setBoolItem(subRow[Column::Pattern],
getSettings()->enableSubHighlight.getValue(), true, false);
subRow[Column::Pattern]->setData("Subscriptions", Qt::DisplayRole);
subRow[Column::ShowInMentions]->setFlags(0);
setBoolItem(subRow[Column::FlashTaskbar],
getSettings()->enableSubHighlightTaskbar.getValue(), true,
false);
@@ -122,6 +129,7 @@ void HighlightModel::afterInit()
getSettings()->enableRedeemedHighlight.getValue(), true, false);
redeemedRow[Column::Pattern]->setData(
"Highlights redeemed with Channel Points", Qt::DisplayRole);
redeemedRow[Column::ShowInMentions]->setFlags(0);
// setBoolItem(redeemedRow[Column::FlashTaskbar],
// getSettings()->enableRedeemedHighlightTaskbar.getValue(), true,
// false);
@@ -174,6 +182,17 @@ void HighlightModel::customRowSetData(const std::vector<QStandardItem *> &row,
}
}
break;
case Column::ShowInMentions: {
if (role == Qt::CheckStateRole)
{
if (rowIndex == 0)
{
getSettings()->showSelfHighlightInMentions.setValue(
value.toBool());
}
}
}
break;
case Column::FlashTaskbar: {
if (role == Qt::CheckStateRole)
{