mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Clear up Highlight sound settings (#4194)
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com> Closes https://github.com/Chatterino/chatterino2/issues/1540
This commit is contained in:
parent
8d4ee72478
commit
2aa8af47e7
8 changed files with 99 additions and 88 deletions
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
## Unversioned
|
## Unversioned
|
||||||
|
|
||||||
|
- Minor: Cleared up highlight sound settings (#4194)
|
||||||
|
- Bugfix: Fixed highlight sounds not reloading on change properly. (#4194)
|
||||||
- Bugfix: Fixed CTRL + C not working in reply thread popups. (#4209)
|
- Bugfix: Fixed CTRL + C not working in reply thread popups. (#4209)
|
||||||
- Bugfix: Fixed message input showing as red after removing a message that was more than 500 characters. (#4204)
|
- Bugfix: Fixed message input showing as red after removing a message that was more than 500 characters. (#4204)
|
||||||
- Bugfix: Fixed unnecessary saving of windows layout. (#4201)
|
- Bugfix: Fixed unnecessary saving of windows layout. (#4201)
|
||||||
|
|
|
@ -50,8 +50,7 @@ void rebuildSubscriptionHighlights(Settings &settings,
|
||||||
{
|
{
|
||||||
auto highlightSound = settings.enableSubHighlightSound.getValue();
|
auto highlightSound = settings.enableSubHighlightSound.getValue();
|
||||||
auto highlightAlert = settings.enableSubHighlightTaskbar.getValue();
|
auto highlightAlert = settings.enableSubHighlightTaskbar.getValue();
|
||||||
auto highlightSoundUrlValue =
|
auto highlightSoundUrlValue = settings.subHighlightSoundUrl.getValue();
|
||||||
settings.whisperHighlightSoundUrl.getValue();
|
|
||||||
boost::optional<QUrl> highlightSoundUrl;
|
boost::optional<QUrl> highlightSoundUrl;
|
||||||
if (!highlightSoundUrlValue.isEmpty())
|
if (!highlightSoundUrlValue.isEmpty())
|
||||||
{
|
{
|
||||||
|
@ -284,15 +283,22 @@ namespace chatterino {
|
||||||
|
|
||||||
void HighlightController::initialize(Settings &settings, Paths & /*paths*/)
|
void HighlightController::initialize(Settings &settings, Paths & /*paths*/)
|
||||||
{
|
{
|
||||||
|
this->rebuildListener_.addSetting(settings.enableSelfHighlight);
|
||||||
|
this->rebuildListener_.addSetting(settings.enableSelfHighlightSound);
|
||||||
|
this->rebuildListener_.addSetting(settings.enableSelfHighlightTaskbar);
|
||||||
|
this->rebuildListener_.addSetting(settings.selfHighlightSoundUrl);
|
||||||
|
this->rebuildListener_.addSetting(settings.showSelfHighlightInMentions);
|
||||||
|
|
||||||
this->rebuildListener_.addSetting(settings.enableWhisperHighlight);
|
this->rebuildListener_.addSetting(settings.enableWhisperHighlight);
|
||||||
this->rebuildListener_.addSetting(settings.enableWhisperHighlightSound);
|
this->rebuildListener_.addSetting(settings.enableWhisperHighlightSound);
|
||||||
this->rebuildListener_.addSetting(settings.enableWhisperHighlightTaskbar);
|
this->rebuildListener_.addSetting(settings.enableWhisperHighlightTaskbar);
|
||||||
this->rebuildListener_.addSetting(settings.whisperHighlightSoundUrl);
|
this->rebuildListener_.addSetting(settings.whisperHighlightSoundUrl);
|
||||||
this->rebuildListener_.addSetting(settings.whisperHighlightColor);
|
|
||||||
this->rebuildListener_.addSetting(settings.enableSelfHighlight);
|
|
||||||
this->rebuildListener_.addSetting(settings.enableSubHighlight);
|
this->rebuildListener_.addSetting(settings.enableSubHighlight);
|
||||||
this->rebuildListener_.addSetting(settings.enableSubHighlightSound);
|
this->rebuildListener_.addSetting(settings.enableSubHighlightSound);
|
||||||
this->rebuildListener_.addSetting(settings.enableSubHighlightTaskbar);
|
this->rebuildListener_.addSetting(settings.enableSubHighlightTaskbar);
|
||||||
|
this->rebuildListener_.addSetting(settings.subHighlightSoundUrl);
|
||||||
|
|
||||||
this->rebuildListener_.addSetting(settings.enableThreadHighlight);
|
this->rebuildListener_.addSetting(settings.enableThreadHighlight);
|
||||||
this->rebuildListener_.addSetting(settings.enableThreadHighlightSound);
|
this->rebuildListener_.addSetting(settings.enableThreadHighlightSound);
|
||||||
this->rebuildListener_.addSetting(settings.enableThreadHighlightTaskbar);
|
this->rebuildListener_.addSetting(settings.enableThreadHighlightTaskbar);
|
||||||
|
|
|
@ -140,10 +140,7 @@ void HighlightModel::afterInit()
|
||||||
redeemedRow[Column::PlaySound]->setFlags({});
|
redeemedRow[Column::PlaySound]->setFlags({});
|
||||||
redeemedRow[Column::UseRegex]->setFlags({});
|
redeemedRow[Column::UseRegex]->setFlags({});
|
||||||
redeemedRow[Column::CaseSensitive]->setFlags({});
|
redeemedRow[Column::CaseSensitive]->setFlags({});
|
||||||
|
redeemedRow[Column::SoundPath]->setFlags(Qt::NoItemFlags);
|
||||||
QUrl RedeemedSound =
|
|
||||||
QUrl(getSettings()->redeemedHighlightSoundUrl.getValue());
|
|
||||||
setFilePathItem(redeemedRow[Column::SoundPath], RedeemedSound, false);
|
|
||||||
|
|
||||||
auto RedeemedColor =
|
auto RedeemedColor =
|
||||||
ColorProvider::instance().color(ColorType::RedeemedHighlight);
|
ColorProvider::instance().color(ColorType::RedeemedHighlight);
|
||||||
|
@ -169,11 +166,7 @@ void HighlightModel::afterInit()
|
||||||
firstMessageRow[Column::PlaySound]->setFlags({});
|
firstMessageRow[Column::PlaySound]->setFlags({});
|
||||||
firstMessageRow[Column::UseRegex]->setFlags({});
|
firstMessageRow[Column::UseRegex]->setFlags({});
|
||||||
firstMessageRow[Column::CaseSensitive]->setFlags({});
|
firstMessageRow[Column::CaseSensitive]->setFlags({});
|
||||||
|
firstMessageRow[Column::SoundPath]->setFlags(Qt::NoItemFlags);
|
||||||
QUrl FirstMessageSound =
|
|
||||||
QUrl(getSettings()->firstMessageHighlightSoundUrl.getValue());
|
|
||||||
setFilePathItem(firstMessageRow[Column::SoundPath], FirstMessageSound,
|
|
||||||
false);
|
|
||||||
|
|
||||||
auto FirstMessageColor =
|
auto FirstMessageColor =
|
||||||
ColorProvider::instance().color(ColorType::FirstMessageHighlight);
|
ColorProvider::instance().color(ColorType::FirstMessageHighlight);
|
||||||
|
@ -200,11 +193,7 @@ void HighlightModel::afterInit()
|
||||||
elevatedMessageRow[Column::PlaySound]->setFlags({});
|
elevatedMessageRow[Column::PlaySound]->setFlags({});
|
||||||
elevatedMessageRow[Column::UseRegex]->setFlags({});
|
elevatedMessageRow[Column::UseRegex]->setFlags({});
|
||||||
elevatedMessageRow[Column::CaseSensitive]->setFlags({});
|
elevatedMessageRow[Column::CaseSensitive]->setFlags({});
|
||||||
|
elevatedMessageRow[Column::SoundPath]->setFlags(Qt::NoItemFlags);
|
||||||
QUrl elevatedMessageSound =
|
|
||||||
QUrl(getSettings()->elevatedMessageHighlightSoundUrl.getValue());
|
|
||||||
setFilePathItem(elevatedMessageRow[Column::SoundPath], elevatedMessageSound,
|
|
||||||
false);
|
|
||||||
|
|
||||||
auto elevatedMessageColor =
|
auto elevatedMessageColor =
|
||||||
ColorProvider::instance().color(ColorType::ElevatedMessageHighlight);
|
ColorProvider::instance().color(ColorType::ElevatedMessageHighlight);
|
||||||
|
@ -416,21 +405,6 @@ void HighlightModel::customRowSetData(const std::vector<QStandardItem *> &row,
|
||||||
getSettings()->subHighlightSoundUrl.setValue(
|
getSettings()->subHighlightSoundUrl.setValue(
|
||||||
value.toString());
|
value.toString());
|
||||||
}
|
}
|
||||||
else if (rowIndex == HighlightRowIndexes::RedeemedRow)
|
|
||||||
{
|
|
||||||
getSettings()->redeemedHighlightSoundUrl.setValue(
|
|
||||||
value.toString());
|
|
||||||
}
|
|
||||||
else if (rowIndex == HighlightRowIndexes::FirstMessageRow)
|
|
||||||
{
|
|
||||||
getSettings()->firstMessageHighlightSoundUrl.setValue(
|
|
||||||
value.toString());
|
|
||||||
}
|
|
||||||
if (rowIndex == HighlightRowIndexes::ElevatedMessageRow)
|
|
||||||
{
|
|
||||||
getSettings()->elevatedMessageHighlightSoundUrl.setValue(
|
|
||||||
value.toString());
|
|
||||||
}
|
|
||||||
else if (rowIndex == HighlightRowIndexes::ThreadMessageRow)
|
else if (rowIndex == HighlightRowIndexes::ThreadMessageRow)
|
||||||
{
|
{
|
||||||
getSettings()->threadHighlightSoundUrl.setValue(
|
getSettings()->threadHighlightSoundUrl.setValue(
|
||||||
|
|
|
@ -17,9 +17,9 @@ public:
|
||||||
Pattern = 0,
|
Pattern = 0,
|
||||||
ShowInMentions = 1,
|
ShowInMentions = 1,
|
||||||
FlashTaskbar = 2,
|
FlashTaskbar = 2,
|
||||||
PlaySound = 3,
|
UseRegex = 3,
|
||||||
UseRegex = 4,
|
CaseSensitive = 4,
|
||||||
CaseSensitive = 5,
|
PlaySound = 5,
|
||||||
SoundPath = 6,
|
SoundPath = 6,
|
||||||
Color = 7,
|
Color = 7,
|
||||||
COUNT // keep this as last member of enum
|
COUNT // keep this as last member of enum
|
||||||
|
|
|
@ -19,14 +19,17 @@ namespace chatterino {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the default sound url if the user set one,
|
||||||
|
* or the chatterino default ping sound if no url is set.
|
||||||
|
*/
|
||||||
QUrl getFallbackHighlightSound()
|
QUrl getFallbackHighlightSound()
|
||||||
{
|
{
|
||||||
QString path = getSettings()->pathHighlightSound;
|
QString path = getSettings()->pathHighlightSound;
|
||||||
bool fileExists = QFileInfo::exists(path) && QFileInfo(path).isFile();
|
bool fileExists = !path.isEmpty() && QFileInfo::exists(path) &&
|
||||||
|
QFileInfo(path).isFile();
|
||||||
|
|
||||||
// Use fallback sound when checkbox is not checked
|
if (fileExists)
|
||||||
// or custom file doesn't exist
|
|
||||||
if (getSettings()->customHighlightSound && fileExists)
|
|
||||||
{
|
{
|
||||||
return QUrl::fromLocalFile(path);
|
return QUrl::fromLocalFile(path);
|
||||||
}
|
}
|
||||||
|
|
|
@ -271,7 +271,6 @@ public:
|
||||||
|
|
||||||
/// Highlighting
|
/// Highlighting
|
||||||
// BoolSetting enableHighlights = {"/highlighting/enabled", true};
|
// BoolSetting enableHighlights = {"/highlighting/enabled", true};
|
||||||
BoolSetting customHighlightSound = {"/highlighting/useCustomSound", false};
|
|
||||||
|
|
||||||
BoolSetting enableSelfHighlight = {
|
BoolSetting enableSelfHighlight = {
|
||||||
"/highlighting/selfHighlight/nameIsHighlightKeyword", true};
|
"/highlighting/selfHighlight/nameIsHighlightKeyword", true};
|
||||||
|
@ -303,8 +302,8 @@ public:
|
||||||
// "/highlighting/redeemedHighlight/enableSound", false};
|
// "/highlighting/redeemedHighlight/enableSound", false};
|
||||||
// BoolSetting enableRedeemedHighlightTaskbar = {
|
// BoolSetting enableRedeemedHighlightTaskbar = {
|
||||||
// "/highlighting/redeemedHighlight/enableTaskbarFlashing", false};
|
// "/highlighting/redeemedHighlight/enableTaskbarFlashing", false};
|
||||||
QStringSetting redeemedHighlightSoundUrl = {
|
// QStringSetting redeemedHighlightSoundUrl = {
|
||||||
"/highlighting/redeemedHighlightSoundUrl", ""};
|
// "/highlighting/redeemedHighlightSoundUrl", ""};
|
||||||
QStringSetting redeemedHighlightColor = {
|
QStringSetting redeemedHighlightColor = {
|
||||||
"/highlighting/redeemedHighlightColor", ""};
|
"/highlighting/redeemedHighlightColor", ""};
|
||||||
|
|
||||||
|
@ -314,8 +313,8 @@ public:
|
||||||
// "/highlighting/firstMessageHighlight/enableSound", false};
|
// "/highlighting/firstMessageHighlight/enableSound", false};
|
||||||
// BoolSetting enableFirstMessageHighlightTaskbar = {
|
// BoolSetting enableFirstMessageHighlightTaskbar = {
|
||||||
// "/highlighting/firstMessageHighlight/enableTaskbarFlashing", false};
|
// "/highlighting/firstMessageHighlight/enableTaskbarFlashing", false};
|
||||||
QStringSetting firstMessageHighlightSoundUrl = {
|
// QStringSetting firstMessageHighlightSoundUrl = {
|
||||||
"/highlighting/firstMessageHighlightSoundUrl", ""};
|
// "/highlighting/firstMessageHighlightSoundUrl", ""};
|
||||||
QStringSetting firstMessageHighlightColor = {
|
QStringSetting firstMessageHighlightColor = {
|
||||||
"/highlighting/firstMessageHighlightColor", ""};
|
"/highlighting/firstMessageHighlightColor", ""};
|
||||||
|
|
||||||
|
@ -325,8 +324,8 @@ public:
|
||||||
// "/highlighting/elevatedMessageHighlight/enableSound", false};
|
// "/highlighting/elevatedMessageHighlight/enableSound", false};
|
||||||
// BoolSetting enableElevatedMessageHighlightTaskbar = {
|
// BoolSetting enableElevatedMessageHighlightTaskbar = {
|
||||||
// "/highlighting/elevatedMessageHighlight/enableTaskbarFlashing", false};
|
// "/highlighting/elevatedMessageHighlight/enableTaskbarFlashing", false};
|
||||||
QStringSetting elevatedMessageHighlightSoundUrl = {
|
// QStringSetting elevatedMessageHighlightSoundUrl = {
|
||||||
"/highlighting/elevatedMessageHighlight/soundUrl", ""};
|
// "/highlighting/elevatedMessageHighlight/soundUrl", ""};
|
||||||
QStringSetting elevatedMessageHighlightColor = {
|
QStringSetting elevatedMessageHighlightColor = {
|
||||||
"/highlighting/elevatedMessageHighlight/color", ""};
|
"/highlighting/elevatedMessageHighlight/color", ""};
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "controllers/highlights/UserHighlightModel.hpp"
|
#include "controllers/highlights/UserHighlightModel.hpp"
|
||||||
#include "singletons/Settings.hpp"
|
#include "singletons/Settings.hpp"
|
||||||
#include "singletons/Theme.hpp"
|
#include "singletons/Theme.hpp"
|
||||||
|
#include "util/Helpers.hpp"
|
||||||
#include "util/LayoutCreator.hpp"
|
#include "util/LayoutCreator.hpp"
|
||||||
#include "util/StandardItemHelper.hpp"
|
#include "util/StandardItemHelper.hpp"
|
||||||
#include "widgets/dialogs/BadgePickerDialog.hpp"
|
#include "widgets/dialogs/BadgePickerDialog.hpp"
|
||||||
|
@ -14,17 +15,11 @@
|
||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QListWidget>
|
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QTableView>
|
#include <QTableView>
|
||||||
#include <QTabWidget>
|
#include <QTabWidget>
|
||||||
#include <QTextEdit>
|
|
||||||
|
|
||||||
#define ENABLE_HIGHLIGHTS "Enable Highlighting"
|
|
||||||
#define HIGHLIGHT_MSG "Highlight messages containing your name"
|
|
||||||
#define PLAY_SOUND "Play sound when your name is mentioned"
|
|
||||||
#define FLASH_TASKBAR "Flash taskbar when your name is mentioned"
|
|
||||||
#define ALWAYS_PLAY "Play highlight sound even when Chatterino is focused"
|
#define ALWAYS_PLAY "Play highlight sound even when Chatterino is focused"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
@ -76,8 +71,8 @@ HighlightingPage::HighlightingPage()
|
||||||
.getElement();
|
.getElement();
|
||||||
view->addRegexHelpLink();
|
view->addRegexHelpLink();
|
||||||
view->setTitles({"Pattern", "Show in\nMentions",
|
view->setTitles({"Pattern", "Show in\nMentions",
|
||||||
"Flash\ntaskbar", "Play\nsound",
|
"Flash\ntaskbar", "Enable\nregex",
|
||||||
"Enable\nregex", "Case-\nsensitive",
|
"Case-\nsensitive", "Play\nsound",
|
||||||
"Custom\nsound", "Color"});
|
"Custom\nsound", "Color"});
|
||||||
view->getTableView()->horizontalHeader()->setSectionResizeMode(
|
view->getTableView()->horizontalHeader()->setSectionResizeMode(
|
||||||
QHeaderView::Fixed);
|
QHeaderView::Fixed);
|
||||||
|
@ -88,7 +83,7 @@ HighlightingPage::HighlightingPage()
|
||||||
// dpiChanged
|
// dpiChanged
|
||||||
QTimer::singleShot(1, [view] {
|
QTimer::singleShot(1, [view] {
|
||||||
view->getTableView()->resizeColumnsToContents();
|
view->getTableView()->resizeColumnsToContents();
|
||||||
view->getTableView()->setColumnWidth(0, 200);
|
view->getTableView()->setColumnWidth(0, 400);
|
||||||
});
|
});
|
||||||
|
|
||||||
view->addButtonPressed.connect([] {
|
view->addButtonPressed.connect([] {
|
||||||
|
@ -127,8 +122,8 @@ HighlightingPage::HighlightingPage()
|
||||||
// Case-sensitivity doesn't make sense for user names so it is
|
// Case-sensitivity doesn't make sense for user names so it is
|
||||||
// set to "false" by default & the column is hidden
|
// set to "false" by default & the column is hidden
|
||||||
view->setTitles({"Username", "Show in\nMentions",
|
view->setTitles({"Username", "Show in\nMentions",
|
||||||
"Flash\ntaskbar", "Play\nsound",
|
"Flash\ntaskbar", "Enable\nregex",
|
||||||
"Enable\nregex", "Case-\nsensitive",
|
"Case-\nsensitive", "Play\nsound",
|
||||||
"Custom\nsound", "Color"});
|
"Custom\nsound", "Color"});
|
||||||
view->getTableView()->horizontalHeader()->setSectionResizeMode(
|
view->getTableView()->horizontalHeader()->setSectionResizeMode(
|
||||||
QHeaderView::Fixed);
|
QHeaderView::Fixed);
|
||||||
|
@ -247,33 +242,57 @@ HighlightingPage::HighlightingPage()
|
||||||
// MISC
|
// MISC
|
||||||
auto customSound = layout.emplace<QHBoxLayout>().withoutMargin();
|
auto customSound = layout.emplace<QHBoxLayout>().withoutMargin();
|
||||||
{
|
{
|
||||||
auto fallbackSound = customSound.append(this->createCheckBox(
|
auto label = customSound.append(this->createLabel<QString>(
|
||||||
"Fallback sound (played when no other sound is set)",
|
[](const auto &value) {
|
||||||
getSettings()->customHighlightSound));
|
if (value.isEmpty())
|
||||||
|
{
|
||||||
|
return QString("Default sound: Chatterino Ping");
|
||||||
|
}
|
||||||
|
|
||||||
auto getSelectFileText = [] {
|
auto url = QUrl::fromLocalFile(value);
|
||||||
const QString value = getSettings()->pathHighlightSound;
|
return QString("Default sound: <a href=\"%1\"><span "
|
||||||
return value.isEmpty() ? "Select custom fallback sound"
|
"style=\"color: white\">%2</span></a>")
|
||||||
: QUrl::fromLocalFile(value).fileName();
|
.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 selectFile =
|
auto clearSound = customSound.emplace<QPushButton>("Clear");
|
||||||
customSound.emplace<QPushButton>(getSelectFileText());
|
auto selectFile = customSound.emplace<QPushButton>("Change...");
|
||||||
|
|
||||||
QObject::connect(
|
QObject::connect(selectFile.getElement(), &QPushButton::clicked,
|
||||||
selectFile.getElement(), &QPushButton::clicked, this,
|
this, [=]() mutable {
|
||||||
[=]() mutable {
|
|
||||||
auto fileName = QFileDialog::getOpenFileName(
|
auto fileName = QFileDialog::getOpenFileName(
|
||||||
this, tr("Open Sound"), "",
|
this, tr("Open Sound"), "",
|
||||||
tr("Audio Files (*.mp3 *.wav)"));
|
tr("Audio Files (*.mp3 *.wav)"));
|
||||||
|
|
||||||
getSettings()->pathHighlightSound = fileName;
|
getSettings()->pathHighlightSound = fileName;
|
||||||
selectFile.getElement()->setText(getSelectFileText());
|
|
||||||
|
|
||||||
// Set check box according to updated value
|
|
||||||
fallbackSound->setCheckState(
|
|
||||||
fileName.isEmpty() ? Qt::Unchecked : Qt::Checked);
|
|
||||||
});
|
});
|
||||||
|
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_);
|
||||||
}
|
}
|
||||||
|
|
||||||
layout.append(createCheckBox(ALWAYS_PLAY,
|
layout.append(createCheckBox(ALWAYS_PLAY,
|
||||||
|
@ -294,13 +313,6 @@ void HighlightingPage::openSoundDialog(const QModelIndex &clicked,
|
||||||
tr("Audio Files (*.mp3 *.wav)"));
|
tr("Audio Files (*.mp3 *.wav)"));
|
||||||
view->getModel()->setData(clicked, fileUrl, Qt::UserRole);
|
view->getModel()->setData(clicked, fileUrl, Qt::UserRole);
|
||||||
view->getModel()->setData(clicked, fileUrl.fileName(), Qt::DisplayRole);
|
view->getModel()->setData(clicked, fileUrl.fileName(), Qt::DisplayRole);
|
||||||
|
|
||||||
// Enable custom sound check box if user set a sound
|
|
||||||
if (!fileUrl.isEmpty())
|
|
||||||
{
|
|
||||||
QModelIndex checkBox = clicked.siblingAtColumn(soundColumn);
|
|
||||||
view->getModel()->setData(checkBox, Qt::Checked, Qt::CheckStateRole);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HighlightingPage::openColorDialog(const QModelIndex &clicked,
|
void HighlightingPage::openColorDialog(const QModelIndex &clicked,
|
||||||
|
@ -356,7 +368,8 @@ void HighlightingPage::tableCellClicked(const QModelIndex &clicked,
|
||||||
(tab == HighlightTab::Messages &&
|
(tab == HighlightTab::Messages &&
|
||||||
clicked.row() ==
|
clicked.row() ==
|
||||||
HighlightModel::HighlightRowIndexes::WhisperRow);
|
HighlightModel::HighlightRowIndexes::WhisperRow);
|
||||||
if (clicked.column() == Column::SoundPath)
|
if (clicked.column() == Column::SoundPath &&
|
||||||
|
clicked.flags().testFlag(Qt::ItemIsEnabled))
|
||||||
{
|
{
|
||||||
this->openSoundDialog(clicked, view, Column::SoundPath);
|
this->openSoundDialog(clicked, view, Column::SoundPath);
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,20 @@ public:
|
||||||
QLineEdit *createLineEdit(pajlada::Settings::Setting<QString> &setting);
|
QLineEdit *createLineEdit(pajlada::Settings::Setting<QString> &setting);
|
||||||
QSpinBox *createSpinBox(pajlada::Settings::Setting<int> &setting,
|
QSpinBox *createSpinBox(pajlada::Settings::Setting<int> &setting,
|
||||||
int min = 0, int max = 2500);
|
int min = 0, int max = 2500);
|
||||||
|
template <typename T>
|
||||||
|
SLabel *createLabel(const std::function<QString(const T &)> &makeText,
|
||||||
|
pajlada::Settings::Setting<T> &setting)
|
||||||
|
{
|
||||||
|
auto *label = new SLabel();
|
||||||
|
|
||||||
|
setting.connect(
|
||||||
|
[label, makeText](const T &value, auto) {
|
||||||
|
label->setText(makeText(value));
|
||||||
|
},
|
||||||
|
this->managedConnections_);
|
||||||
|
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
virtual void onShow()
|
virtual void onShow()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue