2015-02-12 23:16:25 +08:00
|
|
|
// Aseprite
|
2019-05-28 03:29:53 +08:00
|
|
|
// Copyright (C) 2018-2019 Igara Studio S.A.
|
2018-03-14 23:08:02 +08:00
|
|
|
// Copyright (C) 2001-2018 David Capello
|
2015-02-12 23:16:25 +08:00
|
|
|
//
|
2016-08-27 04:02:58 +08:00
|
|
|
// This program is distributed under the terms of
|
|
|
|
|
// the End-User License Agreement for Aseprite.
|
2007-09-19 07:57:02 +08:00
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
#ifndef APP_RECENT_FILES_H_INCLUDED
|
|
|
|
|
#define APP_RECENT_FILES_H_INCLUDED
|
2014-03-30 06:40:17 +08:00
|
|
|
#pragma once
|
2007-09-19 07:57:02 +08:00
|
|
|
|
2018-12-22 00:48:35 +08:00
|
|
|
#include "base/paths.h"
|
2016-09-14 02:02:00 +08:00
|
|
|
#include "obs/signal.h"
|
2014-04-21 06:53:27 +08:00
|
|
|
|
|
|
|
|
#include <string>
|
2007-09-19 07:57:02 +08:00
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
namespace app {
|
2015-02-12 23:16:25 +08:00
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
class RecentFiles {
|
2018-12-22 13:08:04 +08:00
|
|
|
enum { kPinnedFiles,
|
|
|
|
|
kRecentFiles,
|
|
|
|
|
kPinnedFolders,
|
|
|
|
|
kRecentFolders,
|
|
|
|
|
kCollections };
|
2013-08-06 08:20:19 +08:00
|
|
|
public:
|
2019-05-28 03:29:53 +08:00
|
|
|
const base::paths& pinnedFiles() const { return m_paths[kPinnedFiles]; }
|
|
|
|
|
const base::paths& recentFiles() const { return m_paths[kRecentFiles]; }
|
|
|
|
|
const base::paths& pinnedFolders() const { return m_paths[kPinnedFolders]; }
|
|
|
|
|
const base::paths& recentFolders() const { return m_paths[kRecentFolders]; }
|
2007-09-19 07:57:02 +08:00
|
|
|
|
2018-03-15 01:14:47 +08:00
|
|
|
RecentFiles(const int limit);
|
2013-08-06 08:20:19 +08:00
|
|
|
~RecentFiles();
|
2010-03-28 10:43:08 +08:00
|
|
|
|
2018-03-14 23:08:02 +08:00
|
|
|
void addRecentFile(const std::string& filename);
|
|
|
|
|
void removeRecentFile(const std::string& filename);
|
|
|
|
|
void removeRecentFolder(const std::string& dir);
|
2018-12-22 13:08:04 +08:00
|
|
|
void setLimit(const int newLimit);
|
2018-03-15 01:14:47 +08:00
|
|
|
void clear();
|
2010-09-18 11:28:24 +08:00
|
|
|
|
2018-12-22 13:08:04 +08:00
|
|
|
void setFiles(const base::paths& pinnedFiles,
|
|
|
|
|
const base::paths& recentFiles);
|
|
|
|
|
void setFolders(const base::paths& pinnedFolders,
|
|
|
|
|
const base::paths& recentFolders);
|
2018-12-22 00:48:35 +08:00
|
|
|
|
2016-09-14 02:02:00 +08:00
|
|
|
obs::signal<void()> Changed;
|
2015-03-02 22:18:33 +08:00
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
private:
|
2018-03-14 23:08:02 +08:00
|
|
|
std::string normalizePath(const std::string& filename);
|
2018-12-22 13:08:04 +08:00
|
|
|
void addItem(base::paths& list, const std::string& filename);
|
|
|
|
|
void removeItem(base::paths& list, const std::string& filename);
|
|
|
|
|
void load();
|
|
|
|
|
void save();
|
2015-08-27 22:12:30 +08:00
|
|
|
|
2018-12-22 13:08:04 +08:00
|
|
|
base::paths m_paths[kCollections];
|
|
|
|
|
int m_limit;
|
2013-08-06 08:20:19 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace app
|
2007-09-19 07:57:02 +08:00
|
|
|
|
2009-08-18 05:38:00 +08:00
|
|
|
#endif
|