mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Rework to use controllers
This commit is contained in:
parent
b54c68d746
commit
971326212c
3 changed files with 31 additions and 14 deletions
|
@ -8,7 +8,7 @@ namespace chatterino {
|
||||||
|
|
||||||
// commandmodel
|
// commandmodel
|
||||||
UserHighlightModel::UserHighlightModel(QObject *parent)
|
UserHighlightModel::UserHighlightModel(QObject *parent)
|
||||||
: SignalVectorModel<UserHighlight>(2, parent)
|
: SignalVectorModel<UserHighlight>(4, parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,8 +18,9 @@ UserHighlight UserHighlightModel::getItemFromRow(std::vector<QStandardItem *> &r
|
||||||
{
|
{
|
||||||
// key, regex
|
// key, regex
|
||||||
|
|
||||||
return UserHighlight{row[0]->data(Qt::DisplayRole).toString(),
|
return UserHighlight{
|
||||||
row[1]->data(Qt::CheckStateRole).toBool()};
|
row[0]->data(Qt::DisplayRole).toString(), row[1]->data(Qt::CheckStateRole).toBool(),
|
||||||
|
row[2]->data(Qt::CheckStateRole).toBool(), row[3]->data(Qt::CheckStateRole).toBool()};
|
||||||
}
|
}
|
||||||
|
|
||||||
// row into vector item
|
// row into vector item
|
||||||
|
@ -27,7 +28,9 @@ void UserHighlightModel::getRowFromItem(const UserHighlight &item,
|
||||||
std::vector<QStandardItem *> &row)
|
std::vector<QStandardItem *> &row)
|
||||||
{
|
{
|
||||||
setStringItem(row[0], item.getPattern());
|
setStringItem(row[0], item.getPattern());
|
||||||
setBoolItem(row[1], item.isRegex());
|
setBoolItem(row[1], item.getAlert());
|
||||||
|
setBoolItem(row[2], item.getSound());
|
||||||
|
setBoolItem(row[3], item.isRegex());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -443,6 +443,7 @@ void TwitchMessageBuilder::parseHighlights()
|
||||||
// TODO: This vector should only be rebuilt upon highlights being changed
|
// TODO: This vector should only be rebuilt upon highlights being changed
|
||||||
// fourtf: should be implemented in the HighlightsController
|
// fourtf: should be implemented in the HighlightsController
|
||||||
std::vector<HighlightPhrase> activeHighlights = app->highlights->phrases.getVector();
|
std::vector<HighlightPhrase> activeHighlights = app->highlights->phrases.getVector();
|
||||||
|
std::vector<UserHighlight> userHighlights = app->highlights->highlightedUsers.getVector();
|
||||||
|
|
||||||
if (app->settings->enableHighlightsSelf && currentUsername.size() > 0) {
|
if (app->settings->enableHighlightsSelf && currentUsername.size() > 0) {
|
||||||
HighlightPhrase selfHighlight(currentUsername, app->settings->enableHighlightTaskbar,
|
HighlightPhrase selfHighlight(currentUsername, app->settings->enableHighlightTaskbar,
|
||||||
|
@ -458,14 +459,9 @@ void TwitchMessageBuilder::parseHighlights()
|
||||||
|
|
||||||
if (!app->highlights->blacklistContains(this->ircMessage->nick())) {
|
if (!app->highlights->blacklistContains(this->ircMessage->nick())) {
|
||||||
for (const HighlightPhrase &highlight : activeHighlights) {
|
for (const HighlightPhrase &highlight : activeHighlights) {
|
||||||
if (highlight.isMatch(this->originalMessage) ||
|
if (highlight.isMatch(this->originalMessage)) {
|
||||||
app->highlights->userContains(this->ircMessage->nick())) {
|
Log("Highlight because {} matches {}", this->originalMessage,
|
||||||
if (app->highlights->userContains(this->ircMessage->nick())) {
|
highlight.getPattern());
|
||||||
Log("Highlight because user {} sent a message", this->ircMessage->nick());
|
|
||||||
} else {
|
|
||||||
Log("Highlight because {} matches {}", this->originalMessage,
|
|
||||||
highlight.getPattern());
|
|
||||||
}
|
|
||||||
doHighlight = true;
|
doHighlight = true;
|
||||||
|
|
||||||
if (highlight.getAlert()) {
|
if (highlight.getAlert()) {
|
||||||
|
@ -483,6 +479,24 @@ void TwitchMessageBuilder::parseHighlights()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (const UserHighlight &userHighlight : userHighlights) {
|
||||||
|
if (userHighlight.isMatch(this->ircMessage->nick())) {
|
||||||
|
Log("Highlight because user {} sent a message", this->ircMessage->nick());
|
||||||
|
if (userHighlight.getAlert()) {
|
||||||
|
doAlert = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (userHighlight.getSound()) {
|
||||||
|
playSound = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (playSound && doAlert) {
|
||||||
|
// Break if no further action can be taken from other usernames
|
||||||
|
// Mostly used for regex stuff
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this->setHighlight(doHighlight);
|
this->setHighlight(doHighlight);
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ HighlightingPage::HighlightingPage()
|
||||||
pingUsers.emplace<EditableModelView>(app->highlights->createUserModel(nullptr))
|
pingUsers.emplace<EditableModelView>(app->highlights->createUserModel(nullptr))
|
||||||
.getElement();
|
.getElement();
|
||||||
|
|
||||||
view->setTitles({"Username", "Regex"});
|
view->setTitles({"Username", "Flash taskbar", "Play sound", "Regex"});
|
||||||
view->getTableView()->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed);
|
view->getTableView()->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed);
|
||||||
view->getTableView()->horizontalHeader()->setSectionResizeMode(
|
view->getTableView()->horizontalHeader()->setSectionResizeMode(
|
||||||
0, QHeaderView::Stretch);
|
0, QHeaderView::Stretch);
|
||||||
|
@ -109,7 +109,7 @@ HighlightingPage::HighlightingPage()
|
||||||
|
|
||||||
view->addButtonPressed.connect([] {
|
view->addButtonPressed.connect([] {
|
||||||
getApp()->highlights->highlightedUsers.appendItem(
|
getApp()->highlights->highlightedUsers.appendItem(
|
||||||
UserHighlight{"highlighted user", false});
|
UserHighlight{"highlighted user", true, false, false});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue