Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for issue 43 #153

Merged
merged 9 commits into from
Jun 12, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/gui/plugins/video_recorder/VideoRecorder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,15 @@ void VideoRecorder::OnStop()
}

/////////////////////////////////////////////////
void VideoRecorder::OnSave(const QString &_url)
void VideoRecorder::OnSave(const QString &_url, const QString &_format)
{
std::string path = QUrl(_url).toLocalFile().toStdString();
std::string format = _format.toStdString();

bool urlHasFormat = path.substr(path.find_last_of(".") + 1) == format;
if (!urlHasFormat)
path = path + "." + format;

bool result = common::moveFile(this->dataPtr->filename, path);

if (!result)
Expand Down
3 changes: 2 additions & 1 deletion src/gui/plugins/video_recorder/VideoRecorder.hh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ namespace gazebo

/// \brief Callback when user selects a path to save the recorded video
/// \param[in] _url Path of the file to save the recorded video
public slots: void OnSave(const QString &_url);
/// \param[in] _format Format of the file to save the recorded video
public slots: void OnSave(const QString &_url, const QString &_format);

/// \brief Callback when user cancels saving the recorded video
public slots: void OnCancel();
Expand Down
8 changes: 7 additions & 1 deletion src/gui/plugins/video_recorder/VideoRecorder.qml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ ToolBar {
title: "Save the recorded video"
folder: shortcuts.home
selectExisting: false
nameFilters: [ "*.mp4", "*.ogv" ]
onAccepted: {
VideoRecorder.OnSave(fileDialog.fileUrl)
VideoRecorder.OnSave(fileDialog.fileUrl, recordMenu.saveFormat)
close()
}
onRejected: {
Expand Down Expand Up @@ -70,16 +71,21 @@ ToolBar {
Menu {
id: recordMenu
y: record.height
property string saveFormat
MenuItem {
text: "mp4"
onTriggered: {
recordMenu.saveFormat = "mp4"
fileDialog.selectedNameFilter = "*.mp4"
VideoRecorder.OnStart("mp4")
animation.start()
}
}
MenuItem {
text: "ogv"
onTriggered: {
recordMenu.saveFormat = "ogv"
fileDialog.selectedNameFilter = "*.ogv"
VideoRecorder.OnStart("ogv")
animation.start()
}
Expand Down