/* SWR INI Tool - Switchroot INI Configuration Editor Copyright (C) 2026 Switchroot */ #include "settings_tab.h" #include "file_browser.h" #include "main_frame.h" #include "os_config_tab.h" SettingsTab::SettingsTab() { this->setSpacing(2); this->setMarginBottom(20); brls::Label *info = new brls::Label( brls::LabelStyle::DESCRIPTION, "Select which INI file each OS tab reads and writes.\n" "Changes take effect immediately.", true ); this->addView(info); // ── INI File Paths ── this->addView(new brls::Header("INI File Paths")); addPathItem(OsTarget::ANDROID); addPathItem(OsTarget::LINUX); addPathItem(OsTarget::LAKKA); } void SettingsTab::addPathItem(OsTarget target) { AppConfig& cfg = AppConfig::get(); std::string currentPath = cfg.getPath(target); std::string label = std::string(AppConfig::getLabel(target)) + " INI"; std::string description = (target == OsTarget::LAKKA) ? "Tap to browse for an INI file" : ""; brls::ListItem* item = new brls::ListItem(label, description); item->setValue(currentPath); item->getClickEvent()->subscribe([target, item](brls::View* view) { // Determine start directory from current path std::string curPath = AppConfig::get().getPath(target); std::string startDir = DEFAULT_BROWSE_DIR; size_t lastSlash = curPath.find_last_of('/'); if (lastSlash != std::string::npos && lastSlash > 0) startDir = curPath.substr(0, lastSlash + 1); FileBrowser* browser = new FileBrowser(startDir, [target, item](const std::string& selectedPath) { AppConfig::get().setPath(target, selectedPath); AppConfig::get().save(); item->setValue(selectedPath); // Reload the corresponding OS tab immediately OsConfigTab* tab = MainFrame::getOsTab(target); if (tab) tab->reload(selectedPath); brls::Application::notify("\uE14B Path updated"); } ); brls::Application::pushView(browser); }); this->addView(item); }