void MainWindow::loadProject(Project_sV *project)
{
    Q_ASSERT(project != NULL);
    resetDialogs();

    Project_sV *projTemp = NULL;
    if (m_project != NULL) {
        projTemp = m_project;
    }
    m_project = project;
    m_wCanvas->load(m_project);
    m_wRenderPreview->load(m_project);
    updateWindowTitle();

    if (projTemp != NULL) {
        // Do not delete the old project object earlier to avoid segfaults
        // (may still be used in the ShutterFunction dialog e.g.)
        delete projTemp;
    }

    connect(m_project->frameSource(), SIGNAL(signalNextTask(QString,int)), this, SLOT(slotNewFrameSourceTask(QString,int)));
    connect(m_project->frameSource(), SIGNAL(signalAllTasksFinished()), this, SLOT(slotFrameSourceTasksFinished()));

    m_project->frameSource()->initialize();
    
}
void MainWindow::slotNewFrameSourceTask(const QString taskDescription, int taskSize)
{
    if (m_progressDialog == NULL) {
        m_progressDialog = new ProgressDialog(this);
        m_progressDialog->setWindowTitle(tr("Frame extraction progress"));
        connect(m_project->frameSource(), SIGNAL(signalNextTask(QString,int)), m_progressDialog, SLOT(slotNextTask(QString,int)));
        connect(m_project->frameSource(), SIGNAL(signalTaskProgress(int)), m_progressDialog, SLOT(slotTaskProgress(int)));
        connect(m_project->frameSource(), SIGNAL(signalTaskItemDescription(QString)), m_progressDialog, SLOT(slotTaskItemDescription(QString)));
        connect(m_project->frameSource(), SIGNAL(signalAllTasksFinished()), m_progressDialog, SLOT(slotAllTasksFinished()));
        connect(m_progressDialog, SIGNAL(signalAbortTask()), m_project->frameSource(), SLOT(slotAbortInitialization()));
    }
/// \todo What if image missing?
void ImagesFrameSource_sV::slotContinueInitialization()
{
    emit signalNextTask("Creating preview images from the input images", m_imagesList.size());
    for (; m_nextFrame < m_imagesList.size(); m_nextFrame++) {

        QString outputFile(framePath(m_nextFrame, FrameSize_Small));
        if (QFile(outputFile).exists()) {
            emit signalTaskItemDescription("Resized image already exists for " + QFileInfo(m_imagesList.at(m_nextFrame)).fileName());
        } else {
            emit signalTaskItemDescription(QString("Re-sizing image %1 to:\n%2")
                                           .arg(QFileInfo(m_imagesList.at(m_nextFrame)).fileName())
                                           .arg(outputFile));
            QImage small = QImage(m_imagesList.at(m_nextFrame)).scaled(m_sizeSmall, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
            small.save(outputFile);
        }

        emit signalTaskProgress(m_nextFrame);
        if (m_stopInitialization) {
            break;
        }
    }
    m_initialized = true;
    emit signalAllTasksFinished();
}
void EmptyFrameSource_sV::initialize()
{
    emit signalAllTasksFinished();
}