2014-11-19 02:23:05 +00:00
|
|
|
/***************************************************************************
|
2022-11-28 05:53:07 +02:00
|
|
|
* Copyright (C) 2022 by Ivailo Monev <xakepa10@gmail.com> *
|
2014-11-19 02:23:05 +00:00
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#include "snapshottaker.h"
|
|
|
|
|
2022-11-28 05:48:24 +02:00
|
|
|
#include <KFileItem>
|
2014-11-19 02:23:05 +00:00
|
|
|
|
2022-11-28 05:48:24 +02:00
|
|
|
SnapshotTaker::SnapshotTaker( const KUrl &url, QObject *parent, const QSize &size )
|
2014-11-19 02:23:05 +00:00
|
|
|
: QObject( parent )
|
2022-11-28 05:48:24 +02:00
|
|
|
, m_job( nullptr )
|
2014-11-19 02:23:05 +00:00
|
|
|
{
|
2022-11-28 05:48:24 +02:00
|
|
|
m_plugins.append(QString::fromLatin1("ffmpegthumbs"));
|
|
|
|
|
|
|
|
m_job = KIO::filePreview(
|
|
|
|
KFileItemList() << KFileItem(url, QString(), 0),
|
|
|
|
size,
|
|
|
|
&m_plugins
|
|
|
|
);
|
|
|
|
m_job->setScaleType(KIO::PreviewJob::Scaled);
|
|
|
|
connect(
|
|
|
|
m_job, SIGNAL(gotPreview(KFileItem,QPixmap)),
|
|
|
|
this, SLOT(slotPreview(KFileItem,QPixmap))
|
|
|
|
);
|
|
|
|
connect(
|
|
|
|
m_job, SIGNAL(failed(KFileItem)),
|
|
|
|
this, SLOT(slotFailed(KFileItem))
|
|
|
|
);
|
|
|
|
m_job->start();
|
2014-11-19 02:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SnapshotTaker::~SnapshotTaker()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-11-28 05:48:24 +02:00
|
|
|
void SnapshotTaker::slotPreview(const KFileItem& item, const QPixmap &preview)
|
2014-11-19 02:23:05 +00:00
|
|
|
{
|
2022-11-28 05:48:24 +02:00
|
|
|
Q_UNUSED(item);
|
|
|
|
if (!preview.isNull()) {
|
|
|
|
emit finished( preview.toImage() );
|
2014-11-19 02:23:05 +00:00
|
|
|
}
|
2022-11-28 05:48:24 +02:00
|
|
|
deleteLater();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SnapshotTaker::slotFailed(const KFileItem& item)
|
|
|
|
{
|
|
|
|
Q_UNUSED(item);
|
|
|
|
deleteLater();
|
2014-11-19 02:23:05 +00:00
|
|
|
}
|