mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Merge pull request #693 from apa420/apa-minor
Highlighting whispers works better and looks better
This commit is contained in:
commit
873b0b3c67
|
@ -124,7 +124,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);
|
||||||
|
@ -230,7 +230,8 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void customRowSetData(const std::vector<QStandardItem *> &row,
|
virtual void customRowSetData(const std::vector<QStandardItem *> &row,
|
||||||
int column, const QVariant &value, int role)
|
int column, const QVariant &value, int role,
|
||||||
|
int rowIndex)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,36 +36,67 @@ void HighlightModel::getRowFromItem(const HighlightPhrase &item,
|
||||||
|
|
||||||
void HighlightModel::afterInit()
|
void HighlightModel::afterInit()
|
||||||
{
|
{
|
||||||
std::vector<QStandardItem *> row = this->createRow();
|
std::vector<QStandardItem *> usernameRow = this->createRow();
|
||||||
setBoolItem(row[0], getSettings()->enableHighlightsSelf.getValue(), true,
|
setBoolItem(usernameRow[0], getSettings()->enableSelfHighlight.getValue(),
|
||||||
|
true, false);
|
||||||
|
usernameRow[0]->setData("Your username (automatic)", Qt::DisplayRole);
|
||||||
|
setBoolItem(usernameRow[1],
|
||||||
|
getSettings()->enableSelfHighlightTaskbar.getValue(), true,
|
||||||
false);
|
false);
|
||||||
row[0]->setData("Your username (automatic)", Qt::DisplayRole);
|
setBoolItem(usernameRow[2],
|
||||||
setBoolItem(row[1], getSettings()->enableHighlightTaskbar.getValue(), true,
|
getSettings()->enableSelfHighlightSound.getValue(), true,
|
||||||
false);
|
false);
|
||||||
setBoolItem(row[2], getSettings()->enableHighlightSound.getValue(), true,
|
usernameRow[3]->setFlags(0);
|
||||||
|
this->insertCustomRow(usernameRow, 0);
|
||||||
|
std::vector<QStandardItem *> whisperRow = this->createRow();
|
||||||
|
setBoolItem(whisperRow[0], getSettings()->enableWhisperHighlight.getValue(),
|
||||||
|
true, false);
|
||||||
|
whisperRow[0]->setData("Whispers", Qt::DisplayRole);
|
||||||
|
setBoolItem(whisperRow[1],
|
||||||
|
getSettings()->enableWhisperHighlightTaskbar.getValue(), true,
|
||||||
false);
|
false);
|
||||||
row[3]->setFlags(0);
|
setBoolItem(whisperRow[2],
|
||||||
this->insertCustomRow(row, 0);
|
getSettings()->enableWhisperHighlightSound.getValue(), true,
|
||||||
|
false);
|
||||||
|
whisperRow[3]->setFlags(0);
|
||||||
|
this->insertCustomRow(whisperRow, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HighlightModel::customRowSetData(const std::vector<QStandardItem *> &row,
|
void HighlightModel::customRowSetData(const std::vector<QStandardItem *> &row,
|
||||||
int column, const QVariant &value,
|
int column, const QVariant &value,
|
||||||
int role)
|
int role, int rowIndex)
|
||||||
{
|
{
|
||||||
switch (column) {
|
switch (column) {
|
||||||
case 0: {
|
case 0: {
|
||||||
if (role == Qt::CheckStateRole) {
|
if (role == Qt::CheckStateRole) {
|
||||||
getSettings()->enableHighlightsSelf.setValue(value.toBool());
|
if (rowIndex == 0) {
|
||||||
|
getSettings()->enableSelfHighlight.setValue(value.toBool());
|
||||||
|
} else if (rowIndex == 1) {
|
||||||
|
getSettings()->enableWhisperHighlight.setValue(
|
||||||
|
value.toBool());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case 1: {
|
case 1: {
|
||||||
if (role == Qt::CheckStateRole) {
|
if (role == Qt::CheckStateRole) {
|
||||||
getSettings()->enableHighlightTaskbar.setValue(value.toBool());
|
if (rowIndex == 0) {
|
||||||
|
getSettings()->enableSelfHighlightTaskbar.setValue(
|
||||||
|
value.toBool());
|
||||||
|
} else if (rowIndex == 1) {
|
||||||
|
getSettings()->enableWhisperHighlightTaskbar.setValue(
|
||||||
|
value.toBool());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case 2: {
|
case 2: {
|
||||||
if (role == Qt::CheckStateRole) {
|
if (role == Qt::CheckStateRole) {
|
||||||
getSettings()->enableHighlightSound.setValue(value.toBool());
|
if (rowIndex == 0) {
|
||||||
|
getSettings()->enableSelfHighlightSound.setValue(
|
||||||
|
value.toBool());
|
||||||
|
} else if (rowIndex == 1) {
|
||||||
|
getSettings()->enableWhisperHighlightSound.setValue(
|
||||||
|
value.toBool());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case 3: {
|
case 3: {
|
||||||
|
|
|
@ -26,8 +26,8 @@ protected:
|
||||||
virtual void afterInit() override;
|
virtual void afterInit() override;
|
||||||
|
|
||||||
virtual void customRowSetData(const std::vector<QStandardItem *> &row,
|
virtual void customRowSetData(const std::vector<QStandardItem *> &row,
|
||||||
int column, const QVariant &value,
|
int column, const QVariant &value, int role,
|
||||||
int role) override;
|
int rowIndex) override;
|
||||||
|
|
||||||
friend class HighlightController;
|
friend class HighlightController;
|
||||||
};
|
};
|
||||||
|
|
|
@ -516,10 +516,10 @@ void TwitchMessageBuilder::parseHighlights(bool isPastMsg)
|
||||||
std::vector<HighlightPhrase> userHighlights =
|
std::vector<HighlightPhrase> userHighlights =
|
||||||
app->highlights->highlightedUsers.getVector();
|
app->highlights->highlightedUsers.getVector();
|
||||||
|
|
||||||
if (getSettings()->enableHighlightsSelf && currentUsername.size() > 0) {
|
if (getSettings()->enableSelfHighlight && currentUsername.size() > 0) {
|
||||||
HighlightPhrase selfHighlight(
|
HighlightPhrase selfHighlight(
|
||||||
currentUsername, getSettings()->enableHighlightTaskbar,
|
currentUsername, getSettings()->enableSelfHighlightTaskbar,
|
||||||
getSettings()->enableHighlightSound, false);
|
getSettings()->enableSelfHighlightSound, false);
|
||||||
activeHighlights.emplace_back(std::move(selfHighlight));
|
activeHighlights.emplace_back(std::move(selfHighlight));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -573,6 +573,15 @@ void TwitchMessageBuilder::parseHighlights(bool isPastMsg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (this->args.isReceivedWhisper &&
|
||||||
|
getSettings()->enableWhisperHighlight) {
|
||||||
|
if (getSettings()->enableWhisperHighlightTaskbar) {
|
||||||
|
doAlert = true;
|
||||||
|
}
|
||||||
|
if (getSettings()->enableWhisperHighlightSound) {
|
||||||
|
playSound = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this->message().flags.set(MessageFlag::Highlighted, doHighlight);
|
this->message().flags.set(MessageFlag::Highlighted, doHighlight);
|
||||||
|
|
||||||
|
@ -587,12 +596,6 @@ void TwitchMessageBuilder::parseHighlights(bool isPastMsg)
|
||||||
2500);
|
2500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this->args.isReceivedWhisper &&
|
|
||||||
getSettings()->highlightSoundOnWhisper) {
|
|
||||||
if (!hasFocus || getSettings()->highlightAlwaysPlaySound) {
|
|
||||||
player->play();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,14 +115,19 @@ public:
|
||||||
|
|
||||||
/// Highlighting
|
/// Highlighting
|
||||||
// BoolSetting enableHighlights = {"/highlighting/enabled", true};
|
// BoolSetting enableHighlights = {"/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 highlightSoundOnWhisper = {
|
BoolSetting enableSelfHighlight = {
|
||||||
"/highlighting/highlightSoundOnWhisper", false};
|
"/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};
|
||||||
|
|
|
@ -149,8 +149,6 @@ HighlightingPage::HighlightingPage()
|
||||||
|
|
||||||
layout.append(createCheckBox(ALWAYS_PLAY,
|
layout.append(createCheckBox(ALWAYS_PLAY,
|
||||||
getSettings()->highlightAlwaysPlaySound));
|
getSettings()->highlightAlwaysPlaySound));
|
||||||
layout.append(createCheckBox(("Notification on whisper"),
|
|
||||||
getSettings()->highlightSoundOnWhisper));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- misc
|
// ---- misc
|
||||||
|
|
Loading…
Reference in a new issue