feat: Ask the users if they want to check for updates (#803)

* ask the users for updates

* Only treat 1 as enabled

* Fix formatting

* update locales

* comment to document value
This commit is contained in:
iTrooz_
2022-10-29 23:43:40 +02:00
committed by GitHub
parent 2826e6f325
commit bececff9e5
11 changed files with 71 additions and 12 deletions

View File

@@ -35,6 +35,22 @@ namespace hex::plugin::builtin {
/* General */
/* Values of this setting :
0 - do not check for updates on startup
1 - check for updates on startup
2 - default value - ask the user if he wants to check for updates. This value should only be encountered on the first startup.
*/
ContentRegistry::Settings::add("hex.builtin.setting.general", "hex.builtin.setting.general.check_for_updates", 2, [](auto name, nlohmann::json &setting) {
static bool enabled = static_cast<int>(setting) == 1;
if (ImGui::Checkbox(name.data(), &enabled)) {
setting = static_cast<int>(enabled);
return true;
}
return false;
});
ContentRegistry::Settings::add("hex.builtin.setting.general", "hex.builtin.setting.general.show_tips", 1, [](auto name, nlohmann::json &setting) {
static bool enabled = static_cast<int>(setting);

View File

@@ -517,6 +517,21 @@ namespace hex::plugin::builtin {
loadDefaultLayout();
});
EventManager::subscribe<EventWindowInitialized>([] {
// documentation of the value above the setting definition
int showCheckForUpdates = ContentRegistry::Settings::read("hex.builtin.setting.general", "hex.builtin.setting.general.check_for_updates", 2);
if (showCheckForUpdates == 2) {
ContentRegistry::Settings::write("hex.builtin.setting.general", "hex.builtin.setting.general.check_for_updates", 0);
View::showYesNoQuestionPopup("hex.builtin.welcome.check_for_updates_text"_lang,
[] { // yes
ContentRegistry::Settings::write("hex.builtin.setting.general", "hex.builtin.setting.general.check_for_updates", 1);
ImGui::CloseCurrentPopup();
}, [] { // no
ImGui::CloseCurrentPopup();
});
}
});
ContentRegistry::Interface::addMenuItem("hex.builtin.menu.file", 1075, [&] {
if (ImGui::BeginMenu("hex.builtin.menu.file.open_recent"_lang, !s_recentProvidersUpdating && !s_recentProviders.empty())) {
// Copy to avoid changing list while iteration