From f417006d6a741f1d50a470d8334cd76c04b7ef1a Mon Sep 17 00:00:00 2001 From: TranRed Date: Sat, 20 Jul 2019 18:49:17 +0200 Subject: [PATCH] Added channelView with last messages to user popup currently uses last messages from that channel - might want to use online logs later (or make a setting for that) --- src/widgets/dialogs/UserInfoPopup.cpp | 21 +++++++++++++++++++++ src/widgets/dialogs/UserInfoPopup.hpp | 2 ++ 2 files changed, 23 insertions(+) diff --git a/src/widgets/dialogs/UserInfoPopup.cpp b/src/widgets/dialogs/UserInfoPopup.cpp index 80ccdcf0f..fd9633e4b 100644 --- a/src/widgets/dialogs/UserInfoPopup.cpp +++ b/src/widgets/dialogs/UserInfoPopup.cpp @@ -5,6 +5,7 @@ #include "common/NetworkRequest.hpp" #include "controllers/accounts/AccountController.hpp" #include "controllers/highlights/HighlightController.hpp" +#include "messages/Message.hpp" #include "providers/twitch/PartialTwitchUser.hpp" #include "providers/twitch/TwitchChannel.hpp" #include "singletons/Resources.hpp" @@ -15,6 +16,8 @@ #include "widgets/dialogs/LogsPopup.hpp" #include "widgets/helper/EffectLabel.hpp" #include "widgets/helper/Line.hpp" +#include "widgets/helper/ChannelView.hpp" + #include #include @@ -200,6 +203,11 @@ UserInfoPopup::UserInfoPopup() }); } + // fourth line (last messages) + this->lastMessages_ = new ChannelView(); + this->lastMessages_->setScaleIndependantHeight(150); + layout.append(this->lastMessages_); + this->setStyleSheet("font-size: 11pt;"); this->installEvents(); @@ -338,6 +346,19 @@ void UserInfoPopup::setData(const QString &name, const ChannelPtr &channel) this->updateUserData(); this->userStateChanged_.invoke(); + + LimitedQueueSnapshot snapshot = this->channel_->getMessageSnapshot(); + ChannelPtr channelPtr(new Channel("search", Channel::Type::None)); + for (size_t i = 0; i < snapshot.size(); i++) + { + MessagePtr message = snapshot[i]; + if ( message->loginName.compare(this->userName_, Qt::CaseInsensitive) == 0) + { + channelPtr->addMessage(message); + } + } + + this->lastMessages_->setChannel(channelPtr); } void UserInfoPopup::updateUserData() diff --git a/src/widgets/dialogs/UserInfoPopup.hpp b/src/widgets/dialogs/UserInfoPopup.hpp index 8699f8dde..9a603b405 100644 --- a/src/widgets/dialogs/UserInfoPopup.hpp +++ b/src/widgets/dialogs/UserInfoPopup.hpp @@ -1,6 +1,7 @@ #pragma once #include "widgets/BaseWindow.hpp" +#include "widgets/helper/ChannelView.hpp" #include @@ -36,6 +37,7 @@ private: QString userName_; QString userId_; ChannelPtr channel_; + ChannelView* lastMessages_; pajlada::Signals::NoArgSignal userStateChanged_;