2014-11-19 02:23:05 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2012 by Tobias Koening <tokoe@kde.org> *
|
|
|
|
* *
|
|
|
|
* 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"
|
|
|
|
|
|
|
|
#include <QtGui/QImage>
|
|
|
|
|
2015-01-03 02:00:01 +00:00
|
|
|
#include <KUrl>
|
|
|
|
|
2014-11-19 02:23:05 +00:00
|
|
|
SnapshotTaker::SnapshotTaker( const QString &url, QObject *parent )
|
|
|
|
: QObject( parent )
|
2016-03-31 06:40:57 +00:00
|
|
|
, m_player( new KMediaPlayer )
|
2014-11-19 02:23:05 +00:00
|
|
|
{
|
2021-02-26 09:57:27 +02:00
|
|
|
m_player->setPlayerID("okularpart_snapshot");
|
2016-03-31 06:40:57 +00:00
|
|
|
m_player->load( url );
|
2014-11-19 02:23:05 +00:00
|
|
|
m_player->hide();
|
|
|
|
|
2016-03-31 06:40:57 +00:00
|
|
|
connect(m_player, SIGNAL(paused(bool)),
|
|
|
|
this, SLOT(stateChanged(bool)));
|
2014-11-19 02:23:05 +00:00
|
|
|
|
|
|
|
m_player->play();
|
|
|
|
}
|
|
|
|
|
|
|
|
SnapshotTaker::~SnapshotTaker()
|
|
|
|
{
|
|
|
|
m_player->stop();
|
|
|
|
delete m_player;
|
|
|
|
}
|
|
|
|
|
2016-03-31 06:40:57 +00:00
|
|
|
void SnapshotTaker::stateChanged(bool paused)
|
2014-11-19 02:23:05 +00:00
|
|
|
{
|
2016-03-31 06:40:57 +00:00
|
|
|
if (paused) {
|
|
|
|
QPixmap pixmap = QPixmap::grabWidget(m_player);
|
|
|
|
if (!pixmap.isNull())
|
|
|
|
emit finished( pixmap.toImage() );
|
2014-11-19 02:23:05 +00:00
|
|
|
|
|
|
|
m_player->stop();
|
|
|
|
deleteLater();
|
|
|
|
}
|
|
|
|
}
|