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