Fixed tabs not highlighting on new messages/highlights

This commit is contained in:
fourtf 2018-04-10 16:53:40 +02:00
parent c5a47ed24e
commit 41b3340d61
5 changed files with 27 additions and 19 deletions

View file

@ -86,19 +86,26 @@ void ThemeManager::actuallyUpdate(double hue, double multiplier)
this->messages.textColors.regular = isLight ? "#000" : "#fff"; this->messages.textColors.regular = isLight ? "#000" : "#fff";
/// TABS /// TABS
// text, {regular, hover, unfocused}
if (lightWin) { if (lightWin) {
this->tabs.regular = {fg, {bg, QColor("#ccc"), bg}}; this->tabs.regular = {fg, {bg, QColor("#ccc"), bg}};
this->tabs.newMessage = {fg, {bg, QColor("#ccc"), bg}}; this->tabs.newMessage = {
this->tabs.highlighted = {fg, {bg, QColor("#ccc"), bg}}; fg,
this->tabs.selected = {QColor("#fff"), {QColor("#333"), QColor("#333"), QColor("#666")}}; {QBrush(blendColors(themeColor, "#ccc", 0.9), Qt::FDiagPattern),
QBrush(blendColors(themeColor, "#ccc", 0.9), Qt::FDiagPattern),
QBrush(blendColors(themeColorNoSat, "#ccc", 0.9), Qt::FDiagPattern)}};
this->tabs.highlighted = {fg, {QColor("#ccc"), QColor("#ccc"), QColor("#bbb")}};
this->tabs.selected = {QColor("#fff"),
{QColor("#777"), QColor("#777"), QColor("#888")}};
} else { } else {
this->tabs.regular = {fg, {bg, QColor("#555"), bg}}; this->tabs.regular = {fg, {bg, QColor("#555"), bg}};
this->tabs.newMessage = {fg, {bg, QColor("#555"), bg}}; this->tabs.newMessage = {
this->tabs.highlighted = {fg, {bg, QColor("#555"), bg}}; fg,
// this->tabs.selected = {"#000", {themeColor, themeColor, themeColorNoSat}}; {QBrush(blendColors(themeColor, "#666", 0.7), Qt::FDiagPattern),
this->tabs.selected = {QColor("#000"), {QColor("#999"), QColor("#999"), QColor("#888")}}; QBrush(blendColors(themeColor, "#666", 0.5), Qt::FDiagPattern),
QBrush(blendColors(themeColorNoSat, "#666", 0.7), Qt::FDiagPattern)}};
this->tabs.highlighted = {fg, {QColor("#777"), QColor("#777"), QColor("#666")}};
this->tabs.selected = {QColor("#000"),
{QColor("#999"), QColor("#999"), QColor("#888")}};
} }
} }

View file

@ -359,8 +359,12 @@ void ChannelView::setChannel(ChannelPtr newChannel)
} }
} }
if (message->flags & ~Message::DoNotTriggerNotification) { if (!(message->flags & Message::DoNotTriggerNotification)) {
this->highlightedMessageReceived.invoke(); if (message->flags & Message::Highlighted) {
this->tabHighlightRequested.invoke(HighlightState::Highlighted);
} else {
this->tabHighlightRequested.invoke(HighlightState::NewMessage);
}
} }
this->scrollBar.addHighlight(message->getScrollBarHighlight()); this->scrollBar.addHighlight(message->getScrollBarHighlight());

View file

@ -51,7 +51,7 @@ public:
pajlada::Signals::Signal<QMouseEvent *> mouseDown; pajlada::Signals::Signal<QMouseEvent *> mouseDown;
pajlada::Signals::NoArgSignal selectionChanged; pajlada::Signals::NoArgSignal selectionChanged;
pajlada::Signals::NoArgSignal highlightedMessageReceived; pajlada::Signals::Signal<HighlightState> tabHighlightRequested;
pajlada::Signals::Signal<const messages::Link &> linkClicked; pajlada::Signals::Signal<const messages::Link &> linkClicked;
protected: protected:

View file

@ -19,8 +19,6 @@ class Notebook : public BaseWidget
Q_OBJECT Q_OBJECT
public: public:
enum HighlightType { none, highlighted, newMessage };
explicit Notebook(Window *parent, bool _showButtons); explicit Notebook(Window *parent, bool _showButtons);
SplitContainer *addNewPage(bool select = false); SplitContainer *addNewPage(bool select = false);

View file

@ -66,6 +66,8 @@ int SplitContainer::splitCount() const
std::pair<int, int> SplitContainer::removeFromLayout(Split *widget) std::pair<int, int> SplitContainer::removeFromLayout(Split *widget)
{ {
widget->getChannelView().tabHighlightRequested.disconnectAll();
// remove reference to chat widget from chatWidgets vector // remove reference to chat widget from chatWidgets vector
auto it = std::find(std::begin(this->splits), std::end(this->splits), widget); auto it = std::find(std::begin(this->splits), std::end(this->splits), widget);
if (it != std::end(this->splits)) { if (it != std::end(this->splits)) {
@ -150,6 +152,8 @@ std::pair<int, int> SplitContainer::removeFromLayout(Split *widget)
void SplitContainer::addToLayout(Split *widget, std::pair<int, int> position) void SplitContainer::addToLayout(Split *widget, std::pair<int, int> position)
{ {
this->splits.push_back(widget); this->splits.push_back(widget);
widget->getChannelView().tabHighlightRequested.connect(
[this](HighlightState state) { this->tab->setHighlightState(state); });
this->refreshTitle(); this->refreshTitle();
@ -506,11 +510,6 @@ Split *SplitContainer::createChatWidget()
{ {
auto split = new Split(this); auto split = new Split(this);
split->getChannelView().highlightedMessageReceived.connect([this] {
// fourtf: error potentionally here
this->tab->setHighlightState(HighlightState::Highlighted); //
});
return split; return split;
} }