Commit fc61d488 authored by Clement CHAVANCE's avatar Clement CHAVANCE

DockWidgetManager is now a singleton

parent 679fe222
......@@ -22,9 +22,19 @@
#include "DockWidgetManager.h"
DockWidgetManager::DockWidgetManager( QMainWindow* mainWin )
: m_mainWin(mainWin)
DockWidgetManager *DockWidgetManager::m_instance = 0;
DockWidgetManager *DockWidgetManager::instance()
{
if (m_instance == 0)
m_instance = new DockWidgetManager();
return (m_instance);
}
void DockWidgetManager::setMainWindow( QMainWindow *mainWin )
{
m_mainWin = mainWin;
}
void DockWidgetManager::addDockedWidget( QWidget *widget,
......@@ -40,3 +50,7 @@ void DockWidgetManager::addDockedWidget( QWidget *widget,
dock->setFeatures( features );
m_mainWin->addDockWidget( startArea, dock );
}
DockWidgetManager::DockWidgetManager()
{
}
......@@ -34,7 +34,8 @@ class DockWidgetManager : public QObject
Q_OBJECT
public:
explicit DockWidgetManager( QMainWindow *mainWin );
static DockWidgetManager *instance();
void setMainWindow( QMainWindow *mainWin );
void addDockedWidget( QWidget *widget,
const QString &qs_name,
Qt::DockWidgetAreas areas,
......@@ -42,7 +43,12 @@ class DockWidgetManager : public QObject
Qt::DockWidgetArea startArea );
private:
explicit DockWidgetManager();
~DockWidgetManager() {}
DockWidgetManager(const DockWidgetManager &);
DockWidgetManager & operator = ( const DockWidgetManager & );
QMainWindow *m_mainWin;
static DockWidgetManager *m_instance;
};
#endif
......@@ -30,7 +30,7 @@ MainWindow::MainWindow( QWidget *parent ) :
QMainWindow( parent )
{
m_ui.setupUi( this );
m_dockManager = new DockWidgetManager( this );
DockWidgetManager::instance()->setMainWindow( this );
m_initializeDockWidgets();
}
......@@ -49,13 +49,22 @@ void MainWindow::changeEvent( QEvent *e )
void MainWindow::m_initializeDockWidgets( void )
{
QWidget *central = new QWidget( this );
DockWidgetManager *dockManager = DockWidgetManager::instance();
central->show();
setCentralWidget( central );
//First param is NULL for the moment. It will be replaced by the LibraryWidget
m_dockManager->addDockedWidget( 0, "library", Qt::AllDockWidgetAreas, QDockWidget::AllDockWidgetFeatures, Qt::RightDockWidgetArea );
m_dockManager->addDockedWidget( 0, "library2", Qt::AllDockWidgetAreas, QDockWidget::AllDockWidgetFeatures, Qt::RightDockWidgetArea );
dockManager->addDockedWidget( 0,
"library",
Qt::AllDockWidgetAreas,
QDockWidget::AllDockWidgetFeatures,
Qt::RightDockWidgetArea );
dockManager->addDockedWidget( 0,
"library2",
Qt::AllDockWidgetAreas,
QDockWidget::AllDockWidgetFeatures,
Qt::RightDockWidgetArea );
//Create the library widget
}
......
......@@ -44,7 +44,6 @@ private:
Ui::MainWindow m_ui;
DockWidgetManager *m_dockManager;
LibraryWidget* m_library;
......
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