Commit dcfdb53e authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Workspace: Check if there's a current workspace before coying files in it.

parent 22c35342
...@@ -25,6 +25,7 @@ SET(VLMC_SRCS ...@@ -25,6 +25,7 @@ SET(VLMC_SRCS
Renderer/GenericRenderer.cpp Renderer/GenericRenderer.cpp
Renderer/WorkflowFileRenderer.cpp Renderer/WorkflowFileRenderer.cpp
Renderer/WorkflowRenderer.cpp Renderer/WorkflowRenderer.cpp
Tools/ErrorHandler.cpp
Tools/Pool.hpp Tools/Pool.hpp
Tools/QSingleton.hpp Tools/QSingleton.hpp
Tools/Singleton.hpp Tools/Singleton.hpp
...@@ -67,6 +68,7 @@ SET (VLMC_HDRS ...@@ -67,6 +68,7 @@ SET (VLMC_HDRS
Renderer/GenericRenderer.h Renderer/GenericRenderer.h
Renderer/WorkflowFileRenderer.h Renderer/WorkflowFileRenderer.h
Renderer/WorkflowRenderer.h Renderer/WorkflowRenderer.h
Tools/ErrorHandler.h
Tools/VlmcDebug.h Tools/VlmcDebug.h
Workflow/AudioClipWorkflow.h Workflow/AudioClipWorkflow.h
Workflow/ClipWorkflow.h Workflow/ClipWorkflow.h
......
...@@ -280,5 +280,11 @@ MediaCellView::contextMenuEvent( QContextMenuEvent *event ) ...@@ -280,5 +280,11 @@ MediaCellView::contextMenuEvent( QContextMenuEvent *event )
if ( selectedAction == NULL ) if ( selectedAction == NULL )
return ; return ;
if ( copyInWorkspace == selectedAction ) if ( copyInWorkspace == selectedAction )
Workspace::getInstance()->copyToWorkspace( m_clip->getMedia() ); {
if ( Workspace::getInstance()->copyToWorkspace( m_clip->getMedia() ) == false )
{
QMessageBox::warning( NULL, tr( "Can't copy to workspace" ),
tr( "Can't copy this media to workspace: %1" ).arg( Workspace::getInstance()->lastError() ) );
}
}
} }
...@@ -46,9 +46,14 @@ Workspace::~Workspace() ...@@ -46,9 +46,14 @@ Workspace::~Workspace()
delete m_mediasToCopyMutex; delete m_mediasToCopyMutex;
} }
void bool
Workspace::copyToWorkspace( Media *media ) Workspace::copyToWorkspace( Media *media )
{ {
if ( VLMC_PROJECT_GET_STRING("general/Workspace").length() == 0 )
{
setError( "There is no current workspace. Please create a project first.");
return false;
}
QMutexLocker lock( m_mediasToCopyMutex ); QMutexLocker lock( m_mediasToCopyMutex );
if ( m_copyInProgress == true ) if ( m_copyInProgress == true )
...@@ -64,6 +69,7 @@ Workspace::copyToWorkspace( Media *media ) ...@@ -64,6 +69,7 @@ Workspace::copyToWorkspace( Media *media )
startCopyWorker( media ); startCopyWorker( media );
} }
} }
return true;
} }
void void
......
...@@ -23,18 +23,20 @@ ...@@ -23,18 +23,20 @@
#ifndef WORKSPACE_H #ifndef WORKSPACE_H
#define WORKSPACE_H #define WORKSPACE_H
#include <QObject> #include "Singleton.hpp"
#include "ErrorHandler.h"
#include <QMutex> #include <QMutex>
#include <QObject>
#include <QQueue> #include <QQueue>
#include "Singleton.hpp"
class Clip; class Clip;
class Media; class Media;
class QFileInfo; class QFileInfo;
class Workspace : public QObject, public Singleton<Workspace> class Workspace : public QObject, public Singleton<Workspace>, public ErrorHandler
{ {
Q_OBJECT Q_OBJECT
...@@ -46,7 +48,7 @@ class Workspace : public QObject, public Singleton<Workspace> ...@@ -46,7 +48,7 @@ class Workspace : public QObject, public Singleton<Workspace>
static bool isInProjectDir( const Media *media ); static bool isInProjectDir( const Media *media );
static QString pathInProjectDir( const Media* media ); static QString pathInProjectDir( const Media* media );
void copyToWorkspace( Media* media ); bool copyToWorkspace( Media* media );
void copyAllToWorkspace(); void copyAllToWorkspace();
private: private:
Workspace(); Workspace();
......
/*****************************************************************************
* ErrorHandler.cpp: Manage errors.
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzée-Luyssen <beauze.h@gmail.com>
*
* 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.
*****************************************************************************/
#include "ErrorHandler.h"
QString
ErrorHandler::lastError()
{
QString ret = m_lastError;
resetError();
return ret;
}
bool
ErrorHandler::isInErrorState() const
{
return m_lastError.size() > 0;
}
void
ErrorHandler::resetError()
{
m_lastError.clear();
}
void
ErrorHandler::setError( const QString &error )
{
m_lastError = error;
}
/*****************************************************************************
* ErrorHandler.h: Manage errors.
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzée-Luyssen <beauze.h@gmail.com>
*
* 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.
*****************************************************************************/
#ifndef ERRORHANDLER_H
#define ERRORHANDLER_H
#include <QString>
class ErrorHandler
{
public:
QString lastError();
bool isInErrorState() const;
void resetError();
protected:
void setError( const QString& error );
private:
QString m_lastError;
};
#endif // ERRORHANDLER_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment