[vlmc-devel] commit: Make the preview widget "promotable" in the designer. ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Sun Jun 27 23:06:26 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Sun Jun 27 21:47:52 2010 +0200| [bbba8ad3b6bcd96ef465835c979f602238b76812] | committer: Hugo Beauzée-Luyssen 

Make the preview widget "promotable" in the designer.

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

 src/Gui/MainWindow.cpp                |    6 +++-
 src/Gui/import/ImportController.cpp   |    9 +++----
 src/Gui/import/ImportController.h     |    1 -
 src/Gui/import/ui/ImportController.ui |    8 +++++-
 src/Gui/preview/PreviewWidget.cpp     |   42 ++++++++++++++++++---------------
 src/Gui/preview/PreviewWidget.h       |    3 +-
 6 files changed, 40 insertions(+), 29 deletions(-)

diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp
index 2c9d79c..950f70a 100644
--- a/src/Gui/MainWindow.cpp
+++ b/src/Gui/MainWindow.cpp
@@ -446,7 +446,8 @@ MainWindow::initializeDockWidgets( void )
 
     DockWidgetManager *dockManager = DockWidgetManager::getInstance();
 
-    m_clipPreview = new PreviewWidget( new ClipRenderer, this );
+    m_clipPreview = new PreviewWidget( this );
+    m_clipPreview->setRenderer( new ClipRenderer );
     dockManager->addDockedWidget( m_clipPreview,
                                   QT_TRANSLATE_NOOP( "DockWidgetManager", "Clip Preview" ),
                                   Qt::AllDockWidgetAreas,
@@ -455,7 +456,8 @@ MainWindow::initializeDockWidgets( void )
     KeyboardShortcutHelper* clipShortcut = new KeyboardShortcutHelper( "keyboard/mediapreview", this );
     connect( clipShortcut, SIGNAL( activated() ), m_clipPreview, SLOT( on_pushButtonPlay_clicked() ) );
 
-    m_projectPreview = new PreviewWidget( m_renderer, this );
+    m_projectPreview = new PreviewWidget( this );
+    m_projectPreview->setRenderer( m_renderer );
     dockManager->addDockedWidget( m_projectPreview,
                                   QT_TRANSLATE_NOOP( "DockWidgetManager", "Project Preview" ),
                                   Qt::AllDockWidgetAreas,
diff --git a/src/Gui/import/ImportController.cpp b/src/Gui/import/ImportController.cpp
index 6d7c708..b4396e0 100644
--- a/src/Gui/import/ImportController.cpp
+++ b/src/Gui/import/ImportController.cpp
@@ -53,7 +53,7 @@ ImportController::ImportController(QWidget *parent) :
     m_ui->setupUi(this);
     //The renderer will be deleted by the PreviewWidget
     m_clipRenderer = new ClipRenderer;
-    m_preview = new PreviewWidget( m_clipRenderer, m_ui->previewContainer );
+    m_ui->previewContainer->setRenderer( m_clipRenderer );
     m_stackNav = new StackViewController( m_ui->stackViewContainer );
     m_temporaryMedias = new MediaContainer;
     m_mediaListView = new MediaListView( m_stackNav, m_temporaryMedias );
@@ -107,7 +107,6 @@ ImportController::ImportController(QWidget *parent) :
 
 ImportController::~ImportController()
 {
-    delete m_preview;
     delete m_ui;
     delete m_stackNav;
     delete m_tag;
@@ -134,7 +133,7 @@ ImportController::clipSelection( Clip* clip )
     if ( m_currentUuid == uuid )
         return ;
     m_ui->metadataContainer->setWatchedClip( clip );
-    m_preview->stop();
+    m_ui->previewContainer->stop();
     m_currentUuid = uuid;
     m_tag->clipSelected( clip );
     emit clipSelected( clip );
@@ -209,7 +208,7 @@ ImportController::treeViewDoubleClicked( const QModelIndex& index )
 void
 ImportController::reject()
 {
-    m_preview->stop();
+    m_ui->previewContainer->stop();
     m_mediaListView->clear();
     m_temporaryMedias->clear();
     collapseAllButCurrentPath();
@@ -221,7 +220,7 @@ void
 ImportController::accept()
 {
     m_mediaListView->clear();
-    m_preview->stop();
+    m_ui->previewContainer->stop();
     collapseAllButCurrentPath();
     foreach ( Clip* clip, m_temporaryMedias->clips().values() )
         Library::getInstance()->addClip( clip );
diff --git a/src/Gui/import/ImportController.h b/src/Gui/import/ImportController.h
index 0162a4e..2dc1896 100644
--- a/src/Gui/import/ImportController.h
+++ b/src/Gui/import/ImportController.h
@@ -74,7 +74,6 @@ class ImportController : public QDialog
         void                        importMedia( const QString &filePath );
         void                        importDir( const QString &path );
         Ui::ImportController*       m_ui;
-        PreviewWidget*              m_preview;
         StackViewController*        m_stackNav;
         TagWidget*                  m_tag;
         MediaListView               *m_mediaListView;
diff --git a/src/Gui/import/ui/ImportController.ui b/src/Gui/import/ui/ImportController.ui
index 0a8f53b..075813b 100644
--- a/src/Gui/import/ui/ImportController.ui
+++ b/src/Gui/import/ui/ImportController.ui
@@ -111,7 +111,7 @@
        <item>
         <layout class="QVBoxLayout" name="verticalLayout_2">
          <item>
-          <widget class="QWidget" name="previewContainer" native="true">
+          <widget class="PreviewWidget" name="previewContainer" native="true">
            <property name="minimumSize">
             <size>
              <width>328</width>
@@ -157,6 +157,12 @@
    <header>ClipMetadataDisplayer.h</header>
    <container>1</container>
   </customwidget>
+  <customwidget>
+   <class>PreviewWidget</class>
+   <extends>QWidget</extends>
+   <header>PreviewWidget.h</header>
+   <container>1</container>
+  </customwidget>
  </customwidgets>
  <resources>
   <include location="../../../../ressources.qrc"/>
diff --git a/src/Gui/preview/PreviewWidget.cpp b/src/Gui/preview/PreviewWidget.cpp
index 3a42839..59da678 100644
--- a/src/Gui/preview/PreviewWidget.cpp
+++ b/src/Gui/preview/PreviewWidget.cpp
@@ -29,10 +29,9 @@
 
 #include <QMessageBox>
 
-PreviewWidget::PreviewWidget( GenericRenderer* genericRenderer, QWidget *parent ) :
+PreviewWidget::PreviewWidget( QWidget *parent ) :
     QWidget( parent ),
     m_ui( new Ui::PreviewWidget ),
-    m_renderer( genericRenderer ),
     m_previewStopped( true )
 {
     m_ui->setupUi( this );
@@ -45,22 +44,37 @@ PreviewWidget::PreviewWidget( GenericRenderer* genericRenderer, QWidget *parent
     m_videoPalette.setColor( QPalette::Window, QColor( Qt::black ) );
     m_ui->renderWidget->setPalette( m_videoPalette );
 
+    setAcceptDrops( false );
+
+    connect( m_ui->rulerWidget, SIGNAL( timeChanged(int,int,int,int) ),
+             m_ui->lcdNumber,   SLOT( setTime(int,int,int,int) ) );
+
+    connect( m_ui->pushButtonMarkerStart, SIGNAL( clicked() ), this, SLOT( markerStartClicked() ) );
+    connect( m_ui->pushButtonMarkerStop, SIGNAL( clicked() ), this, SLOT( markerStopClicked() ) );
+    connect( m_ui->pushButtonCreateClip, SIGNAL( clicked() ), this, SLOT( createNewClipFromMarkers() ) );
+}
+
+PreviewWidget::~PreviewWidget()
+{
+    delete m_renderer;
+    delete m_ui;
+}
+
+void
+PreviewWidget::setRenderer( GenericRenderer *renderer )
+{
+    m_renderer = renderer;
+
     // Hide markers and createClip buttons if we are not using a ClipRenderer
-    if ( !qobject_cast<ClipRenderer*>( genericRenderer ) )
+    if ( qobject_cast<ClipRenderer*>( renderer ) == NULL )
     {
         m_ui->pushButtonMarkerStart->hide();
         m_ui->pushButtonMarkerStop->hide();
         m_ui->pushButtonCreateClip->hide();
     }
-
     // Give the renderer to the ruler
     m_ui->rulerWidget->setRenderer( m_renderer );
 
-    setAcceptDrops( false );
-
-    connect( m_ui->rulerWidget, SIGNAL( timeChanged(int,int,int,int) ),
-             m_ui->lcdNumber,   SLOT( setTime(int,int,int,int) ) );
-
     m_renderer->setRenderWidget( m_ui->renderWidget );
 
     connect( m_renderer,     SIGNAL( stopped() ),               this,       SLOT( videoStopped() ) );
@@ -72,16 +86,6 @@ PreviewWidget::PreviewWidget( GenericRenderer* genericRenderer, QWidget *parent
     connect( m_ui->rulerWidget, SIGNAL( frameChanged(qint64, MainWorkflow::FrameChangedReason) ),
              m_renderer,       SLOT( previewWidgetCursorChanged(qint64) ) );
     connect( m_renderer, SIGNAL( error() ), this, SLOT( error() ) );
-
-    connect( m_ui->pushButtonMarkerStart, SIGNAL( clicked() ), this, SLOT( markerStartClicked() ) );
-    connect( m_ui->pushButtonMarkerStop, SIGNAL( clicked() ), this, SLOT( markerStopClicked() ) );
-    connect( m_ui->pushButtonCreateClip, SIGNAL( clicked() ), this, SLOT( createNewClipFromMarkers() ) );
-}
-
-PreviewWidget::~PreviewWidget()
-{
-    delete m_renderer;
-    delete m_ui;
 }
 
 void    PreviewWidget::changeEvent( QEvent *e )
diff --git a/src/Gui/preview/PreviewWidget.h b/src/Gui/preview/PreviewWidget.h
index 386276e..b444ac8 100644
--- a/src/Gui/preview/PreviewWidget.h
+++ b/src/Gui/preview/PreviewWidget.h
@@ -39,9 +39,10 @@ class   PreviewWidget : public QWidget
     Q_DISABLE_COPY( PreviewWidget )
 
 public:
-    explicit PreviewWidget( GenericRenderer* renderer, QWidget* parent = NULL );
+    explicit PreviewWidget( QWidget* parent = NULL );
     virtual ~PreviewWidget();
     const GenericRenderer*  getGenericRenderer() const;
+    void                    setRenderer( GenericRenderer *renderer );
 
 private:
     Ui::PreviewWidget*      m_ui;



More information about the Vlmc-devel mailing list