mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Added functionality of highlighitng whispers #640
This commit is contained in:
parent
b220ac765a
commit
02f0a5e054
8 changed files with 75 additions and 32 deletions
|
@ -118,7 +118,7 @@ public:
|
||||||
rowItem.items[column]->setData(value, role);
|
rowItem.items[column]->setData(value, role);
|
||||||
|
|
||||||
if (rowItem.isCustomRow) {
|
if (rowItem.isCustomRow) {
|
||||||
this->customRowSetData(rowItem.items, column, value, role);
|
this->customRowSetData(rowItem.items, column, value, role, row);
|
||||||
} else {
|
} else {
|
||||||
int vecRow = this->getVectorIndexFromModelIndex(row);
|
int vecRow = this->getVectorIndexFromModelIndex(row);
|
||||||
this->vector_->removeItem(vecRow, this);
|
this->vector_->removeItem(vecRow, this);
|
||||||
|
@ -217,7 +217,7 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void customRowSetData(const std::vector<QStandardItem *> &row, int column,
|
virtual void customRowSetData(const std::vector<QStandardItem *> &row, int column,
|
||||||
const QVariant &value, int role)
|
const QVariant &value, int role, int rowIndex)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,32 +34,55 @@ void HighlightModel::getRowFromItem(const HighlightPhrase &item, std::vector<QSt
|
||||||
|
|
||||||
void HighlightModel::afterInit()
|
void HighlightModel::afterInit()
|
||||||
{
|
{
|
||||||
std::vector<QStandardItem *> row = this->createRow();
|
std::vector<QStandardItem *> usernameRow = this->createRow();
|
||||||
setBoolItem(row[0], getApp()->settings->enableHighlightsSelf.getValue(), true, false);
|
setBoolItem(usernameRow[0], getApp()->settings->enableSelfHighlight.getValue(), true, false);
|
||||||
row[0]->setData("Your username (automatic)", Qt::DisplayRole);
|
usernameRow[0]->setData("Your username (automatic)", Qt::DisplayRole);
|
||||||
setBoolItem(row[1], getApp()->settings->enableHighlightTaskbar.getValue(), true, false);
|
setBoolItem(usernameRow[1], getApp()->settings->enableSelfHighlightTaskbar.getValue(), true,
|
||||||
setBoolItem(row[2], getApp()->settings->enableHighlightSound.getValue(), true, false);
|
false);
|
||||||
row[3]->setFlags(0);
|
setBoolItem(usernameRow[2], getApp()->settings->enableSelfHighlightSound.getValue(), true,
|
||||||
this->insertCustomRow(row, 0);
|
false);
|
||||||
|
usernameRow[3]->setFlags(0);
|
||||||
|
this->insertCustomRow(usernameRow, 0);
|
||||||
|
std::vector<QStandardItem *> whisperRow = this->createRow();
|
||||||
|
setBoolItem(whisperRow[0], getApp()->settings->enableWhisperHighlight.getValue(), true, false);
|
||||||
|
whisperRow[0]->setData("Whispers", Qt::DisplayRole);
|
||||||
|
setBoolItem(whisperRow[1], getApp()->settings->enableWhisperHighlightTaskbar.getValue(), true,
|
||||||
|
false);
|
||||||
|
setBoolItem(whisperRow[2], getApp()->settings->enableWhisperHighlightSound.getValue(), true,
|
||||||
|
false);
|
||||||
|
whisperRow[3]->setFlags(0);
|
||||||
|
this->insertCustomRow(whisperRow, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HighlightModel::customRowSetData(const std::vector<QStandardItem *> &row, int column,
|
void HighlightModel::customRowSetData(const std::vector<QStandardItem *> &row, int column,
|
||||||
const QVariant &value, int role)
|
const QVariant &value, int role, int rowIndex)
|
||||||
{
|
{
|
||||||
switch (column) {
|
switch (column) {
|
||||||
case 0: {
|
case 0: {
|
||||||
if (role == Qt::CheckStateRole) {
|
if (role == Qt::CheckStateRole) {
|
||||||
getApp()->settings->enableHighlightsSelf.setValue(value.toBool());
|
if (rowIndex == 0) {
|
||||||
|
getApp()->settings->enableSelfHighlight.setValue(value.toBool());
|
||||||
|
} else if (rowIndex == 1) {
|
||||||
|
getApp()->settings->enableWhisperHighlight.setValue(value.toBool());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case 1: {
|
case 1: {
|
||||||
if (role == Qt::CheckStateRole) {
|
if (role == Qt::CheckStateRole) {
|
||||||
getApp()->settings->enableHighlightTaskbar.setValue(value.toBool());
|
if (rowIndex == 0) {
|
||||||
|
getApp()->settings->enableSelfHighlightTaskbar.setValue(value.toBool());
|
||||||
|
} else if (rowIndex == 1) {
|
||||||
|
getApp()->settings->enableWhisperHighlightTaskbar.setValue(value.toBool());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case 2: {
|
case 2: {
|
||||||
if (role == Qt::CheckStateRole) {
|
if (role == Qt::CheckStateRole) {
|
||||||
getApp()->settings->enableHighlightSound.setValue(value.toBool());
|
if (rowIndex == 0) {
|
||||||
|
getApp()->settings->enableSelfHighlightSound.setValue(value.toBool());
|
||||||
|
} else if (rowIndex == 1) {
|
||||||
|
getApp()->settings->enableWhisperHighlightSound.setValue(value.toBool());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case 3: {
|
case 3: {
|
||||||
|
|
|
@ -25,7 +25,7 @@ protected:
|
||||||
virtual void afterInit() override;
|
virtual void afterInit() override;
|
||||||
|
|
||||||
virtual void customRowSetData(const std::vector<QStandardItem *> &row, int column,
|
virtual void customRowSetData(const std::vector<QStandardItem *> &row, int column,
|
||||||
const QVariant &value, int role) override;
|
const QVariant &value, int role, int rowIndex) override;
|
||||||
|
|
||||||
friend class HighlightController;
|
friend class HighlightController;
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,10 +27,10 @@ void TaggedUsersModel::getRowFromItem(const TaggedUser &item, std::vector<QStand
|
||||||
void TaggedUsersModel::afterInit()
|
void TaggedUsersModel::afterInit()
|
||||||
{
|
{
|
||||||
// std::vector<QStandardItem *> row = this->createRow();
|
// std::vector<QStandardItem *> row = this->createRow();
|
||||||
// setBoolItem(row[0], getApp()->settings->enableHighlightsSelf.getValue(), true,
|
// setBoolItem(row[0], getApp()->settings->enableSelfHighlight.getValue(), true,
|
||||||
// false); row[0]->setData("Your username (automatic)", Qt::DisplayRole);
|
// false); row[0]->setData("Your username (automatic)", Qt::DisplayRole);
|
||||||
// setBoolItem(row[1], getApp()->settings->enableHighlightTaskbar.getValue(), true,
|
// setBoolItem(row[1], getApp()->settings->enableSelfHighlightTaskbar.getValue(), true,
|
||||||
// false); setBoolItem(row[2], getApp()->settings->enableHighlightSound.getValue(),
|
// false); setBoolItem(row[2], getApp()->settings->enableSelfHighlightSound.getValue(),
|
||||||
// true, false); row[3]->setFlags(0); this->insertCustomRow(row, 0);
|
// true, false); row[3]->setFlags(0); this->insertCustomRow(row, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,17 +40,17 @@ void TaggedUsersModel::afterInit()
|
||||||
// switch (column) {
|
// switch (column) {
|
||||||
// case 0: {
|
// case 0: {
|
||||||
// if (role == Qt::CheckStateRole) {
|
// if (role == Qt::CheckStateRole) {
|
||||||
// getApp()->settings->enableHighlightsSelf.setValue(value.toBool());
|
// getApp()->settings->enableSelfHighlight.setValue(value.toBool());
|
||||||
// }
|
// }
|
||||||
// } break;
|
// } break;
|
||||||
// case 1: {
|
// case 1: {
|
||||||
// if (role == Qt::CheckStateRole) {
|
// if (role == Qt::CheckStateRole) {
|
||||||
// getApp()->settings->enableHighlightTaskbar.setValue(value.toBool());
|
// getApp()->settings->enableSelfHighlightTaskbar.setValue(value.toBool());
|
||||||
// }
|
// }
|
||||||
// } break;
|
// } break;
|
||||||
// case 2: {
|
// case 2: {
|
||||||
// if (role == Qt::CheckStateRole) {
|
// if (role == Qt::CheckStateRole) {
|
||||||
// getApp()->settings->enableHighlightSound.setValue(value.toBool());
|
// getApp()->settings->enableSelfHighlightSound.setValue(value.toBool());
|
||||||
// }
|
// }
|
||||||
// } break;
|
// } break;
|
||||||
// case 3: {
|
// case 3: {
|
||||||
|
|
|
@ -456,9 +456,9 @@ void TwitchMessageBuilder::parseHighlights(bool isPastMsg)
|
||||||
std::vector<HighlightPhrase> activeHighlights = app->highlights->phrases.getVector();
|
std::vector<HighlightPhrase> activeHighlights = app->highlights->phrases.getVector();
|
||||||
std::vector<HighlightPhrase> userHighlights = app->highlights->highlightedUsers.getVector();
|
std::vector<HighlightPhrase> userHighlights = app->highlights->highlightedUsers.getVector();
|
||||||
|
|
||||||
if (app->settings->enableHighlightsSelf && currentUsername.size() > 0) {
|
if (app->settings->enableSelfHighlight && currentUsername.size() > 0) {
|
||||||
HighlightPhrase selfHighlight(currentUsername, app->settings->enableHighlightTaskbar,
|
HighlightPhrase selfHighlight(currentUsername, app->settings->enableSelfHighlightTaskbar,
|
||||||
app->settings->enableHighlightSound, false);
|
app->settings->enableSelfHighlightSound, false);
|
||||||
activeHighlights.emplace_back(std::move(selfHighlight));
|
activeHighlights.emplace_back(std::move(selfHighlight));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -510,6 +510,20 @@ void TwitchMessageBuilder::parseHighlights(bool isPastMsg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (app->settings->enableWhisperHighlight) {
|
||||||
|
if (this->args.isReceivedWhisper) {
|
||||||
|
Log("Highlight because it's a whisper", this->args.isReceivedWhisper);
|
||||||
|
doHighlight = true;
|
||||||
|
|
||||||
|
if (getSettings()->enableWhisperHighlightTaskbar) {
|
||||||
|
doAlert = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getSettings()->enableWhisperHighlightSound) {
|
||||||
|
playSound = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this->setHighlight(doHighlight);
|
this->setHighlight(doHighlight);
|
||||||
|
|
||||||
|
|
|
@ -91,11 +91,17 @@ public:
|
||||||
QStringSetting timeoutAction = {"/moderation/timeoutAction", "Disable"};
|
QStringSetting timeoutAction = {"/moderation/timeoutAction", "Disable"};
|
||||||
|
|
||||||
/// Highlighting
|
/// Highlighting
|
||||||
// BoolSetting enableHighlights = {"/highlighting/enabled", true};
|
// BoolSetting enableSelfHighlights = {"/highlighting/enabled", true};
|
||||||
BoolSetting enableHighlightsSelf = {"/highlighting/nameIsHighlightKeyword", true};
|
|
||||||
BoolSetting enableHighlightSound = {"/highlighting/enableSound", true};
|
|
||||||
BoolSetting enableHighlightTaskbar = {"/highlighting/enableTaskbarFlashing", true};
|
|
||||||
BoolSetting customHighlightSound = {"/highlighting/useCustomSound", false};
|
BoolSetting customHighlightSound = {"/highlighting/useCustomSound", false};
|
||||||
|
BoolSetting enableSelfHighlight = {"/highlighting/selfHighlight/nameIsHighlightKeyword", true};
|
||||||
|
BoolSetting enableSelfHighlightSound = {"/highlighting/selfHighlight/enableSound", true};
|
||||||
|
BoolSetting enableSelfHighlightTaskbar = {"/highlighting/selfHighlight/enableTaskbarFlashing",
|
||||||
|
true};
|
||||||
|
BoolSetting enableWhisperHighlight = {"/highlighting/whisperHighlight/whispersHighlighted",
|
||||||
|
true};
|
||||||
|
BoolSetting enableWhisperHighlightSound = {"/highlighting/whisperHighlight/enableSound", false};
|
||||||
|
BoolSetting enableWhisperHighlightTaskbar = {
|
||||||
|
"/highlighting/whisperHighlight/enableTaskbarFlashing", false};
|
||||||
|
|
||||||
/// Logging
|
/// Logging
|
||||||
BoolSetting enableLogging = {"/logging/enabled", false};
|
BoolSetting enableLogging = {"/logging/enabled", false};
|
||||||
|
|
|
@ -50,15 +50,15 @@ NotebookTab::NotebookTab(Notebook *notebook)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// QAction *enableHighlightsOnNewMessageAction =
|
// QAction *enableSelfHighlightsOnNewMessageAction =
|
||||||
// new QAction("Enable highlights on new message", &this->menu);
|
// new QAction("Enable highlights on new message", &this->menu);
|
||||||
// enableHighlightsOnNewMessageAction->setCheckable(true);
|
// enableSelfHighlightsOnNewMessageAction->setCheckable(true);
|
||||||
|
|
||||||
this->menu_.addAction("Close", [=]() { this->notebook_->removePage(this->page); });
|
this->menu_.addAction("Close", [=]() { this->notebook_->removePage(this->page); });
|
||||||
|
|
||||||
// this->menu.addAction(enableHighlightsOnNewMessageAction);
|
// this->menu.addAction(enableSelfHighlightsOnNewMessageAction);
|
||||||
|
|
||||||
// QObject::connect(enableHighlightsOnNewMessageAction, &QAction::toggled, [this](bool
|
// QObject::connect(enableSelfHighlightsOnNewMessageAction, &QAction::toggled, [this](bool
|
||||||
// newValue) {
|
// newValue) {
|
||||||
// Log("New value is {}", newValue); //
|
// Log("New value is {}", newValue); //
|
||||||
// });
|
// });
|
||||||
|
|
|
@ -37,7 +37,7 @@ HighlightingPage::HighlightingPage()
|
||||||
auto layout = layoutCreator.emplace<QVBoxLayout>().withoutMargin();
|
auto layout = layoutCreator.emplace<QVBoxLayout>().withoutMargin();
|
||||||
{
|
{
|
||||||
// GENERAL
|
// GENERAL
|
||||||
// layout.append(this->createCheckBox(ENABLE_HIGHLIGHTS, app->settings->enableHighlights));
|
// layout.append(this->createCheckBox(ENABLE_HIGHLIGHTS, app->settings->enableSelfHighlights));
|
||||||
|
|
||||||
// TABS
|
// TABS
|
||||||
auto tabs = layout.emplace<QTabWidget>();
|
auto tabs = layout.emplace<QTabWidget>();
|
||||||
|
|
Loading…
Reference in a new issue