feat: launch arg to start logged in as a supplied user (#5626)

This commit is contained in:
Liam Rooney 2024-10-06 01:29:44 -07:00 committed by GitHub
parent c1e04eeeff
commit 0085fb64ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 23 additions and 0 deletions

View file

@ -31,6 +31,7 @@
- Minor: Removed experimental IRC support. (#5547)
- Minor: Moderators can now see which mods start and cancel raids. (#5563)
- Minor: The emote popup now reloads when Twitch emotes are reloaded. (#5580)
- Minor: Added `--login <username>` CLI argument to specify which account to start logged in as. (#5626)
- Bugfix: Fixed tab move animation occasionally failing to start after closing a tab. (#5426, #5612)
- Bugfix: If a network request errors with 200 OK, Qt's error code is now reported instead of the HTTP status. (#5378)
- Bugfix: Fixed restricted users usernames not being clickable. (#5405)

View file

@ -117,6 +117,13 @@ Args::Args(const QApplication &app, const Paths &paths)
"safe-mode", "Starts Chatterino without loading Plugins and always "
"show the settings button.");
QCommandLineOption loginOption(
"login",
"Starts Chatterino logged in as the account matching the supplied "
"username. If the supplied username does not match any account "
"Chatterino starts logged in as anonymous.",
"username");
// Channel layout
auto channelLayout = QCommandLineOption(
{"c", "channels"},
@ -142,6 +149,7 @@ Args::Args(const QApplication &app, const Paths &paths)
parentWindowIdOption,
verboseOption,
safeModeOption,
loginOption,
channelLayout,
activateOption,
});
@ -197,6 +205,11 @@ Args::Args(const QApplication &app, const Paths &paths)
this->safeMode = true;
}
if (parser.isSet(loginOption))
{
this->initialLogin = parser.value(loginOption);
}
if (parser.isSet(activateOption))
{
this->activateChannel =
@ -206,6 +219,7 @@ Args::Args(const QApplication &app, const Paths &paths)
this->currentArguments_ = extractCommandLine(parser, {
verboseOption,
safeModeOption,
loginOption,
channelLayout,
activateOption,
});

View file

@ -60,6 +60,7 @@ public:
bool dontLoadMainWindow{};
std::optional<WindowLayout> customChannelLayout;
std::optional<Channel> activateChannel;
std::optional<QString> initialLogin;
bool verbose{};
bool safeMode{};

View file

@ -1,5 +1,7 @@
#include "providers/twitch/TwitchAccountManager.hpp"
#include "Application.hpp"
#include "common/Args.hpp"
#include "common/Common.hpp"
#include "common/QLogging.hpp"
#include "providers/twitch/api/Helix.hpp"
@ -144,6 +146,11 @@ void TwitchAccountManager::reloadUsers()
void TwitchAccountManager::load()
{
if (getApp()->getArgs().initialLogin.has_value())
{
this->currentUsername = getApp()->getArgs().initialLogin.value();
}
this->reloadUsers();
this->currentUsername.connect([this](const QString &newUsername) {