Skip to content

Commit

Permalink
Updated session metadata.
Browse files Browse the repository at this point in the history
  • Loading branch information
ggarra13 committed Oct 10, 2023
1 parent af0b5a2 commit 5106588
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 62 deletions.
7 changes: 5 additions & 2 deletions mrv2/docs/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ v0.8.0
- Fixed a typo in Python's binding to sessios (oepenSession instead of
openSession).
- Made Save Session not save temporary EDLs in the session file.
- Added a __divider__ tuple entry to Plug-in menus to add a divider line between
menu entries.
- Added a '__divider__' tuple entry to Plug-in menus to add a divider line
between menu entries.
- Made Python's output and errors automatically be sent to the Python editor,
instead of waiting until the commands finish, like in v0.7.9 and previous
ones.
Expand All @@ -22,6 +22,9 @@ v0.8.0
ones.
- Made saving of .otio files also work from File/Save/Movie or Sequence if the
extension given is .otio.
- Added user metadata to save in the session file as "metadata". This can be
set with the Python commands setSessionMetadata and retrieved with
sessionMetadata.

v0.7.9
======
Expand Down
24 changes: 22 additions & 2 deletions mrv2/lib/mrvFl/mrvSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
namespace
{
const char* kModule = "mrv2s";
}
const int kSessionVersion = 7;
} // namespace

namespace mrv
{
Expand All @@ -47,6 +48,7 @@ namespace mrv
w->hide();
}

std::string sessionMetadata;
std::string currentSession;

std::string current_session()
Expand All @@ -71,7 +73,7 @@ namespace mrv
enable_cypher(false);

Message session;
session["version"] = 6;
session["version"] = kSessionVersion;

std::vector< FilesModelItem > files;
for (const auto file : files_ptrs)
Expand Down Expand Up @@ -286,6 +288,7 @@ namespace mrv
session["environmentMapOptions"] = environmentMap;
session["displayOptions"] = display;
session["editMode"] = editMode;
session["metadata"] = sessionMetadata;

std::ofstream ofs(fileName);
if (!ofs.is_open())
Expand Down Expand Up @@ -579,6 +582,11 @@ namespace mrv
set_edit_mode_cb(editMode, ui);
}

if (version >= 7)
{
session["metadata"].get_to(sessionMetadata);
}

enable_cypher(true);
ui->uiMain->fill_menu(ui->uiMenuBar);

Expand All @@ -588,4 +596,16 @@ namespace mrv
return true;
}

//! Returns user provided metadata in the last saved session.
const std::string& session_metadata()
{
return sessionMetadata;
}

//! Stores some user provided metadata.
void set_session_metadata(const std::string& metadata)
{
sessionMetadata = metadata;
}

} // namespace mrv
8 changes: 8 additions & 0 deletions mrv2/lib/mrvFl/mrvSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@

namespace mrv
{
//! Returns user provided metadata in the last saved session.
const std::string& session_metadata();

//! Stores some user provided metadata.
void set_session_metadata(const std::string& metadata);

//! Returns the current session file name.
std::string current_session();

//! Sets the current session to file.
void set_current_session(const std::string& file);

//! Returns true on success, false on failure
Expand Down
25 changes: 13 additions & 12 deletions mrv2/lib/mrvPy/Cmds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,16 +371,6 @@ namespace mrv2
return current_session();
}

/**
* \brief Returns the current session file.
*
* @param file The path to the session file, like: /home/gga/test.mrv2s
*/
void setCurrentSession(const std::string& session)
{
return set_current_session(session);
}

/**
* \brief Open a session file.
*
Expand Down Expand Up @@ -550,12 +540,23 @@ Used to run main commands and get and set the display, image, compare, LUT optio
py::arg("file"));
#endif

//
// Session commands
//
cmds.def(
"sessionMetadata", &mrv::session_metadata,
_("Returns the current session metadata."));

cmds.def(
"setSessionMetadata", &mrv::set_session_metadata,
_("Sets the current session metadata."));

cmds.def(
"currentSession", &mrv2::cmd::currentSession,
"currentSession", &mrv::current_session,
_("Returns current session file."));

cmds.def(
"setCurrentSession", &mrv2::cmd::setCurrentSession,
"setCurrentSession", &mrv::set_current_session,
_("Sets the current session file."), py::arg("file"));

cmds.def(
Expand Down
Loading

0 comments on commit 5106588

Please sign in to comment.