mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Make clang-tidy complain a little less
This commit is contained in:
parent
ff49aebf08
commit
ee1bb1956b
3 changed files with 20 additions and 15 deletions
|
@ -101,7 +101,9 @@ bool PluginController::tryLoadFromDir(const QDir &pluginDir)
|
||||||
this->load(index, pluginDir, PluginMeta(doc.object()));
|
this->load(index, pluginDir, PluginMeta(doc.object()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
void PluginController::openLibrariesFor(lua_State *L, PluginMeta meta)
|
|
||||||
|
void PluginController::openLibrariesFor(lua_State *L,
|
||||||
|
const PluginMeta & /*meta*/)
|
||||||
{
|
{
|
||||||
// Stuff to change, remove or hide behind a permission system:
|
// Stuff to change, remove or hide behind a permission system:
|
||||||
static const std::vector<luaL_Reg> loadedlibs = {
|
static const std::vector<luaL_Reg> loadedlibs = {
|
||||||
|
@ -135,12 +137,13 @@ void PluginController::openLibrariesFor(lua_State *L, PluginMeta meta)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PluginController::load(QFileInfo index, QDir pluginDir, PluginMeta meta)
|
void PluginController::load(const QFileInfo &index, const QDir &pluginDir,
|
||||||
|
const PluginMeta &meta)
|
||||||
{
|
{
|
||||||
qCDebug(chatterinoLua) << "Running lua file" << index;
|
qCDebug(chatterinoLua) << "Running lua file" << index;
|
||||||
lua_State *l = luaL_newstate();
|
lua_State *l = luaL_newstate();
|
||||||
this->openLibrariesFor(l, meta);
|
PluginController::openLibrariesFor(l, meta);
|
||||||
this->loadChatterinoLib(l);
|
PluginController::loadChatterinoLib(l);
|
||||||
|
|
||||||
auto pluginName = pluginDir.dirName();
|
auto pluginName = pluginDir.dirName();
|
||||||
auto plugin = std::make_unique<Plugin>(pluginName, l, meta, pluginDir);
|
auto plugin = std::make_unique<Plugin>(pluginName, l, meta, pluginDir);
|
||||||
|
@ -154,7 +157,7 @@ void PluginController::load(QFileInfo index, QDir pluginDir, PluginMeta meta)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this->plugins_.insert({pluginName, std::move(plugin)});
|
this->plugins_.insert({pluginName, std::move(plugin)});
|
||||||
if (!this->isEnabled(pluginName))
|
if (!PluginController::isEnabled(pluginName))
|
||||||
{
|
{
|
||||||
qCInfo(chatterinoLua) << "Skipping loading" << pluginName << "("
|
qCInfo(chatterinoLua) << "Skipping loading" << pluginName << "("
|
||||||
<< meta.name << ") because it is disabled";
|
<< meta.name << ") because it is disabled";
|
||||||
|
@ -189,7 +192,7 @@ bool PluginController::reload(const QString &codename)
|
||||||
getApp()->commands->unregisterPluginCommand(cmd);
|
getApp()->commands->unregisterPluginCommand(cmd);
|
||||||
}
|
}
|
||||||
it->second->ownedCommands.clear();
|
it->second->ownedCommands.clear();
|
||||||
if (this->isEnabled(codename))
|
if (PluginController::isEnabled(codename))
|
||||||
{
|
{
|
||||||
QDir loadDir = it->second->loadDirectory_;
|
QDir loadDir = it->second->loadDirectory_;
|
||||||
this->plugins_.erase(codename);
|
this->plugins_.erase(codename);
|
||||||
|
@ -209,7 +212,8 @@ void PluginController::callEvery(const QString &functionName)
|
||||||
|
|
||||||
void PluginController::callEveryWithArgs(
|
void PluginController::callEveryWithArgs(
|
||||||
const QString &functionName, int count,
|
const QString &functionName, int count,
|
||||||
std::function<void(const std::unique_ptr<Plugin> &pl, lua_State *L)> argCb)
|
const std::function<void(const std::unique_ptr<Plugin> &pl, lua_State *L)>
|
||||||
|
&argCb)
|
||||||
{
|
{
|
||||||
for (const auto &[name, plugin] : this->plugins_)
|
for (const auto &[name, plugin] : this->plugins_)
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,8 +30,8 @@ public:
|
||||||
void callEvery(const QString &functionName);
|
void callEvery(const QString &functionName);
|
||||||
void callEveryWithArgs(
|
void callEveryWithArgs(
|
||||||
const QString &functionName, int count,
|
const QString &functionName, int count,
|
||||||
std::function<void(const std::unique_ptr<Plugin> &pl, lua_State *L)>
|
const std::function<void(const std::unique_ptr<Plugin> &pl,
|
||||||
argCb);
|
lua_State *L)> &argCb);
|
||||||
|
|
||||||
QString tryExecPluginCommand(const QString &commandName,
|
QString tryExecPluginCommand(const QString &commandName,
|
||||||
const CommandContext &ctx);
|
const CommandContext &ctx);
|
||||||
|
@ -56,15 +56,16 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
bool reload(const QString &codename);
|
bool reload(const QString &codename);
|
||||||
bool isEnabled(const QString &codename);
|
static bool isEnabled(const QString &codename);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void actuallyInitialize();
|
void actuallyInitialize();
|
||||||
void load(QFileInfo index, QDir pluginDir, PluginMeta meta);
|
void load(const QFileInfo &index, const QDir &pluginDir,
|
||||||
void loadChatterinoLib(lua_State *l);
|
const PluginMeta &meta);
|
||||||
|
|
||||||
// This function adds lua standard libraries into the state
|
// This function adds lua standard libraries into the state
|
||||||
void openLibrariesFor(lua_State *L, PluginMeta meta);
|
static void openLibrariesFor(lua_State *L, const PluginMeta & /*meta*/);
|
||||||
|
static void loadChatterinoLib(lua_State *l);
|
||||||
bool tryLoadFromDir(const QDir &pluginDir);
|
bool tryLoadFromDir(const QDir &pluginDir);
|
||||||
std::map<QString, std::unique_ptr<Plugin>> plugins_;
|
std::map<QString, std::unique_ptr<Plugin>> plugins_;
|
||||||
};
|
};
|
||||||
|
|
|
@ -106,7 +106,7 @@ void PluginsPage::rebuildContent()
|
||||||
pl->addRow("Commands", new QLabel(cmds));
|
pl->addRow("Commands", new QLabel(cmds));
|
||||||
|
|
||||||
QString enableOrDisableStr = "Enable";
|
QString enableOrDisableStr = "Enable";
|
||||||
if (getApp()->plugins->isEnabled(codename))
|
if (PluginController::isEnabled(codename))
|
||||||
{
|
{
|
||||||
enableOrDisableStr = "Disable";
|
enableOrDisableStr = "Disable";
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ void PluginsPage::rebuildContent()
|
||||||
enableDisable, &QPushButton::pressed, [name = codename, this]() {
|
enableDisable, &QPushButton::pressed, [name = codename, this]() {
|
||||||
std::vector<QString> val =
|
std::vector<QString> val =
|
||||||
getSettings()->enabledPlugins.getValue();
|
getSettings()->enabledPlugins.getValue();
|
||||||
if (getApp()->plugins->isEnabled(name))
|
if (PluginController::isEnabled(name))
|
||||||
{
|
{
|
||||||
val.erase(std::remove(val.begin(), val.end(), name),
|
val.erase(std::remove(val.begin(), val.end(), name),
|
||||||
val.end());
|
val.end());
|
||||||
|
|
Loading…
Reference in a new issue