qt: Add media history manager for recently used images

This commit is contained in:
cold-brewed
2022-08-30 17:18:51 -04:00
parent df0e12bccc
commit 9daa721d44
9 changed files with 564 additions and 14 deletions

View File

@@ -1829,6 +1829,15 @@ load_floppy_and_cdrom_drives(void)
sprintf(temp, "cdrom_%02i_iso_path", c + 1);
config_delete_var(cat, temp);
for (int i = 0; i < MAX_PREV_IMAGES; i++) {
cdrom[c].image_history[i] = (char *) calloc(MAX_IMAGE_PATH_LEN + 1, sizeof(char));
sprintf(temp, "cdrom_%02i_image_history_%02i", c + 1, i + 1);
p = config_get_string(cat, temp, NULL);
if(p) {
sprintf(cdrom[c].image_history[i], "%s", p);
}
}
}
}
@@ -3137,6 +3146,15 @@ save_floppy_and_cdrom_drives(void)
} else {
config_set_string(cat, temp, cdrom[c].image_path);
}
for (int i = 0; i < MAX_PREV_IMAGES; i++) {
sprintf(temp, "cdrom_%02i_image_history_%02i", c + 1, i + 1);
if(strlen(cdrom[c].image_history[i]) == 0) {
config_delete_var(cat, temp);
} else {
config_set_string(cat, temp, cdrom[c].image_history[i]);
}
}
}
delete_section_if_empty(cat);