Browse Source

Make module info context menu similar to VCV Library page.

tags/v2.0.0
Andrew Belt 4 years ago
parent
commit
d84110e4ee
3 changed files with 68 additions and 29 deletions
  1. +7
    -0
      include/plugin/Plugin.hpp
  2. +52
    -28
      src/app/ModuleWidget.cpp
  3. +9
    -1
      src/plugin/Plugin.cpp

+ 7
- 0
include/plugin/Plugin.hpp View File

@@ -39,6 +39,10 @@ struct Plugin {
If blank, `name` is used. If blank, `name` is used.
*/ */
std::string brand; 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. /** Your name, company, alias, or GitHub username.
*/ */
std::string author; std::string author;
@@ -60,6 +64,9 @@ struct Plugin {
/** Link to donation page for users who wish to donate. E.g. PayPal URL. /** Link to donation page for users who wish to donate. E.g. PayPal URL.
*/ */
std::string donateUrl; std::string donateUrl;
/** Link to the changelog of the plugin.
*/
std::string changelogUrl;
/** Last modified timestamp of the plugin directory. /** Last modified timestamp of the plugin directory.
*/ */
double modifiedTimestamp = -INFINITY; double modifiedTimestamp = -INFINITY;


+ 52
- 28
src/app/ModuleWidget.cpp View File

@@ -49,55 +49,69 @@ struct ModuleInfoItem : ui::MenuItem {
ui::Menu* createChildMenu() override { ui::Menu* createChildMenu() override {
ui::Menu* menu = new ui::Menu; 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 != "") { 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->author != "") {
if (model->plugin->authorUrl != "") { if (model->plugin->authorUrl != "") {
ModuleUrlItem* authorItem = new ModuleUrlItem; ModuleUrlItem* authorItem = new ModuleUrlItem;
authorItem->text = model->plugin->author + " website";
authorItem->text = "by " + model->plugin->author;
authorItem->url = model->plugin->authorUrl; authorItem->url = model->plugin->authorUrl;
menu->addChild(authorItem); menu->addChild(authorItem);
} }
else { else {
ui::MenuLabel* authorLabel = new ui::MenuLabel; ui::MenuLabel* authorLabel = new ui::MenuLabel;
authorLabel->text = model->plugin->author;
authorLabel->text = "by " + model->plugin->author;
menu->addChild(authorLabel); 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; ModuleUrlItem* manualItem = new ModuleUrlItem;
manualItem->text = "Plugin manual";
manualItem->url = model->plugin->manualUrl;
manualItem->text = "User manual";
manualItem->url = manualUrl;
menu->addChild(manualItem); menu->addChild(manualItem);
} }


// source code
if (model->plugin->sourceUrl != "") { if (model->plugin->sourceUrl != "") {
ModuleUrlItem* sourceItem = new ModuleUrlItem; ModuleUrlItem* sourceItem = new ModuleUrlItem;
sourceItem->text = "Source code"; sourceItem->text = "Source code";
@@ -105,6 +119,7 @@ struct ModuleInfoItem : ui::MenuItem {
menu->addChild(sourceItem); menu->addChild(sourceItem);
} }


// donate
if (model->plugin->donateUrl != "") { if (model->plugin->donateUrl != "") {
ModuleUrlItem* donateItem = new ModuleUrlItem; ModuleUrlItem* donateItem = new ModuleUrlItem;
donateItem->text = "Donate"; donateItem->text = "Donate";
@@ -112,6 +127,15 @@ struct ModuleInfoItem : ui::MenuItem {
menu->addChild(donateItem); 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 != "") { if (model->plugin->path != "") {
ModuleFolderItem* pathItem = new ModuleFolderItem; ModuleFolderItem* pathItem = new ModuleFolderItem;
pathItem->text = "Open plugin folder"; pathItem->text = "Open plugin folder";


+ 9
- 1
src/plugin/Plugin.cpp View File

@@ -61,10 +61,14 @@ void Plugin::fromJson(json_t* rootJ) {
json_t* brandJ = json_object_get(rootJ, "brand"); json_t* brandJ = json_object_get(rootJ, "brand");
if (brandJ) if (brandJ)
brand = json_string_value(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 == "") if (brand == "")
brand = name; 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"); json_t* authorJ = json_object_get(rootJ, "author");
if (authorJ) if (authorJ)
author = json_string_value(authorJ); author = json_string_value(authorJ);
@@ -97,6 +101,10 @@ void Plugin::fromJson(json_t* rootJ) {
if (donateUrlJ) if (donateUrlJ)
donateUrl = json_string_value(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"); json_t* modulesJ = json_object_get(rootJ, "modules");
if (modulesJ) { if (modulesJ) {
size_t moduleId; size_t moduleId;


Loading…
Cancel
Save