kde-playground/kimagesorter/image_loader.cpp

54 lines
1.5 KiB
C++
Raw Permalink Normal View History

/*
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.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
---
Copyright (C) 2011, Dmitry Chernov diman4ik.chernov@gmail.com
*/
#include "image_loader.h"
#include "picture_widget.h"
ImageLoaderThread::ImageLoaderThread( QObject* parent ) : QThread(parent)
{
m_parent = parent;
start();
}
ImageLoaderThread::~ImageLoaderThread()
{
quit();
wait();
}
void ImageLoaderThread::run()
{
ImageLoader* il = new ImageLoader();
connect( ( PictureWidget* )m_parent, SIGNAL( load( const QString& ) ), il, SLOT( load( const QString& ) ) );
connect( il, SIGNAL( imageLoaded( QImage ) ), ( PictureWidget* )m_parent, SLOT( imageLoaded( QImage ) ) );
exec();
}
ImageLoader::ImageLoader( QObject* parent ) : QObject(parent)
{}
void ImageLoader::load( const QString& name )
{
emit( imageLoaded( QImage(name) ) );
}