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

MainWindow: Fixing dock widget parenting.

This prevents the widget to be blank when undocked.
parent 2f227018
......@@ -49,28 +49,30 @@ DockWidgetManager::setMainWindow( MainWindow *mainWin )
}
QDockWidget*
DockWidgetManager::addDockedWidget( QWidget *widget,
const char *qs_name,
Qt::DockWidgetAreas areas,
QDockWidget::DockWidgetFeature features,
Qt::DockWidgetArea startArea)
DockWidgetManager::createDockedWidget( const char *qs_name,
Qt::DockWidgetAreas areas,
QDockWidget::DockWidgetFeature features )
{
if ( m_dockWidgets.contains( qs_name ) )
return NULL;
QDockWidget* dock = new QDockWidget( tr( qs_name ), m_mainWin );
m_dockWidgets.insert( qs_name, dock );
dock->setObjectName( QString( "docked_" ) + qs_name );
dock->setWidget( widget );
dock->setAllowedAreas( areas );
dock->setFeatures( features );
m_mainWin->addDockWidget( startArea, dock );
m_mainWin->registerWidgetInWindowMenu( dock );
widget->show();
m_dockWidgets.insert( qs_name, dock );
return dock;
}
void
DockWidgetManager::addDockedWidget( QDockWidget *dockWidget, QWidget *containedWidget, Qt::DockWidgetArea startArea )
{
dockWidget->setWidget( containedWidget );
m_mainWin->addDockWidget( startArea, dockWidget );
m_mainWin->registerWidgetInWindowMenu( dockWidget );
}
void
DockWidgetManager::retranslateUi()
{
......
......@@ -36,25 +36,23 @@ class MainWindow;
class DockWidgetManager : public QObject, public QSingleton<DockWidgetManager>
{
Q_OBJECT
Q_DISABLE_COPY( DockWidgetManager );
public:
static DockWidgetManager *instance( QObject *parent = 0 );
void setMainWindow( MainWindow *mainWin );
QDockWidget* addDockedWidget( QWidget *widget,
const char *qs_name,
Qt::DockWidgetAreas areas,
QDockWidget::DockWidgetFeature features,
Qt::DockWidgetArea startArea );
void retranslateUi();
void setMainWindow( MainWindow *mainWin );
QDockWidget* createDockedWidget( const char *qs_name,
Qt::DockWidgetAreas areas,
QDockWidget::DockWidgetFeature features );
void addDockedWidget( QDockWidget *dockWidget, QWidget *containedWidget,
Qt::DockWidgetArea startArea );
void retranslateUi();
private:
explicit DockWidgetManager( QObject *parent = 0 );
virtual ~DockWidgetManager();
DockWidgetManager(const DockWidgetManager &);
DockWidgetManager & operator = ( const DockWidgetManager & );
MainWindow *m_mainWin;
QMap<const char*, QDockWidget*> m_dockWidgets;
MainWindow *m_mainWin;
QMap<const char*, QDockWidget*> m_dockWidgets;
friend class QSingleton<DockWidgetManager>;
};
......
......@@ -411,10 +411,6 @@ MainWindow::createStatusBar()
void
MainWindow::initializeDockWidgets( void )
{
m_effectsList = new EffectsListView( this );
m_effectsList->setType( Effect::Filter );
EffectsEngine::getInstance()->loadEffects();
m_renderer = new WorkflowRenderer();
m_renderer->initializeRenderer();
m_timeline = new Timeline( m_renderer, this );
......@@ -422,60 +418,88 @@ MainWindow::initializeDockWidgets( void )
m_timeline->show();
setCentralWidget( m_timeline );
m_clipPreview = new PreviewWidget( this );
m_clipPreview->setRenderer( new ClipRenderer );
m_importController = new ImportController();
KeyboardShortcutHelper* clipShortcut = new KeyboardShortcutHelper( "keyboard/mediapreview", this );
connect( clipShortcut, SIGNAL( activated() ), m_clipPreview, SLOT( on_pushButtonPlay_clicked() ) );
setupEffectsList();
setupClipPreview();
setupProjectPreview();
//Clip renderer must exist before this method is called, as it connects the library with the renderer.
setupLibrary();
setupUndoRedoWidget();
}
m_projectPreview = new PreviewWidget( this );
m_projectPreview->setRenderer( m_renderer );
KeyboardShortcutHelper* renderShortcut = new KeyboardShortcutHelper( "keyboard/renderpreview", this );
connect( renderShortcut, SIGNAL( activated() ), m_projectPreview, SLOT( on_pushButtonPlay_clicked() ) );
void
MainWindow::setupUndoRedoWidget()
{
QDockWidget *dockedWidget = DockWidgetManager::getInstance()->createDockedWidget(
QT_TRANSLATE_NOOP( "DockWidgetManager", "History" ),
Qt::AllDockWidgetAreas,
QDockWidget::AllDockWidgetFeatures );
QWidget *undoRedoWidget = UndoStack::getInstance( dockedWidget );
DockWidgetManager::getInstance()->addDockedWidget( dockedWidget, undoRedoWidget, Qt::LeftDockWidgetArea );
}
m_importController = new ImportController();
void
MainWindow::setupEffectsList()
{
QDockWidget *dockedWidget = DockWidgetManager::getInstance()->createDockedWidget(
QT_TRANSLATE_NOOP( "DockWidgetManager", "Effects List" ),
Qt::AllDockWidgetAreas,
QDockWidget::AllDockWidgetFeatures );
m_effectsList = new EffectsListView( dockedWidget );
m_effectsList->setType( Effect::Filter );
EffectsEngine::getInstance()->loadEffects();
DockWidgetManager::getInstance()->addDockedWidget( dockedWidget, m_effectsList, Qt::LeftDockWidgetArea );
}
void
MainWindow::setupLibrary()
{
const ClipRenderer* clipRenderer = qobject_cast<const ClipRenderer*>( m_clipPreview->getGenericRenderer() );
Q_ASSERT( clipRenderer != NULL );
m_mediaLibrary = new MediaLibrary( this );
QDockWidget *dockedLibrary = DockWidgetManager::getInstance()->createDockedWidget(
QT_TRANSLATE_NOOP( "DockWidgetManager", "Media Library" ),
Qt::AllDockWidgetAreas,
QDockWidget::AllDockWidgetFeatures );
m_mediaLibrary = new MediaLibrary( dockedLibrary );
connect( m_mediaLibrary, SIGNAL( clipSelected( Clip* ) ),
clipRenderer, SLOT( setClip( Clip* ) ) );
connect( m_mediaLibrary, SIGNAL( importRequired() ),
this, SLOT( on_actionImport_triggered() ) );
connect( Library::getInstance(), SIGNAL( clipRemoved( const QUuid& ) ),
clipRenderer, SLOT( clipUnloaded( const QUuid& ) ) );
setupDockedWidgets();
DockWidgetManager::getInstance()->addDockedWidget( dockedLibrary, m_mediaLibrary, Qt::LeftDockWidgetArea );
}
void
MainWindow::setupDockedWidgets()
MainWindow::setupClipPreview()
{
DockWidgetManager *dockManager = DockWidgetManager::getInstance();
QDockWidget *dockedWidget = DockWidgetManager::getInstance()->createDockedWidget(
QT_TRANSLATE_NOOP( "DockWidgetManager", "Clip Preview" ),
Qt::AllDockWidgetAreas,
QDockWidget::AllDockWidgetFeatures );
m_clipPreview = new PreviewWidget( dockedWidget );
m_clipPreview->setRenderer( new ClipRenderer );
dockManager->addDockedWidget( m_mediaLibrary, QT_TRANSLATE_NOOP( "DockWidgetManager", "Media Library" ),
Qt::AllDockWidgetAreas,
QDockWidget::AllDockWidgetFeatures,
Qt::TopDockWidgetArea );
dockManager->addDockedWidget( m_clipPreview,
QT_TRANSLATE_NOOP( "DockWidgetManager", "Clip Preview" ),
Qt::AllDockWidgetAreas,
QDockWidget::AllDockWidgetFeatures,
Qt::TopDockWidgetArea );
dockManager->addDockedWidget( m_projectPreview,
QT_TRANSLATE_NOOP( "DockWidgetManager", "Project Preview" ),
Qt::AllDockWidgetAreas,
QDockWidget::AllDockWidgetFeatures,
Qt::TopDockWidgetArea );
dockManager->addDockedWidget( m_effectsList,
QT_TRANSLATE_NOOP( "DockWidgetManager", "Effects List" ),
Qt::AllDockWidgetAreas,
QDockWidget::AllDockWidgetFeatures,
Qt::LeftDockWidgetArea );
dockManager->addDockedWidget( UndoStack::getInstance( this ),
QT_TRANSLATE_NOOP( "DockWidgetManager", "History" ),
Qt::AllDockWidgetAreas,
QDockWidget::AllDockWidgetFeatures,
Qt::LeftDockWidgetArea );
KeyboardShortcutHelper* clipShortcut = new KeyboardShortcutHelper( "keyboard/mediapreview", this );
connect( clipShortcut, SIGNAL( activated() ), m_clipPreview, SLOT( on_pushButtonPlay_clicked() ) );
DockWidgetManager::getInstance()->addDockedWidget( dockedWidget, m_clipPreview, Qt::TopDockWidgetArea );
}
void
MainWindow::setupProjectPreview()
{
QDockWidget *dockedWidget = DockWidgetManager::getInstance()->createDockedWidget(
QT_TRANSLATE_NOOP( "DockWidgetManager", "Project Preview" ),
Qt::AllDockWidgetAreas,
QDockWidget::AllDockWidgetFeatures );
m_projectPreview = new PreviewWidget( dockedWidget );
m_projectPreview->setRenderer( m_renderer );
KeyboardShortcutHelper* renderShortcut = new KeyboardShortcutHelper( "keyboard/renderpreview", this );
connect( renderShortcut, SIGNAL( activated() ), m_projectPreview, SLOT( on_pushButtonPlay_clicked() ) );
DockWidgetManager::getInstance()->addDockedWidget( dockedWidget, m_projectPreview, Qt::TopDockWidgetArea );
}
void
......
......@@ -64,7 +64,6 @@ protected:
private:
void initializeDockWidgets( void );
void checkFolders();
void setupDockedWidgets();
void createStatusBar();
void createNotificationZone();
void createGlobalPreferences();
......@@ -73,6 +72,11 @@ private:
void loadVlmcPreferences( const QString& subPart );
void loadGlobalProxySettings();
void initToolbar();
void setupLibrary();
void setupClipPreview();
void setupProjectPreview();
void setupEffectsList();
void setupUndoRedoWidget();
#ifdef WITH_CRASHBUTTON
void setupCrashTester();
#endif
......
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