Tabs now highlight when a highlight is received

Work on #88
This commit is contained in:
Rasmus Karlsson 2017-12-26 12:32:24 +01:00
parent 7a8cc91eec
commit 13b39e374b
8 changed files with 29 additions and 6 deletions

View file

@ -16,7 +16,7 @@
namespace chatterino {
namespace messages {
bool Message::getCanHighlightTab() const
bool Message::containsHighlightedPhrase() const
{
return this->highlightTab;
}

View file

@ -18,7 +18,7 @@ typedef std::shared_ptr<Message> SharedMessage;
class Message
{
public:
bool getCanHighlightTab() const;
bool containsHighlightedPhrase() const;
void setHighlight(bool value);
const QString &getTimeoutUser() const;
int getTimeoutCount() const;

View file

@ -354,6 +354,10 @@ void ChannelView::setChannel(std::shared_ptr<Channel> newChannel)
}
}
if (message->containsHighlightedPhrase()) {
this->highlightedMessageReceived.invoke();
}
layoutMessages();
update();
});
@ -533,7 +537,7 @@ void ChannelView::updateMessageBuffer(messages::MessageRef *messageRef, QPixmap
// this->selectionMax.messageIndex >= messageIndex) {
// painter.fillRect(buffer->rect(), QColor(24, 55, 25));
//} else {
painter.fillRect(buffer->rect(), (messageRef->getMessage()->getCanHighlightTab())
painter.fillRect(buffer->rect(), (messageRef->getMessage()->containsHighlightedPhrase())
? this->colorScheme.ChatBackgroundHighlighted
: this->colorScheme.ChatBackground);
//}

View file

@ -15,8 +15,8 @@
#include <QTimer>
#include <QWheelEvent>
#include <QWidget>
#include <boost/signals2.hpp>
#include <pajlada/signals/signal.hpp>
namespace chatterino {
namespace widgets {
@ -103,6 +103,7 @@ public:
boost::signals2::signal<void(QMouseEvent *)> mouseDown;
boost::signals2::signal<void()> selectionChanged;
pajlada::Signals::NoArgSignal highlightedMessageReceived;
protected:
virtual void resizeEvent(QResizeEvent *) override;

View file

@ -107,11 +107,17 @@ void NotebookTab::setSelected(bool value)
{
this->selected = value;
this->highlightState = HighlightState::None;
this->update();
}
void NotebookTab::setHighlightState(HighlightState newHighlightStyle)
{
if (this->isSelected()) {
return;
}
this->highlightState = newHighlightStyle;
this->update();

View file

@ -277,7 +277,7 @@ void Split::doPopup()
void Split::doClearChat()
{
view.clearMessages();
this->view.clearMessages();
}
void Split::doOpenChannel()

View file

@ -53,6 +53,11 @@ public:
pajlada::Settings::Setting<std::string> channelName;
boost::signals2::signal<void()> channelChanged;
ChannelView &getChannelView()
{
return this->view;
}
const std::string &getUUID() const;
std::shared_ptr<Channel> getChannel() const;
std::shared_ptr<Channel> &getChannelRef();

View file

@ -1,5 +1,6 @@
#include "widgets/splitcontainer.hpp"
#include "colorscheme.hpp"
#include "common.hpp"
#include "util/helpers.hpp"
#include "widgets/helper/notebooktab.hpp"
#include "widgets/notebook.hpp"
@ -431,7 +432,13 @@ std::pair<int, int> SplitContainer::getChatPosition(const Split *chatWidget)
Split *SplitContainer::createChatWidget(const std::string &uuid)
{
return new Split(this->channelManager, this, uuid);
auto split = new Split(this->channelManager, this, uuid);
split->getChannelView().highlightedMessageReceived.connect([this] {
this->tab->setHighlightState(HighlightState::Highlighted); //
});
return split;
}
void SplitContainer::refreshTitle()