Skip to content

Commit

Permalink
Merge pull request #29 from darbyjohnston/settings
Browse files Browse the repository at this point in the history
Add settings
  • Loading branch information
darbyjohnston authored Nov 30, 2024
2 parents 80edb53 + 7d8dc45 commit 4b93454
Show file tree
Hide file tree
Showing 39 changed files with 721 additions and 575 deletions.
2 changes: 1 addition & 1 deletion cmake/SuperBuild/Builddtk-deps.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include(ExternalProject)

set(dtk_GIT_REPOSITORY "https://github.com/darbyjohnston/dtk.git")
set(dtk_GIT_TAG "fe317ed208c6befeeb832fd9e8c6cce18575f9cb")
set(dtk_GIT_TAG "3f569280b3ea1c9cf37241f80be7847b6105d12c")

set(dtk-deps_ARGS
${toucan_EXTERNAL_PROJECT_ARGS}
Expand Down
2 changes: 1 addition & 1 deletion cmake/SuperBuild/Builddtk.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include(ExternalProject)

set(dtk_GIT_REPOSITORY "https://github.com/darbyjohnston/dtk.git")
set(dtk_GIT_TAG "fe317ed208c6befeeb832fd9e8c6cce18575f9cb")
set(dtk_GIT_TAG "3f569280b3ea1c9cf37241f80be7847b6105d12c")

set(dtk_DEPS dtk-deps)
set(dtk_ARGS
Expand Down
2 changes: 1 addition & 1 deletion lib/toucan/FFmpegRead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ namespace toucan
!_avFormatContext ? fileName.c_str() : nullptr,
nullptr,
nullptr);
if (r < 0)
if (r < 0 || !_avFormatContext)
{
throw std::runtime_error("Cannot open file");
}
Expand Down
30 changes: 19 additions & 11 deletions lib/toucanView/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,30 @@

#include "App.h"

#include "DocumentsModel.h"
#include "FilesModel.h"
#include "MainWindow.h"
#include "TimeUnitsModel.h"
#include "WindowModel.h"

#include <dtk/ui/DialogSystem.h>
#include <dtk/ui/FileBrowser.h>
#include <dtk/ui/MessageDialog.h>
#include <dtk/ui/RecentFilesModel.h>

#include <dtk/core/CmdLine.h>

#include <nlohmann/json.hpp>

namespace toucan
{
void App::_init(
const std::shared_ptr<dtk::Context>& context,
std::vector<std::string>& argv)
{
_messageLog = std::make_shared<MessageLog>();

_settings = dtk::Settings::create(dtk::getSettingsPath("toucan", "toucan-view.settings"));

dtk::App::_init(
context,
argv,
Expand All @@ -31,13 +38,11 @@ namespace toucan
"input",
"Input timeline.",
true)
});

context->getSystem<dtk::FileBrowserSystem>()->setNativeFileDialog(false);

_messageLog = std::make_shared<MessageLog>();
},
{},
_settings);

_timeUnitsModel = std::make_shared<TimeUnitsModel>();
_timeUnitsModel = std::make_shared<TimeUnitsModel>(_settings);

std::vector<std::filesystem::path> searchPath;
const std::filesystem::path parentPath = std::filesystem::path(argv[0]).parent_path();
Expand All @@ -51,7 +56,10 @@ namespace toucan
//hostOptions.log = _messageLog;
_host = std::make_shared<ImageEffectHost>(searchPath, hostOptions);

_documentsModel = std::make_shared<DocumentsModel>(context, _host);
auto fileBrowserSystem = context->getSystem<dtk::FileBrowserSystem>();
fileBrowserSystem->setNativeFileDialog(false);

_filesModel = std::make_shared<FilesModel>(context, _settings, _host);

_windowModel = std::make_shared<WindowModel>();

Expand All @@ -66,7 +74,7 @@ namespace toucan
{
try
{
_documentsModel->open(_path);
_filesModel->open(_path);
}
catch (const std::exception& e)
{
Expand Down Expand Up @@ -99,9 +107,9 @@ namespace toucan
return _host;
}

const std::shared_ptr<DocumentsModel>& App::getDocumentsModel() const
const std::shared_ptr<FilesModel>& App::getFilesModel() const
{
return _documentsModel;
return _filesModel;
}

const std::shared_ptr<WindowModel>& App::getWindowModel() const
Expand Down
7 changes: 4 additions & 3 deletions lib/toucanView/App.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace toucan
{
class DocumentsModel;
class FilesModel;
class ImageEffectHost;
class MainWindow;
class MessageLog;
Expand All @@ -30,15 +30,16 @@ namespace toucan

const std::shared_ptr<TimeUnitsModel>& getTimeUnitsModel() const;
const std::shared_ptr<ImageEffectHost>& getHost() const;
const std::shared_ptr<DocumentsModel>& getDocumentsModel() const;
const std::shared_ptr<FilesModel>& getFilesModel() const;
const std::shared_ptr<WindowModel>& getWindowModel() const;

private:
std::shared_ptr<MessageLog> _messageLog;
std::shared_ptr<dtk::Settings> _settings;
std::string _path;
std::shared_ptr<TimeUnitsModel> _timeUnitsModel;
std::shared_ptr<ImageEffectHost> _host;
std::shared_ptr<DocumentsModel> _documentsModel;
std::shared_ptr<FilesModel> _filesModel;
std::shared_ptr<WindowModel> _windowModel;
std::shared_ptr<MainWindow> _window;
};
Expand Down
12 changes: 6 additions & 6 deletions lib/toucanView/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
set(HEADERS
App.h
ClipItem.h
DocumentTab.h
Document.h
DocumentsModel.h
ExportTool.h
FileTab.h
File.h
FilesModel.h
GapItem.h
GraphTool.h
IItem.h
Expand All @@ -31,10 +31,10 @@ set(HEADERS
set(SOURCE
App.cpp
ClipItem.cpp
DocumentTab.cpp
Document.cpp
DocumentsModel.cpp
ExportTool.cpp
FileTab.cpp
File.cpp
FilesModel.cpp
GapItem.cpp
GraphTool.cpp
IItem.cpp
Expand Down
140 changes: 0 additions & 140 deletions lib/toucanView/DocumentsModel.cpp

This file was deleted.

50 changes: 0 additions & 50 deletions lib/toucanView/DocumentsModel.h

This file was deleted.

Loading

0 comments on commit 4b93454

Please sign in to comment.