[vlmc-devel] [PATCH 07/14] Core: Mark WITH_GUI on Widget-related code

yikei lu luyikei.qmltu at gmail.com
Tue Apr 12 14:04:00 CEST 2016


How about singleton in Command:: ?

2016-04-12 20:55 GMT+09:00 Hugo Beauzée-Luyssen <hugo at beauzee.fr>:
> On 04/11/2016 08:09 AM, Yikai Lu wrote:
>>
>> ---
>>   src/Main/Core.cpp | 10 ++++++++--
>>   src/Main/Core.h   |  8 ++++++--
>>   2 files changed, 14 insertions(+), 4 deletions(-)
>>
>> diff --git a/src/Main/Core.cpp b/src/Main/Core.cpp
>> index 2d496e1..6e20128 100644
>> --- a/src/Main/Core.cpp
>> +++ b/src/Main/Core.cpp
>> @@ -25,7 +25,9 @@
>>   #include <QCoreApplication>
>>   #include <QDir>
>>   #include <QtGlobal>
>> +#ifdef WITH_GUI
>>   #include <QUndoStack>
>> +#endif
>>   #include <QStandardPaths>
>>
>>
>> @@ -52,10 +54,12 @@ Core::Core()
>>       m_workspace = new Workspace( m_settings );
>>       m_workflow = new MainWorkflow( m_currentProject->settings() );
>>       m_workflowRenderer = new WorkflowRenderer( Backend::getBackend(),
>> m_workflow );
>> +#ifdef WITH_GUI
>>       m_undoStack = new QUndoStack;
>>
>>       connect( m_undoStack, &QUndoStack::cleanChanged, m_currentProject,
>> &Project::cleanChanged );
>>       connect( m_currentProject, &Project::projectSaved, m_undoStack,
>> &QUndoStack::setClean );
>> +#endif
>>       connect( m_library, &Library::cleanStateChanged, m_currentProject,
>> &Project::libraryCleanChanged );
>>       connect( m_currentProject, SIGNAL( projectLoaded( QString, QString )
>> ),
>>                m_recentProjects, SLOT( projectLoaded( QString, QString ) )
>> );
>> @@ -69,7 +73,9 @@ Core::~Core()
>>   {
>>       m_settings->save();
>>       delete m_library;
>> +#ifdef WITH_GUI
>>       delete m_undoStack;
>> +#endif
>>       delete m_workflowRenderer;
>>       delete m_workflow;
>>       delete m_currentProject;
>> @@ -165,13 +171,13 @@ Core::workflow()
>>   {
>>       return m_workflow;
>>   }
>> -
>> +#ifdef WITH_GUI
>>   QUndoStack*
>>   Core::undoStack()
>>   {
>>       return m_undoStack;
>>   }
>> -
>> +#endif
>>   Library*
>>   Core::library()
>>   {
>> diff --git a/src/Main/Core.h b/src/Main/Core.h
>> index 72a36db..1ce1993 100644
>> --- a/src/Main/Core.h
>> +++ b/src/Main/Core.h
>> @@ -34,9 +34,9 @@ class Settings;
>>   class VlmcLogger;
>>   class Workspace;
>>   class WorkflowRenderer;
>> -
>> +#ifdef WITH_GUI
>>   class QUndoStack;
>> -
>> +#endif
>>   namespace Backend
>>   {
>>       class IBackend;
>> @@ -59,7 +59,9 @@ class Core : public QObject
>>           Project*                project();
>>           WorkflowRenderer*       workflowRenderer();
>>           MainWorkflow*           workflow();
>> +#ifdef WITH_GUI
>>           QUndoStack*             undoStack();
>> +#endif
>>           Library*                library();
>>           /**
>>            * @brief runtime returns the application runtime
>> @@ -88,7 +90,9 @@ class Core : public QObject
>>           Project*                m_currentProject;
>>           MainWorkflow*           m_workflow;
>>           WorkflowRenderer*       m_workflowRenderer;
>> +#ifdef WITH_GUI
>>           QUndoStack*             m_undoStack;
>> +#endif
>>           Library*                m_library;
>>           QElapsedTimer           m_timer;
>>   };
>>
>
> No, this should simply be moved out of the Core class. Where to is another
> question, but it this is a GUI component, it should be moved out of Core.
> The thing is, we will probably need something similar for the remote view,
> which needs to be built without UI (as in, without QtGui) support. I'm
> afraid we need to abstract the QUndoStack behind an interface, that will
> either be implemented by a plain QUndoStack, or our own implementation.
> We could also simply use our own implementation, but I'm not sure how this
> flies with QUndoView.
>
> Regards,
>
> _______________________________________________
> Vlmc-devel mailing list
> Vlmc-devel at videolan.org
> https://mailman.videolan.org/listinfo/vlmc-devel


More information about the Vlmc-devel mailing list