Added functionality of highlighitng whispers #640

This commit is contained in:
apa420 2018-08-02 00:14:29 +02:00
parent b220ac765a
commit 02f0a5e054
8 changed files with 75 additions and 32 deletions

View file

@ -118,7 +118,7 @@ public:
rowItem.items[column]->setData(value, role);
if (rowItem.isCustomRow) {
this->customRowSetData(rowItem.items, column, value, role);
this->customRowSetData(rowItem.items, column, value, role, row);
} else {
int vecRow = this->getVectorIndexFromModelIndex(row);
this->vector_->removeItem(vecRow, this);
@ -217,7 +217,7 @@ protected:
}
virtual void customRowSetData(const std::vector<QStandardItem *> &row, int column,
const QVariant &value, int role)
const QVariant &value, int role, int rowIndex)
{
}

View file

@ -34,32 +34,55 @@ void HighlightModel::getRowFromItem(const HighlightPhrase &item, std::vector<QSt
void HighlightModel::afterInit()
{
std::vector<QStandardItem *> row = this->createRow();
setBoolItem(row[0], getApp()->settings->enableHighlightsSelf.getValue(), true, false);
row[0]->setData("Your username (automatic)", Qt::DisplayRole);
setBoolItem(row[1], getApp()->settings->enableHighlightTaskbar.getValue(), true, false);
setBoolItem(row[2], getApp()->settings->enableHighlightSound.getValue(), true, false);
row[3]->setFlags(0);
this->insertCustomRow(row, 0);
std::vector<QStandardItem *> usernameRow = this->createRow();
setBoolItem(usernameRow[0], getApp()->settings->enableSelfHighlight.getValue(), true, false);
usernameRow[0]->setData("Your username (automatic)", Qt::DisplayRole);
setBoolItem(usernameRow[1], getApp()->settings->enableSelfHighlightTaskbar.getValue(), true,
false);
setBoolItem(usernameRow[2], getApp()->settings->enableSelfHighlightSound.getValue(), true,
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,
const QVariant &value, int role)
const QVariant &value, int role, int rowIndex)
{
switch (column) {
case 0: {
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;
case 1: {
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;
case 2: {
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;
case 3: {

View file

@ -25,7 +25,7 @@ protected:
virtual void afterInit() override;
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;
};

View file

@ -27,10 +27,10 @@ void TaggedUsersModel::getRowFromItem(const TaggedUser &item, std::vector<QStand
void TaggedUsersModel::afterInit()
{
// 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);
// setBoolItem(row[1], getApp()->settings->enableHighlightTaskbar.getValue(), true,
// false); setBoolItem(row[2], getApp()->settings->enableHighlightSound.getValue(),
// setBoolItem(row[1], getApp()->settings->enableSelfHighlightTaskbar.getValue(), true,
// false); setBoolItem(row[2], getApp()->settings->enableSelfHighlightSound.getValue(),
// true, false); row[3]->setFlags(0); this->insertCustomRow(row, 0);
}
@ -40,17 +40,17 @@ void TaggedUsersModel::afterInit()
// switch (column) {
// case 0: {
// if (role == Qt::CheckStateRole) {
// getApp()->settings->enableHighlightsSelf.setValue(value.toBool());
// getApp()->settings->enableSelfHighlight.setValue(value.toBool());
// }
// } break;
// case 1: {
// if (role == Qt::CheckStateRole) {
// getApp()->settings->enableHighlightTaskbar.setValue(value.toBool());
// getApp()->settings->enableSelfHighlightTaskbar.setValue(value.toBool());
// }
// } break;
// case 2: {
// if (role == Qt::CheckStateRole) {
// getApp()->settings->enableHighlightSound.setValue(value.toBool());
// getApp()->settings->enableSelfHighlightSound.setValue(value.toBool());
// }
// } break;
// case 3: {

View file

@ -456,9 +456,9 @@ void TwitchMessageBuilder::parseHighlights(bool isPastMsg)
std::vector<HighlightPhrase> activeHighlights = app->highlights->phrases.getVector();
std::vector<HighlightPhrase> userHighlights = app->highlights->highlightedUsers.getVector();
if (app->settings->enableHighlightsSelf && currentUsername.size() > 0) {
HighlightPhrase selfHighlight(currentUsername, app->settings->enableHighlightTaskbar,
app->settings->enableHighlightSound, false);
if (app->settings->enableSelfHighlight && currentUsername.size() > 0) {
HighlightPhrase selfHighlight(currentUsername, app->settings->enableSelfHighlightTaskbar,
app->settings->enableSelfHighlightSound, false);
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);

View file

@ -91,11 +91,17 @@ public:
QStringSetting timeoutAction = {"/moderation/timeoutAction", "Disable"};
/// Highlighting
// BoolSetting enableHighlights = {"/highlighting/enabled", true};
BoolSetting enableHighlightsSelf = {"/highlighting/nameIsHighlightKeyword", true};
BoolSetting enableHighlightSound = {"/highlighting/enableSound", true};
BoolSetting enableHighlightTaskbar = {"/highlighting/enableTaskbarFlashing", true};
// BoolSetting enableSelfHighlights = {"/highlighting/enabled", true};
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
BoolSetting enableLogging = {"/logging/enabled", false};

View file

@ -50,15 +50,15 @@ NotebookTab::NotebookTab(Notebook *notebook)
}
});
// QAction *enableHighlightsOnNewMessageAction =
// QAction *enableSelfHighlightsOnNewMessageAction =
// 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(enableHighlightsOnNewMessageAction);
// this->menu.addAction(enableSelfHighlightsOnNewMessageAction);
// QObject::connect(enableHighlightsOnNewMessageAction, &QAction::toggled, [this](bool
// QObject::connect(enableSelfHighlightsOnNewMessageAction, &QAction::toggled, [this](bool
// newValue) {
// Log("New value is {}", newValue); //
// });

View file

@ -37,7 +37,7 @@ HighlightingPage::HighlightingPage()
auto layout = layoutCreator.emplace<QVBoxLayout>().withoutMargin();
{
// GENERAL
// layout.append(this->createCheckBox(ENABLE_HIGHLIGHTS, app->settings->enableHighlights));
// layout.append(this->createCheckBox(ENABLE_HIGHLIGHTS, app->settings->enableSelfHighlights));
// TABS
auto tabs = layout.emplace<QTabWidget>();