[vlmc-devel] commit: Workspace: Don't copy the media by default. ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Sun Jun 20 23:50:35 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Sun Jun 20 23:48:40 2010 +0200| [984527e55838ff876d8b29e863c8b8e76102e6b2] | committer: Hugo Beauzée-Luyssen 

Workspace: Don't copy the media by default.

Adding a contextual menu to the MediaCellView so the action can be
triggered manually.

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=984527e55838ff876d8b29e863c8b8e76102e6b2
---

 src/Gui/library/MediaCellView.cpp |   21 +++++++++++++++++++++
 src/Gui/library/MediaCellView.h   |    1 +
 src/Project/Workspace.cpp         |    4 ++--
 src/Project/Workspace.h           |    3 ++-
 4 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/src/Gui/library/MediaCellView.cpp b/src/Gui/library/MediaCellView.cpp
index 4cc808a..b624b08 100644
--- a/src/Gui/library/MediaCellView.cpp
+++ b/src/Gui/library/MediaCellView.cpp
@@ -30,7 +30,9 @@
 #include "Media.h"
 #include "MetaDataManager.h"
 #include "MainWorkflow.h"
+#include "Workspace.h"
 
+#include <QMenu>
 #include <QMessageBox>
 #include <QTime>
 
@@ -261,3 +263,22 @@ MediaCellView::clip() const
 {
     return m_clip;
 }
+
+void
+MediaCellView::contextMenuEvent( QContextMenuEvent *event )
+{
+    QMenu menu( this );
+
+    //For now, as we only have the copy to workspace option, don't do anything if the clip
+    //is not the root clip. Obviously, this will have to be removed if other actions are to be added.
+    if ( m_clip->isRootClip() == false )
+        return ;
+
+    QAction* copyInWorkspace = menu.addAction( "Copy in workspace" );
+
+    QAction* selectedAction = menu.exec( event->globalPos() );
+    if ( selectedAction == NULL )
+        return ;
+    if ( copyInWorkspace == selectedAction )
+        Workspace::getInstance()->copyToWorkspace( m_clip->getMedia() );
+}
diff --git a/src/Gui/library/MediaCellView.h b/src/Gui/library/MediaCellView.h
index acba3b9..c55a493 100644
--- a/src/Gui/library/MediaCellView.h
+++ b/src/Gui/library/MediaCellView.h
@@ -66,6 +66,7 @@ protected:
     void                mouseDoubleClickEvent( QMouseEvent* );
     void                mousePressEvent( QMouseEvent* );
     void                mouseMoveEvent( QMouseEvent* );
+    void                contextMenuEvent( QContextMenuEvent * );
 
 public slots:
     void                deleteButtonClicked( QWidget *sender, QMouseEvent *event );
diff --git a/src/Project/Workspace.cpp b/src/Project/Workspace.cpp
index 126617b..32095ff 100644
--- a/src/Project/Workspace.cpp
+++ b/src/Project/Workspace.cpp
@@ -34,8 +34,8 @@ const QString   Workspace::workspacePrefix = "workspace://";
 
 Workspace::Workspace()
 {
-    connect( Library::getInstance(), SIGNAL( newClipLoaded( Clip* ) ),
-             this, SLOT( clipLoaded( Clip* ) ) );
+//    connect( Library::getInstance(), SIGNAL( newClipLoaded( Clip* ) ),
+//             this, SLOT( clipLoaded( Clip* ) ) );
 }
 
 void
diff --git a/src/Project/Workspace.h b/src/Project/Workspace.h
index 994237a..a480fa4 100644
--- a/src/Project/Workspace.h
+++ b/src/Project/Workspace.h
@@ -38,11 +38,12 @@ class Workspace : public QObject, public Singleton<Workspace>
 
         static bool                 isInProjectDir( const Media* media );
         static QString              pathInProjectDir( const Media* media );
+
+        void    copyToWorkspace( Media* media );
     private:
         Workspace();
         ~Workspace(){}
 
-        void    copyToWorkspace( Media* media );
     public slots:
         void    clipLoaded( Clip* clip );
     private slots:



More information about the Vlmc-devel mailing list