1 | // Aseprite |
---|---|
2 | // Copyright (C) 2019 Igara Studio S.A. |
3 | // |
4 | // This program is distributed under the terms of |
5 | // the End-User License Agreement for Aseprite. |
6 | |
7 | #ifdef HAVE_CONFIG_H |
8 | #include "config.h" |
9 | #endif |
10 | |
11 | #include "app/app.h" |
12 | #include "app/commands/command.h" |
13 | #include "app/recent_files.h" |
14 | |
15 | namespace app { |
16 | |
17 | class ClearRecentFilesCommand : public Command { |
18 | public: |
19 | ClearRecentFilesCommand(); |
20 | |
21 | protected: |
22 | bool onEnabled(Context* ctx) override; |
23 | void onExecute(Context* ctx) override; |
24 | }; |
25 | |
26 | ClearRecentFilesCommand::ClearRecentFilesCommand() |
27 | : Command(CommandId::ClearRecentFiles(), CmdUIOnlyFlag) |
28 | { |
29 | } |
30 | |
31 | bool ClearRecentFilesCommand::onEnabled(Context* ctx) |
32 | { |
33 | auto recent = App::instance()->recentFiles(); |
34 | return (recent && |
35 | (!recent->recentFiles().empty() || |
36 | !recent->recentFolders().empty())); |
37 | } |
38 | |
39 | void ClearRecentFilesCommand::onExecute(Context* ctx) |
40 | { |
41 | App::instance()->recentFiles()->clear(); |
42 | } |
43 | |
44 | Command* CommandFactory::createClearRecentFilesCommand() |
45 | { |
46 | return new ClearRecentFilesCommand; |
47 | } |
48 | |
49 | } // namespace app |
50 |