mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
feat: add --safe-mode
command line option (#4985)
This ensures the settings button isn't hidden, and disables plugins from being loaded to make sure the user can always recover from messing things up
This commit is contained in:
parent
44abe6b487
commit
c3d3903b6f
|
@ -14,6 +14,7 @@
|
|||
- Minor: The `/reply` command now replies to the latest message of the user. (#4919)
|
||||
- Minor: All sound capabilities can now be disabled by setting your "Sound backend" setting to "Null" and restarting Chatterino. (#4978)
|
||||
- Minor: Add an option to use new experimental smarter emote completion. (#4987)
|
||||
- Minor: Add `--safe-mode` command line option that can be used for troubleshooting when Chatterino is misbehaving or is misconfigured. It disables hiding the settings button & prevents plugins from loading. (#4985)
|
||||
- Bugfix: Fixed an issue where certain emojis did not send to Twitch chat correctly. (#4840)
|
||||
- Bugfix: Fixed capitalized channel names in log inclusion list not being logged. (#4848)
|
||||
- Bugfix: Trimmed custom streamlink paths on all platforms making sure you don't accidentally add spaces at the beginning or end of its path. (#4834)
|
||||
|
|
|
@ -38,6 +38,9 @@ Args::Args(const QApplication &app)
|
|||
"Attaches to the Console on windows, "
|
||||
"allowing you to see debug output."});
|
||||
crashRecoveryOption.setFlags(QCommandLineOption::HiddenFromHelp);
|
||||
QCommandLineOption safeModeOption(
|
||||
"safe-mode", "Starts Chatterino without loading Plugins and always "
|
||||
"show the settings button.");
|
||||
|
||||
parser.addOptions({
|
||||
{{"V", "version"}, "Displays version information."},
|
||||
|
@ -45,6 +48,7 @@ Args::Args(const QApplication &app)
|
|||
parentWindowOption,
|
||||
parentWindowIdOption,
|
||||
verboseOption,
|
||||
safeModeOption,
|
||||
});
|
||||
parser.addOption(QCommandLineOption(
|
||||
{"c", "channels"},
|
||||
|
@ -89,6 +93,10 @@ Args::Args(const QApplication &app)
|
|||
|
||||
this->parentWindowId = parser.value(parentWindowIdOption).toULongLong();
|
||||
}
|
||||
if (parser.isSet(safeModeOption))
|
||||
{
|
||||
this->safeMode = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Args::applyCustomChannelLayout(const QString &argValue)
|
||||
|
|
|
@ -26,6 +26,7 @@ public:
|
|||
bool dontLoadMainWindow{};
|
||||
std::optional<WindowLayout> customChannelLayout;
|
||||
bool verbose{};
|
||||
bool safeMode{};
|
||||
|
||||
private:
|
||||
void applyCustomChannelLayout(const QString &argValue);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# include "controllers/plugins/PluginController.hpp"
|
||||
|
||||
# include "Application.hpp"
|
||||
# include "common/Args.hpp"
|
||||
# include "common/QLogging.hpp"
|
||||
# include "controllers/commands/CommandContext.hpp"
|
||||
# include "controllers/commands/CommandController.hpp"
|
||||
|
@ -194,12 +195,20 @@ void PluginController::openLibrariesFor(lua_State *L,
|
|||
void PluginController::load(const QFileInfo &index, const QDir &pluginDir,
|
||||
const PluginMeta &meta)
|
||||
{
|
||||
lua_State *l = luaL_newstate();
|
||||
PluginController::openLibrariesFor(l, meta);
|
||||
|
||||
auto pluginName = pluginDir.dirName();
|
||||
lua_State *l = luaL_newstate();
|
||||
auto plugin = std::make_unique<Plugin>(pluginName, l, meta, pluginDir);
|
||||
this->plugins_.insert({pluginName, std::move(plugin)});
|
||||
|
||||
if (getArgs().safeMode)
|
||||
{
|
||||
// This isn't done earlier to ensure the user can disable a misbehaving plugin
|
||||
qCWarning(chatterinoLua) << "Skipping loading plugin " << meta.name
|
||||
<< " because safe mode is enabled.";
|
||||
return;
|
||||
}
|
||||
PluginController::openLibrariesFor(l, meta);
|
||||
|
||||
if (!PluginController::isPluginEnabled(pluginName) ||
|
||||
!getSettings()->pluginsEnabled)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "widgets/Notebook.hpp"
|
||||
|
||||
#include "Application.hpp"
|
||||
#include "common/Args.hpp"
|
||||
#include "common/QLogging.hpp"
|
||||
#include "controllers/hotkeys/HotkeyCategory.hpp"
|
||||
#include "controllers/hotkeys/HotkeyController.hpp"
|
||||
|
@ -1345,13 +1346,22 @@ void SplitNotebook::addCustomButtons()
|
|||
// settings
|
||||
auto settingsBtn = this->addCustomButton();
|
||||
|
||||
settingsBtn->setVisible(!getSettings()->hidePreferencesButton.getValue());
|
||||
// This is to ensure you can't lock yourself out of the settings
|
||||
if (getArgs().safeMode)
|
||||
{
|
||||
settingsBtn->setVisible(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
settingsBtn->setVisible(
|
||||
!getSettings()->hidePreferencesButton.getValue());
|
||||
|
||||
getSettings()->hidePreferencesButton.connect(
|
||||
[settingsBtn](bool hide, auto) {
|
||||
settingsBtn->setVisible(!hide);
|
||||
},
|
||||
this->signalHolder_);
|
||||
}
|
||||
|
||||
settingsBtn->setIcon(NotebookButton::Settings);
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "widgets/Window.hpp"
|
||||
|
||||
#include "Application.hpp"
|
||||
#include "common/Args.hpp"
|
||||
#include "common/Credentials.hpp"
|
||||
#include "common/Modes.hpp"
|
||||
#include "common/QLogging.hpp"
|
||||
|
@ -736,6 +737,11 @@ void Window::onAccountSelected()
|
|||
}
|
||||
#endif
|
||||
|
||||
if (getArgs().safeMode)
|
||||
{
|
||||
windowTitle += " (safe mode)";
|
||||
}
|
||||
|
||||
this->setWindowTitle(windowTitle);
|
||||
|
||||
// update user
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# include "widgets/settingspages/PluginsPage.hpp"
|
||||
|
||||
# include "Application.hpp"
|
||||
# include "common/Args.hpp"
|
||||
# include "controllers/plugins/PluginController.hpp"
|
||||
# include "singletons/Paths.hpp"
|
||||
# include "singletons/Settings.hpp"
|
||||
|
@ -52,6 +53,15 @@ PluginsPage::PluginsPage()
|
|||
this->rebuildContent();
|
||||
});
|
||||
groupLayout->addRow(box);
|
||||
if (getArgs().safeMode)
|
||||
{
|
||||
box->setEnabled(false);
|
||||
auto *disabledLabel = new QLabel(this);
|
||||
disabledLabel->setText("Plugins will not be fully loaded because "
|
||||
"Chatterino is in safe mode. You can still "
|
||||
"enable and disable them.");
|
||||
groupLayout->addRow(disabledLabel);
|
||||
}
|
||||
}
|
||||
|
||||
this->rebuildContent();
|
||||
|
@ -177,6 +187,10 @@ void PluginsPage::rebuildContent()
|
|||
this->rebuildContent();
|
||||
});
|
||||
pluginEntry->addRow(reloadButton);
|
||||
if (getArgs().safeMode)
|
||||
{
|
||||
reloadButton->setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue