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

Merge pull request #2 from sailfishos-applications/rectify-webdav #59

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 1 addition & 1 deletion qml/pages/FileDelegate.qml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import QtQuick 2.0
import Sailfish.Silica 1.0
import FileCase 1.0
import org.nemomobile.thumbnailer 1.0
import Nemo.Thumbnailer 1.0

ListItem {

Expand Down
4 changes: 2 additions & 2 deletions qml/pages/FileInfo.qml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import QtQuick 2.0
import Sailfish.Silica 1.0
import FileCase 1.0
import org.nemomobile.thumbnailer 1.0
import QtMultimedia 5.0
import Nemo.Thumbnailer 1.0

Page {
id: infoPage
Expand Down Expand Up @@ -108,7 +108,7 @@ Page {
MenuItem {
text: isPackage && !cloudFile? qsTr("Install") : qsTr("Open")
visible: !cloudFile && !isTextFile
onClicked: utilities.openFile(fileInfo.data.path + "/" + fileInfo.data.name)
onClicked: Qt.openUrlExternally(fileInfo.data.path + "/" + fileInfo.data.name)
}

MenuItem {
Expand Down
37 changes: 20 additions & 17 deletions src/thumbgenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <QImage>
#include <QSettings>
#include <QDebug>

#include <QProcess>
#include <QLibrary>

typedef QImage (*CreateThumbnailFunc)(const QString &fileName, const QSize &requestedSize, bool crop);
Expand Down Expand Up @@ -94,28 +94,31 @@ void ThumbGenerator::generate(QString filename)
file.replace("#","%2523");
file.replace(",","%2C");
file.replace(" ","%20");
file = "file://"+file;
file = "file://" + file;
md.addData(file.toUtf8());
QString tf = Config::getHome() + "/.thumbnails/whatsup/"+ QString(md.result().toHex().constData()) + ".jpeg";
QString tf = Config::getHome() + "/.thumbnails/whatsup/" + QString(md.result().toHex().constData()) + ".jpeg";
thumb = tf;

if ( !QFileInfo(tf).exists() )
if (!QFileInfo(thumb).exists())
{
//Utilities::logData("Generating video thumbnail for " + fileInfo.absoluteFilePath());
//VideoThumbnailer *thumbnailer = new VideoThumbnailer;
//QImage result = thumbnailer->createThumbnail(filename.remove("file://"), QSize(170,170), true);
QImage image;

static CreateThumbnailFunc createThumbnail = (CreateThumbnailFunc)QLibrary::resolve(
QLatin1String("/usr/lib/qt5/qml/org/nemomobile/thumbnailer/thumbnailers/libvideothumbnailer.so"), "createThumbnail");

if (createThumbnail) {
image = createThumbnail(filename, QSize(800,800), false);
QString command = "ffmpeg"; //used to replace "/usr/lib/qt5/qml/org/nemomobile/thumbnailer/thumbnailers/libvideothumbnailer.so" solution
QStringList arguments;
arguments << "-i" << fileInfo.absoluteFilePath()
<< "-ss" << "00:00:01" // Arbitrary time can be anything (1 second here)
<< "-vframes" << "1"
<< "-q:v" << "2" // Quality factor. Lower is better. Higher gives lower bitrate. 2 is 1735 kb/s Check https://ffmpeg.org/ffmpeg-codecs.html#Options-22
<< thumb;

QProcess process;
process.start(command, arguments);
process.waitForFinished();

if (process.exitCode() != 0) {
//Need to test what might go wrong..should add .close()
qDebug() << "ffmpeg ERROR: " << file;
}

image.save( tf, "JPEG" );
}
emit imgLoaded(tf);
emit imgLoaded(thumb);
}

imagesToProcess.removeAt(0);
Expand Down
1 change: 1 addition & 0 deletions src/utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ void Utilities::removeFromBookmarks(QString folder)

void Utilities::openFile(QString file)
{
//This is no longer needed since we will be using Qt.openUrlExternally keeping it here untill final testing
QProcess * process = new QProcess();
process->start(QString("xdg-open \"%2\"").arg(file));

Expand Down