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:
@@ -14,6 +14,7 @@
|
|||||||
- Minor: The `/reply` command now replies to the latest message of the user. (#4919)
|
- 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: 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 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 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: 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)
|
- 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, "
|
"Attaches to the Console on windows, "
|
||||||
"allowing you to see debug output."});
|
"allowing you to see debug output."});
|
||||||
crashRecoveryOption.setFlags(QCommandLineOption::HiddenFromHelp);
|
crashRecoveryOption.setFlags(QCommandLineOption::HiddenFromHelp);
|
||||||
|
QCommandLineOption safeModeOption(
|
||||||
|
"safe-mode", "Starts Chatterino without loading Plugins and always "
|
||||||
|
"show the settings button.");
|
||||||
|
|
||||||
parser.addOptions({
|
parser.addOptions({
|
||||||
{{"V", "version"}, "Displays version information."},
|
{{"V", "version"}, "Displays version information."},
|
||||||
@@ -45,6 +48,7 @@ Args::Args(const QApplication &app)
|
|||||||
parentWindowOption,
|
parentWindowOption,
|
||||||
parentWindowIdOption,
|
parentWindowIdOption,
|
||||||
verboseOption,
|
verboseOption,
|
||||||
|
safeModeOption,
|
||||||
});
|
});
|
||||||
parser.addOption(QCommandLineOption(
|
parser.addOption(QCommandLineOption(
|
||||||
{"c", "channels"},
|
{"c", "channels"},
|
||||||
@@ -89,6 +93,10 @@ Args::Args(const QApplication &app)
|
|||||||
|
|
||||||
this->parentWindowId = parser.value(parentWindowIdOption).toULongLong();
|
this->parentWindowId = parser.value(parentWindowIdOption).toULongLong();
|
||||||
}
|
}
|
||||||
|
if (parser.isSet(safeModeOption))
|
||||||
|
{
|
||||||
|
this->safeMode = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Args::applyCustomChannelLayout(const QString &argValue)
|
void Args::applyCustomChannelLayout(const QString &argValue)
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ public:
|
|||||||
bool dontLoadMainWindow{};
|
bool dontLoadMainWindow{};
|
||||||
std::optional<WindowLayout> customChannelLayout;
|
std::optional<WindowLayout> customChannelLayout;
|
||||||
bool verbose{};
|
bool verbose{};
|
||||||
|
bool safeMode{};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void applyCustomChannelLayout(const QString &argValue);
|
void applyCustomChannelLayout(const QString &argValue);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
# include "controllers/plugins/PluginController.hpp"
|
# include "controllers/plugins/PluginController.hpp"
|
||||||
|
|
||||||
# include "Application.hpp"
|
# include "Application.hpp"
|
||||||
|
# include "common/Args.hpp"
|
||||||
# include "common/QLogging.hpp"
|
# include "common/QLogging.hpp"
|
||||||
# include "controllers/commands/CommandContext.hpp"
|
# include "controllers/commands/CommandContext.hpp"
|
||||||
# include "controllers/commands/CommandController.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,
|
void PluginController::load(const QFileInfo &index, const QDir &pluginDir,
|
||||||
const PluginMeta &meta)
|
const PluginMeta &meta)
|
||||||
{
|
{
|
||||||
lua_State *l = luaL_newstate();
|
|
||||||
PluginController::openLibrariesFor(l, meta);
|
|
||||||
|
|
||||||
auto pluginName = pluginDir.dirName();
|
auto pluginName = pluginDir.dirName();
|
||||||
|
lua_State *l = luaL_newstate();
|
||||||
auto plugin = std::make_unique<Plugin>(pluginName, l, meta, pluginDir);
|
auto plugin = std::make_unique<Plugin>(pluginName, l, meta, pluginDir);
|
||||||
this->plugins_.insert({pluginName, std::move(plugin)});
|
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) ||
|
if (!PluginController::isPluginEnabled(pluginName) ||
|
||||||
!getSettings()->pluginsEnabled)
|
!getSettings()->pluginsEnabled)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "widgets/Notebook.hpp"
|
#include "widgets/Notebook.hpp"
|
||||||
|
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
|
#include "common/Args.hpp"
|
||||||
#include "common/QLogging.hpp"
|
#include "common/QLogging.hpp"
|
||||||
#include "controllers/hotkeys/HotkeyCategory.hpp"
|
#include "controllers/hotkeys/HotkeyCategory.hpp"
|
||||||
#include "controllers/hotkeys/HotkeyController.hpp"
|
#include "controllers/hotkeys/HotkeyController.hpp"
|
||||||
@@ -1345,13 +1346,22 @@ void SplitNotebook::addCustomButtons()
|
|||||||
// settings
|
// settings
|
||||||
auto settingsBtn = this->addCustomButton();
|
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(
|
getSettings()->hidePreferencesButton.connect(
|
||||||
[settingsBtn](bool hide, auto) {
|
[settingsBtn](bool hide, auto) {
|
||||||
settingsBtn->setVisible(!hide);
|
settingsBtn->setVisible(!hide);
|
||||||
},
|
},
|
||||||
this->signalHolder_);
|
this->signalHolder_);
|
||||||
|
}
|
||||||
|
|
||||||
settingsBtn->setIcon(NotebookButton::Settings);
|
settingsBtn->setIcon(NotebookButton::Settings);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "widgets/Window.hpp"
|
#include "widgets/Window.hpp"
|
||||||
|
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
|
#include "common/Args.hpp"
|
||||||
#include "common/Credentials.hpp"
|
#include "common/Credentials.hpp"
|
||||||
#include "common/Modes.hpp"
|
#include "common/Modes.hpp"
|
||||||
#include "common/QLogging.hpp"
|
#include "common/QLogging.hpp"
|
||||||
@@ -736,6 +737,11 @@ void Window::onAccountSelected()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (getArgs().safeMode)
|
||||||
|
{
|
||||||
|
windowTitle += " (safe mode)";
|
||||||
|
}
|
||||||
|
|
||||||
this->setWindowTitle(windowTitle);
|
this->setWindowTitle(windowTitle);
|
||||||
|
|
||||||
// update user
|
// update user
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
# include "widgets/settingspages/PluginsPage.hpp"
|
# include "widgets/settingspages/PluginsPage.hpp"
|
||||||
|
|
||||||
# include "Application.hpp"
|
# include "Application.hpp"
|
||||||
|
# include "common/Args.hpp"
|
||||||
# include "controllers/plugins/PluginController.hpp"
|
# include "controllers/plugins/PluginController.hpp"
|
||||||
# include "singletons/Paths.hpp"
|
# include "singletons/Paths.hpp"
|
||||||
# include "singletons/Settings.hpp"
|
# include "singletons/Settings.hpp"
|
||||||
@@ -52,6 +53,15 @@ PluginsPage::PluginsPage()
|
|||||||
this->rebuildContent();
|
this->rebuildContent();
|
||||||
});
|
});
|
||||||
groupLayout->addRow(box);
|
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();
|
this->rebuildContent();
|
||||||
@@ -177,6 +187,10 @@ void PluginsPage::rebuildContent()
|
|||||||
this->rebuildContent();
|
this->rebuildContent();
|
||||||
});
|
});
|
||||||
pluginEntry->addRow(reloadButton);
|
pluginEntry->addRow(reloadButton);
|
||||||
|
if (getArgs().safeMode)
|
||||||
|
{
|
||||||
|
reloadButton->setEnabled(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user