Browse Source

Add "Library > Check for plugin updates" and "Help > Check for VCV Rack update" menu items.

Rename "checkAppUpdates" setting to "autoCheckUpdates".
Make it disable/enable plugin updates in addition to app update.
tags/v2.0.0
Andrew Belt 4 years ago
parent
commit
8bfa54bbe9
5 changed files with 50 additions and 23 deletions
  1. +2
    -1
      include/library.hpp
  2. +1
    -1
      include/settings.hpp
  3. +32
    -0
      src/app/MenuBar.cpp
  4. +10
    -16
      src/library.cpp
  5. +5
    -5
      src/settings.cpp

+ 2
- 1
include/library.hpp View File

@@ -23,12 +23,13 @@ struct Update {
void init(); void init();
void destroy(); void destroy();


void checkAppUpdate();
bool isAppUpdateAvailable(); bool isAppUpdateAvailable();


bool isLoggedIn(); bool isLoggedIn();
void logIn(const std::string& email, const std::string& password); void logIn(const std::string& email, const std::string& password);
void logOut(); void logOut();
void queryUpdates();
void checkUpdates();
bool hasUpdates(); bool hasUpdates();
void syncUpdate(const std::string& slug); void syncUpdate(const std::string& slug);
void syncUpdates(); void syncUpdates();


+ 1
- 1
include/settings.hpp View File

@@ -53,7 +53,7 @@ extern std::list<std::string> recentPatchPaths;
extern std::vector<NVGcolor> cableColors; extern std::vector<NVGcolor> cableColors;
// pluginSlug -> moduleSlugs // pluginSlug -> moduleSlugs
extern std::map<std::string, std::set<std::string>> moduleWhitelist; extern std::map<std::string, std::set<std::string>> moduleWhitelist;
extern bool checkAppUpdates;
extern bool autoCheckUpdates;


json_t* toJson(); json_t* toJson();
void fromJson(json_t* rootJ); void fromJson(json_t* rootJ);


+ 32
- 0
src/app/MenuBar.cpp View File

@@ -714,12 +714,24 @@ struct SyncUpdateItem : ui::MenuItem {
} }
}; };



struct CheckUpdatesItem : ui::MenuItem {
void onAction(const event::Action& e) override {
std::thread t([&] {
library::checkUpdates();
});
t.detach();
}
};


struct LogOutItem : ui::MenuItem { struct LogOutItem : ui::MenuItem {
void onAction(const event::Action& e) override { void onAction(const event::Action& e) override {
library::logOut(); library::logOut();
} }
}; };



struct LibraryMenu : ui::Menu { struct LibraryMenu : ui::Menu {
bool loggedIn = false; bool loggedIn = false;


@@ -793,6 +805,11 @@ struct LibraryMenu : ui::Menu {
addChild(updateItem); addChild(updateItem);
} }
} }
else if (!settings::autoCheckUpdates) {
CheckUpdatesItem* checkUpdatesItem = new CheckUpdatesItem;
checkUpdatesItem->text = "Check for updates";
addChild(checkUpdatesItem);
}
} }
} }
}; };
@@ -851,6 +868,16 @@ struct AppUpdateItem : ui::MenuItem {
}; };




struct CheckAppUpdateItem : ui::MenuItem {
void onAction(const event::Action& e) override {
std::thread t([&]() {
library::checkAppUpdate();
});
t.detach();
}
};


struct HelpButton : MenuButton { struct HelpButton : MenuButton {
NotificationIcon* notification; NotificationIcon* notification;


@@ -870,6 +897,11 @@ struct HelpButton : MenuButton {
appUpdateItem->rightText = APP_VERSION + " → " + library::appVersion; appUpdateItem->rightText = APP_VERSION + " → " + library::appVersion;
menu->addChild(appUpdateItem); menu->addChild(appUpdateItem);
} }
else if (!settings::autoCheckUpdates && !settings::devMode) {
CheckAppUpdateItem* checkAppUpdateItem = new CheckAppUpdateItem;
checkAppUpdateItem->text = "Check for " + APP_NAME + " update";
menu->addChild(checkAppUpdateItem);
}


UrlItem* manualItem = new UrlItem; UrlItem* manualItem = new UrlItem;
manualItem->text = "Manual"; manualItem->text = "Manual";


+ 10
- 16
src/library.cpp View File

@@ -16,24 +16,18 @@ namespace rack {
namespace library { namespace library {




static void queryAppUpdate();


void init() { void init() {
if (settings::devMode)
return;

if (settings::checkAppUpdates) {
if (settings::autoCheckUpdates && !settings::devMode) {
std::thread t([&]() { std::thread t([&]() {
queryAppUpdate();
checkAppUpdate();
}); });
t.detach(); t.detach();
}


std::thread t2([&] {
queryUpdates();
});
t2.detach();
std::thread t2([&] {
checkUpdates();
});
t2.detach();
}
} }




@@ -41,7 +35,7 @@ void destroy() {
} }




static void queryAppUpdate() {
void checkAppUpdate() {
std::string versionUrl = API_URL + "/version"; std::string versionUrl = API_URL + "/version";
json_t* resJ = network::requestJson(network::METHOD_GET, versionUrl, NULL); json_t* resJ = network::requestJson(network::METHOD_GET, versionUrl, NULL);
if (!resJ) { if (!resJ) {
@@ -108,7 +102,7 @@ void logIn(const std::string& email, const std::string& password) {
const char* tokenStr = json_string_value(tokenJ); const char* tokenStr = json_string_value(tokenJ);
settings::token = tokenStr; settings::token = tokenStr;
loginStatus = ""; loginStatus = "";
queryUpdates();
checkUpdates();
} }




@@ -118,7 +112,7 @@ void logOut() {
} }




void queryUpdates() {
void checkUpdates() {
if (settings::token.empty()) if (settings::token.empty())
return; return;




+ 5
- 5
src/settings.cpp View File

@@ -50,7 +50,7 @@ std::vector<NVGcolor> cableColors = {
color::fromHexString("#8c1889ff"), // purple color::fromHexString("#8c1889ff"), // purple
}; };
std::map<std::string, std::set<std::string>> moduleWhitelist = {}; std::map<std::string, std::set<std::string>> moduleWhitelist = {};
bool checkAppUpdates = true;
bool autoCheckUpdates = true;




json_t* toJson() { json_t* toJson() {
@@ -120,7 +120,7 @@ json_t* toJson() {
} }
json_object_set_new(rootJ, "moduleWhitelist", moduleWhitelistJ); json_object_set_new(rootJ, "moduleWhitelist", moduleWhitelistJ);


json_object_set_new(rootJ, "checkAppUpdates", json_boolean(checkAppUpdates));
json_object_set_new(rootJ, "autoCheckUpdates", json_boolean(autoCheckUpdates));


return rootJ; return rootJ;
} }
@@ -246,9 +246,9 @@ void fromJson(json_t* rootJ) {
} }
} }


json_t* checkAppUpdatesJ = json_object_get(rootJ, "checkAppUpdates");
if (checkAppUpdatesJ)
checkAppUpdates = json_boolean_value(checkAppUpdatesJ);
json_t* autoCheckUpdatesJ = json_object_get(rootJ, "autoCheckUpdates");
if (autoCheckUpdatesJ)
autoCheckUpdates = json_boolean_value(autoCheckUpdatesJ);
} }


void save(const std::string& path) { void save(const std::string& path) {


Loading…
Cancel
Save