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

Fixed autosaving of playlist not working on linux #357

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions YUViewLib/src/common/EnumMapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <optional>
#include <string>
#include <vector>
#include <stdexcept>

/* This class implement mapping of "enum class" values to and from names (string).
*/
Expand Down
9 changes: 2 additions & 7 deletions YUViewLib/src/playlistitem/playlistItemCompressedVideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,19 +360,14 @@ void playlistItemCompressedVideo::savePlaylist(QDomElement &root, const QDir &pl
{
auto filename = this->properties().name;

// Determine the relative path to the HEVC file. We save both in the playlist.
QUrl fileURL(filename);
fileURL.setScheme("file");
QString relativePath = playlistDir.relativeFilePath(filename);

YUViewDomElement d = root.ownerDocument().createElement("playlistItemCompressedVideo");

// Append the properties of the playlistItem
playlistItem::appendPropertiesToPlaylist(d);

// Append all the properties of the HEVC file (the path to the file. Relative and absolute)
d.appendProperiteChild("absolutePath", fileURL.toString());
d.appendProperiteChild("relativePath", relativePath);
d.appendProperiteChild("absolutePath", playlistDir.absoluteFilePath(filename));
d.appendProperiteChild("relativePath", playlistDir.relativeFilePath(filename));
d.appendProperiteChild("displayComponent",
QString::number(loadingDecoder ? loadingDecoder->getDecodeSignal() : -1));

Expand Down
16 changes: 5 additions & 11 deletions YUViewLib/src/playlistitem/playlistItemImageFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include <QImageReader>
#include <QPainter>
#include <QSettings>
#include <QUrl>

#include "common/functionsGui.h"
#include "filesource/FileSource.h"
Expand Down Expand Up @@ -85,19 +84,14 @@ void playlistItemImageFile::savePlaylist(QDomElement &root, const QDir &playlist
{
const auto filename = this->properties().name;

// Determine the relative path to the raw file. We save both in the playlist.
QUrl fileURL(filename);
fileURL.setScheme("file");
QString relativePath = playlistDir.relativeFilePath(filename);

YUViewDomElement d = root.ownerDocument().createElement("playlistItemImageFile");

// Append the properties of the playlistItem
playlistItem::appendPropertiesToPlaylist(d);

// Append all the properties of the raw file (the path to the file. Relative and absolute)
d.appendProperiteChild("absolutePath", fileURL.toString());
d.appendProperiteChild("relativePath", relativePath);
d.appendProperiteChild("absolutePath", playlistDir.absoluteFilePath(filename));
d.appendProperiteChild("relativePath", playlistDir.relativeFilePath(filename));

root.appendChild(d);
}
Expand All @@ -109,11 +103,11 @@ playlistItemImageFile::newplaylistItemImageFile(const YUViewDomElement &root,
const QString & playlistFilePath)
{
// Parse the DOM element. It should have all values of a playlistItemImageFile
QString absolutePath = root.findChildValue("absolutePath");
QString relativePath = root.findChildValue("relativePath");
auto absolutePath = root.findChildValue("absolutePath");
auto relativePath = root.findChildValue("relativePath");

// check if file with absolute path exists, otherwise check relative path
QString filePath =
auto filePath =
FileSource::getAbsPathFromAbsAndRel(playlistFilePath, absolutePath, relativePath);
if (filePath.isEmpty())
return nullptr;
Expand Down
10 changes: 2 additions & 8 deletions YUViewLib/src/playlistitem/playlistItemImageFileSequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

#include <QImageReader>
#include <QSettings>
#include <QUrl>

#include "common/functionsGui.h"
#include "filesource/FileSource.h"
Expand Down Expand Up @@ -199,14 +198,9 @@ void playlistItemImageFileSequence::savePlaylist(QDomElement &root, const QDir &
// Put a list of all input files into the playlist
for (int i = 0; i < imageFiles.length(); i++)
{
// Determine the relative path to the file. We save both in the playlist.
QUrl fileURL(imageFiles[i]);
fileURL.setScheme("file");
QString relativePath = playlistDir.relativeFilePath(imageFiles[i]);

// Append the relative and absolute path to the file
d.appendProperiteChild(QString("file%1_absolutePath").arg(i), fileURL.toString());
d.appendProperiteChild(QString("file%1_relativePath").arg(i), relativePath);
d.appendProperiteChild(QString("file%1_absolutePath").arg(i), playlistDir.absoluteFilePath(imageFiles[i]));
d.appendProperiteChild(QString("file%1_relativePath").arg(i), playlistDir.relativeFilePath(imageFiles[i]));
}

root.appendChild(d);
Expand Down
12 changes: 4 additions & 8 deletions YUViewLib/src/playlistitem/playlistItemRawFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include "playlistItemRawFile.h"

#include <QPainter>
#include <QUrl>
#include <QVBoxLayout>

#include "common/functions.h"
Expand Down Expand Up @@ -443,19 +442,16 @@ void playlistItemRawFile::createPropertiesWidget()

void playlistItemRawFile::savePlaylist(QDomElement &root, const QDir &playlistDir) const
{
// Determine the relative path to the raw file. We save both in the playlist.
QUrl fileURL(dataSource.getAbsoluteFilePath());
fileURL.setScheme("file");
auto relativePath = playlistDir.relativeFilePath(dataSource.getAbsoluteFilePath());
auto filename = dataSource.getAbsoluteFilePath();

auto d = YUViewDomElement(root.ownerDocument().createElement("playlistItemRawFile"));

// Append the properties of the playlistItem
playlistItem::appendPropertiesToPlaylist(d);

// Append all the properties of the raw file (the path to the file. Relative and absolute)
d.appendProperiteChild("absolutePath", fileURL.toString());
d.appendProperiteChild("relativePath", relativePath);
d.appendProperiteChild("absolutePath", playlistDir.absoluteFilePath(filename));
d.appendProperiteChild("relativePath", playlistDir.relativeFilePath(filename));
d.appendProperiteChild(std::string("type"), (rawFormat == raw_YUV) ? "YUV" : "RGB");

this->video->savePlaylist(d);
Expand All @@ -480,7 +476,7 @@ playlistItemRawFile *playlistItemRawFile::newplaylistItemRawFile(const YUViewDom

// We can still not be sure that the file really exists, but we gave our best to try to find it.
auto newFile = new playlistItemRawFile(filePath, {}, {}, type);

newFile->video->loadPlaylist(root);
playlistItem::loadPropertiesFromPlaylist(root, newFile);

Expand Down
15 changes: 5 additions & 10 deletions YUViewLib/src/playlistitem/playlistItemStatisticsFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

#include <QDebug>
#include <QTime>
#include <QUrl>
#include <QtConcurrent>
#include <cassert>
#include <iostream>
Expand Down Expand Up @@ -104,8 +103,8 @@ playlistItemStatisticsFile *playlistItemStatisticsFile::newplaylistItemStatistic
const YUViewDomElement &root, const QString &playlistFilePath, OpenMode openMode)
{
// Parse the DOM element. It should have all values of a playlistItemStatisticsFile
auto absolutePath = root.findChildValue("absolutePath");
auto relativePath = root.findChildValue("relativePath");
auto absolutePath = root.findChildValue("absolutePath");
auto relativePath = root.findChildValue("relativePath");

// check if file with absolute path exists, otherwise check relative path
auto filePath = FileSource::getAbsPathFromAbsAndRel(playlistFilePath, absolutePath, relativePath);
Expand Down Expand Up @@ -152,20 +151,16 @@ void playlistItemStatisticsFile::drawItem(QPainter *painter, int frameIdx, doubl

void playlistItemStatisticsFile::savePlaylist(QDomElement &root, const QDir &playlistDir) const
{
// Determine the relative path to the YUV file-> We save both in the playlist.
auto absolutePath = QFileInfo(this->prop.name).absoluteFilePath();
QUrl fileURL(absolutePath);
fileURL.setScheme("file");
auto relativePath = playlistDir.relativeFilePath(absolutePath);
auto filename = this->properties().name;

YUViewDomElement d = root.ownerDocument().createElement("playlistItemStatisticsFile");

// Append the properties of the playlistItem
playlistItem::appendPropertiesToPlaylist(d);

// Append all the properties of the YUV file (the path to the file-> Relative and absolute)
d.appendProperiteChild("absolutePath", fileURL.toString());
d.appendProperiteChild("relativePath", relativePath);
d.appendProperiteChild("absolutePath", playlistDir.absoluteFilePath(filename));
d.appendProperiteChild("relativePath", playlistDir.relativeFilePath(filename));

// Save the status of the statistics (which are shown, transparency ...)
this->statisticsData.savePlaylist(d);
Expand Down
6 changes: 3 additions & 3 deletions YUViewLib/src/ui/widgets/PlaylistTreeWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,10 @@ void PlaylistTreeWidget::dropEvent(QDropEvent *event)
if (event->mimeData()->hasUrls())
{
QStringList fileList;
const QList<QUrl> urls = event->mimeData()->urls();
const auto urls = event->mimeData()->urls();
for (auto &url : urls)
{
QString fileName = url.toLocalFile();
auto fileName = url.toLocalFile();
fileList.append(fileName);
}
event->acceptProposedAction();
Expand All @@ -233,7 +233,7 @@ void PlaylistTreeWidget::dropEvent(QDropEvent *event)
else
{
// get the list of the items that are about to be dragged
QList<QTreeWidgetItem *> dragItems = selectedItems();
auto dragItems = selectedItems();

// Actually move all the items
QTreeWidget::dropEvent(event);
Expand Down