fix highlights - reformat some stuff

This commit is contained in:
Rasmus Karlsson 2017-09-24 18:43:24 +02:00
parent 903cf30ddf
commit c14dc43b18
8 changed files with 27 additions and 46 deletions

View file

@ -7,11 +7,6 @@
#include "ircmanager.hpp" #include "ircmanager.hpp"
#include "messages/link.hpp" #include "messages/link.hpp"
#include "resources.hpp" #include "resources.hpp"
#include "settingsmanager.hpp"
#include <QColor>
#include <QObjectUserData>
#include <QStringList>
#include <ctime> #include <ctime>
#include <list> #include <list>
@ -20,27 +15,16 @@
namespace chatterino { namespace chatterino {
namespace messages { namespace messages {
/*
Message::Message(const QString &text)
: text(text)
{
this->words.push_back(
Word(text, Word::Text, ColorScheme::getInstance().SystemMessageColor, text, QString()));
}
*/
//Message::Message(const QString &text, const std::vector<Word> &words, const bool &highlight)
// : text(text)
// , highlightTab(highlight)
// , words(words)
//{
//}
bool Message::getCanHighlightTab() const bool Message::getCanHighlightTab() const
{ {
return this->highlightTab; return this->highlightTab;
} }
void Message::setHighlight(bool value)
{
this->highlightTab = value;
}
const QString &Message::getTimeoutUser() const const QString &Message::getTimeoutUser() const
{ {
return this->timeoutUser; return this->timeoutUser;

View file

@ -1,15 +1,10 @@
#pragma once #pragma once
#include "messages/message.hpp"
#include "messages/messageparseargs.hpp"
#include "messages/word.hpp" #include "messages/word.hpp"
#include "messages/wordpart.hpp"
#include <IrcMessage>
#include <QVector>
#include <chrono> #include <chrono>
#include <memory> #include <memory>
#include <vector>
namespace chatterino { namespace chatterino {
@ -23,11 +18,8 @@ typedef std::shared_ptr<Message> SharedMessage;
class Message class Message
{ {
public: public:
// explicit Message(const QString &text);
// explicit Message(const QString &text, const std::vector<messages::Word> &words,
// const bool &highlight);
bool getCanHighlightTab() const; bool getCanHighlightTab() const;
void setHighlight(bool value);
const QString &getTimeoutUser() const; const QString &getTimeoutUser() const;
int getTimeoutCount() const; int getTimeoutCount() const;
const QString &getUserName() const; const QString &getUserName() const;
@ -52,7 +44,9 @@ private:
static QRegularExpression *cheerRegex; static QRegularExpression *cheerRegex;
// what is highlightTab?
bool highlightTab = false; bool highlightTab = false;
QString timeoutUser = ""; QString timeoutUser = "";
int timeoutCount = 0; int timeoutCount = 0;
bool disabled = false; bool disabled = false;

View file

@ -24,14 +24,14 @@ void MessageBuilder::appendWord(const Word &&word)
void MessageBuilder::appendTimestamp() void MessageBuilder::appendTimestamp()
{ {
time_t t; std::time_t t;
time(&t); time(&t);
appendTimestamp(t); this->appendTimestamp(t);
} }
void MessageBuilder::setHighlight(const bool &value) void MessageBuilder::setHighlight(bool value)
{ {
highlight = value; this->message->setHighlight(value);
} }
void MessageBuilder::appendTimestamp(time_t time) void MessageBuilder::appendTimestamp(time_t time)
@ -41,14 +41,14 @@ void MessageBuilder::appendTimestamp(time_t time)
// Add word for timestamp with no seconds // Add word for timestamp with no seconds
strftime(timeStampBuffer, 69, "%H:%M", localtime(&time)); strftime(timeStampBuffer, 69, "%H:%M", localtime(&time));
QString timestampNoSeconds(timeStampBuffer); QString timestampNoSeconds(timeStampBuffer);
appendWord(Word(timestampNoSeconds, Word::TimestampNoSeconds, this->appendWord(Word(timestampNoSeconds, Word::TimestampNoSeconds,
MessageColor(MessageColor::System), QString(), QString())); MessageColor(MessageColor::System), QString(), QString()));
// Add word for timestamp with seconds // Add word for timestamp with seconds
strftime(timeStampBuffer, 69, "%H:%M:%S", localtime(&time)); strftime(timeStampBuffer, 69, "%H:%M:%S", localtime(&time));
QString timestampWithSeconds(timeStampBuffer); QString timestampWithSeconds(timeStampBuffer);
appendWord(Word(timestampWithSeconds, Word::TimestampWithSeconds, this->appendWord(Word(timestampWithSeconds, Word::TimestampWithSeconds,
MessageColor(MessageColor::System), QString(), QString())); MessageColor(MessageColor::System), QString(), QString()));
} }
QString MessageBuilder::matchLink(const QString &string) QString MessageBuilder::matchLink(const QString &string)
@ -67,6 +67,7 @@ QString MessageBuilder::matchLink(const QString &string)
if (!captured.contains(httpRegex)) { if (!captured.contains(httpRegex)) {
captured.insert(0, "http://"); captured.insert(0, "http://");
} }
return captured; return captured;
} }

View file

@ -19,7 +19,7 @@ public:
void appendWord(const Word &&word); void appendWord(const Word &&word);
void appendTimestamp(); void appendTimestamp();
void appendTimestamp(std::time_t time); void appendTimestamp(std::time_t time);
void setHighlight(const bool &value); void setHighlight(bool value);
QString matchLink(const QString &string); QString matchLink(const QString &string);
QRegularExpression linkRegex; QRegularExpression linkRegex;

View file

@ -1,4 +1,4 @@
#include "messageref.hpp" #include "messages/messageref.hpp"
#include "emotemanager.hpp" #include "emotemanager.hpp"
#include "settingsmanager.hpp" #include "settingsmanager.hpp"

View file

@ -1,6 +1,7 @@
#pragma once #pragma once
#include "messages/message.hpp" #include "messages/message.hpp"
#include "messages/wordpart.hpp"
#include <QPixmap> #include <QPixmap>
@ -28,14 +29,14 @@ public:
std::shared_ptr<QPixmap> buffer = nullptr; std::shared_ptr<QPixmap> buffer = nullptr;
bool updateBuffer = false; bool updateBuffer = false;
const messages::Word *tryGetWordPart(QPoint point); const Word *tryGetWordPart(QPoint point);
int getSelectionIndex(QPoint position); int getSelectionIndex(QPoint position);
private: private:
// variables // variables
SharedMessage message; SharedMessage message;
std::vector<messages::WordPart> wordParts; std::vector<WordPart> wordParts;
int height = 0; int height = 0;

View file

@ -390,7 +390,8 @@ void TwitchMessageBuilder::parseHighlights()
bool alert; bool alert;
}; };
QStringList blackList = settings.highlightUserBlacklist.get().split("\n",QString::SkipEmptyParts); QStringList blackList =
settings.highlightUserBlacklist.get().split("\n", QString::SkipEmptyParts);
// TODO: This vector should only be rebuilt upon highlights being changed // TODO: This vector should only be rebuilt upon highlights being changed
std::vector<Highlight> activeHighlights; std::vector<Highlight> activeHighlights;
@ -410,8 +411,7 @@ void TwitchMessageBuilder::parseHighlights()
bool doHighlight = false; bool doHighlight = false;
bool playSound = false; bool playSound = false;
bool doAlert = false; bool doAlert = false;
if(!blackList.contains(this->ircMessage->nick(),Qt::CaseInsensitive)) if (!blackList.contains(this->ircMessage->nick(), Qt::CaseInsensitive)) {
{
for (const Highlight &highlight : activeHighlights) { for (const Highlight &highlight : activeHighlights) {
if (this->originalMessage.contains(highlight.target, Qt::CaseInsensitive)) { if (this->originalMessage.contains(highlight.target, Qt::CaseInsensitive)) {
qDebug() << "Highlight because " << this->originalMessage << " contains " qDebug() << "Highlight because " << this->originalMessage << " contains "

View file

@ -2,6 +2,7 @@
#include "emotemanager.hpp" #include "emotemanager.hpp"
#include "messages/messagebuilder.hpp" #include "messages/messagebuilder.hpp"
#include "messages/messageparseargs.hpp"
#include "resources.hpp" #include "resources.hpp"
#include "twitch/twitchchannel.hpp" #include "twitch/twitchchannel.hpp"