From 6e40bb7f1b71d1c67f6befc99c1b7be6205f4cda Mon Sep 17 00:00:00 2001 From: John Shepherd Date: Thu, 20 Aug 2020 15:52:28 -0700 Subject: [PATCH 1/2] Add file extension automatically for record plugin Signed-off-by: John Shepherd --- src/gui/plugins/video_recorder/VideoRecorder.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/gui/plugins/video_recorder/VideoRecorder.cc b/src/gui/plugins/video_recorder/VideoRecorder.cc index cdde859871..3b9b55ad64 100644 --- a/src/gui/plugins/video_recorder/VideoRecorder.cc +++ b/src/gui/plugins/video_recorder/VideoRecorder.cc @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -106,6 +107,17 @@ void VideoRecorder::OnStop() void VideoRecorder::OnSave(const QString &_url) { std::string path = QUrl(_url).toLocalFile().toStdString(); + + // Get the user selected file extension + std::string filenameBaseName = common::basename(this->dataPtr->filename); + std::string::size_type filenameExtensionIndex = + filenameBaseName.rfind("."); + std::string fileExtension = + filenameBaseName.substr(filenameExtensionIndex + 1); + + // Append file extension to the user entered path + path += "." + fileExtension; + bool result = common::moveFile(this->dataPtr->filename, path); if (!result) From 05aab20c556b8093dd2111712ac6f9463c3f3086 Mon Sep 17 00:00:00 2001 From: John Shepherd Date: Mon, 31 Aug 2020 16:05:41 -0700 Subject: [PATCH 2/2] Add suggested extension functionality Signed-off-by: John Shepherd --- .../plugins/video_recorder/VideoRecorder.cc | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/gui/plugins/video_recorder/VideoRecorder.cc b/src/gui/plugins/video_recorder/VideoRecorder.cc index 3b9b55ad64..f7520c9ef9 100644 --- a/src/gui/plugins/video_recorder/VideoRecorder.cc +++ b/src/gui/plugins/video_recorder/VideoRecorder.cc @@ -108,15 +108,20 @@ void VideoRecorder::OnSave(const QString &_url) { std::string path = QUrl(_url).toLocalFile().toStdString(); - // Get the user selected file extension - std::string filenameBaseName = common::basename(this->dataPtr->filename); - std::string::size_type filenameExtensionIndex = - filenameBaseName.rfind("."); - std::string fileExtension = - filenameBaseName.substr(filenameExtensionIndex + 1); - - // Append file extension to the user entered path - path += "." + fileExtension; + // If we cannot find an extension in the user entered file name, + // append the format of the selected codec + if (common::basename(path).find(".") == std::string::npos) + { + // Get the user selected file extension + std::string filenameBaseName = common::basename(this->dataPtr->filename); + std::string::size_type filenameExtensionIndex = + filenameBaseName.rfind("."); + std::string fileExtension = + filenameBaseName.substr(filenameExtensionIndex + 1); + + // Append file extension to the user entered path + path += "." + fileExtension; + } bool result = common::moveFile(this->dataPtr->filename, path);