reformat code
This commit is contained in:
@@ -24,7 +24,8 @@ class Message
|
||||
{
|
||||
public:
|
||||
// explicit Message(const QString &text);
|
||||
explicit Message(const QString &text, const std::vector<messages::Word> &words, const bool &highlight);
|
||||
explicit Message(const QString &text, const std::vector<messages::Word> &words,
|
||||
const bool &highlight);
|
||||
|
||||
bool getCanHighlightTab() const;
|
||||
const QString &getTimeoutUser() const;
|
||||
|
||||
@@ -31,7 +31,8 @@ void MessageBuilder::appendTimestamp()
|
||||
appendTimestamp(t);
|
||||
}
|
||||
|
||||
void MessageBuilder::setHighlight(const bool &value){
|
||||
void MessageBuilder::setHighlight(const bool &value)
|
||||
{
|
||||
highlight = value;
|
||||
}
|
||||
|
||||
@@ -58,7 +59,10 @@ void MessageBuilder::appendTimestamp(time_t time)
|
||||
|
||||
QString MessageBuilder::matchLink(const QString &string)
|
||||
{
|
||||
QString match = regex.match(string,0,QRegularExpression::PartialPreferCompleteMatch,QRegularExpression::NoMatchOption).captured();
|
||||
QString match = regex
|
||||
.match(string, 0, QRegularExpression::PartialPreferCompleteMatch,
|
||||
QRegularExpression::NoMatchOption)
|
||||
.captured();
|
||||
if (!match.contains(QRegularExpression("\\bhttps?:\/\/"))) {
|
||||
match.insert(0, "https://");
|
||||
}
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
|
||||
#include "messages/message.hpp"
|
||||
|
||||
#include <ctime>
|
||||
#include <QRegularExpression>
|
||||
|
||||
#include <ctime>
|
||||
|
||||
namespace chatterino {
|
||||
namespace messages {
|
||||
|
||||
|
||||
+4
-3
@@ -43,7 +43,8 @@ public:
|
||||
return _value;
|
||||
}
|
||||
|
||||
T &getnonConst() {
|
||||
T &getnonConst()
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
@@ -69,12 +70,12 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void insertMap(QString id, bool sound, bool task){
|
||||
void insertMap(QString id, bool sound, bool task)
|
||||
{
|
||||
QPair<bool, bool> pair(sound, task);
|
||||
_value.insert(id, pair);
|
||||
}
|
||||
|
||||
|
||||
boost::signals2::signal<void(const T &newValue)> valueChanged;
|
||||
|
||||
private:
|
||||
|
||||
@@ -93,7 +93,8 @@ void SettingsManager::load()
|
||||
qDebug() << list.join(",");
|
||||
for (auto string : list) {
|
||||
_settings.beginGroup(string);
|
||||
highlightProperties.insertMap(string,_settings.value("highlightSound").toBool(),_settings.value("highlightTask").toBool());
|
||||
highlightProperties.insertMap(string, _settings.value("highlightSound").toBool(),
|
||||
_settings.value("highlightTask").toBool());
|
||||
_settings.endGroup();
|
||||
}
|
||||
_settings.endGroup();
|
||||
@@ -101,7 +102,6 @@ void SettingsManager::load()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Word::Type SettingsManager::getWordTypeMask()
|
||||
{
|
||||
return _wordTypeMask;
|
||||
|
||||
@@ -18,12 +18,12 @@ public:
|
||||
std::pair<std::reference_wrapper<BaseSetting>, QVariant>(setting.get(), value));
|
||||
}
|
||||
|
||||
void addMapItem(QString string,QPair<bool,bool> pair){
|
||||
void addMapItem(QString string, QPair<bool, bool> pair)
|
||||
{
|
||||
QMap<QString, QPair<bool, bool>> map;
|
||||
_mapItems.insert(string, pair);
|
||||
}
|
||||
|
||||
|
||||
void apply()
|
||||
{
|
||||
for (auto &item : _items) {
|
||||
|
||||
@@ -62,8 +62,10 @@ SharedMessage TwitchMessageBuilder::parse()
|
||||
} else {
|
||||
player->setMedia(QUrl("qrc:/sounds/ping2.wav"));
|
||||
}
|
||||
if(settings.enableHighlights.get() && ircMessage->nick().compare(settings.selectedUser.get(), Qt::CaseInsensitive)){
|
||||
if(settings.enableHighlightsSelf.get() && originalMessage.contains(settings.selectedUser.get(), Qt::CaseInsensitive)){
|
||||
if (settings.enableHighlights.get() &&
|
||||
ircMessage->nick().compare(settings.selectedUser.get(), Qt::CaseInsensitive)) {
|
||||
if (settings.enableHighlightsSelf.get() &&
|
||||
originalMessage.contains(settings.selectedUser.get(), Qt::CaseInsensitive)) {
|
||||
this->setHighlight(true);
|
||||
if (settings.enableHighlightSound.get()) {
|
||||
player->play();
|
||||
|
||||
@@ -227,7 +227,9 @@ void ChatWidgetView::paintEvent(QPaintEvent * /*event*/)
|
||||
// update messages that have been changed
|
||||
if (updateBuffer) {
|
||||
QPainter painter(buffer);
|
||||
painter.fillRect(buffer->rect(), (messageRef->getMessage()->getCanHighlightTab()) ? this->colorScheme.ChatBackgroundHighlighted : this->colorScheme.ChatBackground);
|
||||
painter.fillRect(buffer->rect(), (messageRef->getMessage()->getCanHighlightTab())
|
||||
? this->colorScheme.ChatBackgroundHighlighted
|
||||
: this->colorScheme.ChatBackground);
|
||||
for (messages::WordPart const &wordPart : messageRef->getWordParts()) {
|
||||
// image
|
||||
if (wordPart.getWord().isImage()) {
|
||||
|
||||
@@ -9,15 +9,15 @@
|
||||
#include <QComboBox>
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QFileDialog>
|
||||
#include <QFontDialog>
|
||||
#include <QFormLayout>
|
||||
#include <QFileDialog>
|
||||
#include <QGroupBox>
|
||||
#include <QLabel>
|
||||
#include <QListWidget>
|
||||
#include <QPalette>
|
||||
#include <QTextEdit>
|
||||
#include <QResource>
|
||||
#include <QTextEdit>
|
||||
|
||||
namespace chatterino {
|
||||
namespace widgets {
|
||||
@@ -111,7 +111,8 @@ void SettingsDialog::addTabs()
|
||||
if (listWidget->count()) {
|
||||
int itemIndex = 0;
|
||||
for (; itemIndex < listWidget->count(); ++itemIndex) {
|
||||
if(listWidget->item(itemIndex)->text().compare(settings.selectedUser.get(),Qt::CaseInsensitive)){
|
||||
if (listWidget->item(itemIndex)->text().compare(settings.selectedUser.get(),
|
||||
Qt::CaseInsensitive)) {
|
||||
++itemIndex;
|
||||
break;
|
||||
}
|
||||
@@ -374,14 +375,17 @@ void SettingsDialog::addTabs()
|
||||
auto soundForm = new QFormLayout();
|
||||
{
|
||||
vbox->addWidget(createCheckbox("Enable Highlighting", settings.enableHighlights));
|
||||
vbox->addWidget(createCheckbox("Highlight messages containing your name", settings.enableHighlightsSelf));
|
||||
vbox->addWidget(createCheckbox("Play sound when your name is mentioned", settings.enableHighlightSound));
|
||||
vbox->addWidget(createCheckbox("Flash taskbar when your name is mentioned", settings.enableHighlightTaskbar));
|
||||
vbox->addWidget(createCheckbox("Highlight messages containing your name",
|
||||
settings.enableHighlightsSelf));
|
||||
vbox->addWidget(createCheckbox("Play sound when your name is mentioned",
|
||||
settings.enableHighlightSound));
|
||||
vbox->addWidget(createCheckbox("Flash taskbar when your name is mentioned",
|
||||
settings.enableHighlightTaskbar));
|
||||
customSound->addWidget(createCheckbox("Custom sound", settings.customHighlightSound));
|
||||
auto selectBtn = new QPushButton("Select");
|
||||
QObject::connect(selectBtn, &QPushButton::clicked, this, [&settings, this] {
|
||||
auto fileName = QFileDialog::getOpenFileName(this,
|
||||
tr("Open Sound"), "", tr("Image Files (*.mp3 *.wav)"));
|
||||
auto fileName = QFileDialog::getOpenFileName(this, tr("Open Sound"), "",
|
||||
tr("Image Files (*.mp3 *.wav)"));
|
||||
settings.pathHighlightSound.set(fileName);
|
||||
});
|
||||
customSound->addWidget(selectBtn);
|
||||
@@ -408,7 +412,8 @@ void SettingsDialog::addTabs()
|
||||
QObject::connect(add, &QPushButton::clicked, this, [=, &settings] {
|
||||
if (edit->text().length()) {
|
||||
highlights->addItem(edit->text());
|
||||
settings.highlightProperties.insertMap(edit->text(),sound->isChecked(),task->isChecked());
|
||||
settings.highlightProperties.insertMap(edit->text(), sound->isChecked(),
|
||||
task->isChecked());
|
||||
show->close();
|
||||
}
|
||||
});
|
||||
@@ -433,26 +438,33 @@ void SettingsDialog::addTabs()
|
||||
|
||||
QObject::connect(add, &QPushButton::clicked, this, [=, &settings] {
|
||||
if (edit->text().length()) {
|
||||
settings.highlightProperties.getnonConst().remove(highlights->selectedItems().first()->text());
|
||||
settings.highlightProperties.getnonConst().remove(
|
||||
highlights->selectedItems().first()->text());
|
||||
delete highlights->selectedItems().first();
|
||||
highlights->addItem(edit->text());
|
||||
settings.highlightProperties.insertMap(edit->text(),sound->isChecked(),task->isChecked());
|
||||
settings.highlightProperties.insertMap(edit->text(), sound->isChecked(),
|
||||
task->isChecked());
|
||||
show->close();
|
||||
}
|
||||
});
|
||||
box->addWidget(edit);
|
||||
box->addWidget(add);
|
||||
box->addWidget(sound);
|
||||
sound->setChecked(settings.highlightProperties.get().value(highlights->selectedItems().first()->text()).first);
|
||||
sound->setChecked(settings.highlightProperties.get()
|
||||
.value(highlights->selectedItems().first()->text())
|
||||
.first);
|
||||
box->addWidget(task);
|
||||
task->setChecked(settings.highlightProperties.get().value(highlights->selectedItems().first()->text()).second);
|
||||
task->setChecked(settings.highlightProperties.get()
|
||||
.value(highlights->selectedItems().first()->text())
|
||||
.second);
|
||||
show->setLayout(box);
|
||||
show->show();
|
||||
}
|
||||
});
|
||||
QObject::connect(delBtn, &QPushButton::clicked, this, [highlights, &settings] {
|
||||
if (!highlights->selectedItems().isEmpty()) {
|
||||
settings.highlightProperties.getnonConst().remove(highlights->selectedItems().first()->text());
|
||||
settings.highlightProperties.getnonConst().remove(
|
||||
highlights->selectedItems().first()->text());
|
||||
delete highlights->selectedItems().first();
|
||||
}
|
||||
});
|
||||
@@ -586,8 +598,7 @@ void SettingsDialog::cancelButtonClicked()
|
||||
|
||||
QStringList list = instance.highlightProperties.get().keys();
|
||||
list.removeDuplicates();
|
||||
while(globalHighlights->count()>0)
|
||||
{
|
||||
while (globalHighlights->count() > 0) {
|
||||
delete globalHighlights->takeItem(0);
|
||||
}
|
||||
globalHighlights->addItems(list);
|
||||
|
||||
Reference in New Issue
Block a user