1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-19 09:01:15 +02:00

Do not require AudacityApp.h when using global file history

This commit is contained in:
Paul Licameli
2019-04-23 20:57:18 -04:00
parent d4f71c2c64
commit 2d8c287384
7 changed files with 51 additions and 40 deletions

View File

@@ -9,7 +9,7 @@
*******************************************************************//**
\class FileHistory
\brief Similar to FileHistory, but customized to our needs.
\brief Similar to wxFileHistory, but customized to our needs.
*//*******************************************************************/
@@ -21,6 +21,9 @@
#include <wx/menu.h>
#include "../Internat.h"
#include "../Prefs.h"
#include <mutex>
FileHistory::FileHistory(size_t maxfiles, wxWindowID base)
{
@@ -32,6 +35,19 @@ FileHistory::~FileHistory()
{
}
FileHistory &FileHistory::Global()
{
// TODO - read the number of files to store in history from preferences
static FileHistory history{
ID_RECENT_LAST - ID_RECENT_FIRST + 1, ID_RECENT_CLEAR };
static std::once_flag flag;
std::call_once( flag, [&]{
history.Load(*gPrefs, wxT("RecentFiles"));
});
return history;
}
// File history management
void FileHistory::AddFileToHistory(const FilePath & file, bool update)
{

View File

@@ -28,6 +28,15 @@ class AUDACITY_DLL_API FileHistory
FileHistory(size_t maxfiles = 12, wxWindowID idbase = wxID_FILE);
virtual ~FileHistory();
// These constants define the range of IDs reserved by the global file history
enum {
ID_RECENT_CLEAR = 6100,
ID_RECENT_FIRST = 6101,
ID_RECENT_LAST = 6112
};
static FileHistory &Global();
void AddFileToHistory(const FilePath & file, bool update = true);
void RemoveFileFromHistory(size_t i, bool update = true);
void Clear();