Add option always include broadcaster in user completions (#5193)

This commit is contained in:
KleberPF 2024-02-24 10:21:29 -03:00 committed by GitHub
parent 66910507dc
commit 86111d59b6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 36 additions and 7 deletions

View file

@ -20,6 +20,7 @@
- Minor: Add a new completion API for experimental plugins feature. (#5000, #5047)
- Minor: Re-enabled _Restart on crash_ option on Windows. (#5012)
- Minor: The whisper highlight color can now be configured through the settings. (#5053)
- Minor: Added an option to always include the broadcaster in user completions. This is enabled by default. (#5193)
- Minor: Added missing periods at various moderator messages and commands. (#5061)
- Minor: Improved color selection and display. (#5057)
- Minor: Improved Streamlink documentation in the settings dialog. (#5076)

View file

@ -59,6 +59,26 @@ void UserSource::initializeFromChannel(const Channel *channel)
}
this->items_ = tc->accessChatters()->all();
if (getSettings()->alwaysIncludeBroadcasterInUserCompletions)
{
auto it = std::find_if(this->items_.begin(), this->items_.end(),
[tc](const UserItem &user) {
return user.first == tc->getName();
});
if (it != this->items_.end())
{
auto broadcaster = *it;
this->items_.erase(it);
this->items_.insert(this->items_.begin(), broadcaster);
}
else
{
this->items_.insert(this->items_.begin(),
{tc->getName(), tc->getDisplayName()});
}
}
}
const std::vector<UserItem> &UserSource::output() const

View file

@ -264,6 +264,12 @@ public:
void updateStreamStatus(const std::optional<HelixStream> &helixStream);
void updateStreamTitle(const QString &title);
/**
* Returns the display name of the user
*
* If the display name contained chinese, japenese, or korean characters, the user's login name is returned instead
**/
const QString &getDisplayName() const override;
void updateDisplayName(const QString &displayName);
private:
@ -323,13 +329,6 @@ private:
void setDisplayName(const QString &name);
void setLocalizedName(const QString &name);
/**
* Returns the display name of the user
*
* If the display name contained chinese, japenese, or korean characters, the user's login name is returned instead
**/
const QString &getDisplayName() const override;
/**
* Returns the localized name of the user
**/

View file

@ -218,6 +218,10 @@ public:
"/behaviour/autocompletion/emoteCompletionWithColon", true};
BoolSetting showUsernameCompletionMenu = {
"/behaviour/autocompletion/showUsernameCompletionMenu", true};
BoolSetting alwaysIncludeBroadcasterInUserCompletions = {
"/behaviour/autocompletion/alwaysIncludeBroadcasterInUserCompletions",
true,
};
BoolSetting useSmartEmoteCompletion = {
"/experiments/useSmartEmoteCompletion",
false,

View file

@ -1032,6 +1032,11 @@ void GeneralPage::initLayout(GeneralPageView &layout)
"Find mentions of users in chat without the @ prefix.");
layout.addCheckbox("Show username autocompletion popup menu",
s.showUsernameCompletionMenu);
layout.addCheckbox(
"Always include broadcaster in user completions",
s.alwaysIncludeBroadcasterInUserCompletions, false,
"This will ensure a broadcaster is always easy to ping, even if they "
"don't have chat open or have typed recently.");
const QStringList usernameDisplayModes = {"Username", "Localized name",
"Username and localized name"};