Bug 426859 - Idea: Move to trash from slideshow
Summary: Idea: Move to trash from slideshow
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Plugin-Generic-SlideShow (show other bugs)
Version: 7.1.0
Platform: Other Other
: NOR wishlist
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-09-22 09:31 UTC by Tom de Geus
Modified: 2021-05-02 04:05 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 7.3.0


Attachments
Button for moving image to trash in slideshow (7.11 KB, patch)
2021-03-31 10:06 UTC, Phuoc Khanh LE
Details
move image to trash (digiKam)/ delete image (not digikam) (10.64 KB, patch)
2021-04-19 23:19 UTC, Phuoc Khanh LE
Details
generic func deleteImage() in DInfoInterface (12.73 KB, patch)
2021-04-21 20:18 UTC, Phuoc Khanh LE
Details
remove dependency of digikamgui from plugin (11.71 KB, patch)
2021-04-22 09:00 UTC, Phuoc Khanh LE
Details
Move image to trash in presentation (7.16 KB, patch)
2021-05-01 11:28 UTC, Phuoc Khanh LE
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tom de Geus 2020-09-22 09:31:01 UTC
SUMMARY

After getting back from a trip my workflow is that I start watching the photos I took whilst making a selection (deleting photos I don't like). It would be great if this could be done from the slideshow directly. Also, it would be great if one can just hit the "Delete" key on the keyboard to move photos to Trash.

P.S. If you'd be interested in such a feature I'd be happy to try to contribute by opening a PR. Though a few pointers to where and want would be great.
Comment 1 Maik Qualmann 2020-09-22 11:13:22 UTC
A similar bug report is bug 280133

Maik
Comment 2 caulier.gilles 2021-03-12 04:33:50 UTC
Le,

I think this file can be easily fixed by patching the slideshow tool bar with a new button to move item to digiKam trashbin. What do you think ?

Note: Maik comment #1 point to bug #280133 where another option can be also append to toolbar to rotate current item. Note that the thumbbar support from #280133 is another story, more complex to solve, and out of topic...

Best

Gilles Caulier
Comment 3 Phuoc Khanh LE 2021-03-31 10:06:13 UTC
Created attachment 137192 [details]
Button for moving image to trash in slideshow

Hi Gilles,

This patch creates a button in slideshow. By clicking this button, it moves image the image to trash of digiKam, and remove image from current list of image slide show.

LE
Comment 4 caulier.gilles 2021-03-31 10:18:41 UTC
Hi Le,

You cannot use this code in the plugin :

+    ItemInfo info = ItemInfo::fromUrl(url);
+
+    DIO::del(info, true);

ItemInfo and DIO can only used from digiKam as they depends of database.

The plugin is also avaialble in Showfoto, and there is no database...

The solution is to use the host interface for plugins:

The abstract parent class: https://invent.kde.org/graphics/digikam/-/blob/master/core/libs/dplugins/iface/dinfointerface.h

The re-implementation for Showfoto using file metadata instead database :

https://invent.kde.org/graphics/digikam/-/blob/master/core/libs/dplugins/iface/dmetainfoiface.h

The re-implementation for digiKam using the database :

https://invent.kde.org/graphics/digikam/-/blob/master/core/libs/database/utils/ifaces/dbinfoiface.h

The interface instance is always available in all plugin and must be used to play with items. Of course there is no method in interface to move item to trash. New one must be implemented.

In the digiKam version, DIO and ItemInfo must be used.
In the Showfoto version, just delete the item like it do here :

https://invent.kde.org/graphics/digikam/-/blob/master/core/showfoto/main/showfoto.cpp#L802

Gilles Caulier
Comment 5 Phuoc Khanh LE 2021-04-19 23:19:11 UTC
Created attachment 137716 [details]
move image to trash (digiKam)/ delete image (not digikam)

Hi Gilles,

This patch solve the problem that you mentioned. The DIO is used to move image to trash if the application is digiKam, if not, image file will be deleted by DMetaInfoIface
Comment 6 caulier.gilles 2021-04-20 09:44:02 UTC
Hi Le,

Unfortunately, the new patch do not the problem. The plugin still depend of digiKam database with DIO/DItemInfo class.

You cannot use these classes in the plugin which is also available in Showfoto and it do not have the database, as explained in comment #4.

In other word, the plugin must depend on digiKam core shared lib at linking time, not digiKam database shared lib.

To wrap around this problem, DMetaInfoIface (showfoto) and DBInfoIface (digiKam) interface have been created and based on DInfoInterface abstract class.

A DInfoInterface instance is always available in the plugin instance and must be used to preform the item operation. Depending of the host application running the plugin,  DInfoInterface instance == DMetaInfoIface | DBInfoIface.

From your patch, your customized digiKam code must be moved on a re-implemented method to DBInfoIface, and your Showfoto code must be moved on a re-implemented method from DMetaInfoIface. Calling the generic method from the plugin DInfoInterface instance at run time will delegate on the right host method re-implemented.

This is a use case of abstract class with interface signatures in oriented programming language :

https://en.wikipedia.org/wiki/Class_(computer_programming)#Abstract_and_concrete

Best

Gilles
Comment 7 Maik Qualmann 2021-04-20 10:29:23 UTC
In the file delete function for Showfoto, if Qt-5.15 is available, we should use the new function QFile::moveToTrash() instead of deleting. This new feature in Qt-5.15 moves the file to the System Trash.

Maik
Comment 8 Phuoc Khanh LE 2021-04-21 20:18:51 UTC
Created attachment 137771 [details]
generic func deleteImage() in DInfoInterface

Hi,

Update for previous pack:
+ deleteImage() virtual in DInfoInterface, using DIO in DBInfoIface, and QFile::remove() in DMetaInfoIface
+ condition for version of Qt >= 5.15, using QFile::moveToTrash()

Is it better now ?
Best
Comment 9 Maik Qualmann 2021-04-22 07:35:29 UTC
More correct, but you must not call DBInfoIface or DMetaInfoIface directly in the SlideShow plugin. The DInfoInterface is overloaded with the respective interface. The SlideShow plugin must not be dependent on digikamgui either.

Maik
Comment 10 Phuoc Khanh LE 2021-04-22 09:00:56 UTC
Created attachment 137792 [details]
remove dependency of digikamgui from plugin

Hi,

The plugin is now independent to digikamgui. I misunderstood this in the first place.

Best
Comment 11 Maik Qualmann 2021-04-22 11:17:35 UTC
I can't test it until tonight, but the patch looks good now.

Maik
Comment 12 Maik Qualmann 2021-04-24 19:29:30 UTC
Git commit c797b69c8741ce966f52daa954d01f78ab689ba9 by Maik Qualmann.
Committed on 24/04/2021 at 19:28.
Pushed by mqualmann into branch 'master'.

apply patch #137792 from Phuoc Khanh LE to move image to trash in the slideshow
FIXED-IN: 7.3.0

M  +2    -2    NEWS
M  +13   -0    core/dplugins/generic/view/slideshow/common/slideshowloader.cpp
M  +1    -0    core/dplugins/generic/view/slideshow/common/slideshowloader.h
M  +3    -0    core/dplugins/generic/view/slideshow/widgets/slideosd.cpp
M  +38   -0    core/dplugins/generic/view/slideshow/widgets/slidetoolbar.cpp
M  +2    -0    core/dplugins/generic/view/slideshow/widgets/slidetoolbar.h
M  +7    -0    core/libs/database/utils/ifaces/dbinfoiface.cpp
M  +2    -0    core/libs/database/utils/ifaces/dbinfoiface.h
M  +5    -0    core/libs/dplugins/iface/dinfointerface.cpp
M  +5    -0    core/libs/dplugins/iface/dinfointerface.h
M  +14   -0    core/libs/dplugins/iface/dmetainfoiface.cpp
M  +3    -0    core/libs/dplugins/iface/dmetainfoiface.h
M  +22   -0    core/showfoto/main/showfoto.cpp
M  +2    -0    core/showfoto/main/showfoto.h

https://invent.kde.org/graphics/digikam/commit/c797b69c8741ce966f52daa954d01f78ab689ba9
Comment 13 caulier.gilles 2021-04-28 11:06:10 UTC
Hi Le,

I tested your patch reviewed by Maik and it work perfectly with the Slideshow plugin.

Can this patch can be adapted quickly to the Presentation plugin ? This will add the benefit to have the same feature in both View tools...

Thank in advance

Gilles
Comment 14 Phuoc Khanh LE 2021-05-01 11:28:32 UTC
Created attachment 138055 [details]
Move image to trash in presentation

Hi,

This patch add same feature of removing image to trash in presentation.
Comment 15 caulier.gilles 2021-05-02 04:05:41 UTC
Git commit 476caf2a9fdc504007569b5483cb6c354f6d5c22 by Gilles Caulier.
Committed on 02/05/2021 at 04:03.
Pushed by cgilles into branch 'master'.

Apply patch #426859 from Phuoc Khanh Le about to add new option to move items to the trash, as SlideShow tool.

M  +1    -1    NEWS
M  +0    -1    core/dplugins/generic/view/presentation/TODO
M  +2    -1    core/dplugins/generic/view/presentation/audio/presentationaudiowidget.h
M  +2    -1    core/dplugins/generic/view/presentation/dialogs/presentation_captionpage.h
M  +14   -9    core/dplugins/generic/view/presentation/dialogs/presentation_mainpage.cpp
M  +4    -2    core/dplugins/generic/view/presentation/dialogs/presentation_mainpage.h
M  +10   -3    core/dplugins/generic/view/presentation/opengl/kbeffect.cpp
M  +4    -5    core/dplugins/generic/view/presentation/opengl/presentationgl.cpp
M  +1    -1    core/dplugins/generic/view/presentation/opengl/presentationgl.h
M  +0    -1    core/dplugins/generic/view/presentation/opengl/presentationkb.cpp
M  +2    -0    core/dplugins/generic/view/presentation/opengl/presentationkb_p.h
M  +8    -2    core/dplugins/generic/view/presentation/presentationmngr.cpp
M  +38   -1    core/dplugins/generic/view/presentation/widgets/presentationctrlwidget.cpp
M  +2    -0    core/dplugins/generic/view/presentation/widgets/presentationctrlwidget.h
M  +7    -0    core/dplugins/generic/view/presentation/widgets/presentationctrlwidget.ui
M  +29   -1    core/dplugins/generic/view/presentation/widgets/presentationwidget.cpp
M  +1    -0    core/dplugins/generic/view/presentation/widgets/presentationwidget.h

https://invent.kde.org/graphics/digikam/commit/476caf2a9fdc504007569b5483cb6c354f6d5c22