From d84110e4ee79939c2257b47fc1d55737c1ee7156 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Sun, 19 Jul 2020 11:07:32 -0400 Subject: [PATCH] Make module info context menu similar to VCV Library page. --- include/plugin/Plugin.hpp | 7 ++++ src/app/ModuleWidget.cpp | 80 +++++++++++++++++++++++++-------------- src/plugin/Plugin.cpp | 10 ++++- 3 files changed, 68 insertions(+), 29 deletions(-) diff --git a/include/plugin/Plugin.hpp b/include/plugin/Plugin.hpp index ff941dfb..e3596ba5 100644 --- a/include/plugin/Plugin.hpp +++ b/include/plugin/Plugin.hpp @@ -39,6 +39,10 @@ struct Plugin { If blank, `name` is used. */ std::string brand; + /** A one-line summary of the plugin's purpose. + If your plugin doesn't follow a theme, it’s probably best to omit this. + */ + std::string description; /** Your name, company, alias, or GitHub username. */ std::string author; @@ -60,6 +64,9 @@ struct Plugin { /** Link to donation page for users who wish to donate. E.g. PayPal URL. */ std::string donateUrl; + /** Link to the changelog of the plugin. + */ + std::string changelogUrl; /** Last modified timestamp of the plugin directory. */ double modifiedTimestamp = -INFINITY; diff --git a/src/app/ModuleWidget.cpp b/src/app/ModuleWidget.cpp index 5e932e34..9c746302 100644 --- a/src/app/ModuleWidget.cpp +++ b/src/app/ModuleWidget.cpp @@ -49,55 +49,69 @@ struct ModuleInfoItem : ui::MenuItem { ui::Menu* createChildMenu() override { ui::Menu* menu = new ui::Menu; - ui::MenuLabel* pluginLabel = new ui::MenuLabel; - pluginLabel->text = model->plugin->name; - menu->addChild(pluginLabel); - - ui::MenuLabel* versionLabel = new ui::MenuLabel; - versionLabel->text = "v" + model->plugin->version; - menu->addChild(versionLabel); - - for (int tagId : model->tags) { - ui::MenuLabel* tagLabel = new ui::MenuLabel; - tagLabel->text = tag::getTag(tagId); - menu->addChild(tagLabel); - } - + // plugin if (model->plugin->pluginUrl != "") { - ModuleUrlItem* websiteItem = new ModuleUrlItem; - websiteItem->text = "Plugin website"; - websiteItem->url = model->plugin->pluginUrl; - menu->addChild(websiteItem); + ModuleUrlItem* pluginItem = new ModuleUrlItem; + pluginItem->text = model->plugin->name; + pluginItem->url = model->plugin->pluginUrl; + menu->addChild(pluginItem); + } + else { + ui::MenuLabel* pluginLabel = new ui::MenuLabel; + pluginLabel->text = model->plugin->name; + menu->addChild(pluginLabel); } + // author if (model->plugin->author != "") { if (model->plugin->authorUrl != "") { ModuleUrlItem* authorItem = new ModuleUrlItem; - authorItem->text = model->plugin->author + " website"; + authorItem->text = "by " + model->plugin->author; authorItem->url = model->plugin->authorUrl; menu->addChild(authorItem); } else { ui::MenuLabel* authorLabel = new ui::MenuLabel; - authorLabel->text = model->plugin->author; + authorLabel->text = "by " + model->plugin->author; menu->addChild(authorLabel); } } - if (model->manualUrl != "") { - ModuleUrlItem* manualItem = new ModuleUrlItem; - manualItem->text = "Module manual"; - manualItem->url = model->manualUrl; - menu->addChild(manualItem); + // version + ui::MenuLabel* versionLabel = new ui::MenuLabel; + versionLabel->text = "v" + model->plugin->version; + menu->addChild(versionLabel); + + // tags + if (!model->tags.empty()) { + ui::MenuLabel* tagsLabel = new ui::MenuLabel; + tagsLabel->text = "Tags:"; + menu->addChild(tagsLabel); + for (int tagId : model->tags) { + ui::MenuLabel* tagLabel = new ui::MenuLabel; + tagLabel->text = tag::getTag(tagId); + menu->addChild(tagLabel); + } } - if (model->plugin->manualUrl != "") { + menu->addChild(new ui::MenuSeparator); + + // library + ModuleUrlItem* libraryItem = new ModuleUrlItem; + libraryItem->text = "VCV Library page"; + libraryItem->url = "https://library.vcvrack.com/" + model->plugin->slug + "/" + model->slug; + menu->addChild(libraryItem); + + // manual + std::string manualUrl = (model->manualUrl != "") ? model->manualUrl : model->plugin->manualUrl; + if (manualUrl != "") { ModuleUrlItem* manualItem = new ModuleUrlItem; - manualItem->text = "Plugin manual"; - manualItem->url = model->plugin->manualUrl; + manualItem->text = "User manual"; + manualItem->url = manualUrl; menu->addChild(manualItem); } + // source code if (model->plugin->sourceUrl != "") { ModuleUrlItem* sourceItem = new ModuleUrlItem; sourceItem->text = "Source code"; @@ -105,6 +119,7 @@ struct ModuleInfoItem : ui::MenuItem { menu->addChild(sourceItem); } + // donate if (model->plugin->donateUrl != "") { ModuleUrlItem* donateItem = new ModuleUrlItem; donateItem->text = "Donate"; @@ -112,6 +127,15 @@ struct ModuleInfoItem : ui::MenuItem { menu->addChild(donateItem); } + // changelog + if (model->plugin->changelogUrl != "") { + ModuleUrlItem* changelogItem = new ModuleUrlItem; + changelogItem->text = "Changelog"; + changelogItem->url = model->plugin->changelogUrl; + menu->addChild(changelogItem); + } + + // plugin folder if (model->plugin->path != "") { ModuleFolderItem* pathItem = new ModuleFolderItem; pathItem->text = "Open plugin folder"; diff --git a/src/plugin/Plugin.cpp b/src/plugin/Plugin.cpp index 6ee12fa8..591fa9ed 100644 --- a/src/plugin/Plugin.cpp +++ b/src/plugin/Plugin.cpp @@ -61,10 +61,14 @@ void Plugin::fromJson(json_t* rootJ) { json_t* brandJ = json_object_get(rootJ, "brand"); if (brandJ) brand = json_string_value(brandJ); - // Use name for brand name by default + // If brand is not set, fall back to the plugin name if (brand == "") brand = name; + json_t* descriptionJ = json_object_get(rootJ, "description"); + if (descriptionJ) + description = json_string_value(descriptionJ); + json_t* authorJ = json_object_get(rootJ, "author"); if (authorJ) author = json_string_value(authorJ); @@ -97,6 +101,10 @@ void Plugin::fromJson(json_t* rootJ) { if (donateUrlJ) donateUrl = json_string_value(donateUrlJ); + json_t* changelogUrlJ = json_object_get(rootJ, "changelogUrl"); + if (changelogUrlJ) + changelogUrl = json_string_value(changelogUrlJ); + json_t* modulesJ = json_object_get(rootJ, "modules"); if (modulesJ) { size_t moduleId;