added watching channel
This commit is contained in:
@@ -341,6 +341,7 @@ void ChannelView::setChannel(ChannelPtr newChannel)
|
||||
if (this->channel) {
|
||||
this->detachChannel();
|
||||
}
|
||||
|
||||
this->messages.clear();
|
||||
|
||||
// on new message
|
||||
@@ -445,15 +446,10 @@ void ChannelView::setChannel(ChannelPtr newChannel)
|
||||
|
||||
void ChannelView::detachChannel()
|
||||
{
|
||||
// on message added
|
||||
if (this->messageAppendedConnection.isConnected()) {
|
||||
this->messageAppendedConnection.disconnect();
|
||||
}
|
||||
|
||||
// on message removed
|
||||
if (this->messageRemovedConnection.isConnected()) {
|
||||
this->messageRemovedConnection.disconnect();
|
||||
}
|
||||
messageAppendedConnection.disconnect();
|
||||
messageAddedAtStartConnection.disconnect();
|
||||
messageRemovedConnection.disconnect();
|
||||
messageReplacedConnection.disconnect();
|
||||
}
|
||||
|
||||
void ChannelView::pause(int msecTimeout)
|
||||
|
||||
@@ -129,6 +129,7 @@ private:
|
||||
pajlada::Signals::Connection layoutConnection;
|
||||
|
||||
std::vector<pajlada::Signals::ScopedConnection> managedConnections;
|
||||
std::vector<pajlada::Signals::ScopedConnection> channelConnections;
|
||||
|
||||
std::unordered_set<std::shared_ptr<messages::MessageLayout>> messagesOnScreen;
|
||||
|
||||
|
||||
@@ -154,14 +154,14 @@ void SplitHeader::scaleChangedEvent(float scale)
|
||||
|
||||
void SplitHeader::updateChannelText()
|
||||
{
|
||||
const QString channelName = this->split->getChannel()->name;
|
||||
auto channel = this->split->getChannel();
|
||||
|
||||
const QString channelName = channel->name;
|
||||
if (channelName.isEmpty()) {
|
||||
this->titleLabel->setText("<no channel>");
|
||||
return;
|
||||
}
|
||||
|
||||
auto channel = this->split->getChannel();
|
||||
|
||||
TwitchChannel *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get());
|
||||
|
||||
if (twitchChannel != nullptr) {
|
||||
|
||||
@@ -21,7 +21,7 @@ SplitInput::SplitInput(Split *_chatWidget)
|
||||
{
|
||||
this->initLayout();
|
||||
|
||||
auto completer = new QCompleter(&this->chatWidget->getChannel()->completionModel);
|
||||
auto completer = new QCompleter(&this->chatWidget->getChannel().get()->completionModel);
|
||||
this->ui.textEdit->setCompleter(completer);
|
||||
|
||||
this->chatWidget->channelChanged.connect([this] {
|
||||
|
||||
@@ -138,8 +138,10 @@ void SelectChannelDialog::ok()
|
||||
this->close();
|
||||
}
|
||||
|
||||
void SelectChannelDialog::setSelectedChannel(ChannelPtr channel)
|
||||
void SelectChannelDialog::setSelectedChannel(IndirectChannel _channel)
|
||||
{
|
||||
auto channel = _channel.get();
|
||||
|
||||
assert(channel);
|
||||
|
||||
this->selectedChannel = channel;
|
||||
@@ -171,7 +173,7 @@ void SelectChannelDialog::setSelectedChannel(ChannelPtr channel)
|
||||
this->_hasSelectedChannel = false;
|
||||
}
|
||||
|
||||
ChannelPtr SelectChannelDialog::getSelectedChannel() const
|
||||
IndirectChannel SelectChannelDialog::getSelectedChannel() const
|
||||
{
|
||||
if (!this->_hasSelectedChannel) {
|
||||
return this->selectedChannel;
|
||||
|
||||
@@ -17,8 +17,8 @@ class SelectChannelDialog : public BaseWindow
|
||||
public:
|
||||
SelectChannelDialog();
|
||||
|
||||
void setSelectedChannel(ChannelPtr selectedChannel);
|
||||
ChannelPtr getSelectedChannel() const;
|
||||
void setSelectedChannel(IndirectChannel selectedChannel);
|
||||
IndirectChannel getSelectedChannel() const;
|
||||
bool hasSeletedChannel() const;
|
||||
|
||||
pajlada::Signals::NoArgSignal closed;
|
||||
|
||||
+22
-11
@@ -119,28 +119,39 @@ Split::~Split()
|
||||
{
|
||||
this->usermodeChangedConnection.disconnect();
|
||||
this->channelIDChangedConnection.disconnect();
|
||||
this->indirectChannelChangedConnection.disconnect();
|
||||
}
|
||||
|
||||
ChannelPtr Split::getChannel() const
|
||||
IndirectChannel Split::getIndirectChannel()
|
||||
{
|
||||
return this->channel;
|
||||
}
|
||||
|
||||
void Split::setChannel(ChannelPtr _newChannel)
|
||||
ChannelPtr Split::getChannel()
|
||||
{
|
||||
this->view.setChannel(_newChannel);
|
||||
return this->channel.get();
|
||||
}
|
||||
|
||||
void Split::setChannel(IndirectChannel newChannel)
|
||||
{
|
||||
this->view.setChannel(newChannel.get());
|
||||
|
||||
this->usermodeChangedConnection.disconnect();
|
||||
this->indirectChannelChangedConnection.disconnect();
|
||||
|
||||
this->channel = _newChannel;
|
||||
this->channel = newChannel;
|
||||
|
||||
TwitchChannel *tc = dynamic_cast<TwitchChannel *>(_newChannel.get());
|
||||
TwitchChannel *tc = dynamic_cast<TwitchChannel *>(newChannel.get().get());
|
||||
|
||||
if (tc != nullptr) {
|
||||
this->usermodeChangedConnection =
|
||||
tc->userStateChanged.connect([this] { this->header.updateModerationModeIcon(); });
|
||||
}
|
||||
|
||||
this->indirectChannelChangedConnection = newChannel.getChannelChanged().connect([this] { //
|
||||
QTimer::singleShot(0, [this] { this->setChannel(this->channel); });
|
||||
});
|
||||
|
||||
this->header.updateModerationModeIcon();
|
||||
this->header.updateChannelText();
|
||||
|
||||
@@ -316,7 +327,7 @@ void Split::doClearChat()
|
||||
|
||||
void Split::doOpenChannel()
|
||||
{
|
||||
ChannelPtr _channel = this->channel;
|
||||
ChannelPtr _channel = this->getChannel();
|
||||
TwitchChannel *tc = dynamic_cast<TwitchChannel *>(_channel.get());
|
||||
|
||||
if (tc != nullptr) {
|
||||
@@ -326,7 +337,7 @@ void Split::doOpenChannel()
|
||||
|
||||
void Split::doOpenPopupPlayer()
|
||||
{
|
||||
ChannelPtr _channel = this->channel;
|
||||
ChannelPtr _channel = this->getChannel();
|
||||
TwitchChannel *tc = dynamic_cast<TwitchChannel *>(_channel.get());
|
||||
|
||||
if (tc != nullptr) {
|
||||
@@ -337,7 +348,7 @@ void Split::doOpenPopupPlayer()
|
||||
void Split::doOpenStreamlink()
|
||||
{
|
||||
try {
|
||||
streamlink::Start(this->channel->name);
|
||||
streamlink::Start(this->getChannel()->name);
|
||||
} catch (const streamlink::Exception &ex) {
|
||||
debug::Log("Error in doOpenStreamlink: {}", ex.what());
|
||||
}
|
||||
@@ -353,7 +364,7 @@ void Split::doOpenViewerList()
|
||||
this->height() - this->header.height() - this->input.height());
|
||||
viewerDock->move(0, this->header.height());
|
||||
|
||||
auto accountPopup = new AccountPopupWidget(this->channel);
|
||||
auto accountPopup = new AccountPopupWidget(this->getChannel());
|
||||
accountPopup->setAttribute(Qt::WA_DeleteOnClose);
|
||||
auto multiWidget = new QWidget(viewerDock);
|
||||
auto dockVbox = new QVBoxLayout(viewerDock);
|
||||
@@ -372,8 +383,8 @@ void Split::doOpenViewerList()
|
||||
}
|
||||
auto loadingLabel = new QLabel("Loading...");
|
||||
|
||||
util::twitch::get("https://tmi.twitch.tv/group/user/" + channel->name + "/chatters", this,
|
||||
[=](QJsonObject obj) {
|
||||
util::twitch::get("https://tmi.twitch.tv/group/user/" + this->getChannel()->name + "/chatters",
|
||||
this, [=](QJsonObject obj) {
|
||||
QJsonObject chattersObj = obj.value("chatters").toObject();
|
||||
|
||||
loadingLabel->hide();
|
||||
|
||||
@@ -53,8 +53,9 @@ public:
|
||||
return this->view;
|
||||
}
|
||||
|
||||
ChannelPtr getChannel() const;
|
||||
void setChannel(ChannelPtr newChannel);
|
||||
IndirectChannel getIndirectChannel();
|
||||
ChannelPtr getChannel();
|
||||
void setChannel(IndirectChannel newChannel);
|
||||
|
||||
void setFlexSizeX(double x);
|
||||
double getFlexSizeX();
|
||||
@@ -83,7 +84,7 @@ protected:
|
||||
|
||||
private:
|
||||
SplitContainer &parentPage;
|
||||
ChannelPtr channel;
|
||||
IndirectChannel channel;
|
||||
|
||||
QVBoxLayout vbox;
|
||||
SplitHeader header;
|
||||
@@ -96,6 +97,7 @@ private:
|
||||
|
||||
pajlada::Signals::Connection channelIDChangedConnection;
|
||||
pajlada::Signals::Connection usermodeChangedConnection;
|
||||
pajlada::Signals::Connection indirectChannelChangedConnection;
|
||||
void doOpenAccountPopupWidget(AccountPopupWidget *widget, QString user);
|
||||
void channelNameUpdated(const QString &newChannelName);
|
||||
void handleModifiers(QEvent *event, Qt::KeyboardModifiers modifiers);
|
||||
|
||||
Reference in New Issue
Block a user