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

yikei lu luyikei.qmltu at gmail.com
Tue Apr 12 14:29:17 CEST 2016


An undo/redo feature will be used only in GUI I think :) But for a
remote GUI that uses the non-GUI build... I don't know.
I think we can implement non-GUI QUndoStack since it uses Widgets only
in QAction * createRedoAction and QAction *createUndoAction. We can
have libqbasicundostack ?

2016-04-12 21:22 GMT+09:00 Hugo Beauzée-Luyssen <hugo at beauzee.fr>:
> On 04/12/2016 02:12 PM, yikei lu wrote:
>>
>> in Command:: namespace
>>
>> 2016-04-12 21:11 GMT+09:00 yikei lu <luyikei.qmltu at gmail.com>:
>>>
>>> I think we can have a code like QUndoStack version of
>>>
>>> Core::instance()
>>> {
>>>      static Core core;
>>>      return &core;
>>> }
>>>
>>>
>>> 2016-04-12 21:09 GMT+09:00 Hugo Beauzée-Luyssen <hugo at beauzee.fr>:
>>>>
>>>> On 04/12/2016 02:04 PM, yikei lu wrote:
>>>>>
>>>>>
>>>>> 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
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Vlmc-devel mailing list
>>>>> Vlmc-devel at videolan.org
>>>>> https://mailman.videolan.org/listinfo/vlmc-devel
>>>>>
>>>> I'll need you to elaborate :)
>>>>
>>>> _______________________________________________
>>>> Vlmc-devel mailing list
>>>> Vlmc-devel at videolan.org
>>>> https://mailman.videolan.org/listinfo/vlmc-devel
>>
>> _______________________________________________
>> Vlmc-devel mailing list
>> Vlmc-devel at videolan.org
>> https://mailman.videolan.org/listinfo/vlmc-devel
>>
> Oh ok I think I got it.
> Indeed that solves the "where" question, now the "what should we do for non
> GUI build which could still need an undo/redo feature" question remains :)
>
> _______________________________________________
> Vlmc-devel mailing list
> Vlmc-devel at videolan.org
> https://mailman.videolan.org/listinfo/vlmc-devel


More information about the Vlmc-devel mailing list