Refactored TwitchChannel

This commit is contained in:
fourtf
2018-07-15 20:28:54 +02:00
parent 111853c574
commit 1614b11e42
11 changed files with 268 additions and 247 deletions
+3 -5
View File
@@ -56,7 +56,7 @@ void EmotePopup::loadChannel(ChannelPtr _channel)
ChannelPtr emoteChannel(new Channel("", Channel::Type::None));
auto addEmotes = [&](EmoteMap &map, const QString &title, const QString &emoteDesc) {
auto addEmotes = [&](const EmoteMap &map, const QString &title, const QString &emoteDesc) {
// TITLE
MessageBuilder builder1;
@@ -120,12 +120,10 @@ void EmotePopup::loadChannel(ChannelPtr _channel)
}
addEmotes(app->emotes->bttv.globalEmotes, "BetterTTV Global Emotes", "BetterTTV Global Emote");
addEmotes(*channel->bttvChannelEmotes.get(), "BetterTTV Channel Emotes",
"BetterTTV Channel Emote");
addEmotes(channel->getBttvEmotes(), "BetterTTV Channel Emotes", "BetterTTV Channel Emote");
addEmotes(app->emotes->ffz.globalEmotes, "FrankerFaceZ Global Emotes",
"FrankerFaceZ Global Emote");
addEmotes(*channel->ffzChannelEmotes.get(), "FrankerFaceZ Channel Emotes",
"FrankerFaceZ Channel Emote");
addEmotes(channel->getFfzEmotes(), "FrankerFaceZ Channel Emotes", "FrankerFaceZ Channel Emote");
this->viewEmotes_->setChannel(emoteChannel);
}
+24 -26
View File
@@ -80,9 +80,7 @@ SplitHeader::SplitHeader(Split *_split)
// dropdown->setScaleIndependantSize(23, 23);
this->addDropdownItems(dropdown.getElement());
QObject::connect(dropdown.getElement(), &RippleEffectButton::leftMousePress, this, [this] {
QTimer::singleShot(80, [&, this] {
this->dropdownMenu_.popup(QCursor::pos());
});
QTimer::singleShot(80, [&, this] { this->dropdownMenu_.popup(QCursor::pos()); });
});
}
@@ -168,17 +166,17 @@ void SplitHeader::setupModeLabel(RippleEffectLabel &label)
label.setEnable(twitchChannel->hasModRights());
// set the label text
auto roomModes = twitchChannel->getRoomModes();
QString text;
if (roomModes.r9k)
text += "r9k, ";
if (roomModes.slowMode)
text += QString("slow(%1), ").arg(QString::number(roomModes.slowMode));
if (roomModes.emoteOnly)
text += "emote, ";
if (roomModes.submode)
text += "sub, ";
{
auto roomModes = twitchChannel->accessRoomModes();
if (roomModes->r9k) text += "r9k, ";
if (roomModes->slowMode)
text += QString("slow(%1), ").arg(QString::number(roomModes->slowMode));
if (roomModes->emoteOnly) text += "emote, ";
if (roomModes->submode) text += "sub, ";
}
if (text.length() > 2) {
text = text.mid(0, text.size() - 2);
@@ -229,12 +227,12 @@ void SplitHeader::addModeActions(QMenu &menu)
return;
}
auto roomModes = twitchChannel->getRoomModes();
auto roomModes = twitchChannel->accessRoomModes();
setR9k->setChecked(roomModes.r9k);
setSlow->setChecked(roomModes.slowMode);
setEmote->setChecked(roomModes.emoteOnly);
setSub->setChecked(roomModes.submode);
setR9k->setChecked(roomModes->r9k);
setSlow->setChecked(roomModes->slowMode);
setEmote->setChecked(roomModes->emoteOnly);
setSub->setChecked(roomModes->submode);
}));
auto toggle = [this](const QString &_command, QAction *action) mutable {
@@ -315,22 +313,22 @@ void SplitHeader::updateChannelText()
TwitchChannel *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get());
if (twitchChannel != nullptr) {
const auto streamStatus = twitchChannel->getStreamStatus();
const auto streamStatus = twitchChannel->accessStreamStatus();
if (streamStatus.live) {
if (streamStatus->live) {
this->isLive_ = true;
this->tooltip_ = "<style>.center { text-align: center; }</style>"
"<p class = \"center\">" +
streamStatus.title + "<br><br>" + streamStatus.game + "<br>" +
(streamStatus.rerun ? "Vod-casting" : "Live") + " for " +
streamStatus.uptime + " with " +
QString::number(streamStatus.viewerCount) +
streamStatus->title + "<br><br>" + streamStatus->game + "<br>" +
(streamStatus->rerun ? "Vod-casting" : "Live") + " for " +
streamStatus->uptime + " with " +
QString::number(streamStatus->viewerCount) +
" viewers"
"</p>";
if (streamStatus.rerun) {
if (streamStatus->rerun) {
title += " (rerun)";
} else if (streamStatus.streamType.isEmpty()) {
title += " (" + streamStatus.streamType + ")";
} else if (streamStatus->streamType.isEmpty()) {
title += " (" + streamStatus->streamType + ")";
} else {
title += " (live)";
}