Show the title when offline (#1347)

* Channel text for offline chats

* Title refresh timer

* Fixed typo

* Refresh title when room id is loaded

* removed timer

* Typo

* Loaded on demand when hovered over

* removed the extra api request

* Moved refreshTitle function call

* Added thottling for 10s

* Fixed formating style

* reformat

* make status fetcher safer

* Requested changes from fourtf
This commit is contained in:
CommName
2019-10-12 15:09:12 +02:00
committed by fourtf
parent 8153aa7d40
commit dc1e4d2544
3 changed files with 67 additions and 0 deletions
+16
View File
@@ -99,6 +99,12 @@ namespace {
.arg(s.uptime)
.arg(QString::number(s.viewerCount));
}
auto formatOfflineTooltip(const TwitchChannel::StreamStatus &s)
{
return QString("<style>.center { text-align: center; }</style> \
<p class=\"center\">Offline<br>%1</p>")
.arg(s.title.toHtmlEscaped());
}
auto formatTitle(const TwitchChannel::StreamStatus &s, Settings &settings)
{
auto title = QString();
@@ -550,6 +556,10 @@ void SplitHeader::updateChannelText()
this->tooltipText_ = formatTooltip(*streamStatus);
title += formatTitle(*streamStatus, *getSettings());
}
else
{
this->tooltipText_ = formatOfflineTooltip(*streamStatus);
}
}
this->titleLabel_->setText(title.isEmpty() ? "<empty>" : title);
@@ -670,6 +680,12 @@ void SplitHeader::enterEvent(QEvent *event)
{
if (!this->tooltipText_.isEmpty())
{
auto channel = this->split_->getChannel().get();
if (channel->getType() == Channel::Type::Twitch)
{
dynamic_cast<TwitchChannel *>(channel)->refreshTitle();
}
TooltipPreviewImage::instance().setImage(nullptr);
auto tooltip = TooltipWidget::instance();