From 31cc663dd8a6f847a354aa99a70efeb795ff7919 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Mon, 10 Jun 2019 06:37:08 -0400 Subject: [PATCH] Sort modules by plugin brand instead of plugin name. WIP Plugins menu bar item. --- .github/ISSUE_TEMPLATE/bug_report.md | 7 ++++++- include/plugin.hpp | 4 +++- src/app/MenuBar.cpp | 13 ++++++++++-- src/app/ModuleBrowser.cpp | 6 +++--- src/plugin.cpp | 31 +++++++++++++++++++++------- 5 files changed, 47 insertions(+), 14 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index f5730310..1dd301d5 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -6,8 +6,13 @@ about: Bugs, build errors, compatibility/stability issues <-- To file a bug report, fill out the form below. -Post screenshots if the bug is visual. Use a descriptive title that best explains the bug in one sentence. +Attach screenshots if the bug is visual. +Attach your `/log.txt` file if something is crashing or not loading. +Surround terminal output with three tildes +``` +like this. +``` --> ### Details diff --git a/include/plugin.hpp b/include/plugin.hpp index bbc6f573..21a7b59d 100644 --- a/include/plugin.hpp +++ b/include/plugin.hpp @@ -16,6 +16,7 @@ namespace plugin { struct Update { std::string pluginSlug; + std::string pluginName; std::string version; std::string changelogUrl; float progress = 0.f; @@ -26,10 +27,11 @@ void init(); void destroy(); void logIn(const std::string &email, const std::string &password); void logOut(); +bool isLoggedIn(); void queryUpdates(); void syncUpdate(Update *update); void syncUpdates(); -bool isLoggedIn(); +bool isSyncing(); Plugin *getPlugin(const std::string &pluginSlug); Model *getModel(const std::string &pluginSlug, const std::string &modelSlug); std::string normalizeTag(const std::string &tag); diff --git a/src/app/MenuBar.cpp b/src/app/MenuBar.cpp index 8b8fc2e6..6bf179e8 100644 --- a/src/app/MenuBar.cpp +++ b/src/app/MenuBar.cpp @@ -495,6 +495,11 @@ struct LogInItem : ui::MenuItem { }; struct SyncItem : ui::MenuItem { + void step() override { + disabled = plugin::isSyncing(); + MenuItem::step(); + } + void onAction(const event::Action &e) override { std::thread t([=]() { plugin::syncUpdates(); @@ -509,7 +514,7 @@ struct PluginSyncItem : ui::MenuItem { void setUpdate(plugin::Update *update) { this->update = update; - text = update->pluginSlug; + text = update->pluginName; plugin::Plugin *p = plugin::getPlugin(update->pluginSlug); if (p) { rightText += "v" + p->version + " → "; @@ -532,6 +537,7 @@ struct PluginSyncItem : ui::MenuItem { } void step() override { + disabled = plugin::isSyncing(); if (update->progress >= 1) { rightText = CHECKMARK_STRING; } @@ -610,7 +616,10 @@ struct PluginsMenu : ui::Menu { void refresh() { clearChildren(); - if (!plugin::isLoggedIn()) { + if (settings::devMode) { + addChild(createMenuLabel("Disabled in development mode")); + } + else if (!plugin::isLoggedIn()) { UrlItem *registerItem = new UrlItem; registerItem->text = "Register VCV account"; registerItem->url = "https://vcvrack.com/"; diff --git a/src/app/ModuleBrowser.cpp b/src/app/ModuleBrowser.cpp index 50b00ae5..3afc5fb3 100644 --- a/src/app/ModuleBrowser.cpp +++ b/src/app/ModuleBrowser.cpp @@ -515,9 +515,9 @@ struct ModuleBrowser : widget::OpaqueWidget { float score2 = get_default(settings::favoriteScores, std::make_tuple(m2->model->plugin->slug, m2->model->slug), 0.f); if (score1 != score2) return score1 > score2; - // Sort by plugin name - if (m1->model->plugin->name != m2->model->plugin->name) - return m1->model->plugin->name < m2->model->plugin->name; + // Sort by plugin brand + if (m1->model->plugin->brand != m2->model->plugin->brand) + return m1->model->plugin->brand < m2->model->plugin->brand; // Sort by module name return m1->model->name < m2->model->name; }); diff --git a/src/plugin.cpp b/src/plugin.cpp index 9c3be741..6b840f7f 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -339,6 +339,10 @@ void logOut() { settings::token = ""; } +bool isLoggedIn() { + return settings::token != ""; +} + void queryUpdates() { if (settings::token.empty()) return; @@ -393,8 +397,12 @@ void queryUpdates() { continue; } + // Get plugin name + json_t *nameJ = json_object_get(manifestJ, "name"); + if (nameJ) + update.pluginName = json_string_value(nameJ); + // Get version - // TODO Change this to "version" when API changes json_t *versionJ = json_object_get(manifestJ, "version"); if (!versionJ) { WARN("Plugin %s has no version in manifest", update.pluginSlug.c_str()); @@ -425,7 +433,15 @@ void queryUpdates() { } } +static bool isSyncingUpdate = false; +static bool isSyncingUpdates = false; + void syncUpdate(Update *update) { + isSyncingUpdate = true; + DEFER({ + isSyncingUpdate = false; + }); + #if defined ARCH_WIN std::string arch = "win"; #elif ARCH_MAC @@ -451,6 +467,11 @@ void syncUpdate(Update *update) { } void syncUpdates() { + isSyncingUpdates = true; + DEFER({ + isSyncingUpdates = false; + }); + if (settings::token.empty()) return; @@ -459,12 +480,8 @@ void syncUpdates() { } } -void cancelDownload() { - // TODO -} - -bool isLoggedIn() { - return settings::token != ""; +bool isSyncing() { + return isSyncingUpdate || isSyncingUpdates; } Plugin *getPlugin(const std::string &pluginSlug) {