diff --git a/src/controllers/plugins/LuaAPI.cpp b/src/controllers/plugins/LuaAPI.cpp index 9edf33c43..5cae62473 100644 --- a/src/controllers/plugins/LuaAPI.cpp +++ b/src/controllers/plugins/LuaAPI.cpp @@ -105,7 +105,7 @@ namespace { void logHelper(lua_State *L, Plugin *pl, QDebug stream, int argc) { stream.noquote(); - stream << "[" + pl->codename + ":" + pl->meta.name + "]"; + stream << "[" + pl->id + ":" + pl->meta.name + "]"; for (int i = 1; i <= argc; i++) { stream << lua::toString(L, i); @@ -226,8 +226,8 @@ int g_import(lua_State *L) auto dir = QUrl(pl->loadDirectory().canonicalPath() + "/"); auto file = dir.resolved(fname); - qCDebug(chatterinoLua) << "plugin" << pl->codename << "is trying to load" - << file << "(its dir is" << dir << ")"; + qCDebug(chatterinoLua) << "plugin" << pl->id << "is trying to load" << file + << "(its dir is" << dir << ")"; if (!dir.isParentOf(file)) { lua_pushnil(L); diff --git a/src/controllers/plugins/Plugin.hpp b/src/controllers/plugins/Plugin.hpp index 9ebfd999b..45f2cdd97 100644 --- a/src/controllers/plugins/Plugin.hpp +++ b/src/controllers/plugins/Plugin.hpp @@ -193,13 +193,13 @@ struct PluginMeta { class Plugin { public: - QString codename; + QString id; PluginMeta meta; bool isDupeName{}; - Plugin(QString codename, lua_State *state, PluginMeta meta, + Plugin(QString id, lua_State *state, PluginMeta meta, const QDir &loadDirectory) - : codename(std::move(codename)) + : id(std::move(id)) , meta(std::move(meta)) , loadDirectory_(loadDirectory) , state_(state) diff --git a/src/controllers/plugins/PluginController.cpp b/src/controllers/plugins/PluginController.cpp index 02db39649..8b02dc08c 100644 --- a/src/controllers/plugins/PluginController.cpp +++ b/src/controllers/plugins/PluginController.cpp @@ -202,7 +202,7 @@ void PluginController::load(const QFileInfo &index, const QDir &pluginDir, auto pluginName = pluginDir.dirName(); auto plugin = std::make_unique(pluginName, l, meta, pluginDir); - for (const auto &[codename, other] : this->plugins_) + for (const auto &[id, other] : this->plugins_) { if (other->meta.name == meta.name) { @@ -229,9 +229,9 @@ void PluginController::load(const QFileInfo &index, const QDir &pluginDir, qCInfo(chatterinoLua) << "Loaded" << pluginName << "plugin from" << index; } -bool PluginController::reload(const QString &codename) +bool PluginController::reload(const QString &id) { - auto it = this->plugins_.find(codename); + auto it = this->plugins_.find(id); if (it == this->plugins_.end()) { return false; @@ -247,7 +247,7 @@ bool PluginController::reload(const QString &codename) } it->second->ownedCommands.clear(); QDir loadDir = it->second->loadDirectory_; - this->plugins_.erase(codename); + this->plugins_.erase(id); this->tryLoadFromDir(loadDir); return true; } @@ -283,14 +283,14 @@ QString PluginController::tryExecPluginCommand(const QString &commandName, return ""; } -bool PluginController::isEnabled(const QString &codename) +bool PluginController::isEnabled(const QString &id) { if (!getSettings()->pluginSupportEnabled) { return false; } auto vec = getSettings()->enabledPlugins.getValue(); - auto it = std::find(vec.begin(), vec.end(), codename); + auto it = std::find(vec.begin(), vec.end(), id); return it != vec.end(); } diff --git a/src/controllers/plugins/PluginController.hpp b/src/controllers/plugins/PluginController.hpp index 4cae9134a..f5252a446 100644 --- a/src/controllers/plugins/PluginController.hpp +++ b/src/controllers/plugins/PluginController.hpp @@ -51,18 +51,18 @@ public: } /** - * @brief Reload plugin given by codename + * @brief Reload plugin given by id * - * @param codename This is the 'codename' of the plugin, the name of the directory it is in + * @param id This is the unique identifier of the plugin, the name of the directory it is in */ - bool reload(const QString &codename); + bool reload(const QString &id); /** - * @brief Checks settings to tell if a plugin named by codename. + * @brief Checks settings to tell if a plugin named by id. * * It accounts for plugins being enabled/disabled globally. */ - static bool isEnabled(const QString &codename); + static bool isEnabled(const QString &id); private: void loadPlugins(); diff --git a/src/widgets/settingspages/PluginsPage.cpp b/src/widgets/settingspages/PluginsPage.cpp index d73f800ce..5005ef228 100644 --- a/src/widgets/settingspages/PluginsPage.cpp +++ b/src/widgets/settingspages/PluginsPage.cpp @@ -68,7 +68,7 @@ void PluginsPage::rebuildContent() this->dataFrame_ = frame.getElement(); this->scrollAreaWidget_.append(this->dataFrame_); auto layout = frame.setLayoutType(); - for (const auto &[codename, plugin] : getApp()->plugins->plugins()) + for (const auto &[id, plugin] : getApp()->plugins->plugins()) { QString headerText; if (plugin->isDupeName) @@ -77,7 +77,7 @@ void PluginsPage::rebuildContent() .arg(plugin->meta.name, QString::fromStdString( plugin->meta.version.to_string()), - codename); + id); } else { @@ -146,15 +146,14 @@ void PluginsPage::rebuildContent() if (plugin->meta.isValid()) { QString enableOrDisableStr = "Enable"; - if (PluginController::isEnabled(codename)) + if (PluginController::isEnabled(id)) { enableOrDisableStr = "Disable"; } auto *enableDisable = new QPushButton(enableOrDisableStr); QObject::connect( - enableDisable, &QPushButton::pressed, - [name = codename, this]() { + enableDisable, &QPushButton::pressed, [name = id, this]() { std::vector val = getSettings()->enabledPlugins.getValue(); if (PluginController::isEnabled(name)) @@ -174,11 +173,10 @@ void PluginsPage::rebuildContent() } auto *reload = new QPushButton("Reload"); - QObject::connect(reload, &QPushButton::pressed, - [name = codename, this]() { - getApp()->plugins->reload(name); - this->rebuildContent(); - }); + QObject::connect(reload, &QPushButton::pressed, [name = id, this]() { + getApp()->plugins->reload(name); + this->rebuildContent(); + }); pl->addRow(reload); } }