diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 24853e752..784e5829c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -568,6 +568,9 @@ set(SOURCE_FILES widgets/dialogs/EditHotkeyDialog.hpp widgets/dialogs/EmotePopup.cpp widgets/dialogs/EmotePopup.hpp + widgets/dialogs/HighlightConfigureDialog.cpp + widgets/dialogs/HighlightConfigureDialog.hpp + widgets/dialogs/HighlightConfigureDialog.ui widgets/dialogs/IrcConnectionEditor.cpp widgets/dialogs/IrcConnectionEditor.hpp widgets/dialogs/IrcConnectionEditor.ui diff --git a/src/controllers/highlights/HighlightModel.cpp b/src/controllers/highlights/HighlightModel.cpp index 974653115..fe22f52a0 100644 --- a/src/controllers/highlights/HighlightModel.cpp +++ b/src/controllers/highlights/HighlightModel.cpp @@ -77,7 +77,8 @@ void HighlightModel::afterInit() auto selfColor = ColorProvider::instance().color(ColorType::SelfHighlight); setColorItem(usernameRow[Column::Color], *selfColor, false); - this->insertCustomRow(usernameRow, HighlightRowIndexes::SelfHighlightRow); + this->insertCustomRow( + usernameRow, static_cast(HighlightRowIndexes::SelfHighlightRow)); // Highlight settings for whispers std::vector whisperRow = this->createRow(); @@ -101,7 +102,8 @@ void HighlightModel::afterInit() auto whisperColor = ColorProvider::instance().color(ColorType::Whisper); setColorItem(whisperRow[Column::Color], *whisperColor, false); - this->insertCustomRow(whisperRow, HighlightRowIndexes::WhisperRow); + this->insertCustomRow(whisperRow, + static_cast(HighlightRowIndexes::WhisperRow)); // Highlight settings for subscription messages std::vector subRow = this->createRow(); @@ -123,7 +125,8 @@ void HighlightModel::afterInit() auto subColor = ColorProvider::instance().color(ColorType::Subscription); setColorItem(subRow[Column::Color], *subColor, false); - this->insertCustomRow(subRow, HighlightRowIndexes::SubRow); + this->insertCustomRow(subRow, + static_cast(HighlightRowIndexes::SubRow)); // Highlight settings for redeemed highlight messages std::vector redeemedRow = this->createRow(); @@ -148,7 +151,8 @@ void HighlightModel::afterInit() ColorProvider::instance().color(ColorType::RedeemedHighlight); setColorItem(redeemedRow[Column::Color], *RedeemedColor, false); - this->insertCustomRow(redeemedRow, HighlightRowIndexes::RedeemedRow); + this->insertCustomRow(redeemedRow, + static_cast(HighlightRowIndexes::RedeemedRow)); // Highlight settings for first messages std::vector firstMessageRow = this->createRow(); @@ -174,8 +178,9 @@ void HighlightModel::afterInit() ColorProvider::instance().color(ColorType::FirstMessageHighlight); setColorItem(firstMessageRow[Column::Color], *FirstMessageColor, false); - this->insertCustomRow(firstMessageRow, - HighlightRowIndexes::FirstMessageRow); + this->insertCustomRow( + firstMessageRow, + static_cast(HighlightRowIndexes::FirstMessageRow)); // Highlight settings for hype chats std::vector elevatedMessageRow = this->createRow(); @@ -201,8 +206,9 @@ void HighlightModel::afterInit() setColorItem(elevatedMessageRow[Column::Color], *elevatedMessageColor, false); - this->insertCustomRow(elevatedMessageRow, - HighlightRowIndexes::ElevatedMessageRow); + this->insertCustomRow( + elevatedMessageRow, + static_cast(HighlightRowIndexes::ElevatedMessageRow)); // Highlight settings for reply threads std::vector threadMessageRow = this->createRow(); @@ -231,8 +237,9 @@ void HighlightModel::afterInit() ColorProvider::instance().color(ColorType::ThreadMessageHighlight); setColorItem(threadMessageRow[Column::Color], *threadMessageColor, false); - this->insertCustomRow(threadMessageRow, - HighlightRowIndexes::ThreadMessageRow); + this->insertCustomRow( + threadMessageRow, + static_cast(HighlightRowIndexes::ThreadMessageRow)); // Highlight settings for automod caught messages const std::vector automodRow = this->createRow(); @@ -258,52 +265,55 @@ void HighlightModel::afterInit() ColorProvider::instance().color(ColorType::AutomodHighlight); setColorItem(automodRow[Column::Color], *automodColor, false); - this->insertCustomRow(automodRow, HighlightRowIndexes::AutomodRow); + this->insertCustomRow(automodRow, + static_cast(HighlightRowIndexes::AutomodRow)); } void HighlightModel::customRowSetData(const std::vector &row, int column, const QVariant &value, int role, int rowIndex) { - switch (column) + auto rowIndex2 = static_cast(rowIndex); + auto column2 = static_cast(column); + switch (column2) { case Column::Pattern: { if (role == Qt::CheckStateRole) { - if (rowIndex == HighlightRowIndexes::SelfHighlightRow) + if (rowIndex2 == HighlightRowIndexes::SelfHighlightRow) { getSettings()->enableSelfHighlight.setValue(value.toBool()); } - else if (rowIndex == HighlightRowIndexes::WhisperRow) + else if (rowIndex2 == HighlightRowIndexes::WhisperRow) { getSettings()->enableWhisperHighlight.setValue( value.toBool()); } - else if (rowIndex == HighlightRowIndexes::SubRow) + else if (rowIndex2 == HighlightRowIndexes::SubRow) { getSettings()->enableSubHighlight.setValue(value.toBool()); } - else if (rowIndex == HighlightRowIndexes::RedeemedRow) + else if (rowIndex2 == HighlightRowIndexes::RedeemedRow) { getSettings()->enableRedeemedHighlight.setValue( value.toBool()); } - else if (rowIndex == HighlightRowIndexes::FirstMessageRow) + else if (rowIndex2 == HighlightRowIndexes::FirstMessageRow) { getSettings()->enableFirstMessageHighlight.setValue( value.toBool()); } - else if (rowIndex == HighlightRowIndexes::ElevatedMessageRow) + else if (rowIndex2 == HighlightRowIndexes::ElevatedMessageRow) { getSettings()->enableElevatedMessageHighlight.setValue( value.toBool()); } - else if (rowIndex == HighlightRowIndexes::ThreadMessageRow) + else if (rowIndex2 == HighlightRowIndexes::ThreadMessageRow) { getSettings()->enableThreadHighlight.setValue( value.toBool()); } - else if (rowIndex == HighlightRowIndexes::AutomodRow) + else if (rowIndex2 == HighlightRowIndexes::AutomodRow) { getSettings()->enableAutomodHighlight.setValue( value.toBool()); @@ -314,17 +324,17 @@ void HighlightModel::customRowSetData(const std::vector &row, case Column::ShowInMentions: { if (role == Qt::CheckStateRole) { - if (rowIndex == HighlightRowIndexes::SelfHighlightRow) + if (rowIndex2 == HighlightRowIndexes::SelfHighlightRow) { getSettings()->showSelfHighlightInMentions.setValue( value.toBool()); } - else if (rowIndex == HighlightRowIndexes::ThreadMessageRow) + else if (rowIndex2 == HighlightRowIndexes::ThreadMessageRow) { getSettings()->showThreadHighlightInMentions.setValue( value.toBool()); } - else if (rowIndex == HighlightRowIndexes::AutomodRow) + else if (rowIndex2 == HighlightRowIndexes::AutomodRow) { getSettings()->showAutomodInMentions.setValue( value.toBool()); @@ -335,43 +345,43 @@ void HighlightModel::customRowSetData(const std::vector &row, case Column::FlashTaskbar: { if (role == Qt::CheckStateRole) { - if (rowIndex == HighlightRowIndexes::SelfHighlightRow) + if (rowIndex2 == HighlightRowIndexes::SelfHighlightRow) { getSettings()->enableSelfHighlightTaskbar.setValue( value.toBool()); } - else if (rowIndex == HighlightRowIndexes::WhisperRow) + else if (rowIndex2 == HighlightRowIndexes::WhisperRow) { getSettings()->enableWhisperHighlightTaskbar.setValue( value.toBool()); } - else if (rowIndex == HighlightRowIndexes::SubRow) + else if (rowIndex2 == HighlightRowIndexes::SubRow) { getSettings()->enableSubHighlightTaskbar.setValue( value.toBool()); } - else if (rowIndex == HighlightRowIndexes::RedeemedRow) + else if (rowIndex2 == HighlightRowIndexes::RedeemedRow) { // getSettings()->enableRedeemedHighlightTaskbar.setValue( // value.toBool()); } - else if (rowIndex == HighlightRowIndexes::FirstMessageRow) + else if (rowIndex2 == HighlightRowIndexes::FirstMessageRow) { // getSettings()->enableFirstMessageHighlightTaskbar.setValue( // value.toBool()); } - else if (rowIndex == HighlightRowIndexes::ElevatedMessageRow) + else if (rowIndex2 == HighlightRowIndexes::ElevatedMessageRow) { // getSettings() // ->enableElevatedMessageHighlightTaskbar.setvalue( // value.toBool()); } - else if (rowIndex == HighlightRowIndexes::ThreadMessageRow) + else if (rowIndex2 == HighlightRowIndexes::ThreadMessageRow) { getSettings()->enableThreadHighlightTaskbar.setValue( value.toBool()); } - else if (rowIndex == HighlightRowIndexes::AutomodRow) + else if (rowIndex2 == HighlightRowIndexes::AutomodRow) { getSettings()->enableAutomodHighlightTaskbar.setValue( value.toBool()); @@ -382,42 +392,42 @@ void HighlightModel::customRowSetData(const std::vector &row, case Column::PlaySound: { if (role == Qt::CheckStateRole) { - if (rowIndex == HighlightRowIndexes::SelfHighlightRow) + if (rowIndex2 == HighlightRowIndexes::SelfHighlightRow) { getSettings()->enableSelfHighlightSound.setValue( value.toBool()); } - else if (rowIndex == HighlightRowIndexes::WhisperRow) + else if (rowIndex2 == HighlightRowIndexes::WhisperRow) { getSettings()->enableWhisperHighlightSound.setValue( value.toBool()); } - else if (rowIndex == HighlightRowIndexes::SubRow) + else if (rowIndex2 == HighlightRowIndexes::SubRow) { getSettings()->enableSubHighlightSound.setValue( value.toBool()); } - else if (rowIndex == HighlightRowIndexes::RedeemedRow) + else if (rowIndex2 == HighlightRowIndexes::RedeemedRow) { // getSettings()->enableRedeemedHighlightSound.setValue( // value.toBool()); } - else if (rowIndex == HighlightRowIndexes::FirstMessageRow) + else if (rowIndex2 == HighlightRowIndexes::FirstMessageRow) { // getSettings()->enableFirstMessageHighlightSound.setValue( // value.toBool()); } - else if (rowIndex == HighlightRowIndexes::ElevatedMessageRow) + else if (rowIndex2 == HighlightRowIndexes::ElevatedMessageRow) { // getSettings()->enableElevatedMessageHighlightSound.setValue( // value.toBool()); } - else if (rowIndex == HighlightRowIndexes::ThreadMessageRow) + else if (rowIndex2 == HighlightRowIndexes::ThreadMessageRow) { getSettings()->enableThreadHighlightSound.setValue( value.toBool()); } - else if (rowIndex == HighlightRowIndexes::AutomodRow) + else if (rowIndex2 == HighlightRowIndexes::AutomodRow) { getSettings()->enableAutomodHighlightSound.setValue( value.toBool()); @@ -437,27 +447,27 @@ void HighlightModel::customRowSetData(const std::vector &row, // Custom sound file if (role == Qt::UserRole) { - if (rowIndex == HighlightRowIndexes::SelfHighlightRow) + if (rowIndex2 == HighlightRowIndexes::SelfHighlightRow) { getSettings()->selfHighlightSoundUrl.setValue( value.toString()); } - else if (rowIndex == HighlightRowIndexes::WhisperRow) + else if (rowIndex2 == HighlightRowIndexes::WhisperRow) { getSettings()->whisperHighlightSoundUrl.setValue( value.toString()); } - else if (rowIndex == HighlightRowIndexes::SubRow) + else if (rowIndex2 == HighlightRowIndexes::SubRow) { getSettings()->subHighlightSoundUrl.setValue( value.toString()); } - else if (rowIndex == HighlightRowIndexes::ThreadMessageRow) + else if (rowIndex2 == HighlightRowIndexes::ThreadMessageRow) { getSettings()->threadHighlightSoundUrl.setValue( value.toString()); } - else if (rowIndex == HighlightRowIndexes::AutomodRow) + else if (rowIndex2 == HighlightRowIndexes::AutomodRow) { getSettings()->automodHighlightSoundUrl.setValue( value.toString()); @@ -474,42 +484,42 @@ void HighlightModel::customRowSetData(const std::vector &row, setting.setValue(color.name(QColor::HexArgb)); }; - if (rowIndex == HighlightRowIndexes::SelfHighlightRow) + if (rowIndex2 == HighlightRowIndexes::SelfHighlightRow) { setColor(getSettings()->selfHighlightColor, ColorType::SelfHighlight); } - else if (rowIndex == HighlightRowIndexes::WhisperRow) + else if (rowIndex2 == HighlightRowIndexes::WhisperRow) { setColor(getSettings()->whisperHighlightColor, ColorType::Whisper); } - else if (rowIndex == HighlightRowIndexes::SubRow) + else if (rowIndex2 == HighlightRowIndexes::SubRow) { setColor(getSettings()->subHighlightColor, ColorType::Subscription); } - else if (rowIndex == HighlightRowIndexes::RedeemedRow) + else if (rowIndex2 == HighlightRowIndexes::RedeemedRow) { setColor(getSettings()->redeemedHighlightColor, ColorType::RedeemedHighlight); } - else if (rowIndex == HighlightRowIndexes::FirstMessageRow) + else if (rowIndex2 == HighlightRowIndexes::FirstMessageRow) { setColor(getSettings()->firstMessageHighlightColor, ColorType::FirstMessageHighlight); } - else if (rowIndex == HighlightRowIndexes::ElevatedMessageRow) + else if (rowIndex2 == HighlightRowIndexes::ElevatedMessageRow) { setColor(getSettings()->elevatedMessageHighlightColor, ColorType::ElevatedMessageHighlight); } - else if (rowIndex == HighlightRowIndexes::ThreadMessageRow) + else if (rowIndex2 == HighlightRowIndexes::ThreadMessageRow) { setColor(getSettings()->threadHighlightColor, ColorType::ThreadMessageHighlight); } - else if (rowIndex == HighlightRowIndexes::AutomodRow) + else if (rowIndex2 == HighlightRowIndexes::AutomodRow) { setColor(getSettings()->automodHighlightColor, ColorType::AutomodHighlight); diff --git a/src/controllers/highlights/HighlightModel.hpp b/src/controllers/highlights/HighlightModel.hpp index be807d33e..02245076a 100644 --- a/src/controllers/highlights/HighlightModel.hpp +++ b/src/controllers/highlights/HighlightModel.hpp @@ -23,10 +23,11 @@ public: PlaySound = 5, SoundPath = 6, Color = 7, + Configure = 8, COUNT // keep this as last member of enum }; - enum HighlightRowIndexes { + enum class HighlightRowIndexes { SelfHighlightRow = 0, WhisperRow = 1, SubRow = 2, @@ -35,6 +36,7 @@ public: ElevatedMessageRow = 5, ThreadMessageRow = 6, AutomodRow = 7, + COUNT, }; enum UserHighlightRowIndexes { diff --git a/src/widgets/dialogs/HighlightConfigureDialog.cpp b/src/widgets/dialogs/HighlightConfigureDialog.cpp new file mode 100644 index 000000000..f368ad204 --- /dev/null +++ b/src/widgets/dialogs/HighlightConfigureDialog.cpp @@ -0,0 +1,23 @@ +#include "widgets/dialogs/HighlightConfigureDialog.hpp" + +#include "widgets/dialogs/ui_HighlightConfigureDialog.h" + +namespace chatterino { + +HighlightConfigureDialog::HighlightConfigureDialog(HighlightPhrase phrase, + QWidget *parent) + + : QDialog(parent, Qt::WindowStaysOnTopHint) + , ui_(new Ui::HighlightConfigureDialog) +{ + this->ui_->setupUi(this); + + this->ui_->patternLineEdit->setText(phrase.getPattern()); +} + +HighlightConfigureDialog::~HighlightConfigureDialog() +{ + delete ui_; +} + +} // namespace chatterino diff --git a/src/widgets/dialogs/HighlightConfigureDialog.hpp b/src/widgets/dialogs/HighlightConfigureDialog.hpp new file mode 100644 index 000000000..08d41f65e --- /dev/null +++ b/src/widgets/dialogs/HighlightConfigureDialog.hpp @@ -0,0 +1,35 @@ +#pragma once + +#include "controllers/highlights/HighlightPhrase.hpp" + +#include + +namespace Ui { + +class HighlightConfigureDialog; + +} // namespace Ui + +namespace chatterino { + +struct IrcServerData; + +class HighlightConfigureDialog : public QDialog +{ + Q_OBJECT + +public: + explicit HighlightConfigureDialog(HighlightPhrase phrase, QWidget *parent); + + HighlightConfigureDialog(const HighlightConfigureDialog &) = delete; + HighlightConfigureDialog(HighlightConfigureDialog &&) = delete; + HighlightConfigureDialog &operator=(const HighlightConfigureDialog &) = + delete; + HighlightConfigureDialog &operator=(HighlightConfigureDialog &&) = delete; + ~HighlightConfigureDialog() override; + +private: + Ui::HighlightConfigureDialog *ui_; +}; + +} // namespace chatterino diff --git a/src/widgets/dialogs/HighlightConfigureDialog.ui b/src/widgets/dialogs/HighlightConfigureDialog.ui new file mode 100644 index 000000000..96531df10 --- /dev/null +++ b/src/widgets/dialogs/HighlightConfigureDialog.ui @@ -0,0 +1,141 @@ + + + HighlightConfigureDialog + + + + 0 + 0 + 400 + 300 + + + + Configure highlight + + + true + + + + + + + + Pattern + + + + + + + + + + Show in Mentions + + + + + + + + + + Flask taskbar + + + + + + + + + + Enable regex + + + + + + + + + + Play sound + + + + + + + + + + Custom sound + + + + + + + + + + Color + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + HighlightConfigureDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + HighlightConfigureDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/widgets/settingspages/HighlightingPage.cpp b/src/widgets/settingspages/HighlightingPage.cpp index 75d8ad4b5..4946dc436 100644 --- a/src/widgets/settingspages/HighlightingPage.cpp +++ b/src/widgets/settingspages/HighlightingPage.cpp @@ -1,4 +1,4 @@ -#include "HighlightingPage.hpp" +#include "widgets/settingspages/HighlightingPage.hpp" #include "Application.hpp" #include "controllers/highlights/BadgeHighlightModel.hpp" @@ -15,6 +15,7 @@ #include "util/LayoutCreator.hpp" #include "widgets/dialogs/BadgePickerDialog.hpp" #include "widgets/dialogs/ColorPickerDialog.hpp" +#include "widgets/dialogs/HighlightConfigureDialog.hpp" #include "widgets/helper/color/ColorItemDelegate.hpp" #include "widgets/helper/EditableModelView.hpp" @@ -75,10 +76,17 @@ HighlightingPage::HighlightingPage() &getSettings()->highlightedMessages)) .getElement(); view->addRegexHelpLink(); - view->setTitles({"Pattern", "Show in\nMentions", - "Flash\ntaskbar", "Enable\nregex", - "Case-\nsensitive", "Play\nsound", - "Custom\nsound", "Color"}); + view->setTitles({ + "Pattern", + "Show in\nMentions", + "Flash\ntaskbar", + "Enable\nregex", + "Case-\nsensitive", + "Play\nsound", + "Custom\nsound", + "Color", + "Configure", + }); view->getTableView()->horizontalHeader()->setSectionResizeMode( QHeaderView::Fixed); view->getTableView()->horizontalHeader()->setSectionResizeMode( @@ -353,6 +361,21 @@ void HighlightingPage::openColorDialog(const QModelIndex &clicked, dialog->show(); } +void HighlightingPage::openConfigureDialog(const QModelIndex &clicked, + EditableModelView *view, + HighlightTab tab) +{ + if (tab != HighlightTab::Messages) + { + return; + } + + auto phrase = + getSettings()->highlightedMessages.readOnly()->at(clicked.row()); + auto *xd = new HighlightConfigureDialog(phrase, this); + xd->show(); +} + void HighlightingPage::tableCellClicked(const QModelIndex &clicked, EditableModelView *view, HighlightTab tab) @@ -376,6 +399,10 @@ void HighlightingPage::tableCellClicked(const QModelIndex &clicked, { this->openColorDialog(clicked, view, tab); } + else if (clicked.column() == Column::Configure) + { + this->openConfigureDialog(clicked, view, tab); + } } break; diff --git a/src/widgets/settingspages/HighlightingPage.hpp b/src/widgets/settingspages/HighlightingPage.hpp index 47a9c3e3a..6d0a6f6a5 100644 --- a/src/widgets/settingspages/HighlightingPage.hpp +++ b/src/widgets/settingspages/HighlightingPage.hpp @@ -28,6 +28,8 @@ private: int soundColumn); void openColorDialog(const QModelIndex &clicked, EditableModelView *view, HighlightTab tab); + void openConfigureDialog(const QModelIndex &clicked, + EditableModelView *view, HighlightTab tab); }; } // namespace chatterino