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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user