2018-06-26 14:09:39 +02:00
|
|
|
#include "HighlightingPage.hpp"
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2018-06-26 14:09:39 +02:00
|
|
|
#include "Application.hpp"
|
2021-05-03 00:08:08 +02:00
|
|
|
#include "controllers/highlights/BadgeHighlightModel.hpp"
|
2022-12-31 15:41:01 +01:00
|
|
|
#include "controllers/highlights/HighlightBadge.hpp"
|
2018-07-04 13:22:27 +02:00
|
|
|
#include "controllers/highlights/HighlightBlacklistModel.hpp"
|
2022-12-31 15:41:01 +01:00
|
|
|
#include "controllers/highlights/HighlightBlacklistUser.hpp"
|
2018-06-26 14:09:39 +02:00
|
|
|
#include "controllers/highlights/HighlightModel.hpp"
|
2022-12-31 15:41:01 +01:00
|
|
|
#include "controllers/highlights/HighlightPhrase.hpp"
|
2018-07-05 15:58:20 +02:00
|
|
|
#include "controllers/highlights/UserHighlightModel.hpp"
|
2022-12-31 15:41:01 +01:00
|
|
|
#include "providers/colors/ColorProvider.hpp"
|
2018-06-28 19:46:45 +02:00
|
|
|
#include "singletons/Settings.hpp"
|
2020-01-25 11:03:10 +01:00
|
|
|
#include "singletons/Theme.hpp"
|
2022-12-03 17:01:49 +01:00
|
|
|
#include "util/Helpers.hpp"
|
2018-06-26 14:09:39 +02:00
|
|
|
#include "util/LayoutCreator.hpp"
|
2021-05-03 00:08:08 +02:00
|
|
|
#include "widgets/dialogs/BadgePickerDialog.hpp"
|
2020-01-25 11:03:10 +01:00
|
|
|
#include "widgets/dialogs/ColorPickerDialog.hpp"
|
2022-12-31 15:41:01 +01:00
|
|
|
#include "widgets/helper/EditableModelView.hpp"
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2018-01-13 02:00:02 +01:00
|
|
|
#include <QFileDialog>
|
2018-06-21 13:02:34 +02:00
|
|
|
#include <QHeaderView>
|
2018-01-13 02:00:02 +01:00
|
|
|
#include <QPushButton>
|
2018-04-26 20:58:32 +02:00
|
|
|
#include <QStandardItemModel>
|
2018-04-25 14:49:30 +02:00
|
|
|
#include <QTableView>
|
Sort and force grouping of includes (#4172)
This change enforces strict include grouping using IncludeCategories
In addition to adding this to the .clang-format file and applying it in the tests/src and src directories, I also did the following small changes:
In ChatterSet.hpp, I changed lrucache to a <>include
In Irc2.hpp, I change common/SignalVector.hpp to a "project-include"
In AttachedWindow.cpp, NativeMessaging.cpp, WindowsHelper.hpp, BaseWindow.cpp, and StreamerMode.cpp, I disabled clang-format for the windows-includes
In WindowDescriptors.hpp, I added the missing vector include. It was previously not needed because the include was handled by another file that was previously included first.
clang-format minimum version has been bumped, so Ubuntu version used in the check-formatting job has been bumped to 22.04 (which is the latest LTS)
2022-11-27 19:32:53 +01:00
|
|
|
#include <QTabWidget>
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2019-08-26 14:07:21 +02:00
|
|
|
#define ALWAYS_PLAY "Play highlight sound even when Chatterino is focused"
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2018-01-12 23:09:05 +01:00
|
|
|
namespace chatterino {
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2021-05-03 00:08:08 +02:00
|
|
|
namespace {
|
|
|
|
// Add additional badges for highlights here
|
|
|
|
QList<DisplayBadge> availableBadges = {
|
|
|
|
{"Broadcaster", "broadcaster"},
|
|
|
|
{"Admin", "admin"},
|
|
|
|
{"Staff", "staff"},
|
|
|
|
{"Moderator", "moderator"},
|
|
|
|
{"Verified", "partner"},
|
|
|
|
{"VIP", "vip"},
|
2022-01-02 13:30:53 +01:00
|
|
|
{"Founder", "founder"},
|
|
|
|
{"Subscriber", "subscriber"},
|
2021-05-03 00:08:08 +02:00
|
|
|
{"Predicted Blue", "predictions/blue-1,predictions/blue-2"},
|
|
|
|
{"Predicted Pink", "predictions/pink-2,predictions/pink-1"},
|
|
|
|
};
|
|
|
|
} // namespace
|
|
|
|
|
2018-01-12 23:09:05 +01:00
|
|
|
HighlightingPage::HighlightingPage()
|
|
|
|
{
|
2018-06-26 17:06:17 +02:00
|
|
|
LayoutCreator<HighlightingPage> layoutCreator(this);
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2018-01-13 02:00:02 +01:00
|
|
|
auto layout = layoutCreator.emplace<QVBoxLayout>().withoutMargin();
|
|
|
|
{
|
|
|
|
// GENERAL
|
2018-04-28 13:48:49 +02:00
|
|
|
// layout.append(this->createCheckBox(ENABLE_HIGHLIGHTS,
|
2018-08-12 12:56:28 +02:00
|
|
|
// getSettings()->enableHighlights));
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2018-01-13 02:00:02 +01:00
|
|
|
// TABS
|
|
|
|
auto tabs = layout.emplace<QTabWidget>();
|
|
|
|
{
|
|
|
|
// HIGHLIGHTS
|
2019-08-26 14:36:06 +02:00
|
|
|
auto highlights = tabs.appendTab(new QVBoxLayout, "Messages");
|
2018-01-13 02:00:02 +01:00
|
|
|
{
|
2020-01-25 11:03:10 +01:00
|
|
|
highlights.emplace<QLabel>(
|
2020-02-10 16:41:49 +01:00
|
|
|
"Play notification sounds and highlight messages based on "
|
2021-05-03 00:08:08 +02:00
|
|
|
"certain patterns.\n"
|
2023-01-15 14:21:42 +01:00
|
|
|
"Message highlights are prioritized over badge highlights "
|
|
|
|
"and user highlights.");
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2020-02-23 19:31:43 +01:00
|
|
|
auto view =
|
2018-06-26 17:20:03 +02:00
|
|
|
highlights
|
|
|
|
.emplace<EditableModelView>(
|
2020-02-23 19:31:43 +01:00
|
|
|
(new HighlightModel(nullptr))
|
2020-02-23 22:15:13 +01:00
|
|
|
->initialized(
|
|
|
|
&getSettings()->highlightedMessages))
|
2018-06-22 12:34:33 +02:00
|
|
|
.getElement();
|
2019-08-26 14:07:21 +02:00
|
|
|
view->addRegexHelpLink();
|
2020-10-24 14:33:15 +02:00
|
|
|
view->setTitles({"Pattern", "Show in\nMentions",
|
2022-12-03 17:01:49 +01:00
|
|
|
"Flash\ntaskbar", "Enable\nregex",
|
|
|
|
"Case-\nsensitive", "Play\nsound",
|
2020-01-25 11:03:10 +01:00
|
|
|
"Custom\nsound", "Color"});
|
2018-05-06 00:32:45 +02:00
|
|
|
view->getTableView()->horizontalHeader()->setSectionResizeMode(
|
|
|
|
QHeaderView::Fixed);
|
2018-05-07 00:47:35 +02:00
|
|
|
view->getTableView()->horizontalHeader()->setSectionResizeMode(
|
|
|
|
0, QHeaderView::Stretch);
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2018-04-25 20:35:32 +02:00
|
|
|
// fourtf: make class extrend BaseWidget and add this to
|
|
|
|
// dpiChanged
|
|
|
|
QTimer::singleShot(1, [view] {
|
2018-05-06 00:32:45 +02:00
|
|
|
view->getTableView()->resizeColumnsToContents();
|
2022-12-03 17:01:49 +01:00
|
|
|
view->getTableView()->setColumnWidth(0, 400);
|
2018-04-25 20:35:32 +02:00
|
|
|
});
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2018-05-06 00:32:45 +02:00
|
|
|
view->addButtonPressed.connect([] {
|
2020-02-23 22:15:13 +01:00
|
|
|
getSettings()->highlightedMessages.append(HighlightPhrase{
|
2020-10-24 14:33:15 +02:00
|
|
|
"my phrase", true, true, false, false, false, "",
|
2020-01-25 11:03:10 +01:00
|
|
|
*ColorProvider::instance().color(
|
|
|
|
ColorType::SelfHighlight)});
|
2018-04-26 20:58:32 +02:00
|
|
|
});
|
2020-01-25 11:03:10 +01:00
|
|
|
|
|
|
|
QObject::connect(view->getTableView(), &QTableView::clicked,
|
|
|
|
[this, view](const QModelIndex &clicked) {
|
2021-05-03 00:08:08 +02:00
|
|
|
this->tableCellClicked(
|
|
|
|
clicked, view, HighlightTab::Messages);
|
2020-01-25 11:03:10 +01:00
|
|
|
});
|
2018-01-13 02:00:02 +01:00
|
|
|
}
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2018-07-05 16:22:25 +02:00
|
|
|
auto pingUsers = tabs.appendTab(new QVBoxLayout, "Users");
|
2018-01-13 02:00:02 +01:00
|
|
|
{
|
2019-08-26 14:36:06 +02:00
|
|
|
pingUsers.emplace<QLabel>(
|
2020-02-10 16:41:49 +01:00
|
|
|
"Play notification sounds and highlight messages from "
|
|
|
|
"certain users.\n"
|
2023-01-15 14:21:42 +01:00
|
|
|
"User highlights are prioritized badge highlights, but "
|
|
|
|
"under message highlights.");
|
2018-07-04 13:22:27 +02:00
|
|
|
EditableModelView *view =
|
2018-07-05 16:22:25 +02:00
|
|
|
pingUsers
|
|
|
|
.emplace<EditableModelView>(
|
2020-02-23 19:31:43 +01:00
|
|
|
(new UserHighlightModel(nullptr))
|
2020-02-23 22:15:13 +01:00
|
|
|
->initialized(&getSettings()->highlightedUsers))
|
2018-07-04 13:22:27 +02:00
|
|
|
.getElement();
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2019-08-26 14:07:21 +02:00
|
|
|
view->addRegexHelpLink();
|
2021-02-12 14:43:18 +01:00
|
|
|
view->getTableView()->horizontalHeader()->hideSection(
|
|
|
|
HighlightModel::Column::UseRegex);
|
|
|
|
view->getTableView()->horizontalHeader()->hideSection(
|
|
|
|
HighlightModel::Column::CaseSensitive);
|
2019-09-07 18:56:21 +02:00
|
|
|
// Case-sensitivity doesn't make sense for user names so it is
|
2020-01-25 11:03:10 +01:00
|
|
|
// set to "false" by default & the column is hidden
|
2020-10-24 14:33:15 +02:00
|
|
|
view->setTitles({"Username", "Show in\nMentions",
|
2022-12-03 17:01:49 +01:00
|
|
|
"Flash\ntaskbar", "Enable\nregex",
|
|
|
|
"Case-\nsensitive", "Play\nsound",
|
2020-01-25 11:03:10 +01:00
|
|
|
"Custom\nsound", "Color"});
|
2018-07-04 13:22:27 +02:00
|
|
|
view->getTableView()->horizontalHeader()->setSectionResizeMode(
|
|
|
|
QHeaderView::Fixed);
|
|
|
|
view->getTableView()->horizontalHeader()->setSectionResizeMode(
|
|
|
|
0, QHeaderView::Stretch);
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2018-07-04 13:22:27 +02:00
|
|
|
// fourtf: make class extrend BaseWidget and add this to
|
|
|
|
// dpiChanged
|
|
|
|
QTimer::singleShot(1, [view] {
|
|
|
|
view->getTableView()->resizeColumnsToContents();
|
|
|
|
view->getTableView()->setColumnWidth(0, 200);
|
|
|
|
});
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2018-07-04 13:22:27 +02:00
|
|
|
view->addButtonPressed.connect([] {
|
2020-02-23 22:15:13 +01:00
|
|
|
getSettings()->highlightedUsers.append(HighlightPhrase{
|
2020-10-24 14:33:15 +02:00
|
|
|
"highlighted user", true, true, false, false, false, "",
|
2020-02-23 21:18:40 +01:00
|
|
|
*ColorProvider::instance().color(
|
|
|
|
ColorType::SelfHighlight)});
|
2018-01-13 02:00:02 +01:00
|
|
|
});
|
2020-01-25 11:03:10 +01:00
|
|
|
|
|
|
|
QObject::connect(view->getTableView(), &QTableView::clicked,
|
|
|
|
[this, view](const QModelIndex &clicked) {
|
2021-05-03 00:08:08 +02:00
|
|
|
this->tableCellClicked(
|
|
|
|
clicked, view, HighlightTab::Users);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
auto badgeHighlights = tabs.appendTab(new QVBoxLayout, "Badges");
|
|
|
|
{
|
|
|
|
badgeHighlights.emplace<QLabel>(
|
|
|
|
"Play notification sounds and highlight messages based on "
|
|
|
|
"user badges.\n"
|
|
|
|
"Badge highlights are prioritzed under user and message "
|
|
|
|
"highlights.");
|
|
|
|
auto view = badgeHighlights
|
|
|
|
.emplace<EditableModelView>(
|
|
|
|
(new BadgeHighlightModel(nullptr))
|
|
|
|
->initialized(
|
|
|
|
&getSettings()->highlightedBadges))
|
|
|
|
.getElement();
|
2022-10-02 13:25:10 +02:00
|
|
|
view->setTitles({"Name", "Show In\nMentions", "Flash\ntaskbar",
|
|
|
|
"Play\nsound", "Custom\nsound", "Color"});
|
2021-05-03 00:08:08 +02:00
|
|
|
view->getTableView()->horizontalHeader()->setSectionResizeMode(
|
|
|
|
QHeaderView::Fixed);
|
|
|
|
view->getTableView()->horizontalHeader()->setSectionResizeMode(
|
|
|
|
0, QHeaderView::Stretch);
|
|
|
|
|
|
|
|
// fourtf: make class extrend BaseWidget and add this to
|
|
|
|
// dpiChanged
|
|
|
|
QTimer::singleShot(1, [view] {
|
|
|
|
view->getTableView()->resizeColumnsToContents();
|
|
|
|
view->getTableView()->setColumnWidth(0, 200);
|
|
|
|
});
|
|
|
|
|
|
|
|
view->addButtonPressed.connect([this] {
|
|
|
|
auto d = std::make_shared<BadgePickerDialog>(
|
|
|
|
availableBadges, this);
|
|
|
|
|
|
|
|
d->setWindowTitle("Choose badge");
|
|
|
|
if (d->exec() == QDialog::Accepted)
|
|
|
|
{
|
|
|
|
auto s = d->getSelection();
|
|
|
|
if (!s)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2022-10-02 13:25:10 +02:00
|
|
|
getSettings()->highlightedBadges.append(
|
|
|
|
HighlightBadge{s->badgeName(), s->displayName(),
|
|
|
|
false, false, false, "",
|
|
|
|
*ColorProvider::instance().color(
|
|
|
|
ColorType::SelfHighlight)});
|
2021-05-03 00:08:08 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
QObject::connect(view->getTableView(), &QTableView::clicked,
|
|
|
|
[this, view](const QModelIndex &clicked) {
|
|
|
|
this->tableCellClicked(
|
|
|
|
clicked, view, HighlightTab::Badges);
|
2020-01-25 11:03:10 +01:00
|
|
|
});
|
2018-01-13 02:00:02 +01:00
|
|
|
}
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2018-07-05 16:22:25 +02:00
|
|
|
auto disabledUsers =
|
2020-02-10 16:41:49 +01:00
|
|
|
tabs.appendTab(new QVBoxLayout, "Blacklisted Users");
|
2018-07-05 15:58:20 +02:00
|
|
|
{
|
2019-08-26 14:36:06 +02:00
|
|
|
disabledUsers.emplace<QLabel>(
|
2020-02-10 16:41:49 +01:00
|
|
|
"Disable notification sounds and highlights from certain "
|
|
|
|
"users (e.g. bots).");
|
2018-07-05 15:58:20 +02:00
|
|
|
EditableModelView *view =
|
2018-07-05 16:22:25 +02:00
|
|
|
disabledUsers
|
|
|
|
.emplace<EditableModelView>(
|
2020-02-23 19:31:43 +01:00
|
|
|
(new HighlightBlacklistModel(nullptr))
|
2020-02-23 22:15:13 +01:00
|
|
|
->initialized(&getSettings()->blacklistedUsers))
|
2018-07-05 15:58:20 +02:00
|
|
|
.getElement();
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2019-08-26 14:07:21 +02:00
|
|
|
view->addRegexHelpLink();
|
2020-02-10 16:41:49 +01:00
|
|
|
view->setTitles({"Username", "Enable\nregex"});
|
2018-07-05 15:58:20 +02:00
|
|
|
view->getTableView()->horizontalHeader()->setSectionResizeMode(
|
|
|
|
QHeaderView::Fixed);
|
|
|
|
view->getTableView()->horizontalHeader()->setSectionResizeMode(
|
|
|
|
0, QHeaderView::Stretch);
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2018-07-05 15:58:20 +02:00
|
|
|
// fourtf: make class extrend BaseWidget and add this to
|
|
|
|
// dpiChanged
|
|
|
|
QTimer::singleShot(1, [view] {
|
|
|
|
view->getTableView()->resizeColumnsToContents();
|
|
|
|
view->getTableView()->setColumnWidth(0, 200);
|
|
|
|
});
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2018-07-05 15:58:20 +02:00
|
|
|
view->addButtonPressed.connect([] {
|
2020-02-23 22:15:13 +01:00
|
|
|
getSettings()->blacklistedUsers.append(
|
2018-07-05 16:22:25 +02:00
|
|
|
HighlightBlacklistUser{"blacklisted user", false});
|
2018-07-05 15:58:20 +02:00
|
|
|
});
|
|
|
|
}
|
2018-01-13 02:00:02 +01:00
|
|
|
}
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2018-04-26 23:07:02 +02:00
|
|
|
// MISC
|
|
|
|
auto customSound = layout.emplace<QHBoxLayout>().withoutMargin();
|
|
|
|
{
|
2022-12-03 17:01:49 +01:00
|
|
|
auto label = customSound.append(this->createLabel<QString>(
|
|
|
|
[](const auto &value) {
|
|
|
|
if (value.isEmpty())
|
|
|
|
{
|
|
|
|
return QString("Default sound: Chatterino Ping");
|
|
|
|
}
|
|
|
|
|
|
|
|
auto url = QUrl::fromLocalFile(value);
|
|
|
|
return QString("Default sound: <a href=\"%1\"><span "
|
|
|
|
"style=\"color: white\">%2</span></a>")
|
|
|
|
.arg(url.toString(QUrl::FullyEncoded),
|
|
|
|
shortenString(url.fileName(), 50));
|
|
|
|
},
|
|
|
|
getSettings()->pathHighlightSound));
|
|
|
|
label->setToolTip(
|
|
|
|
"This sound will play for all highlight phrases that have "
|
|
|
|
"sound enabled and don't have a custom sound set.");
|
|
|
|
label->setTextFormat(Qt::RichText);
|
|
|
|
label->setTextInteractionFlags(Qt::TextBrowserInteraction |
|
|
|
|
Qt::LinksAccessibleByKeyboard);
|
|
|
|
label->setOpenExternalLinks(true);
|
|
|
|
customSound->setStretchFactor(label.getElement(), 1);
|
|
|
|
|
|
|
|
auto clearSound = customSound.emplace<QPushButton>("Clear");
|
|
|
|
auto selectFile = customSound.emplace<QPushButton>("Change...");
|
|
|
|
|
|
|
|
QObject::connect(selectFile.getElement(), &QPushButton::clicked,
|
2022-12-24 12:56:11 +01:00
|
|
|
this, [this]() mutable {
|
2022-12-03 17:01:49 +01:00
|
|
|
auto fileName = QFileDialog::getOpenFileName(
|
|
|
|
this, tr("Open Sound"), "",
|
|
|
|
tr("Audio Files (*.mp3 *.wav)"));
|
|
|
|
|
|
|
|
getSettings()->pathHighlightSound = fileName;
|
|
|
|
});
|
|
|
|
QObject::connect(clearSound.getElement(), &QPushButton::clicked,
|
|
|
|
this, [=]() mutable {
|
|
|
|
getSettings()->pathHighlightSound = QString();
|
|
|
|
});
|
|
|
|
|
|
|
|
getSettings()->pathHighlightSound.connect(
|
|
|
|
[clearSound = clearSound.getElement()](const auto &value) {
|
|
|
|
if (value.isEmpty())
|
|
|
|
{
|
|
|
|
clearSound->hide();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
clearSound->show();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
this->managedConnections_);
|
2018-04-26 23:07:02 +02:00
|
|
|
}
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2018-04-27 22:11:19 +02:00
|
|
|
layout.append(createCheckBox(ALWAYS_PLAY,
|
2018-08-12 12:56:28 +02:00
|
|
|
getSettings()->highlightAlwaysPlaySound));
|
2018-10-06 17:51:13 +02:00
|
|
|
layout.append(createCheckBox(
|
2021-10-17 15:06:58 +02:00
|
|
|
"Flash taskbar only stops highlighting when Chatterino is focused",
|
2018-10-06 17:51:13 +02:00
|
|
|
getSettings()->longAlerts));
|
2018-01-13 02:00:02 +01:00
|
|
|
}
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2018-01-13 02:00:02 +01:00
|
|
|
// ---- misc
|
2018-07-06 19:23:47 +02:00
|
|
|
this->disabledUsersChangedTimer_.setSingleShot(true);
|
2021-05-03 00:08:08 +02:00
|
|
|
}
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2021-05-03 00:08:08 +02:00
|
|
|
void HighlightingPage::openSoundDialog(const QModelIndex &clicked,
|
|
|
|
EditableModelView *view, int soundColumn)
|
2020-01-25 11:03:10 +01:00
|
|
|
{
|
2021-05-03 00:08:08 +02:00
|
|
|
auto fileUrl = QFileDialog::getOpenFileUrl(this, tr("Open Sound"), QUrl(),
|
|
|
|
tr("Audio Files (*.mp3 *.wav)"));
|
|
|
|
view->getModel()->setData(clicked, fileUrl, Qt::UserRole);
|
|
|
|
view->getModel()->setData(clicked, fileUrl.fileName(), Qt::DisplayRole);
|
|
|
|
}
|
2020-08-22 23:10:10 +02:00
|
|
|
|
2021-05-03 00:08:08 +02:00
|
|
|
void HighlightingPage::openColorDialog(const QModelIndex &clicked,
|
|
|
|
EditableModelView *view,
|
|
|
|
HighlightTab tab)
|
|
|
|
{
|
|
|
|
auto initial =
|
|
|
|
view->getModel()->data(clicked, Qt::DecorationRole).value<QColor>();
|
|
|
|
|
|
|
|
auto dialog = new ColorPickerDialog(initial, this);
|
|
|
|
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
dialog->show();
|
|
|
|
dialog->closed.connect([=](auto selected) {
|
|
|
|
if (selected.isValid())
|
|
|
|
{
|
|
|
|
view->getModel()->setData(clicked, selected, Qt::DecorationRole);
|
2020-01-25 11:03:10 +01:00
|
|
|
|
2021-05-03 00:08:08 +02:00
|
|
|
if (tab == HighlightTab::Messages)
|
2020-01-25 11:03:10 +01:00
|
|
|
{
|
2021-05-03 00:08:08 +02:00
|
|
|
/*
|
|
|
|
* For preset highlights in the "Messages" tab, we need to
|
|
|
|
* manually update the color map.
|
|
|
|
*/
|
|
|
|
auto instance = ColorProvider::instance();
|
|
|
|
switch (clicked.row())
|
2020-01-25 11:03:10 +01:00
|
|
|
{
|
2021-05-03 00:08:08 +02:00
|
|
|
case 0:
|
|
|
|
instance.updateColor(ColorType::SelfHighlight,
|
|
|
|
selected);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
instance.updateColor(ColorType::Whisper, selected);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
instance.updateColor(ColorType::Subscription, selected);
|
|
|
|
break;
|
2020-01-25 11:03:10 +01:00
|
|
|
}
|
|
|
|
}
|
2021-05-03 00:08:08 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void HighlightingPage::tableCellClicked(const QModelIndex &clicked,
|
|
|
|
EditableModelView *view,
|
|
|
|
HighlightTab tab)
|
|
|
|
{
|
|
|
|
switch (tab)
|
|
|
|
{
|
|
|
|
case HighlightTab::Messages:
|
|
|
|
case HighlightTab::Users: {
|
|
|
|
using Column = HighlightModel::Column;
|
2021-06-29 22:32:07 +02:00
|
|
|
bool restrictColorRow =
|
|
|
|
(tab == HighlightTab::Messages &&
|
2022-06-25 11:14:19 +02:00
|
|
|
clicked.row() ==
|
|
|
|
HighlightModel::HighlightRowIndexes::WhisperRow);
|
2022-12-03 17:01:49 +01:00
|
|
|
if (clicked.column() == Column::SoundPath &&
|
|
|
|
clicked.flags().testFlag(Qt::ItemIsEnabled))
|
2021-05-03 00:08:08 +02:00
|
|
|
{
|
|
|
|
this->openSoundDialog(clicked, view, Column::SoundPath);
|
|
|
|
}
|
2021-06-29 22:32:07 +02:00
|
|
|
else if (clicked.column() == Column::Color && !restrictColorRow)
|
2021-05-03 00:08:08 +02:00
|
|
|
{
|
|
|
|
this->openColorDialog(clicked, view, tab);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HighlightTab::Badges: {
|
|
|
|
using Column = BadgeHighlightModel::Column;
|
|
|
|
if (clicked.column() == Column::SoundPath)
|
|
|
|
{
|
|
|
|
this->openSoundDialog(clicked, view, Column::SoundPath);
|
|
|
|
}
|
|
|
|
else if (clicked.column() == Column::Color)
|
|
|
|
{
|
|
|
|
this->openColorDialog(clicked, view, tab);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2020-01-25 11:03:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-12 23:09:05 +01:00
|
|
|
} // namespace chatterino
|