Commit 111cbd6a authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Cleanup: Use the available QSingleton, instead of re-implementing it.

parent 37f37d5d
......@@ -26,8 +26,6 @@
#include <QPlainTextEdit>
#include "About.h"
About* About::m_instance = NULL;
About::About( QWidget *parent ) :
QDialog( parent )
{
......@@ -55,14 +53,6 @@ void About::changeEvent( QEvent *e )
}
}
About* About::instance()
{
if ( m_instance )
return m_instance;
m_instance = new About();
return m_instance;
}
void About::setText( const QString& filename, QPlainTextEdit* widget )
{
QFile file( filename );
......
......@@ -24,17 +24,16 @@
#define ABOUT_H
#include <QDialog>
#include "QSingleton.hpp"
#include "ui_About.h"
class QPlainTextEdit;
class About : public QDialog
class About : public QDialog, public QSingleton<About>
{
Q_OBJECT
Q_DISABLE_COPY( About )
public:
static About* instance();
protected:
virtual void changeEvent( QEvent *e );
......@@ -42,7 +41,8 @@ private:
explicit About( QWidget *parent = 0 );
void setText( const QString& filename, QPlainTextEdit* widget );
Ui::AboutVLMC m_ui;
static About* m_instance;
friend class QSingleton<About>;
};
#endif // ABOUT_H
......@@ -27,16 +27,6 @@
#include "DockWidgetManager.h"
#include "MainWindow.h"
DockWidgetManager *DockWidgetManager::m_instance = 0;
DockWidgetManager *DockWidgetManager::instance( QObject *parent )
{
if (m_instance == 0)
m_instance = new DockWidgetManager( parent );
return (m_instance);
}
void DockWidgetManager::setMainWindow( MainWindow *mainWin )
{
m_mainWin = mainWin;
......
......@@ -23,6 +23,8 @@
#ifndef DOCKWIDGETMANAGER_H
#define DOCKWIDGETMANAGER_H
#include "QSingleton.hpp"
#include <QObject>
#include <QWidget>
#include <QDockWidget>
......@@ -31,7 +33,7 @@
class MainWindow;
class DockWidgetManager : public QObject
class DockWidgetManager : public QObject, public QSingleton<DockWidgetManager>
{
Q_OBJECT
......@@ -55,10 +57,10 @@ class DockWidgetManager : public QObject
MainWindow *m_mainWin;
QMap<QString, QDockWidget*> m_dockWidgets;
static DockWidgetManager *m_instance;
public slots:
void transLateWidgetTitle();
friend class QSingleton<DockWidgetManager>;
};
#endif
......@@ -84,7 +84,7 @@ MainWindow::MainWindow( QWidget *parent ) :
initVlmcPreferences();
// GUI
DockWidgetManager::instance( this )->setMainWindow( this );
DockWidgetManager::getInstance( this )->setMainWindow( this );
createGlobalPreferences();
createProjectPreferences();
initializeDockWidgets();
......@@ -95,7 +95,7 @@ MainWindow::MainWindow( QWidget *parent ) :
// Translations
connect( this, SIGNAL( translateDockWidgetTitle() ),
DockWidgetManager::instance(), SLOT( transLateWidgetTitle() ) );
DockWidgetManager::getInstance(), SLOT( transLateWidgetTitle() ) );
// Zoom
connect( m_zoomSlider, SIGNAL( valueChanged( int ) ),
......@@ -242,7 +242,7 @@ MainWindow::setupLibrary()
const ClipRenderer* clipRenderer = qobject_cast<const ClipRenderer*>( m_clipPreview->getGenericRenderer() );
Q_ASSERT( clipRenderer != NULL );
DockWidgetManager::instance()->addDockedWidget( libraryWidget, tr( "Media Library" ),
DockWidgetManager::getInstance()->addDockedWidget( libraryWidget, tr( "Media Library" ),
Qt::AllDockWidgetAreas,
QDockWidget::AllDockWidgetFeatures,
Qt::LeftDockWidgetArea );
......@@ -343,7 +343,7 @@ void MainWindow::initializeDockWidgets( void )
m_timeline->show();
setCentralWidget( m_timeline );
DockWidgetManager *dockManager = DockWidgetManager::instance();
DockWidgetManager *dockManager = DockWidgetManager::getInstance();
m_clipPreview = new PreviewWidget( new ClipRenderer, this );
dockManager->addDockedWidget( m_clipPreview,
......@@ -413,7 +413,7 @@ void MainWindow::on_actionPreferences_triggered()
void MainWindow::on_actionAbout_triggered()
{
About::instance()->exec();
About::getInstance()->exec();
}
void MainWindow::on_actionTranscode_triggered()
......
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