mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Fix up completion for plugin commands
This commit is contained in:
parent
03ad993ab4
commit
31604beed3
4 changed files with 18 additions and 0 deletions
|
@ -231,6 +231,10 @@ void CompletionModel::refresh(const QString &prefix, bool isFirstWord)
|
||||||
addString(emote.first.string, TaggedString::Type::BTTVGlobalEmote);
|
addString(emote.first.string, TaggedString::Type::BTTVGlobalEmote);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const auto &command : getApp()->commands->pluginCommands())
|
||||||
|
{
|
||||||
|
addString(command, TaggedString::PluginCommand);
|
||||||
|
}
|
||||||
// Custom Chatterino commands
|
// Custom Chatterino commands
|
||||||
for (const auto &command : getApp()->commands->items)
|
for (const auto &command : getApp()->commands->items)
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,6 +34,7 @@ class CompletionModel : public QAbstractListModel
|
||||||
CustomCommand,
|
CustomCommand,
|
||||||
ChatterinoCommand,
|
ChatterinoCommand,
|
||||||
TwitchCommand,
|
TwitchCommand,
|
||||||
|
PluginCommand,
|
||||||
};
|
};
|
||||||
|
|
||||||
TaggedString(QString _string, Type type);
|
TaggedString(QString _string, Type type);
|
||||||
|
|
|
@ -3231,13 +3231,20 @@ bool CommandController::registerPluginCommand(const QString &commandName)
|
||||||
this->commands_[commandName] = [commandName](const CommandContext &ctx) {
|
this->commands_[commandName] = [commandName](const CommandContext &ctx) {
|
||||||
return getApp()->plugins->tryExecPluginCommand(commandName, ctx);
|
return getApp()->plugins->tryExecPluginCommand(commandName, ctx);
|
||||||
};
|
};
|
||||||
|
this->pluginCommands_.append(commandName);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CommandController::unregisterPluginCommand(const QString &commandName)
|
bool CommandController::unregisterPluginCommand(const QString &commandName)
|
||||||
{
|
{
|
||||||
|
if (!this->pluginCommands_.contains(commandName))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this->pluginCommands_.removeAll(commandName);
|
||||||
return this->commands_.erase(commandName) != 0;
|
return this->commands_.erase(commandName) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandController::registerCommand(const QString &commandName,
|
void CommandController::registerCommand(const QString &commandName,
|
||||||
CommandFunctionVariants commandFunction)
|
CommandFunctionVariants commandFunction)
|
||||||
{
|
{
|
||||||
|
|
|
@ -46,6 +46,11 @@ public:
|
||||||
bool registerPluginCommand(const QString &commandName);
|
bool registerPluginCommand(const QString &commandName);
|
||||||
bool unregisterPluginCommand(const QString &commandName);
|
bool unregisterPluginCommand(const QString &commandName);
|
||||||
|
|
||||||
|
const QStringList &pluginCommands()
|
||||||
|
{
|
||||||
|
return this->pluginCommands_;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void load(Paths &paths);
|
void load(Paths &paths);
|
||||||
|
|
||||||
|
@ -76,6 +81,7 @@ private:
|
||||||
commandsSetting_;
|
commandsSetting_;
|
||||||
|
|
||||||
QStringList defaultChatterinoCommandAutoCompletions_;
|
QStringList defaultChatterinoCommandAutoCompletions_;
|
||||||
|
QStringList pluginCommands_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
Loading…
Reference in a new issue