Add showInMentions option for Badge Highlights (#4034)
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -9,7 +9,7 @@ namespace chatterino {
|
||||
|
||||
// commandmodel
|
||||
BadgeHighlightModel::BadgeHighlightModel(QObject *parent)
|
||||
: SignalVectorModel<HighlightBadge>(5, parent)
|
||||
: SignalVectorModel<HighlightBadge>(6, parent)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ HighlightBadge BadgeHighlightModel::getItemFromRow(
|
||||
return HighlightBadge{
|
||||
original.badgeName(),
|
||||
row[Column::Badge]->data(Qt::DisplayRole).toString(),
|
||||
row[Column::ShowInMentions]->data(Qt::CheckStateRole).toBool(),
|
||||
row[Column::FlashTaskbar]->data(Qt::CheckStateRole).toBool(),
|
||||
row[Column::PlaySound]->data(Qt::CheckStateRole).toBool(),
|
||||
row[Column::SoundPath]->data(Qt::UserRole).toString(),
|
||||
@@ -42,6 +43,7 @@ void BadgeHighlightModel::getRowFromItem(const HighlightBadge &item,
|
||||
using Column = BadgeHighlightModel::Column;
|
||||
|
||||
setStringItem(row[Column::Badge], item.displayName(), false, true);
|
||||
setBoolItem(row[Column::ShowInMentions], item.showInMentions());
|
||||
setBoolItem(row[Column::FlashTaskbar], item.hasAlert());
|
||||
setBoolItem(row[Column::PlaySound], item.hasSound());
|
||||
setFilePathItem(row[Column::SoundPath], item.getSoundUrl());
|
||||
|
||||
@@ -17,10 +17,11 @@ public:
|
||||
|
||||
enum Column {
|
||||
Badge = 0,
|
||||
FlashTaskbar = 1,
|
||||
PlaySound = 2,
|
||||
SoundPath = 3,
|
||||
Color = 4
|
||||
ShowInMentions = 1,
|
||||
FlashTaskbar = 2,
|
||||
PlaySound = 3,
|
||||
SoundPath = 4,
|
||||
Color = 5
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
@@ -9,27 +9,31 @@ QColor HighlightBadge::FALLBACK_HIGHLIGHT_COLOR = QColor(127, 63, 73, 127);
|
||||
|
||||
bool HighlightBadge::operator==(const HighlightBadge &other) const
|
||||
{
|
||||
return std::tie(this->badgeName_, this->displayName_, this->hasSound_,
|
||||
this->hasAlert_, this->soundUrl_, this->color_) ==
|
||||
std::tie(other.badgeName_, other.displayName_, other.hasSound_,
|
||||
other.hasAlert_, other.soundUrl_, other.color_);
|
||||
return std::tie(this->badgeName_, this->displayName_, this->showInMentions_,
|
||||
this->hasSound_, this->hasAlert_, this->soundUrl_,
|
||||
this->color_) ==
|
||||
std::tie(other.badgeName_, other.displayName_, other.showInMentions_,
|
||||
other.hasSound_, other.hasAlert_, other.soundUrl_,
|
||||
other.color_);
|
||||
}
|
||||
|
||||
HighlightBadge::HighlightBadge(const QString &badgeName,
|
||||
const QString &displayName, bool hasAlert,
|
||||
bool hasSound, const QString &soundUrl,
|
||||
QColor color)
|
||||
: HighlightBadge(badgeName, displayName, hasAlert, hasSound, soundUrl,
|
||||
std::make_shared<QColor>(color))
|
||||
const QString &displayName, bool showInMentions,
|
||||
bool hasAlert, bool hasSound,
|
||||
const QString &soundUrl, QColor color)
|
||||
: HighlightBadge(badgeName, displayName, showInMentions, hasAlert, hasSound,
|
||||
soundUrl, std::make_shared<QColor>(color))
|
||||
{
|
||||
}
|
||||
|
||||
HighlightBadge::HighlightBadge(const QString &badgeName,
|
||||
const QString &displayName, bool hasAlert,
|
||||
bool hasSound, const QString &soundUrl,
|
||||
const QString &displayName, bool showInMentions,
|
||||
bool hasAlert, bool hasSound,
|
||||
const QString &soundUrl,
|
||||
std::shared_ptr<QColor> color)
|
||||
: badgeName_(badgeName)
|
||||
, displayName_(displayName)
|
||||
, showInMentions_(showInMentions)
|
||||
, hasAlert_(hasAlert)
|
||||
, hasSound_(hasSound)
|
||||
, soundUrl_(soundUrl)
|
||||
@@ -54,6 +58,11 @@ const QString &HighlightBadge::displayName() const
|
||||
return this->displayName_;
|
||||
}
|
||||
|
||||
bool HighlightBadge::showInMentions() const
|
||||
{
|
||||
return this->showInMentions_;
|
||||
}
|
||||
|
||||
bool HighlightBadge::hasAlert() const
|
||||
{
|
||||
return this->hasAlert_;
|
||||
|
||||
@@ -15,15 +15,16 @@ public:
|
||||
bool operator==(const HighlightBadge &other) const;
|
||||
|
||||
HighlightBadge(const QString &badgeName, const QString &displayName,
|
||||
bool hasAlert, bool hasSound, const QString &soundUrl,
|
||||
QColor color);
|
||||
bool showInMentions, bool hasAlert, bool hasSound,
|
||||
const QString &soundUrl, QColor color);
|
||||
|
||||
HighlightBadge(const QString &badgeName, const QString &displayName,
|
||||
bool hasAlert, bool hasSound, const QString &soundUrl,
|
||||
std::shared_ptr<QColor> color);
|
||||
bool showInMentions, bool hasAlert, bool hasSound,
|
||||
const QString &soundUrl, std::shared_ptr<QColor> color);
|
||||
|
||||
const QString &badgeName() const;
|
||||
const QString &displayName() const;
|
||||
bool showInMentions() const;
|
||||
bool hasAlert() const;
|
||||
bool hasSound() const;
|
||||
bool isMatch(const Badge &badge) const;
|
||||
@@ -53,6 +54,7 @@ private:
|
||||
|
||||
QString badgeName_;
|
||||
QString displayName_;
|
||||
bool showInMentions_;
|
||||
bool hasAlert_;
|
||||
bool hasSound_;
|
||||
QUrl soundUrl_;
|
||||
@@ -75,6 +77,7 @@ struct Serialize<chatterino::HighlightBadge> {
|
||||
|
||||
chatterino::rj::set(ret, "name", value.badgeName(), a);
|
||||
chatterino::rj::set(ret, "displayName", value.displayName(), a);
|
||||
chatterino::rj::set(ret, "showInMentions", value.showInMentions(), a);
|
||||
chatterino::rj::set(ret, "alert", value.hasAlert(), a);
|
||||
chatterino::rj::set(ret, "sound", value.hasSound(), a);
|
||||
chatterino::rj::set(ret, "soundUrl", value.getSoundUrl().toString(), a);
|
||||
@@ -94,11 +97,12 @@ struct Deserialize<chatterino::HighlightBadge> {
|
||||
{
|
||||
PAJLADA_REPORT_ERROR(error);
|
||||
return chatterino::HighlightBadge(QString(), QString(), false,
|
||||
false, "", QColor());
|
||||
false, false, "", QColor());
|
||||
}
|
||||
|
||||
QString _name;
|
||||
QString _displayName;
|
||||
bool _showInMentions = false;
|
||||
bool _hasAlert = true;
|
||||
bool _hasSound = false;
|
||||
QString _soundUrl;
|
||||
@@ -106,6 +110,7 @@ struct Deserialize<chatterino::HighlightBadge> {
|
||||
|
||||
chatterino::rj::getSafe(value, "name", _name);
|
||||
chatterino::rj::getSafe(value, "displayName", _displayName);
|
||||
chatterino::rj::getSafe(value, "showInMentions", _showInMentions);
|
||||
chatterino::rj::getSafe(value, "alert", _hasAlert);
|
||||
chatterino::rj::getSafe(value, "sound", _hasSound);
|
||||
chatterino::rj::getSafe(value, "soundUrl", _soundUrl);
|
||||
@@ -115,8 +120,9 @@ struct Deserialize<chatterino::HighlightBadge> {
|
||||
if (!_color.isValid())
|
||||
_color = chatterino::HighlightBadge::FALLBACK_HIGHLIGHT_COLOR;
|
||||
|
||||
return chatterino::HighlightBadge(_name, _displayName, _hasAlert,
|
||||
_hasSound, _soundUrl, _color);
|
||||
return chatterino::HighlightBadge(_name, _displayName, _showInMentions,
|
||||
_hasAlert, _hasSound, _soundUrl,
|
||||
_color);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -181,9 +181,11 @@ void rebuildUserHighlights(Settings &settings,
|
||||
}
|
||||
|
||||
return HighlightResult{
|
||||
highlight.hasAlert(), highlight.hasSound(),
|
||||
highlightSoundUrl, highlight.getColor(),
|
||||
highlight.showInMentions(),
|
||||
highlight.hasAlert(), //
|
||||
highlight.hasSound(), //
|
||||
highlightSoundUrl, //
|
||||
highlight.getColor(), //
|
||||
highlight.showInMentions(), //
|
||||
};
|
||||
}});
|
||||
}
|
||||
@@ -216,11 +218,11 @@ void rebuildBadgeHighlights(Settings &settings,
|
||||
}
|
||||
|
||||
return HighlightResult{
|
||||
highlight.hasAlert(),
|
||||
highlight.hasSound(),
|
||||
highlightSoundUrl,
|
||||
highlight.getColor(),
|
||||
false, // showInMentions
|
||||
highlight.hasAlert(), //
|
||||
highlight.hasSound(), //
|
||||
highlightSoundUrl, //
|
||||
highlight.getColor(), //
|
||||
highlight.showInMentions(), //
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user