settings: Only save config and refresh dir entries after settings is closed

This commit is contained in:
Joel16 2020-09-18 13:37:52 -04:00
parent 4cececbfb9
commit dff3a6ed5e
3 changed files with 11 additions and 10 deletions

View File

@ -2,7 +2,6 @@
#define NX_SHELL_WINDOWS_H
#include "imgui.h"
#include "textures.h"
namespace Windows {
inline void SetupWindow(void) {
@ -18,6 +17,7 @@ namespace Windows {
void FileBrowserWindow(bool *focus, bool *first_item);
void ImageWindow(void);
void PartitionBrowserWindow(void);
void SettingsWindow(void);
void TextReaderWindow(void);
}

View File

@ -104,6 +104,10 @@ namespace GUI {
delete[] text_reader.buf;
item.state = MENU_STATE_HOME;
}
else if (item.state == MENU_STATE_SETTINGS) {
Config::Save(config);
item.file_count = FS::RefreshEntries(&item.entries, item.file_count);
}
else
item.state = MENU_STATE_HOME;
}

View File

@ -11,8 +11,8 @@ namespace Windows {
ImGui::Separator();
ImGui::Dummy(ImVec2(0.0f, 5.0f)); // Spacing
}
void SettingsWindow(void) {
void SettingsWindow(void) {
Windows::SetupWindow();
if (ImGui::Begin("Settings", nullptr, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse)) {
@ -29,15 +29,15 @@ namespace Windows {
}
Windows::Separator();
if (ImGui::TreeNode("Image Viewer")) {
ImGui::Dummy(ImVec2(0.0f, 5.0f)); // Spacing
ImGui::Checkbox(" Display filename", &config.image_filename);
ImGui::TreePop();
}
Windows::Separator();
if (ImGui::TreeNode("Developer Options")) {
ImGui::Dummy(ImVec2(0.0f, 5.0f)); // Spacing
ImGui::Checkbox(" Enable logs", &config.dev_options);
@ -64,9 +64,6 @@ namespace Windows {
ImGui::TreePop();
}
}
Windows::ExitWindow();
Config::Save(config);
item.file_count = FS::RefreshEntries(&item.entries, item.file_count);
Windows::ExitWindow();
}
}