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

Make the preview widget "promotable" in the designer.

parent 0dbdc2a3
......@@ -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,
......
......@@ -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 );
......
......@@ -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;
......
......@@ -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"/>
......
......@@ -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 )
......
......@@ -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;
......
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