1 | // Aseprite |
---|---|
2 | // Copyright (C) 2016-2017 David Capello |
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/commands/params.h" |
14 | #include "app/context.h" |
15 | #include "app/ui/main_window.h" |
16 | |
17 | namespace app { |
18 | |
19 | class OpenBrowserCommand : public Command { |
20 | public: |
21 | OpenBrowserCommand(); |
22 | |
23 | protected: |
24 | void onLoadParams(const Params& params) override; |
25 | void onExecute(Context* context) override; |
26 | |
27 | private: |
28 | std::string m_filename; |
29 | }; |
30 | |
31 | OpenBrowserCommand::OpenBrowserCommand() |
32 | : Command(CommandId::OpenBrowser(), CmdUIOnlyFlag) |
33 | { |
34 | } |
35 | |
36 | void OpenBrowserCommand::onLoadParams(const Params& params) |
37 | { |
38 | m_filename = params.get("filename"); |
39 | } |
40 | |
41 | void OpenBrowserCommand::onExecute(Context* context) |
42 | { |
43 | App::instance()->mainWindow()->showBrowser(m_filename); |
44 | } |
45 | |
46 | Command* CommandFactory::createOpenBrowserCommand() |
47 | { |
48 | return new OpenBrowserCommand; |
49 | } |
50 | |
51 | } // namespace app |
52 |