mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 05:27:41 -05:00
feat: Added statistics and crash log uploading (#1149)
Co-authored-by: Justus Garbe <gihihoh@gmail.com>
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
#include <hex/ui/popup.hpp>
|
||||
|
||||
#include <hex/api/localization.hpp>
|
||||
|
||||
#include <wolv/hash/uuid.hpp>
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
namespace hex::plugin::builtin {
|
||||
|
||||
class PopupTelemetryRequest : public Popup<PopupTelemetryRequest> {
|
||||
public:
|
||||
PopupTelemetryRequest()
|
||||
: hex::Popup<PopupTelemetryRequest>("hex.builtin.common.question", false) {
|
||||
// Check if there is a telemetry uuid
|
||||
this->m_uuid = ContentRegistry::Settings::read("hex.builtin.setting.general", "hex.builtin.setting.general.uuid", "");
|
||||
if(this->m_uuid.empty()) {
|
||||
// Generate a new uuid
|
||||
this->m_uuid = wolv::hash::generateUUID();
|
||||
// Save
|
||||
ContentRegistry::Settings::write("hex.builtin.setting.general", "hex.builtin.setting.general.uuid", this->m_uuid);
|
||||
}
|
||||
}
|
||||
|
||||
void drawContent() override {
|
||||
static std::string message = "hex.builtin.welcome.server_contact_text"_lang;
|
||||
ImGui::TextFormattedWrapped("{}", message.c_str());
|
||||
ImGui::NewLine();
|
||||
|
||||
if(ImGui::CollapsingHeader("hex.builtin.welcome.server_contact.data_collected_title"_lang)) {
|
||||
if(ImGui::BeginTable("hex.builtin.welcome.server_contact.data_collected_table"_lang, 2,
|
||||
ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_ScrollX | ImGuiTableFlags_NoHostExtendY,
|
||||
ImVec2(ImGui::GetContentRegionAvail().x, 80_scaled))) {
|
||||
ImGui::TableSetupColumn("hex.builtin.welcome.server_contact.data_collected_table.key"_lang);
|
||||
ImGui::TableSetupColumn("hex.builtin.welcome.server_contact.data_collected_table.value"_lang, ImGuiTableColumnFlags_WidthStretch);
|
||||
ImGui::TableHeadersRow();
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextUnformatted("hex.builtin.welcome.server_contact.data_collected.uuid"_lang);
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextWrapped("%s", this->m_uuid.c_str());
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextUnformatted("hex.builtin.welcome.server_contact.data_collected.version"_lang);
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextUnformatted(IMHEX_VERSION);
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextUnformatted("hex.builtin.welcome.server_contact.data_collected.os"_lang);
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextWrapped("%s/%s/%s", ImHexApi::System::getOSName().c_str(), ImHexApi::System::getOSVersion().c_str(), ImHexApi::System::getArchitecture().c_str());
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::NewLine();
|
||||
|
||||
const auto width = ImGui::GetWindowWidth();
|
||||
const auto buttonSize = ImVec2(width / 3 - ImGui::GetStyle().FramePadding.x * 3, 0);
|
||||
const auto buttonPos = [&](u8 index) { return ImGui::GetStyle().FramePadding.x + (buttonSize.x + ImGui::GetStyle().FramePadding.x * 3) * index; };
|
||||
|
||||
ImGui::SetCursorPosX(buttonPos(0));
|
||||
if (ImGui::Button("hex.builtin.common.allow"_lang, buttonSize)) {
|
||||
ContentRegistry::Settings::write("hex.builtin.setting.general", "hex.builtin.setting.general.server_contact", 1);
|
||||
ContentRegistry::Settings::write("hex.builtin.setting.general", "hex.builtin.setting.general.upload_crash_logs", 1);
|
||||
this->close();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::SetCursorPosX(buttonPos(1));
|
||||
if (ImGui::Button("hex.builtin.welcome.server_contact.crash_logs_only"_lang, buttonSize)) {
|
||||
ContentRegistry::Settings::write("hex.builtin.setting.general", "hex.builtin.setting.general.server_contact", 0);
|
||||
ContentRegistry::Settings::write("hex.builtin.setting.general", "hex.builtin.setting.general.upload_crash_logs", 1);
|
||||
this->close();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::SetCursorPosX(buttonPos(2));
|
||||
if (ImGui::Button("hex.builtin.common.deny"_lang, buttonSize)) {
|
||||
this->close();
|
||||
}
|
||||
|
||||
ImGui::SetWindowPos((ImHexApi::System::getMainWindowSize() - ImGui::GetWindowSize()) / 2, ImGuiCond_Appearing);
|
||||
}
|
||||
|
||||
[[nodiscard]] ImGuiWindowFlags getFlags() const override {
|
||||
return ImGuiWindowFlags_AlwaysAutoResize;
|
||||
}
|
||||
|
||||
[[nodiscard]] ImVec2 getMinSize() const override {
|
||||
return scaled({ 500, 100 });
|
||||
}
|
||||
|
||||
[[nodiscard]] ImVec2 getMaxSize() const override {
|
||||
return scaled({ 500, 400 });
|
||||
}
|
||||
|
||||
private:
|
||||
std::string m_uuid;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -443,7 +443,7 @@
|
||||
"hex.builtin.setting.font.font_size.tooltip": "",
|
||||
"hex.builtin.setting.general": "Allgemein",
|
||||
"hex.builtin.setting.general.auto_load_patterns": "Automatisches Laden unterstützter Pattern",
|
||||
"hex.builtin.setting.general.check_for_updates": "Automatisch nach Updates beim Start suchen",
|
||||
"hex.builtin.setting.general.server_contact": "Update checks und Statistiken zulassen",
|
||||
"hex.builtin.setting.general.enable_unicode": "Alle Unicode Zeichen laden",
|
||||
"hex.builtin.setting.general.network_interface": "",
|
||||
"hex.builtin.setting.general.save_recent_providers": "",
|
||||
@@ -901,7 +901,7 @@
|
||||
"hex.builtin.visualizer.hexadecimal.8bit": "Hexadezimal (8 bits)",
|
||||
"hex.builtin.visualizer.hexii": "HexII",
|
||||
"hex.builtin.visualizer.rgba8": "RGBA8 Farbe",
|
||||
"hex.builtin.welcome.check_for_updates_text": "Möchtest du beim Start automatisch nach Updates suchen?\nMögliche Updates werden auf der Registerkarte 'Update' des Willkommensbildschirms angezeigt.",
|
||||
"hex.builtin.welcome.server_contact_text": "Möchtest du die Kommunikation mit ImHex Servern zulassen?\n\nDies erlaubt das automatische suchen nach Updates und das hochladen\nvon anonymen crash logs im falle eines absturzes.",
|
||||
"hex.builtin.welcome.customize.settings.desc": "Ändere ImHex's Einstellungen",
|
||||
"hex.builtin.welcome.customize.settings.title": "Einstellungen",
|
||||
"hex.builtin.welcome.header.customize": "Anpassen",
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"hex.builtin.command.web.desc": "Website lookup",
|
||||
"hex.builtin.command.web.result": "Navigate to '{0}'",
|
||||
"hex.builtin.common.address": "Address",
|
||||
"hex.builtin.common.allow": "Allow",
|
||||
"hex.builtin.common.begin": "Begin",
|
||||
"hex.builtin.common.big": "Big",
|
||||
"hex.builtin.common.big_endian": "Big Endian",
|
||||
@@ -21,6 +22,7 @@
|
||||
"hex.builtin.common.comment": "Comment",
|
||||
"hex.builtin.common.count": "Count",
|
||||
"hex.builtin.common.decimal": "Decimal",
|
||||
"hex.builtin.common.deny": "Deny",
|
||||
"hex.builtin.common.dont_show_again": "Don't show again",
|
||||
"hex.builtin.common.encoding.ascii": "ASCII",
|
||||
"hex.builtin.common.encoding.utf16be": "UTF-16BE",
|
||||
@@ -440,12 +442,13 @@
|
||||
"hex.builtin.setting.font.font_size.tooltip": "The font size can only be adjusted when a custom font has been selected above.\n\nThis is because ImHex uses a pixel-perfect bitmap font by default. Scaling it by any non-integer factor will only cause it to become blurry.",
|
||||
"hex.builtin.setting.general": "General",
|
||||
"hex.builtin.setting.general.auto_load_patterns": "Auto-load supported pattern",
|
||||
"hex.builtin.setting.general.check_for_updates": "Check for updates on startup",
|
||||
"hex.builtin.setting.general.server_contact": "Enable update checks and usage statistics",
|
||||
"hex.builtin.setting.general.enable_unicode": "Load all unicode characters",
|
||||
"hex.builtin.setting.general.network_interface": "Enable network interface",
|
||||
"hex.builtin.setting.general.save_recent_providers": "Save recently used providers",
|
||||
"hex.builtin.setting.general.show_tips": "Show tips on startup",
|
||||
"hex.builtin.setting.general.sync_pattern_source": "Sync pattern source code between providers",
|
||||
"hex.builtin.setting.general.upload_crash_logs": "Upload crash reports",
|
||||
"hex.builtin.setting.hex_editor": "Hex Editor",
|
||||
"hex.builtin.setting.hex_editor.byte_padding": "Extra byte cell padding",
|
||||
"hex.builtin.setting.hex_editor.bytes_per_row": "Bytes per row",
|
||||
@@ -903,7 +906,14 @@
|
||||
"hex.builtin.visualizer.hexadecimal.8bit": "Hexadecimal (8 bits)",
|
||||
"hex.builtin.visualizer.hexii": "HexII",
|
||||
"hex.builtin.visualizer.rgba8": "RGBA8 Color",
|
||||
"hex.builtin.welcome.check_for_updates_text": "Do you want to automatically check for updates on startup?\n Possible updates will be shown in the 'Update' tab of the welcome screen",
|
||||
"hex.builtin.welcome.server_contact_text": "Do you want to allow the communication with ImHex's Servers?\n\n\nThis allows performing automatic update checks and uploads of very limited usage statistics, all of which are listed below.\n\nAlternatively you can also choose to only submit crash logs which help immensely with identifying and fixing bugs you might experience.\n\nAll information is processed by our own Servers and is not given out to any third-parties.\n\n\nYou can change these choices at any time in the settings.",
|
||||
"hex.builtin.welcome.server_contact.data_collected_table.key": "Type",
|
||||
"hex.builtin.welcome.server_contact.data_collected_table.value": "Value",
|
||||
"hex.builtin.welcome.server_contact.data_collected_title": "Data that will be shared",
|
||||
"hex.builtin.welcome.server_contact.data_collected.uuid": "Random ID",
|
||||
"hex.builtin.welcome.server_contact.data_collected.version": "ImHex Version",
|
||||
"hex.builtin.welcome.server_contact.data_collected.os": "Operating System",
|
||||
"hex.builtin.welcome.server_contact.crash_logs_only": "Just crash logs",
|
||||
"hex.builtin.welcome.customize.settings.desc": "Change preferences of ImHex",
|
||||
"hex.builtin.welcome.customize.settings.title": "Settings",
|
||||
"hex.builtin.welcome.header.customize": "Customize",
|
||||
@@ -935,6 +945,7 @@
|
||||
"hex.builtin.popup.safety_backup.delete": "No, Delete",
|
||||
"hex.builtin.popup.safety_backup.desc": "Oh no, ImHex crashed last time.\nDo you want to restore your past work?",
|
||||
"hex.builtin.popup.safety_backup.log_file": "Log file: ",
|
||||
"hex.builtin.popup.safety_backup.report_error": "Send crash log to developers",
|
||||
"hex.builtin.popup.safety_backup.restore": "Yes, Restore",
|
||||
"hex.builtin.popup.safety_backup.title": "Restore lost data",
|
||||
"hex.builtin.welcome.start.create_file": "Create New File",
|
||||
|
||||
@@ -441,7 +441,7 @@
|
||||
"hex.builtin.setting.font.font_size.tooltip": "El tamaño de la fuente de letra puede únicamente ajustarse cuando arriba se ha seleccionado una fuente personalizada.\n\nEsto se debe a que ImHex usa una fuente de mapa de bits pixel-perfect por defecto. Escalarla por un factor no entero sólamente causará que se vuelva borrosa.",
|
||||
"hex.builtin.setting.general": "General",
|
||||
"hex.builtin.setting.general.auto_load_patterns": "Cargar automáticamente patterns soportados",
|
||||
"hex.builtin.setting.general.check_for_updates": "Comprobar actualizaciones al inicio",
|
||||
"hex.builtin.setting.general.server_contact": "",
|
||||
"hex.builtin.setting.general.enable_unicode": "Cargar todos los caracteres unicode",
|
||||
"hex.builtin.setting.general.network_interface": "",
|
||||
"hex.builtin.setting.general.save_recent_providers": "Guardar proveedores recientemente utilizados",
|
||||
@@ -899,7 +899,7 @@
|
||||
"hex.builtin.visualizer.hexadecimal.8bit": "Hexadecimal (8 bits)",
|
||||
"hex.builtin.visualizer.hexii": "HexII",
|
||||
"hex.builtin.visualizer.rgba8": "Color RGBA8",
|
||||
"hex.builtin.welcome.check_for_updates_text": "¿Quiere que se busquen actualizaciones automáticamente al inicio?\n Las posibles actualizaciones serán mostradas en la pestaña 'Actualizaciones' de la pantalla de inicio",
|
||||
"hex.builtin.welcome.server_contact_text": "",
|
||||
"hex.builtin.welcome.customize.settings.desc": "Cambie preferencias de ImHex",
|
||||
"hex.builtin.welcome.customize.settings.title": "Ajustes",
|
||||
"hex.builtin.welcome.header.customize": "Personalizar",
|
||||
|
||||
@@ -441,7 +441,7 @@
|
||||
"hex.builtin.setting.font.font_size.tooltip": "",
|
||||
"hex.builtin.setting.general": "Generali",
|
||||
"hex.builtin.setting.general.auto_load_patterns": "Auto-caricamento del pattern supportato",
|
||||
"hex.builtin.setting.general.check_for_updates": "",
|
||||
"hex.builtin.setting.general.server_contact": "",
|
||||
"hex.builtin.setting.general.enable_unicode": "",
|
||||
"hex.builtin.setting.general.network_interface": "",
|
||||
"hex.builtin.setting.general.save_recent_providers": "",
|
||||
@@ -899,7 +899,7 @@
|
||||
"hex.builtin.visualizer.hexadecimal.8bit": "",
|
||||
"hex.builtin.visualizer.hexii": "",
|
||||
"hex.builtin.visualizer.rgba8": "",
|
||||
"hex.builtin.welcome.check_for_updates_text": "",
|
||||
"hex.builtin.welcome.server_contact_text": "",
|
||||
"hex.builtin.welcome.customize.settings.desc": "Cambia le preferenze di ImHex",
|
||||
"hex.builtin.welcome.customize.settings.title": "Impostazioni",
|
||||
"hex.builtin.welcome.header.customize": "Personalizza",
|
||||
|
||||
@@ -441,7 +441,7 @@
|
||||
"hex.builtin.setting.font.font_size.tooltip": "",
|
||||
"hex.builtin.setting.general": "基本",
|
||||
"hex.builtin.setting.general.auto_load_patterns": "対応するパターンを自動で読み込む",
|
||||
"hex.builtin.setting.general.check_for_updates": "",
|
||||
"hex.builtin.setting.general.server_contact": "",
|
||||
"hex.builtin.setting.general.enable_unicode": "",
|
||||
"hex.builtin.setting.general.network_interface": "",
|
||||
"hex.builtin.setting.general.save_recent_providers": "",
|
||||
@@ -899,7 +899,7 @@
|
||||
"hex.builtin.visualizer.hexadecimal.8bit": "16進数 ( 8 bits)",
|
||||
"hex.builtin.visualizer.hexii": "",
|
||||
"hex.builtin.visualizer.rgba8": "RGBA8",
|
||||
"hex.builtin.welcome.check_for_updates_text": "",
|
||||
"hex.builtin.welcome.server_contact_text": "",
|
||||
"hex.builtin.welcome.customize.settings.desc": "ImHexの設定を変更します",
|
||||
"hex.builtin.welcome.customize.settings.title": "設定",
|
||||
"hex.builtin.welcome.header.customize": "カスタマイズ",
|
||||
|
||||
@@ -441,7 +441,7 @@
|
||||
"hex.builtin.setting.font.font_size.tooltip": "",
|
||||
"hex.builtin.setting.general": "일반",
|
||||
"hex.builtin.setting.general.auto_load_patterns": "지원하는 패턴 자동으로 로드",
|
||||
"hex.builtin.setting.general.check_for_updates": "",
|
||||
"hex.builtin.setting.general.server_contact": "",
|
||||
"hex.builtin.setting.general.enable_unicode": "",
|
||||
"hex.builtin.setting.general.network_interface": "",
|
||||
"hex.builtin.setting.general.save_recent_providers": "",
|
||||
@@ -899,7 +899,7 @@
|
||||
"hex.builtin.visualizer.hexadecimal.8bit": "16진수 (8 비트)",
|
||||
"hex.builtin.visualizer.hexii": "HexII",
|
||||
"hex.builtin.visualizer.rgba8": "RGBA8 색상",
|
||||
"hex.builtin.welcome.check_for_updates_text": "",
|
||||
"hex.builtin.welcome.server_contact_text": "",
|
||||
"hex.builtin.welcome.customize.settings.desc": "ImHex의 설정을 변경합니다",
|
||||
"hex.builtin.welcome.customize.settings.title": "설정",
|
||||
"hex.builtin.welcome.header.customize": "커스터마이즈",
|
||||
|
||||
@@ -441,7 +441,7 @@
|
||||
"hex.builtin.setting.font.font_size.tooltip": "",
|
||||
"hex.builtin.setting.general": "General",
|
||||
"hex.builtin.setting.general.auto_load_patterns": "Padrão compatível com carregamento automático",
|
||||
"hex.builtin.setting.general.check_for_updates": "",
|
||||
"hex.builtin.setting.general.server_contact": "",
|
||||
"hex.builtin.setting.general.enable_unicode": "",
|
||||
"hex.builtin.setting.general.network_interface": "",
|
||||
"hex.builtin.setting.general.save_recent_providers": "",
|
||||
@@ -899,7 +899,7 @@
|
||||
"hex.builtin.visualizer.hexadecimal.8bit": "Hexadecimal (8 bits)",
|
||||
"hex.builtin.visualizer.hexii": "HexII",
|
||||
"hex.builtin.visualizer.rgba8": "RGBA8 Color",
|
||||
"hex.builtin.welcome.check_for_updates_text": "",
|
||||
"hex.builtin.welcome.server_contact_text": "",
|
||||
"hex.builtin.welcome.customize.settings.desc": "Mudar preferencias do ImHex",
|
||||
"hex.builtin.welcome.customize.settings.title": "Configurações",
|
||||
"hex.builtin.welcome.header.customize": "Customizar",
|
||||
|
||||
@@ -441,7 +441,7 @@
|
||||
"hex.builtin.setting.font.font_size.tooltip": "",
|
||||
"hex.builtin.setting.general": "通用",
|
||||
"hex.builtin.setting.general.auto_load_patterns": "自动加载支持的模式",
|
||||
"hex.builtin.setting.general.check_for_updates": "启动时检查更新",
|
||||
"hex.builtin.setting.general.server_contact": "",
|
||||
"hex.builtin.setting.general.enable_unicode": "加载所有 Unicode 字符",
|
||||
"hex.builtin.setting.general.network_interface": "",
|
||||
"hex.builtin.setting.general.save_recent_providers": "",
|
||||
@@ -899,7 +899,7 @@
|
||||
"hex.builtin.visualizer.hexadecimal.8bit": "十六进制(8 位)",
|
||||
"hex.builtin.visualizer.hexii": "HexII",
|
||||
"hex.builtin.visualizer.rgba8": "RGBA8 颜色",
|
||||
"hex.builtin.welcome.check_for_updates_text": "你想要在启动时自动检查更新吗?\n 可用的更新会在欢迎屏幕的“更新”中显示",
|
||||
"hex.builtin.welcome.server_contact_text": "",
|
||||
"hex.builtin.welcome.customize.settings.desc": "更改 ImHex 的设置",
|
||||
"hex.builtin.welcome.customize.settings.title": "设置",
|
||||
"hex.builtin.welcome.header.customize": "自定义",
|
||||
|
||||
@@ -441,7 +441,7 @@
|
||||
"hex.builtin.setting.font.font_size.tooltip": "",
|
||||
"hex.builtin.setting.general": "一般",
|
||||
"hex.builtin.setting.general.auto_load_patterns": "自動載入支援的模式",
|
||||
"hex.builtin.setting.general.check_for_updates": "Check for updates on startup",
|
||||
"hex.builtin.setting.general.server_contact": "",
|
||||
"hex.builtin.setting.general.enable_unicode": "載入所有 unicode 字元",
|
||||
"hex.builtin.setting.general.network_interface": "",
|
||||
"hex.builtin.setting.general.save_recent_providers": "",
|
||||
@@ -899,7 +899,7 @@
|
||||
"hex.builtin.visualizer.hexadecimal.8bit": "十六進位 (8 位元)",
|
||||
"hex.builtin.visualizer.hexii": "HexII",
|
||||
"hex.builtin.visualizer.rgba8": "RGBA8 顏色",
|
||||
"hex.builtin.welcome.check_for_updates_text": "您要在啟動時自動檢查更新嗎?\n 可用更新將在歡迎畫面的「更新」分頁顯示。",
|
||||
"hex.builtin.welcome.server_contact_text": "",
|
||||
"hex.builtin.welcome.customize.settings.desc": "更改 ImHex 的設定",
|
||||
"hex.builtin.welcome.customize.settings.title": "設定",
|
||||
"hex.builtin.welcome.header.customize": "自訂",
|
||||
|
||||
@@ -40,24 +40,6 @@ 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.
|
||||
*/
|
||||
#if defined(HEX_UPDATE_CHECK)
|
||||
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;
|
||||
});
|
||||
#endif
|
||||
|
||||
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);
|
||||
|
||||
@@ -124,6 +106,34 @@ namespace hex::plugin::builtin {
|
||||
return false;
|
||||
});
|
||||
|
||||
/*
|
||||
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.server_contact", 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.upload_crash_logs", 1, [](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;
|
||||
});
|
||||
|
||||
/* Interface */
|
||||
|
||||
ContentRegistry::Settings::add("hex.builtin.setting.interface", "hex.builtin.setting.interface.color", "Dark", [](auto name, nlohmann::json &setting) {
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
#include <hex.hpp>
|
||||
#include <hex/helpers/http_requests.hpp>
|
||||
#include <hex/api/event.hpp>
|
||||
#include <hex/api/content_registry.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/plugin_manager.hpp>
|
||||
#include <hex/api/theme_manager.hpp>
|
||||
#include <hex/api/layout_manager.hpp>
|
||||
#include <hex/api_urls.hpp>
|
||||
#include <hex/ui/view.hpp>
|
||||
#include <hex/helpers/fs.hpp>
|
||||
#include <hex/helpers/logger.hpp>
|
||||
@@ -26,6 +28,7 @@
|
||||
|
||||
#include <content/popups/popup_notification.hpp>
|
||||
#include <content/popups/popup_question.hpp>
|
||||
#include <content/popups/popup_telemetry_request.hpp>
|
||||
#include <content/recent.hpp>
|
||||
|
||||
#include <string>
|
||||
@@ -46,20 +49,28 @@ namespace hex::plugin::builtin {
|
||||
std::fs::path m_logFilePath;
|
||||
std::function<void()> m_restoreCallback;
|
||||
std::function<void()> m_deleteCallback;
|
||||
bool m_reportError = true;
|
||||
public:
|
||||
PopupRestoreBackup(std::fs::path logFilePath, std::function<void()> restoreCallback, std::function<void()> deleteCallback)
|
||||
PopupRestoreBackup(const std::fs::path &logFilePath, const std::function<void()> &restoreCallback, const std::function<void()> &deleteCallback)
|
||||
: Popup("hex.builtin.popup.safety_backup.title"),
|
||||
m_logFilePath(logFilePath),
|
||||
m_restoreCallback(restoreCallback),
|
||||
m_deleteCallback(deleteCallback) { }
|
||||
m_deleteCallback(deleteCallback) {
|
||||
|
||||
this->m_reportError = ContentRegistry::Settings::read("hex.builtin.setting.general", "hex.builtin.setting.general.upload_crash_logs", 1);
|
||||
}
|
||||
|
||||
void drawContent() override {
|
||||
ImGui::TextUnformatted("hex.builtin.popup.safety_backup.desc"_lang);
|
||||
if (!this->m_logFilePath.empty()) {
|
||||
ImGui::NewLine();
|
||||
ImGui::TextUnformatted("hex.builtin.popup.safety_backup.log_file"_lang);
|
||||
ImGui::SameLine(0, 2_scaled);
|
||||
if (ImGui::Hyperlink(this->m_logFilePath.filename().string().c_str())) {
|
||||
fs::openFolderWithSelectionExternal(this->m_logFilePath);
|
||||
}
|
||||
|
||||
ImGui::Checkbox("hex.builtin.popup.safety_backup.report_error"_lang, &this->m_reportError);
|
||||
ImGui::NewLine();
|
||||
}
|
||||
|
||||
@@ -69,6 +80,31 @@ namespace hex::plugin::builtin {
|
||||
this->m_restoreCallback();
|
||||
this->m_deleteCallback();
|
||||
|
||||
if (this->m_reportError) {
|
||||
wolv::io::File logFile(this->m_logFilePath, wolv::io::File::Mode::Read);
|
||||
if (logFile.isValid()) {
|
||||
// Read current log file data
|
||||
auto data = logFile.readString();
|
||||
|
||||
// Anonymize the log file
|
||||
{
|
||||
for (u32 pathType = 0; pathType < u32(fs::ImHexPath::END); pathType++) {
|
||||
for (auto &folder : fs::getDefaultPaths(static_cast<fs::ImHexPath>(pathType))) {
|
||||
auto parent = wolv::util::toUTF8String(folder.parent_path());
|
||||
data = wolv::util::replaceStrings(data, parent, "<*****>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TaskManager::createBackgroundTask("Upload Crash report", [path = this->m_logFilePath, data](auto&){
|
||||
HttpRequest request("POST", ImHexApiURL + std::string("/crash_upload"));
|
||||
request.uploadFile(std::vector<u8>(data.begin(), data.end()), "file", path.filename()).wait();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ContentRegistry::Settings::write("hex.builtin.setting.general", "hex.builtin.setting.general.upload_crash_logs", i64(this->m_reportError));
|
||||
|
||||
this->close();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
@@ -398,23 +434,14 @@ namespace hex::plugin::builtin {
|
||||
loadDefaultLayout();
|
||||
});
|
||||
|
||||
#if defined(HEX_UPDATE_CHECK)
|
||||
EventManager::subscribe<EventWindowInitialized>([] {
|
||||
// documentation of the value above the setting definition
|
||||
auto 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);
|
||||
PopupQuestion::open("hex.builtin.welcome.check_for_updates_text"_lang,
|
||||
[] {
|
||||
ContentRegistry::Settings::write("hex.builtin.setting.general", "hex.builtin.setting.general.check_for_updates", 1);
|
||||
},
|
||||
[] {
|
||||
|
||||
}
|
||||
);
|
||||
auto allowServerContact = ContentRegistry::Settings::read("hex.builtin.setting.general", "hex.builtin.setting.general.server_contact", 2);
|
||||
if (allowServerContact == 2) {
|
||||
ContentRegistry::Settings::write("hex.builtin.setting.general", "hex.builtin.setting.general.server_contact", 0);
|
||||
PopupTelemetryRequest::open();
|
||||
}
|
||||
});
|
||||
#endif
|
||||
|
||||
// Clear project context if we go back to the welcome screen
|
||||
EventManager::subscribe<EventProviderChanged>([](hex::prv::Provider *oldProvider, hex::prv::Provider *newProvider) {
|
||||
@@ -452,7 +479,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
auto backupFilePath = path / BackupFileName;
|
||||
bool hasBackupFile = wolv::io::fs::exists(backupFilePath);
|
||||
|
||||
|
||||
PopupRestoreBackup::open(
|
||||
// path of log file
|
||||
crashFileData.value("logFile", ""),
|
||||
|
||||
Reference in New Issue
Block a user