Skip to content

Commit 86111d5

Browse files
authored
Add option always include broadcaster in user completions (#5193)
1 parent 6691050 commit 86111d5

File tree

5 files changed

+36
-7
lines changed

5 files changed

+36
-7
lines changed

CHANGELOG.md

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

src/controllers/completion/sources/UserSource.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,26 @@ void UserSource::initializeFromChannel(const Channel *channel)
5959
}
6060

6161
this->items_ = tc->accessChatters()->all();
62+
63+
if (getSettings()->alwaysIncludeBroadcasterInUserCompletions)
64+
{
65+
auto it = std::find_if(this->items_.begin(), this->items_.end(),
66+
[tc](const UserItem &user) {
67+
return user.first == tc->getName();
68+
});
69+
70+
if (it != this->items_.end())
71+
{
72+
auto broadcaster = *it;
73+
this->items_.erase(it);
74+
this->items_.insert(this->items_.begin(), broadcaster);
75+
}
76+
else
77+
{
78+
this->items_.insert(this->items_.begin(),
79+
{tc->getName(), tc->getDisplayName()});
80+
}
81+
}
6282
}
6383

6484
const std::vector<UserItem> &UserSource::output() const

src/providers/twitch/TwitchChannel.hpp

+6-7
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,12 @@ class TwitchChannel final : public Channel, public ChannelChatters
264264
void updateStreamStatus(const std::optional<HelixStream> &helixStream);
265265
void updateStreamTitle(const QString &title);
266266

267+
/**
268+
* Returns the display name of the user
269+
*
270+
* If the display name contained chinese, japenese, or korean characters, the user's login name is returned instead
271+
**/
272+
const QString &getDisplayName() const override;
267273
void updateDisplayName(const QString &displayName);
268274

269275
private:
@@ -323,13 +329,6 @@ class TwitchChannel final : public Channel, public ChannelChatters
323329
void setDisplayName(const QString &name);
324330
void setLocalizedName(const QString &name);
325331

326-
/**
327-
* Returns the display name of the user
328-
*
329-
* If the display name contained chinese, japenese, or korean characters, the user's login name is returned instead
330-
**/
331-
const QString &getDisplayName() const override;
332-
333332
/**
334333
* Returns the localized name of the user
335334
**/

src/singletons/Settings.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,10 @@ class Settings
218218
"/behaviour/autocompletion/emoteCompletionWithColon", true};
219219
BoolSetting showUsernameCompletionMenu = {
220220
"/behaviour/autocompletion/showUsernameCompletionMenu", true};
221+
BoolSetting alwaysIncludeBroadcasterInUserCompletions = {
222+
"/behaviour/autocompletion/alwaysIncludeBroadcasterInUserCompletions",
223+
true,
224+
};
221225
BoolSetting useSmartEmoteCompletion = {
222226
"/experiments/useSmartEmoteCompletion",
223227
false,

src/widgets/settingspages/GeneralPage.cpp

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

0 commit comments

Comments
 (0)