-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathApp.cpp
More file actions
124 lines (100 loc) · 3.07 KB
/
App.cpp
File metadata and controls
124 lines (100 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// SPDX-License-Identifier: Apache-2.0
// Copyright Contributors to the toucan project.
#include "App.h"
#include "FilesModel.h"
#include "MainWindow.h"
#include "TimeUnitsModel.h"
#include "ViewModel.h"
#include "WindowModel.h"
#include <toucanRender/Util.h>
#include <ftk/Ui/DialogSystem.h>
#include <ftk/Ui/FileBrowser.h>
#include <ftk/Ui/MessageDialog.h>
#include <ftk/Ui/Settings.h>
#include <ftk/Core/CmdLine.h>
#include <nlohmann/json.hpp>
namespace toucan
{
void App::_init(
const std::shared_ptr<ftk::Context>& context,
std::vector<std::string>& argv)
{
_input = ftk::CmdLineValueArg<std::string>::create(
"input",
"Input timeline.",
true);
ftk::App::_init(
context,
argv,
"toucan-view",
"Toucan viewer",
{ _input });
_settings = ftk::Settings::create(context, ftk::getSettingsPath("toucan", "toucan-view.settings"));
_timeUnitsModel = std::make_shared<TimeUnitsModel>(context, _settings);
_host = std::make_shared<ImageEffectHost>(context, getOpenFXPluginPaths(getExeName()));
auto fileBrowserSystem = context->getSystem<ftk::FileBrowserSystem>();
fileBrowserSystem->setNativeFileDialog(false);
_filesModel = std::make_shared<FilesModel>(context, _settings, _host);
_globalViewModel = std::make_shared<GlobalViewModel>(context, _settings);
_windowModel = std::make_shared<WindowModel>(context, _settings);
_window = MainWindow::create(
context,
std::dynamic_pointer_cast<App>(shared_from_this()),
"toucan-view",
ftk::Size2I(1920, 1080));
addWindow(_window);
_window->show();
if (_input->hasValue())
{
open(_input->getValue());
}
}
App::~App()
{}
std::shared_ptr<App> App::create(
const std::shared_ptr<ftk::Context>& context,
std::vector<std::string>& argv)
{
auto out = std::shared_ptr<App>(new App);
out->_init(context, argv);
return out;
}
const std::shared_ptr<ftk::Settings>& App::getSettings() const
{
return _settings;
}
const std::shared_ptr<TimeUnitsModel>& App::getTimeUnitsModel() const
{
return _timeUnitsModel;
}
const std::shared_ptr<ImageEffectHost>& App::getHost() const
{
return _host;
}
const std::shared_ptr<FilesModel>& App::getFilesModel() const
{
return _filesModel;
}
const std::shared_ptr<GlobalViewModel>& App::getGlobalViewModel() const
{
return _globalViewModel;
}
const std::shared_ptr<WindowModel>& App::getWindowModel() const
{
return _windowModel;
}
void App::open(const std::filesystem::path& path)
{
try
{
_filesModel->open(path);
}
catch (const std::exception& e)
{
_context->getSystem<ftk::DialogSystem>()->message(
"ERROR",
e.what(),
_window);
}
}
}