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

Put core functionnalities (non-project related) in a Core class.

Remove singletons from EffectsEngine/SettingsManager/VlmcLogger
parent 65af2efc
......@@ -27,6 +27,7 @@ SET(VLMC_SRCS
EffectsEngine/EffectSettingValue.cpp
Library/Library.cpp
Library/MediaContainer.cpp
Main/Core.cpp
Main/main.cpp
Media/Clip.cpp
Media/Media.cpp
......
......@@ -33,7 +33,7 @@ KeyboardShortcutHelper::KeyboardShortcutHelper( const QString& name, QWidget* pa
{
QString set = VLMC_GET_STRING( name );
setKey( QKeySequence( set ) );
SettingsManager::getInstance()->watchValue( name, this,
Core::getInstance()->settings()->watchValue( name, this,
SLOT( shortcutUpdated( const QVariant& ) ),
SettingsManager::Vlmc );
}
......@@ -46,7 +46,7 @@ KeyboardShortcutHelper::KeyboardShortcutHelper( const QString& name, QAction *ac
{
QString set = VLMC_GET_STRING( name );
action->setShortcut( set );
SettingsManager::getInstance()->watchValue( name, this,
Core::getInstance()->settings()->watchValue( name, this,
SLOT( shortcutUpdated( const QVariant& ) ),
SettingsManager::Vlmc );
}
......
......@@ -27,6 +27,7 @@
#include "EffectsEngine/EffectHelper.h"
#include "EffectsEngine/EffectInstance.h"
#include "Main/Core.h"
#include "Workflow/Types.h"
#include "Tools/VlmcDebug.h"
......@@ -186,7 +187,7 @@ EffectUser::loadEffects( const QDomElement &parent )
effect.hasAttribute( "start" ) == true &&
effect.hasAttribute( "end" ) == true )
{
Effect *e = EffectsEngine::getInstance()->effect( effect.attribute( "name" ) );
Effect *e = Core::getInstance()->effectsEngine()->effect( effect.attribute( "name" ) );
if ( e != NULL )
{
EffectHelper *helper = addEffect( e, effect.attribute( "start" ).toLongLong(),
......
......@@ -42,12 +42,11 @@ class QXmlStreamWriter;
#include <QUuid>
#include <QMetaType>
#include "Tools/Singleton.hpp"
#include "EffectsEngine/Effect.h"
class QSettings;
class EffectsEngine : public QObject, public Singleton<EffectsEngine>
class EffectsEngine : public QObject
{
Q_OBJECT
......@@ -55,14 +54,15 @@ class EffectsEngine : public QObject, public Singleton<EffectsEngine>
typedef QList<EffectHelper*> EffectList;
static const quint32 MaxFramesForMixer = 3;
EffectsEngine();
~EffectsEngine();
Effect* effect( const QString& name );
const QStringList& effects( Effect::Type type ) const;
bool loadEffect( const QString& fileName );
void loadEffects();
private:
EffectsEngine();
~EffectsEngine();
void browseDirectory( const QString& path );
private:
......@@ -73,7 +73,6 @@ class EffectsEngine : public QObject, public Singleton<EffectsEngine>
signals:
void effectAdded( Effect*, const QString& name, Effect::Type );
friend class Singleton<EffectsEngine>;
};
#endif // EFFECTSENGINE_H
......@@ -33,6 +33,7 @@
#include <QNetworkProxy>
#include <QSettings>
#include "Main/Core.h"
#include "Library/Library.h"
#include "Tools/VlmcDebug.h"
#include "Tools/VlmcLogger.h"
......@@ -74,7 +75,7 @@ MainWindow::MainWindow( Backend::IBackend* backend, QWidget *parent ) :
m_ui.setupUi( this );
//We only install message handler here cause it uses configuration.
VlmcLogger::getInstance()->setup();
Core::getInstance()->logger()->setup();
//Preferences
initVlmcPreferences();
......@@ -84,7 +85,7 @@ MainWindow::MainWindow( Backend::IBackend* backend, QWidget *parent ) :
//All preferences have been created: restore them:
loadVlmcPreferences();
SettingsManager::getInstance()->setValue( "private/VlmcVersion", PROJECT_VERSION_MAJOR, SettingsManager::Vlmc );
Core::getInstance()->settings()->setValue( "private/VlmcVersion", PROJECT_VERSION_MAJOR, SettingsManager::Vlmc );
// GUI
DockWidgetManager::getInstance( this )->setMainWindow( this );
......@@ -269,7 +270,7 @@ MainWindow::initVlmcPreferences()
QT_TRANSLATE_NOOP( "PreferenceWidget", "Language" ),
QT_TRANSLATE_NOOP( "PreferenceWidget", "The VLMC's UI language" ) );
SettingsManager::getInstance()->watchValue( "vlmc/VLMCLang",
Core::getInstance()->settings()->watchValue( "vlmc/VLMCLang",
LanguageHelper::getInstance(),
SLOT( languageChanged( const QVariant& ) ),
SettingsManager::Vlmc );
......@@ -348,7 +349,7 @@ void MainWindow::loadVlmcPreferences()
QSettings s;
s.clear();
}
SettingsManager::getInstance()->setValue( "private/VlmcVersion", PROJECT_VERSION_MAJOR, SettingsManager::Vlmc );
Core::getInstance()->settings()->setValue( "private/VlmcVersion", PROJECT_VERSION_MAJOR, SettingsManager::Vlmc );
}
void
......@@ -362,7 +363,7 @@ MainWindow::loadVlmcPreferencesCategory( const QString &subPart )
QVariant value = s.value( key );
QString fullKey = subPart + "/" + key;
vlmcDebug() << "Loading" << fullKey << "=>" << value;
SettingsManager::getInstance()->setValue( fullKey, value, SettingsManager::Vlmc );
Core::getInstance()->settings()->setValue( fullKey, value, SettingsManager::Vlmc );
}
}
......@@ -476,7 +477,7 @@ MainWindow::setupEffectsList()
QDockWidget::AllDockWidgetFeatures );
m_effectsList = new EffectsListView( dockedWidget );
m_effectsList->setType( Effect::Filter );
EffectsEngine::getInstance()->loadEffects();
Core::getInstance()->effectsEngine()->loadEffects();
DockWidgetManager::getInstance()->addDockedWidget( dockedWidget, m_effectsList, Qt::TopDockWidgetArea );
}
......@@ -790,7 +791,7 @@ MainWindow::saveSettings()
clearTemporaryFiles();
if ( pm->askForSaveIfModified() )
{
SettingsManager* sm = SettingsManager::getInstance();
SettingsManager* sm = Core::getInstance()->settings();
// Save the current geometry
sm->setValue( "private/MainWindowGeometry", saveGeometry(), SettingsManager::Vlmc );
// Save the current layout
......@@ -868,7 +869,7 @@ MainWindow::restoreSession()
QMessageBox::warning( this, tr( "Can't restore project" ), tr( "VLMC didn't manage to restore your project. We apology for the inconvenience" ) );
}
}
SettingsManager::getInstance()->setValue( "private/CleanQuit", true, SettingsManager::Vlmc );
Core::getInstance()->settings()->setValue( "private/CleanQuit", true, SettingsManager::Vlmc );
return ret;
}
......
......@@ -22,6 +22,7 @@
#include "EffectInstanceListModel.h"
#include "Main/Core.h"
#include "EffectsEngine/EffectHelper.h"
#include "EffectsEngine/EffectInstance.h"
#include "EffectsEngine/EffectUser.h"
......@@ -98,7 +99,7 @@ EffectInstanceListModel::add( const QString &effectName )
{
if ( effectName.isEmpty() == true )
return NULL;
Effect *effect = EffectsEngine::getInstance()->effect( effectName );
Effect *effect = Core::getInstance()->effectsEngine()->effect( effectName );
if ( effect == NULL )
return NULL;
beginInsertRows( QModelIndex(), m_user->count( Effect::Filter ), m_user->count( Effect::Filter ) );
......
......@@ -23,6 +23,7 @@
#include "EffectStack.h"
#include "ui_EffectStack.h"
#include "Main/Core.h"
#include "EffectsEngine/EffectHelper.h"
#include "EffectsEngine/EffectInstance.h"
#include "EffectsEngine/EffectUser.h"
......@@ -47,7 +48,7 @@ EffectStack::EffectStack( EffectUser *user, QWidget *parent ):
connect( m_ui->removeButton, SIGNAL( clicked() ), this, SLOT( remove() ) );
connect( m_ui->addButton, SIGNAL( clicked() ), this, SLOT( add() ) );
m_ui->addComboBox->addItems( EffectsEngine::getInstance()->effects( Effect::Filter ) );
m_ui->addComboBox->addItems( Core::getInstance()->effectsEngine()->effects( Effect::Filter ) );
m_stackedLayout = new QStackedLayout;
m_ui->horizontalLayout->addLayout( m_stackedLayout );
//Add an empty instance widget.
......
......@@ -20,6 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "Main/Core.h"
#include "EffectsListView.h"
#include "EffectWidget.h"
#include "EffectsEngine/EffectsEngine.h"
......@@ -36,7 +37,7 @@ EffectsListView::EffectsListView( QWidget *parent ) :
QListView(parent)
{
m_model = new QStandardItemModel( this );
connect( EffectsEngine::getInstance(),
connect( Core::getInstance()->effectsEngine(),
SIGNAL( effectAdded( Effect*, const QString&, Effect::Type ) ),
this,
SLOT( effectAdded(Effect*, const QString&, Effect::Type) ) );
......@@ -90,7 +91,7 @@ EffectsListView::effectActivated( const QModelIndex &index ) const
{
if ( index.isValid() == false )
return ;
Effect *effect = EffectsEngine::getInstance()->effect( m_model->data( index, Qt::DisplayRole ).toString() );
Effect *effect = Core::getInstance()->effectsEngine()->effect( m_model->data( index, Qt::DisplayRole ).toString() );
QDialog *dialog = new QDialog();
QVBoxLayout *layout = new QVBoxLayout( dialog );
EffectWidget *wid = new EffectWidget( dialog );
......
......@@ -25,6 +25,7 @@
#include "ImportController.h"
#include "ui_ImportController.h"
#include "Main/Core.h"
#include "Media/Clip.h"
#include "Renderer/ClipRenderer.h"
#include "Backend/ISource.h"
......@@ -287,7 +288,7 @@ ImportController::collapseAllButCurrentPath()
void
ImportController::saveCurrentPath()
{
SettingsManager::getInstance()->setValue( "private/ImportPreviouslySelectPath",
Core::getInstance()->settings()->setValue( "private/ImportPreviouslySelectPath",
m_currentlyWatchedDir, SettingsManager::Vlmc );
}
......
......@@ -22,6 +22,7 @@
#include "GuiProjectManager.h"
#include "Main/Core.h"
#include "Library/Library.h"
#include "Workflow/MainWorkflow.h"
#include "Settings/SettingsManager.h"
......@@ -49,7 +50,7 @@ GUIProjectManager::GUIProjectManager()
QT_TRANSLATE_NOOP( "PreferenceWidget", "When this option is activated,"
"VLMC will automatically save your project "
"at a specified interval" ) );
SettingsManager::getInstance()->watchValue( "vlmc/AutomaticBackup", this,
Core::getInstance()->settings()->watchValue( "vlmc/AutomaticBackup", this,
SLOT( automaticSaveEnabledChanged(QVariant) ),
SettingsManager::Vlmc,
Qt::QueuedConnection );
......@@ -57,12 +58,12 @@ GUIProjectManager::GUIProjectManager()
QT_TRANSLATE_NOOP( "PreferenceWidget", "Automatic save interval" ),
QT_TRANSLATE_NOOP( "PreferenceWidget", "This is the interval that VLMC will wait "
"between two automatic save" ) );
SettingsManager::getInstance()->watchValue( "vlmc/AutomaticBackupInterval", this,
Core::getInstance()->settings()->watchValue( "vlmc/AutomaticBackupInterval", this,
SLOT( automaticSaveIntervalChanged(QVariant) ),
SettingsManager::Vlmc,
Qt::QueuedConnection );
automaticSaveEnabledChanged( VLMC_GET_BOOL( "vlmc/AutomaticBackup" ) );
SettingsManager::getInstance()->watchValue( "vlmc/ProjectName", this,
Core::getInstance()->settings()->watchValue( "vlmc/ProjectName", this,
SLOT(projectNameChanged(QVariant) ),
SettingsManager::Project );
}
......@@ -142,7 +143,7 @@ GUIProjectManager::createNewProjectFile( bool saveAs )
outputFileName += ".vlmc";
m_projectFile = new QFile( outputFileName );
QFileInfo fInfo( outputFileName );
SettingsManager::getInstance()->setValue( "vlmc/Workspace",
Core::getInstance()->settings()->setValue( "vlmc/Workspace",
fInfo.absolutePath(), SettingsManager::Project);
appendToRecentProject( projectName() );
......
......@@ -47,7 +47,7 @@ PreferenceWidget::PreferenceWidget( const QString &name, const char *label, Sett
{
QWidget *container = new QWidget( this );
SettingsManager::SettingList settings =
SettingsManager::getInstance()->group( name, type );
Core::getInstance()->settings()->group( name, type );
QFormLayout *layout = new QFormLayout( container );
layout->setFieldGrowthPolicy( QFormLayout::AllNonFixedFieldsGrow );
......
......@@ -131,7 +131,7 @@ Settings::buttonClicked( QAbstractButton *button )
}
//If we're handling vlmc preferences, save the value in the QSettings
if ( m_type == SettingsManager::Vlmc )
SettingsManager::getInstance()->save();
Core::getInstance()->settings()->save();
}
case QDialogButtonBox::Cancel:
{
......
......@@ -101,7 +101,7 @@ TracksScene::askRemoveSelectedItems()
return ;
if ( clicked == always )
{
SettingsManager::getInstance()->setValue( "vlmc/ConfirmDeletion",
Core::getInstance()->settings()->setValue( "vlmc/ConfirmDeletion",
false, SettingsManager::Vlmc );
}
}
......
......@@ -22,6 +22,7 @@
#include "TracksView.h"
#include "Main/Core.h"
#include "Workflow/ClipHelper.h"
#include "Workflow/ClipWorkflow.h"
#include "Commands/Commands.h"
......@@ -359,7 +360,7 @@ TracksView::dragEnterEvent( QDragEnterEvent *event )
void
TracksView::effectDragEnterEvent( QDragEnterEvent *event )
{
Effect* effect = EffectsEngine::getInstance()->effect( event->mimeData()->data( "vlmc/effect_name") );
Effect* effect = Core::getInstance()->effectsEngine()->effect( event->mimeData()->data( "vlmc/effect_name") );
if ( effect != NULL )
{
m_dragEffectItem = new GraphicsEffectItem( effect );
......
......@@ -97,7 +97,7 @@ ProjectWizard::accept()
//If he was creating a project, the current page will be the video/audio settings one.
if ( currentId() == Page_Video )
{
SettingsManager *sManager = SettingsManager::getInstance();
SettingsManager *sManager = Core::getInstance()->settings();
GUIProjectManager::getInstance()->newProject( field( "projectName" ).toString(), field( "projectPath" ).toString() );
//Save the project workspace
sManager->setValue( "vlmc/Workspace", field( "projectPath" ), SettingsManager::Project );
......
......@@ -214,5 +214,5 @@ WelcomePage::setProjectPath( const QString& path )
void
WelcomePage::hideWizardAtStartup( bool hidden )
{
SettingsManager::getInstance()->setValue( "private/ShowWizardStartup", !hidden, SettingsManager::Vlmc );
Core::getInstance()->settings()->setValue( "private/ShowWizardStartup", !hidden, SettingsManager::Vlmc );
}
/*****************************************************************************
* Core.cpp: VLMC Base functions.
*****************************************************************************
* Copyright (C) 2008-2014 the VLMC team
*
* Authors: Ludovic Fauvet <etix@l0cal.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "Core.h"
#include <Backend/IBackend.h>
#include <EffectsEngine/EffectsEngine.h>
#include <Settings/SettingsManager.h>
#include <Tools/VlmcLogger.h>
Core::Core()
{
m_backend = Backend::getBackend();
m_effectsEngine = new EffectsEngine;
m_logger = new VlmcLogger;
m_settings = new SettingsManager;
}
Core::~Core()
{
delete m_settings;
delete m_logger;
delete m_effectsEngine;
delete m_backend;
}
Backend::IBackend*
Core::backend()
{
return m_backend;
}
EffectsEngine*
Core::effectsEngine()
{
return m_effectsEngine;
}
VlmcLogger*
Core::logger()
{
return m_logger;
}
SettingsManager*
Core::settings()
{
return m_settings;
}
/*****************************************************************************
* Core.h: VLMC Base functions.
*****************************************************************************
* Copyright (C) 2008-2014 the VLMC team
*
* Authors: Ludovic Fauvet <etix@l0cal.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef CORE_H
#define CORE_H
class EffectsEngine;
class NotificationZone;
class SettingsManager;
class VlmcLogger;
namespace Backend
{
class IBackend;
}
#include <Tools/Singleton.hpp>
class Core : public Singleton<Core>
{
public:
Backend::IBackend* backend();
EffectsEngine* effectsEngine();
SettingsManager* settings();
VlmcLogger* logger();
private:
Core();
~Core();
Backend::IBackend* m_backend;
EffectsEngine* m_effectsEngine;
//FIXME: This should only be applications settings.
SettingsManager* m_settings;
VlmcLogger* m_logger;
friend class Singleton<Core>;
};
#endif // CORE_H
......@@ -22,6 +22,7 @@
#include "config.h"
#include "Main/Core.h"
#include "Library/Library.h"
#include "Workflow/MainWorkflow.h"
#include "Gui/project/GuiProjectManager.h"
......@@ -159,8 +160,8 @@ ProjectManager::loadProject( const QString& fileName )
QDomElement root = m_domDocument->documentElement();
//Load settings first, as it contains some informations about the workspace.
SettingsManager::getInstance()->load( root );
SettingsManager::getInstance()->setValue( "vlmc/Workspace", fInfo.absolutePath(), SettingsManager::Project );
Core::getInstance()->settings()->load( root );
Core::getInstance()->settings()->setValue( "vlmc/Workspace", fInfo.absolutePath(), SettingsManager::Project );
Timeline::getInstance()->renderer()->loadProject( root );
Library::getInstance()->loadProject( root );
}
......@@ -171,7 +172,7 @@ ProjectManager::removeProject( const QString& project )
// Remove all occurence of fileName
m_recentsProjects.removeAll( project );
SettingsManager::getInstance()->setValue( SETTINGS_RECENTS, m_recentsProjects, SettingsManager::Vlmc );
Core::getInstance()->settings()->setValue( SETTINGS_RECENTS, m_recentsProjects, SettingsManager::Vlmc );
}
void
......@@ -188,7 +189,7 @@ ProjectManager::__saveProject( const QString &fileName )
Library::getInstance()->saveProject( project );
MainWorkflow::getInstance()->saveProject( project );
Timeline::getInstance()->renderer()->saveProject( project );
SettingsManager::getInstance()->save( project );
Core::getInstance()->settings()->save( project );
saveTimeline( project );
project.writeEndElement();
......@@ -209,7 +210,7 @@ ProjectManager::emergencyBackup()
else
name = createAutoSaveOutputFileName( QDir::currentPath() + "/unsavedproject" );
__saveProject( name );
SettingsManager::getInstance()->setValue( SETTINGS_BACKUP, name, SettingsManager::Vlmc );
Core::getInstance()->settings()->setValue( SETTINGS_BACKUP, name, SettingsManager::Vlmc );
}
bool
......@@ -234,7 +235,7 @@ ProjectManager::appendToRecentProject( const QString& projectName )
while ( m_recentsProjects.count() > 15 )
m_recentsProjects.removeLast();
SettingsManager::getInstance()->setValue( SETTINGS_RECENTS, m_recentsProjects, SettingsManager::Vlmc );
Core::getInstance()->settings()->setValue( SETTINGS_RECENTS, m_recentsProjects, SettingsManager::Vlmc );
}
QString
......
......@@ -23,8 +23,8 @@
#ifndef SETTINGSMANAGER_H
#define SETTINGSMANAGER_H
#include "Main/Core.h"
#include "SettingValue.h"
#include "Tools/Singleton.hpp"
#include <QString>
#include <QMap>
......@@ -38,23 +38,23 @@ class QDomElement;
//Var helpers :
#define VLMC_GET_STRING( key ) SettingsManager::getInstance()->value( key, SettingsManager::Vlmc )->get().toString()
#define VLMC_GET_INT( key ) SettingsManager::getInstance()->value( key, SettingsManager::Vlmc )->get().toInt()
#define VLMC_GET_UINT( key ) SettingsManager::getInstance()->value( key, SettingsManager::Vlmc )->get().toUInt()
#define VLMC_GET_DOUBLE( key ) SettingsManager::getInstance()->value( key, SettingsManager::Vlmc)->get().toDouble()
#define VLMC_GET_BOOL( key ) SettingsManager::getInstance()->value( key, SettingsManager::Vlmc)->get().toBool()
#define VLMC_GET_STRINGLIST( key ) SettingsManager::getInstance()->value( key, SettingsManager::Vlmc )->get().toStringList()
#define VLMC_GET_BYTEARRAY( key ) SettingsManager::getInstance()->value( key, SettingsManager::Vlmc )->get().toByteArray()
#define VLMC_GET_STRING( key ) Core::getInstance()->settings()->value( key, SettingsManager::Vlmc )->get().toString()
#define VLMC_GET_INT( key ) Core::getInstance()->settings()->value( key, SettingsManager::Vlmc )->get().toInt()
#define VLMC_GET_UINT( key ) Core::getInstance()->settings()->value( key, SettingsManager::Vlmc )->get().toUInt()
#define VLMC_GET_DOUBLE( key ) Core::getInstance()->settings()->value( key, SettingsManager::Vlmc)->get().toDouble()
#define VLMC_GET_BOOL( key ) Core::getInstance()->settings()->value( key, SettingsManager::Vlmc)->get().toBool()
#define VLMC_GET_STRINGLIST( key ) Core::getInstance()->settings()->value( key, SettingsManager::Vlmc )->get().toStringList()
#define VLMC_GET_BYTEARRAY( key ) Core::getInstance()->settings()->value( key, SettingsManager::Vlmc )->get().toByteArray()
#define VLMC_PROJECT_GET_STRING( key ) SettingsManager::getInstance()->value( key, SettingsManager::Project )->get().toString()
#define VLMC_PROJECT_GET_INT( key ) SettingsManager::getInstance()->value( key, SettingsManager::Project )->get().toInt()
#define VLMC_PROJECT_GET_UINT( key ) SettingsManager::getInstance()->value( key, SettingsManager::Project )->get().toUInt()
#define VLMC_PROJECT_GET_DOUBLE( key ) SettingsManager::getInstance()->value( key, SettingsManager::Project )->get().toDouble()
#define VLMC_PROJECT_GET_BOOL( key ) SettingsManager::getInstance()->value( key, SettingsManager::Project )->get().toBool()
#define VLMC_PROJECT_GET_STRING( key ) Core::getInstance()->settings()->value( key, SettingsManager::Project )->get().toString()
#define VLMC_PROJECT_GET_INT( key ) Core::getInstance()->settings()->value( key, SettingsManager::Project )->get().toInt()
#define VLMC_PROJECT_GET_UINT( key ) Core::getInstance()->settings()->value( key, SettingsManager::Project )->get().toUInt()
#define VLMC_PROJECT_GET_DOUBLE( key ) Core::getInstance()->settings()->value( key, SettingsManager::Project )->get().toDouble()
#define VLMC_PROJECT_GET_BOOL( key ) Core::getInstance()->settings()->value( key, SettingsManager::Project )->get().toBool()
#define VLMC_CREATE_PROJECT_VAR( type, key, defaultValue, name, desc, flags ) \
SettingsManager::getInstance()->createVar( type, key, defaultValue, name, \
Core::getInstance()->settings()->createVar( type, key, defaultValue, name, \
desc, SettingsManager::Project, flags );
#define VLMC_CREATE_PROJECT_INT( key, defaultValue, name, desc ) \
......@@ -70,7 +70,7 @@ SettingsManager::getInstance()->createVar( type, key, defaultValue, name, \
#define VLMC_CREATE_PREFERENCE( type, key, defaultValue, name, desc, flags ) \
SettingsManager::getInstance()->createVar( type, key, defaultValue, name, \
Core::getInstance()->settings()->createVar( type, key, defaultValue, name, \
desc, SettingsManager::Vlmc, flags );
/// Vlmc preferences macros
......@@ -105,7 +105,7 @@ SettingsManager::getInstance()->createVar( type, key, defaultValue, name, \
VLMC_CREATE_PROJECT_VAR( SettingValue::String, key, defaultValue, "", "", SettingValue::Private )
class SettingsManager : public QObject, public Singleton<SettingsManager>
class SettingsManager : public QObject
{
Q_OBJECT
Q_DISABLE_COPY( SettingsManager );
......@@ -137,6 +137,9 @@ class SettingsManager : public QObject, public Singleton<SettingsManager>
Project,
Vlmc
};
SettingsManager(){}
~SettingsManager(){}
bool setValue( const QString &key,
const QVariant &value,
SettingsManager::Type type = Vlmc);
......@@ -160,11 +163,6 @@ class SettingsManager : public QObject, public Singleton<SettingsManager>
bool load( const QDomElement &element );
private:
friend class Singleton<SettingsManager>;
SettingsManager(){}
~SettingsManager(){}
SettingsContainer m_classicSettings;
SettingsContainer m_xmlSettings;
......
......@@ -24,6 +24,7 @@
#include <QStringList>
#include <QThread>
#include "Main/Core.h"
#include "Settings/SettingsManager.h"
#include "Tools/VlmcLogger.h"
#include "Tools/VlmcDebug.h"
......@@ -48,7 +49,7 @@ VlmcLogger::VlmcLogger()
m_currentLogLevel = VlmcLogger::Verbose;
else
m_currentLogLevel = VlmcLogger::Quiet;
SettingsManager* settingsManager = SettingsManager::getInstance();
SettingsManager* settingsManager = Core::getInstance()->settings();
settingsManager->setValue( "private/LogLevel", m_currentLogLevel, SettingsManager::Vlmc );
settingsManager->watchValue( "private/LogLevel", this, SLOT(logLevelChanged( const QVariant& )),
SettingsManager::Vlmc, Qt::DirectConnection );
......@@ -147,7 +148,7 @@ VlmcLogger::vlmcMessageHandler( QtMsgType type, const char* msg )
//FIXME: This is ok as long as we guarantee no log message will arrive after
// we uninstall the hook
VlmcLogger* self = VlmcLogger::getInstance();
VlmcLogger* self = Core::getInstance()->logger();
if ( self->m_logFile != NULL )
{
//FIXME: Messages are not guaranteed to arrive in order
......
......@@ -27,17 +27,18 @@
#include <cstdio>
#include "Backend/IBackend.h"
#include "Tools/Singleton.hpp"
/**
* \warning Do not use qDebug() qWarning() etc... from here, unless you know exactly what you're doing
* Chances are very high that you end up with a stack overflow !!
*/
class VlmcLogger : public QObject, public Singleton<VlmcLogger>
class VlmcLogger : public QObject
{
Q_OBJECT
public:
VlmcLogger();
virtual ~VlmcLogger();
// Keep the same order as Qt's message levels, since that's what we're
// going to use for comparing log levels in the message handler
enum LogLevel
......@@ -57,8 +58,6 @@ class VlmcLogger : public QObject, public Singleton<VlmcLogger>
void setup();
private:
VlmcLogger();
virtual ~VlmcLogger();
void writeToFile(const char* msg);
void outputToConsole( int level, const char* msg );
......@@ -68,8 +67,6 @@ class VlmcLogger : public QObject, public Singleton<VlmcLogger>
private slots:
void logLevelChanged( const QVariant& logLevel );
friend class Singleton<VlmcLogger>;
};
#endif // VLMCDEBUG_H
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