GUI: fix recent file regression

This commit is contained in:
tildearrow 2024-05-20 02:41:53 -05:00
parent f7a9b3fca9
commit 45783e7797
3 changed files with 44 additions and 15 deletions

View file

@ -6689,6 +6689,14 @@ bool FurnaceGUI::init() {
syncSettings();
syncTutorial();
recentFile.clear();
for (int i=0; i<settings.maxRecentFile; i++) {
String r=e->getConfString(fmt::sprintf("recentFile%d",i),"");
if (!r.empty()) {
recentFile.push_back(r);
}
}
if (!settings.persistFadeOut) {
audioExportOptions.loops=settings.exportLoops;
audioExportOptions.fadeOut=settings.exportFadeOut;
@ -7271,14 +7279,6 @@ void FurnaceGUI::syncState() {
xyOscThickness=e->getConfFloat("xyOscThickness",2.0f);
cvHiScore=e->getConfInt("cvHiScore",25000);
recentFile.clear();
for (int i=0; i<settings.maxRecentFile; i++) {
String r=e->getConfString(fmt::sprintf("recentFile%d",i),"");
if (!r.empty()) {
recentFile.push_back(r);
}
}
}
void FurnaceGUI::commitState(DivConfig& conf) {

View file

@ -2806,6 +2806,8 @@ class FurnaceGUI {
void resetColors();
void resetKeybinds();
void purgeBackups(int year, int month, int day);
void readConfig(DivConfig& conf, FurnaceGUISettingGroups groups=GUI_SETTINGS_ALL);
void writeConfig(DivConfig& conf, FurnaceGUISettingGroups groups=GUI_SETTINGS_ALL);

View file

@ -336,6 +336,10 @@ String stripName(String what) {
return ret;
}
void FurnaceGUI::purgeBackups(int year, int month, int day) {
refreshBackups=true;
}
void FurnaceGUI::promptKey(int which) {
bindSetTarget=which;
bindSetActive=true;
@ -4030,14 +4034,16 @@ void FurnaceGUI::drawSettings() {
CONFIG_SUBSECTION("Backup Management");
bool purgeDateChanged=false;
ImGui::Text("Delete before (year/month/day):");
ImGui::SetNextItemWidth(80.0f*dpiScale);
ImGui::AlignTextToFramePadding();
ImGui::Text("Purge before:");
ImGui::SameLine();
ImGui::SetNextItemWidth(60.0f*dpiScale);
if (ImGui::InputInt("##PYear",&purgeYear,0,0)) purgeDateChanged=true;
ImGui::SameLine();
ImGui::SetNextItemWidth(60.0f*dpiScale);
ImGui::SetNextItemWidth(40.0f*dpiScale);
if (ImGui::InputInt("##PMonth",&purgeMonth,0,0)) purgeDateChanged=true;
ImGui::SameLine();
ImGui::SetNextItemWidth(60.0f*dpiScale);
ImGui::SetNextItemWidth(40.0f*dpiScale);
if (ImGui::InputInt("##PDay",&purgeDay,0,0)) purgeDateChanged=true;
if (purgeDateChanged) {
@ -4103,11 +4109,12 @@ void FurnaceGUI::drawSettings() {
}
ImGui::SameLine();
ImGui::Button("Go##PDate");
ImGui::Button("Delete all");
if (ImGui::Button("Go##PDate")) {
purgeBackups(purgeYear,purgeMonth,purgeDay);
}
backupEntryLock.lock();
ImGui::AlignTextToFramePadding();
if (totalBackupSize>=(1ULL<<50ULL)) {
ImGui::Text("%" PRIu64 "PB used",totalBackupSize>>50);
} else if (totalBackupSize>=(1ULL<<40ULL)) {
@ -4122,6 +4129,16 @@ void FurnaceGUI::drawSettings() {
ImGui::Text("%" PRIu64 " bytes used",totalBackupSize);
}
ImGui::SameLine();
if (ImGui::Button("Refresh")) {
refreshBackups=true;
}
ImGui::SameLine();
if (ImGui::Button("Delete all")) {
purgeBackups(0,0,0);
}
if (ImGui::BeginTable("BackupList",3,ImGuiTableFlags_ScrollY|ImGuiTableFlags_Borders)) {
ImGui::TableSetupColumn("Name",ImGuiTableColumnFlags_WidthStretch,0.6f);
ImGui::TableSetupColumn("Size",ImGuiTableColumnFlags_WidthStretch,0.15f);
@ -4156,9 +4173,11 @@ void FurnaceGUI::drawSettings() {
backupEntryLock.unlock();
if (refreshBackups) {
refreshBackups=false;
if (backupEntryTask.valid()) backupEntryTask.get();
backupEntryTask=std::async(std::launch::async,[this]() -> bool {
backupEntryLock.lock();
backupEntries.clear();
totalBackupSize=0;
backupEntryLock.unlock();
#ifdef _WIN32
@ -5665,6 +5684,14 @@ bool FurnaceGUI::importConfig(String path) {
syncState();
syncSettings();
commitSettings();
recentFile.clear();
for (int i=0; i<settings.maxRecentFile; i++) {
String r=e->getConfString(fmt::sprintf("recentFile%d",i),"");
if (!r.empty()) {
recentFile.push_back(r);
}
}
return true;
}