#include "uistate.h"

#include <algorithm>

#include "fileops.h"
using namespace Xybrid::Config;

std::list<QString> UIState::recentFiles;

void UIState::save() {
    FileOps::saveUIState();
}

void UIState::addRecentFile(const QString &f) {
    if (!recentFiles.empty() && recentFiles.front() == f) return; // if it's already the most recent file, skip
    recentFiles.remove(f); // remove any existing instance from later in the list
    recentFiles.push_front(f);
    while (recentFiles.size() > MAX_RECENTS) recentFiles.pop_back(); // trim to max size
    save(); // and save changes
}
