mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
flash highlight color instead of red in channel tab
This commit is contained in:
parent
59296075e8
commit
cd2ab5e0cd
5 changed files with 37 additions and 1 deletions
|
@ -652,10 +652,12 @@ void ChannelView::messageAppended(MessagePtr &message,
|
|||
!messageFlags->has(MessageFlag::Subscription))
|
||||
{
|
||||
this->tabHighlightRequested.invoke(HighlightState::Highlighted);
|
||||
this->tabHighlightColorRequested.invoke(message->highlightColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->tabHighlightRequested.invoke(HighlightState::NewMessage);
|
||||
this->tabHighlightColorRequested.invoke(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <QColor>
|
||||
#include <QPaintEvent>
|
||||
#include <QScroller>
|
||||
#include <QTimer>
|
||||
|
@ -85,6 +86,8 @@ public:
|
|||
pajlada::Signals::Signal<QMouseEvent *> mouseDown;
|
||||
pajlada::Signals::NoArgSignal selectionChanged;
|
||||
pajlada::Signals::Signal<HighlightState> tabHighlightRequested;
|
||||
pajlada::Signals::Signal<std::shared_ptr<QColor>>
|
||||
tabHighlightColorRequested;
|
||||
pajlada::Signals::NoArgSignal liveStatusChanged;
|
||||
pajlada::Signals::Signal<const Link &> linkClicked;
|
||||
pajlada::Signals::Signal<QString> joinToChannel;
|
||||
|
|
|
@ -190,6 +190,7 @@ void NotebookTab::setSelected(bool value)
|
|||
this->selected_ = value;
|
||||
|
||||
this->highlightState_ = HighlightState::None;
|
||||
this->highlightColor_ = nullptr;
|
||||
|
||||
this->update();
|
||||
}
|
||||
|
@ -219,7 +220,8 @@ void NotebookTab::setHighlightState(HighlightState newHighlightStyle)
|
|||
{
|
||||
return;
|
||||
}
|
||||
if (this->highlightState_ != HighlightState::Highlighted)
|
||||
if (this->highlightState_ != HighlightState::Highlighted &&
|
||||
this->highlightColor_ == nullptr)
|
||||
{
|
||||
this->highlightState_ = newHighlightStyle;
|
||||
|
||||
|
@ -238,6 +240,15 @@ bool NotebookTab::hasHighlightsEnabled() const
|
|||
return this->highlightEnabled_;
|
||||
}
|
||||
|
||||
void NotebookTab::setHighlightColor(std::shared_ptr<QColor> color)
|
||||
{
|
||||
if (this->highlightColor_ != color)
|
||||
{
|
||||
this->highlightColor_ = color;
|
||||
this->update();
|
||||
}
|
||||
}
|
||||
|
||||
QRect NotebookTab::getDesiredRect() const
|
||||
{
|
||||
return QRect(this->positionAnimationDesiredPoint_, size());
|
||||
|
@ -317,6 +328,15 @@ void NotebookTab::paintEvent(QPaintEvent *)
|
|||
|
||||
painter.fillRect(bgRect, tabBackground);
|
||||
|
||||
if (this->highlightColor_ != nullptr)
|
||||
{
|
||||
auto col = *this->highlightColor_.get();
|
||||
col.setAlpha(255);
|
||||
colors.line.regular = col;
|
||||
colors.line.hover = col;
|
||||
colors.line.unfocused = col;
|
||||
}
|
||||
|
||||
// top line
|
||||
painter.fillRect(
|
||||
QRectF(0, ceil((this->selected_ ? 0.f : 1.f) * scale), this->width(),
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "widgets/BaseWidget.hpp"
|
||||
#include "widgets/helper/Button.hpp"
|
||||
|
||||
#include <QColor>
|
||||
#include <QMenu>
|
||||
#include <QPropertyAnimation>
|
||||
#include <pajlada/settings/setting.hpp>
|
||||
|
@ -45,6 +46,7 @@ public:
|
|||
void setHighlightState(HighlightState style);
|
||||
void setHighlightsEnabled(const bool &newVal);
|
||||
bool hasHighlightsEnabled() const;
|
||||
void setHighlightColor(std::shared_ptr<QColor> color);
|
||||
|
||||
void moveAnimated(QPoint pos, bool animated = true);
|
||||
|
||||
|
@ -95,6 +97,7 @@ private:
|
|||
HighlightState highlightState_ = HighlightState::None;
|
||||
bool highlightEnabled_ = true;
|
||||
QAction *highlightNewMessagesAction_;
|
||||
std::shared_ptr<QColor> highlightColor_;
|
||||
|
||||
bool isLive_{};
|
||||
|
||||
|
|
|
@ -207,6 +207,12 @@ void SplitContainer::addSplit(Split *split)
|
|||
}
|
||||
});
|
||||
|
||||
split->getChannelView().tabHighlightColorRequested.connect(
|
||||
[this](std::shared_ptr<QColor> color) {
|
||||
if (color != nullptr)
|
||||
this->tab_->setHighlightColor(color);
|
||||
});
|
||||
|
||||
split->getChannelView().liveStatusChanged.connect([this]() {
|
||||
this->refreshTabLiveStatus(); //
|
||||
});
|
||||
|
@ -265,6 +271,8 @@ SplitContainer::Position SplitContainer::releaseSplit(Split *split)
|
|||
|
||||
split->getChannelView().tabHighlightRequested.disconnectAll();
|
||||
|
||||
split->getChannelView().tabHighlightColorRequested.disconnectAll();
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue