mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Use display/localized names in tab and split titles (#2189)
This commit is contained in:
parent
f1660bfc55
commit
bf4c9cebb1
|
@ -34,6 +34,7 @@
|
|||
- Minor: Allow highlights to be excluded from `/mentions`. Excluded highlights will not trigger tab highlights either. (#1793, #2036)
|
||||
- Minor: Flag all popup dialogs as actual dialogs so they get the relevant window manager hints (#1843, #2182, #2185, #2232, #2234)
|
||||
- Minor: Don't show update button for nightly builds on macOS and Linux, this was already the case for Windows (#2163, #2164)
|
||||
- Minor: Tab and split titles now use display/localized channel names (#2189)
|
||||
- Minor: Add a setting to limit the amount of historical messages loaded from the Recent Messages API (#2250, #2252)
|
||||
- Bugfix: Fix crash occurring when pressing Escape in the Color Picker Dialog (#1843)
|
||||
- Bugfix: Fix bug where the "check user follow state" event could trigger a network request requesting the user to follow or unfollow a user. By itself its quite harmless as it just repeats to Twitch the same follow state we had, so no follows should have been lost by this but it meant there was a rogue network request that was fired that could cause a crash (#1906)
|
||||
|
|
|
@ -49,10 +49,10 @@ Application::Application(Settings &_settings, Paths &_paths)
|
|||
: themes(&this->emplace<Theme>())
|
||||
, fonts(&this->emplace<Fonts>())
|
||||
, emotes(&this->emplace<Emotes>())
|
||||
, accounts(&this->emplace<AccountController>())
|
||||
, windows(&this->emplace<WindowManager>())
|
||||
, toasts(&this->emplace<Toasts>())
|
||||
|
||||
, accounts(&this->emplace<AccountController>())
|
||||
, commands(&this->emplace<CommandController>())
|
||||
, notifications(&this->emplace<NotificationController>())
|
||||
, twitch2(&this->emplace<TwitchIrcServer>())
|
||||
|
|
|
@ -50,10 +50,10 @@ public:
|
|||
Theme *const themes{};
|
||||
Fonts *const fonts{};
|
||||
Emotes *const emotes{};
|
||||
AccountController *const accounts{};
|
||||
WindowManager *const windows{};
|
||||
Toasts *const toasts{};
|
||||
|
||||
AccountController *const accounts{};
|
||||
CommandController *const commands{};
|
||||
NotificationController *const notifications{};
|
||||
TwitchIrcServer *const twitch2{};
|
||||
|
|
|
@ -49,6 +49,11 @@ const QString &Channel::getDisplayName() const
|
|||
return this->getName();
|
||||
}
|
||||
|
||||
const QString &Channel::getLocalizedName() const
|
||||
{
|
||||
return this->getName();
|
||||
}
|
||||
|
||||
bool Channel::isTwitchChannel() const
|
||||
{
|
||||
return this->type_ >= Type::Twitch && this->type_ < Type::TwitchEnd;
|
||||
|
|
|
@ -53,10 +53,12 @@ public:
|
|||
pajlada::Signals::Signal<std::vector<MessagePtr> &> messagesAddedAtStart;
|
||||
pajlada::Signals::Signal<size_t, MessagePtr &> messageReplaced;
|
||||
pajlada::Signals::NoArgSignal destroyed;
|
||||
pajlada::Signals::NoArgSignal displayNameChanged;
|
||||
|
||||
Type getType() const;
|
||||
const QString &getName() const;
|
||||
virtual const QString &getDisplayName() const;
|
||||
virtual const QString &getLocalizedName() const;
|
||||
bool isTwitchChannel() const;
|
||||
virtual bool isEmpty() const;
|
||||
LimitedQueueSnapshot<MessagePtr> getMessageSnapshot();
|
||||
|
|
|
@ -137,6 +137,7 @@ TwitchChannel::TwitchChannel(const QString &name,
|
|||
FfzEmotes &ffz)
|
||||
: Channel(name, Channel::Type::Twitch)
|
||||
, ChannelChatters(*static_cast<Channel *>(this))
|
||||
, nameOptions{name, name}
|
||||
, subscriptionUrl_("https://www.twitch.tv/subs/" + name)
|
||||
, channelUrl_("https://twitch.tv/" + name)
|
||||
, popoutPlayerUrl_("https://player.twitch.tv/?parent=twitch.tv&channel=" +
|
||||
|
@ -202,6 +203,7 @@ TwitchChannel::TwitchChannel(const QString &name,
|
|||
|
||||
void TwitchChannel::initialize()
|
||||
{
|
||||
this->fetchDisplayName();
|
||||
this->refreshChatters();
|
||||
this->refreshBadges();
|
||||
}
|
||||
|
@ -216,6 +218,26 @@ bool TwitchChannel::canSendMessage() const
|
|||
return !this->isEmpty();
|
||||
}
|
||||
|
||||
const QString &TwitchChannel::getDisplayName() const
|
||||
{
|
||||
return this->nameOptions.displayName;
|
||||
}
|
||||
|
||||
void TwitchChannel::setDisplayName(const QString &name)
|
||||
{
|
||||
this->nameOptions.displayName = name;
|
||||
}
|
||||
|
||||
const QString &TwitchChannel::getLocalizedName() const
|
||||
{
|
||||
return this->nameOptions.localizedName;
|
||||
}
|
||||
|
||||
void TwitchChannel::setLocalizedName(const QString &name)
|
||||
{
|
||||
this->nameOptions.localizedName = name;
|
||||
}
|
||||
|
||||
void TwitchChannel::refreshBTTVChannelEmotes(bool manualRefresh)
|
||||
{
|
||||
BttvEmotes::loadChannel(
|
||||
|
@ -761,6 +783,32 @@ void TwitchChannel::refreshChatters()
|
|||
.execute();
|
||||
}
|
||||
|
||||
void TwitchChannel::fetchDisplayName()
|
||||
{
|
||||
getHelix()->getUserByName(
|
||||
this->getName(),
|
||||
[weak = weakOf<Channel>(this)](const auto &user) {
|
||||
auto shared = weak.lock();
|
||||
if (!shared)
|
||||
return;
|
||||
auto channel = static_cast<TwitchChannel *>(shared.get());
|
||||
if (QString::compare(user.displayName, channel->getName(),
|
||||
Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
channel->setDisplayName(user.displayName);
|
||||
channel->setLocalizedName(user.displayName);
|
||||
}
|
||||
else
|
||||
{
|
||||
channel->setLocalizedName(QString("%1(%2)")
|
||||
.arg(channel->getName())
|
||||
.arg(user.displayName));
|
||||
}
|
||||
channel->displayNameChanged.invoke();
|
||||
},
|
||||
[] {});
|
||||
}
|
||||
|
||||
void TwitchChannel::refreshBadges()
|
||||
{
|
||||
auto url = Url{"https://badges.twitch.tv/v1/badges/channels/" +
|
||||
|
|
|
@ -121,7 +121,7 @@ private:
|
|||
struct NameOptions {
|
||||
QString displayName;
|
||||
QString localizedName;
|
||||
};
|
||||
} nameOptions;
|
||||
|
||||
protected:
|
||||
explicit TwitchChannel(const QString &channelName,
|
||||
|
@ -137,6 +137,7 @@ private:
|
|||
void refreshBadges();
|
||||
void refreshCheerEmotes();
|
||||
void loadRecentMessages();
|
||||
void fetchDisplayName();
|
||||
|
||||
void setLive(bool newLiveStatus);
|
||||
void setMod(bool value);
|
||||
|
@ -144,6 +145,11 @@ private:
|
|||
void setStaff(bool value);
|
||||
void setRoomId(const QString &id);
|
||||
void setRoomModes(const RoomModes &roomModes_);
|
||||
void setDisplayName(const QString &name);
|
||||
void setLocalizedName(const QString &name);
|
||||
|
||||
const QString &getDisplayName() const override;
|
||||
const QString &getLocalizedName() const override;
|
||||
|
||||
// Data
|
||||
const QString subscriptionUrl_;
|
||||
|
|
|
@ -381,6 +381,10 @@ void Split::setChannel(IndirectChannel newChannel)
|
|||
this->header_->setViewersButtonVisible(false);
|
||||
}
|
||||
|
||||
this->channel_.get()->displayNameChanged.connect([this] {
|
||||
this->container_->refreshTab();
|
||||
});
|
||||
|
||||
this->channelChanged.invoke();
|
||||
|
||||
// Queue up save because: Split channel changed
|
||||
|
|
|
@ -788,7 +788,7 @@ void SplitContainer::refreshTabTitle()
|
|||
|
||||
for (const auto &chatWidget : this->splits_)
|
||||
{
|
||||
auto channelName = chatWidget->getChannel()->getName();
|
||||
auto channelName = chatWidget->getChannel()->getLocalizedName();
|
||||
if (channelName.isEmpty())
|
||||
{
|
||||
continue;
|
||||
|
|
|
@ -659,7 +659,7 @@ void SplitHeader::updateChannelText()
|
|||
this->isLive_ = false;
|
||||
this->tooltipText_ = QString();
|
||||
|
||||
auto title = channel->getName();
|
||||
auto title = channel->getLocalizedName();
|
||||
|
||||
if (indirectChannel.getType() == Channel::Type::TwitchWatching)
|
||||
title = "watching: " + (title.isEmpty() ? "none" : title);
|
||||
|
|
Loading…
Reference in a new issue