Store a few more properties as plugin state, including favorites

Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
falkTX 2022-04-27 18:16:15 +01:00
parent fb7ccb0beb
commit 310cab2d6d
12 changed files with 408 additions and 134 deletions

View file

@ -117,7 +117,7 @@ std::string Model::getManualUrl() {
}
void Model::appendContextMenu(ui::Menu* menu, bool) {
void Model::appendContextMenu(ui::Menu* menu, bool inBrowser) {
// plugin
menu->addChild(createMenuItem("Plugin: " + plugin->name, "", [=]() {
system::openBrowser(plugin->pluginUrl);
@ -182,15 +182,28 @@ void Model::appendContextMenu(ui::Menu* menu, bool) {
system::openBrowser(plugin->changelogUrl);
}));
}
// Favorite
std::string favoriteRightText = inBrowser ? (RACK_MOD_CTRL_NAME "+click") : "";
if (isFavorite())
favoriteRightText += " " CHECKMARK_STRING;
menu->addChild(createMenuItem("Favorite", favoriteRightText,
[=]() {
setFavorite(!isFavorite());
}
));
}
bool Model::isFavorite() {
return false;
const settings::ModuleInfo* mi = settings::getModuleInfo(plugin->slug, slug);
return mi && mi->favorite;
}
void Model::setFavorite(bool) {
void Model::setFavorite(bool favorite) {
settings::ModuleInfo& mi = settings::moduleInfos[plugin->slug][slug];
mi.favorite = favorite;
}