1 | // Aseprite |
2 | // Copyright (C) 2018-2019 Igara Studio S.A. |
3 | // Copyright (C) 2001-2018 David Capello |
4 | // |
5 | // This program is distributed under the terms of |
6 | // the End-User License Agreement for Aseprite. |
7 | |
8 | #ifndef APP_RECENT_FILES_H_INCLUDED |
9 | #define APP_RECENT_FILES_H_INCLUDED |
10 | #pragma once |
11 | |
12 | #include "base/paths.h" |
13 | #include "obs/signal.h" |
14 | |
15 | #include <string> |
16 | |
17 | namespace app { |
18 | |
19 | class RecentFiles { |
20 | enum { kPinnedFiles, |
21 | kRecentFiles, |
22 | kPinnedFolders, |
23 | kRecentFolders, |
24 | kCollections }; |
25 | public: |
26 | const base::paths& pinnedFiles() const { return m_paths[kPinnedFiles]; } |
27 | const base::paths& recentFiles() const { return m_paths[kRecentFiles]; } |
28 | const base::paths& pinnedFolders() const { return m_paths[kPinnedFolders]; } |
29 | const base::paths& recentFolders() const { return m_paths[kRecentFolders]; } |
30 | |
31 | RecentFiles(const int limit); |
32 | ~RecentFiles(); |
33 | |
34 | void addRecentFile(const std::string& filename); |
35 | void removeRecentFile(const std::string& filename); |
36 | void removeRecentFolder(const std::string& dir); |
37 | void setLimit(const int newLimit); |
38 | void clear(); |
39 | |
40 | void setFiles(const base::paths& pinnedFiles, |
41 | const base::paths& recentFiles); |
42 | void setFolders(const base::paths& pinnedFolders, |
43 | const base::paths& recentFolders); |
44 | |
45 | obs::signal<void()> Changed; |
46 | |
47 | private: |
48 | std::string normalizePath(const std::string& filename); |
49 | void addItem(base::paths& list, const std::string& filename); |
50 | void removeItem(base::paths& list, const std::string& filename); |
51 | void load(); |
52 | void save(); |
53 | |
54 | base::paths m_paths[kCollections]; |
55 | int m_limit; |
56 | }; |
57 | |
58 | } // namespace app |
59 | |
60 | #endif |
61 | |