https://bugs.kde.org/show_bug.cgi?id=414055

--- Comment #8 from caulier.gil...@gmail.com ---
Hi Nghia,

1/ If you want to uderstand how to work the plugin architecture, take a look
first in the test CLI tool for generic plugins:

https://invent.kde.org/kde/digikam/-/blob/master/core/tests/dplugins/loadandrun_generic.cpp

This code is able to load plugin shared object as stand alone application and
start a delegate action embeded in tool. You can test with the ported version
of Slideshow to see if all run fine.

[gilles@localhost dplugins]$ ./loadandrun_generic --help
"/usr/lib64"
"/usr/lib64/qt5/libexec"
"/usr/lib64/qt5/plugins"
Usage: ./loadandrun_generic [options] +[file(s)]
Test application to run digiKam plugins as stand alone

Options:
  -h, --help        Displays this help.
  --list            List all available plugins
  -l <Plugin IID>   Unique name ID of the plugin to use
  -a <Action Name>  Plugin action name to run
  -w                Wait until plugin non-modal dialog is closed

Arguments:
  files             File(s) to open

In this code you will found all the core methods called to play with a plugin
using DPlugins API. You will see that this code is the most generic as possible
to be able to handle all plugins without specific code. This is the goal of the
famous Abstract interface re-implemented for the host application (digiKam or
Showfoto) 

2/ Some pointers from the digiKam core implementation to found all calls
relevant of plugins management.

- digiKam and Showfoto main windows are derivated from this class :

https://invent.kde.org/kde/digikam/-/blob/master/core/libs/widgets/mainview/dxmlguiwindow.h

- now look the virtual pure methods which must be re-implemented in derivated
classes for digiKam and Showfoto :

https://invent.kde.org/kde/digikam/-/blob/master/core/libs/widgets/mainview/dxmlguiwindow.h#L166

This one is to create instance of the plugin interface...

2 other ones are to register plugin action in menu, button context menu, etc,
accordingly with the Setup plugins configuration where the user can enable or
disable a tool between sessions.

https://invent.kde.org/kde/digikam/-/blob/master/core/libs/widgets/mainview/dxmlguiwindow.h#L160

3/ In digiKam, all the plugins are loaded at run time through DPluginLoader :

https://invent.kde.org/kde/digikam/-/blob/master/core/app/main/digikamapp.cpp#L134

...and unloaded in destructor of course :

https://invent.kde.org/kde/digikam/-/blob/master/core/app/main/digikamapp.cpp#L261

4/ this is the implementation to pass the plugin interface instance in digiKam.
Some arguments are wrapped depending of some settings from Setup/Misc
configuration tab about the images grouping feature (digiKam only).

https://invent.kde.org/kde/digikam/-/blob/master/core/app/main/digikamapp.cpp#L1071

5/ For digiKam album GUI, Slideshow is called from icon-view :

https://invent.kde.org/kde/digikam/-/blob/master/core/app/views/stack/itemiconview_slideshow.cpp

All these slots are called from the core of this class :

https://invent.kde.org/kde/digikam/-/blob/master/core/app/views/stack/itemiconview.h#L204

All these methods must be moved in the plugin implementation. They calls the
famous builder to populate items from albums depending of the plugin action
called by user (recursive or not). In the plugin, this kind of method must call
the moved builder in the host plugin interface of course, to be independent. 

6/ Finally where is instancied the Slideshow tool instance in Album GUI
version. It's simple: when builder has fully populated items from albums :

https://invent.kde.org/kde/digikam/-/blob/master/core/app/views/stack/itemiconview_slideshow.cpp#L96

Look like we pass the host plugin interface instance as argument...

7/ Don't forget the rest of digiKam SLideshow calls to migrate/port/fix with
the new plugin Slideshow code. All are more simpler, as the recursive mode do
not exists in these cases :

* The DK Image Editor (this is not Showfoto) :

https://invent.kde.org/kde/digikam/-/blob/master/core/utilities/imageeditor/main/imagewindow_tools.cpp

* The Light Table:

https://invent.kde.org/kde/digikam/-/blob/master/core/utilities/lighttable/lighttablewindow_tools.cpp#L56

Here codes must be factorized/moved/merged with builder and host plugin
interface for digiKam...

VoilĂ .

Gilles

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to