Commit eaffc365 authored by Ludovic Fauvet's avatar Ludovic Fauvet

GUI: Link the dock widgets with their menu action

parent 6566340f
......@@ -29,10 +29,10 @@ DockWidgetManager *DockWidgetManager::m_instance = 0;
DockWidgetManager *DockWidgetManager::instance( QObject *parent )
{
if (m_instance == 0)
if ( !m_instance )
m_instance = new DockWidgetManager( parent );
return (m_instance);
return m_instance;
}
void DockWidgetManager::setMainWindow( MainWindow *mainWin )
......@@ -40,14 +40,15 @@ void DockWidgetManager::setMainWindow( MainWindow *mainWin )
m_mainWin = mainWin;
}
void DockWidgetManager::addDockedWidget( QWidget *widget,
QDockWidget* DockWidgetManager::addDockedWidget( QWidget *widget,
const QString &qs_name,
Qt::DockWidgetAreas areas,
QDockWidget::DockWidgetFeature features,
Qt::DockWidgetArea startArea)
Qt::DockWidgetArea startArea,
QAction* action )
{
if ( m_dockWidgets.contains( qs_name ) )
return ;
return NULL;
QDockWidget* dock = new QDockWidget( tr( qs_name.toStdString().c_str() ), m_mainWin );
......@@ -58,6 +59,17 @@ void DockWidgetManager::addDockedWidget( QWidget *widget,
m_mainWin->addDockWidget( startArea, dock );
m_mainWin->registerWidgetInViewMenu( dock );
widget->show();
if ( action )
{
// Link the dock visibility with the menu
connect( action, SIGNAL( toggled(bool) ),
dock, SLOT( setVisible(bool) ) );
connect( dock, SIGNAL( visibilityChanged(bool) ),
action, SLOT( setChecked(bool) ) );
}
return dock;
}
......
......@@ -39,11 +39,12 @@ class DockWidgetManager : public QObject
public:
static DockWidgetManager *instance( QObject *parent = 0 );
void setMainWindow( MainWindow *mainWin );
void addDockedWidget( QWidget *widget,
QDockWidget* addDockedWidget( QWidget *widget,
const QString &qs_name,
Qt::DockWidgetAreas areas,
QDockWidget::DockWidgetFeature features,
Qt::DockWidgetArea startArea );
Qt::DockWidgetArea startArea,
QAction* action = 0 );
protected:
//virtual void changeEvent( QEvent *e );
......
......@@ -111,7 +111,8 @@ void MainWindow::setupLibrary()
tr( "Media Library" ),
Qt::AllDockWidgetAreas,
QDockWidget::AllDockWidgetFeatures,
Qt::LeftDockWidgetArea );
Qt::LeftDockWidgetArea,
m_ui.actionMedia_library );
//Connecting GUI and Frontend :
connect( libraryWidget,
......@@ -236,31 +237,36 @@ void MainWindow::initializeDockWidgets( void )
setCentralWidget( m_timeline );
DockWidgetManager *dockManager = DockWidgetManager::instance();
dockManager->addDockedWidget( new FileBrowser( this ),
tr( "FileBrowser" ),
Qt::AllDockWidgetAreas,
QDockWidget::AllDockWidgetFeatures,
Qt::TopDockWidgetArea);
Qt::TopDockWidgetArea,
m_ui.actionFile_browser );
m_clipPreview = new PreviewWidget( new ClipRenderer, this );
dockManager->addDockedWidget( m_clipPreview,
tr( "Clip Preview" ),
Qt::AllDockWidgetAreas,
QDockWidget::AllDockWidgetFeatures,
Qt::TopDockWidgetArea );
Qt::TopDockWidgetArea,
m_ui.actionClip_preview );
m_projectPreview = new PreviewWidget( new WorkflowRenderer(), this );
dockManager->addDockedWidget( m_projectPreview,
tr( "Project Preview" ),
Qt::AllDockWidgetAreas,
QDockWidget::AllDockWidgetFeatures,
Qt::TopDockWidgetArea );
Qt::TopDockWidgetArea,
m_ui.actionProject_preview );
dockManager->addDockedWidget( UndoStack::getInstance( this ),
tr( "History" ),
Qt::AllDockWidgetAreas,
QDockWidget::AllDockWidgetFeatures,
Qt::LeftDockWidgetArea );
Qt::LeftDockWidgetArea,
m_ui.actionUndoRedo );
setupLibrary();
m_metaDataManager = MetaDataManager::getInstance();
}
......
......@@ -27,7 +27,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
<height>21</height>
<height>24</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
......@@ -67,8 +67,11 @@
<property name="title">
<string>Window</string>
</property>
<addaction name="actionMedia_Library"/>
<addaction name="actionPreview"/>
<addaction name="actionFile_browser"/>
<addaction name="actionMedia_library"/>
<addaction name="actionProject_preview"/>
<addaction name="actionClip_preview"/>
<addaction name="actionUndoRedo"/>
</widget>
<widget class="QMenu" name="menuHelp">
<property name="title">
......@@ -110,15 +113,15 @@
<string>Preferences</string>
</property>
</action>
<action name="actionMedia_Library">
<action name="actionMedia_library">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Media Library</string>
<string>Media library</string>
</property>
</action>
<action name="actionPreview">
<action name="actionProject_preview">
<property name="checkable">
<bool>true</bool>
</property>
......@@ -126,7 +129,7 @@
<bool>false</bool>
</property>
<property name="text">
<string>Preview</string>
<string>Project preview</string>
</property>
</action>
<action name="actionTranscode_File">
......@@ -176,6 +179,30 @@
<string>Save</string>
</property>
</action>
<action name="actionFile_browser">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>File browser</string>
</property>
</action>
<action name="actionClip_preview">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Clip preview</string>
</property>
</action>
<action name="actionUndoRedo">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Undo/Redo</string>
</property>
</action>
</widget>
<resources>
<include location="../../../ressources.qrc"/>
......
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