[graphics/digikam] core/dplugins/generic/view/slideshow: Start the slide show on the selected item when shuffle is on

Gilles Caulier <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 8060008e954e576562b81e458c23b37226894778 by Gilles Caulier, on behalf of Mark Cockram.
Committed on 30/07/2026 at 13:09.
Pushed by cgilles into branch 'master'.

Start the slide show on the selected item when shuffle is on

The start item was resolved to an index before the file list was
shuffled, so slotStart() loaded whatever item ended up at that
position after the shuffle. Keep the start URL and resolve the
index again after shuffling. Without shuffle the second lookup
returns the same index, so nothing changes there.

M  +11   -0    core/dplugins/generic/view/slideshow/common/slideshowloader.cpp
M  +1    -0    core/dplugins/generic/view/slideshow/common/slideshowloader.h
M  +1    -0    core/dplugins/generic/view/slideshow/widgets/slideosd.cpp

https://invent.kde.org/graphics/digikam/-/commit/8060008e954e576562b81e458c23b37226894778

diff --git a/core/dplugins/generic/view/slideshow/common/slideshowloader.cpp b/core/dplugins/generic/view/slideshow/common/slideshowloader.cpp
index fdcb7bab0f..f9aeda945a 100644
--- a/core/dplugins/generic/view/slideshow/common/slideshowloader.cpp
+++ b/core/dplugins/generic/view/slideshow/common/slideshowloader.cpp
@@ -90,6 +90,8 @@ public:
 
     SlideShowSettings*     settings             = nullptr;
 
+    QUrl                   startUrl;                        ///< The item to start with, if any.
+
     QMap<QString, QString> shortcutPrefixes;
 
 #ifdef Q_OS_MACOS
@@ -321,10 +323,19 @@ void SlideShowLoader::setCurrentItem(const QUrl& url)
 
     if (index != -1)
     {
+        d->startUrl  = url;
         d->fileIndex = index - 1;
     }
 }
 
+void SlideShowLoader::resolveStartItem()
+{
+    if (!d->startUrl.isEmpty())
+    {
+        setCurrentItem(d->startUrl);
+    }
+}
+
 QUrl SlideShowLoader::currentItem() const
 {
     return d->settings->fileList.value(d->fileIndex);
diff --git a/core/dplugins/generic/view/slideshow/common/slideshowloader.h b/core/dplugins/generic/view/slideshow/common/slideshowloader.h
index 7b32b14f34..98bcbaeffa 100644
--- a/core/dplugins/generic/view/slideshow/common/slideshowloader.h
+++ b/core/dplugins/generic/view/slideshow/common/slideshowloader.h
@@ -63,6 +63,7 @@ public:
     ~SlideShowLoader()                          override;
 
     void setCurrentItem(const QUrl& url);
+    void resolveStartItem();
     QUrl currentItem() const;
 
     void setShortCutPrefixes(const QMap<QString, QString>& prefixes);
diff --git a/core/dplugins/generic/view/slideshow/widgets/slideosd.cpp b/core/dplugins/generic/view/slideshow/widgets/slideosd.cpp
index be2f020108..aff99c5bfc 100644
--- a/core/dplugins/generic/view/slideshow/widgets/slideosd.cpp
+++ b/core/dplugins/generic/view/slideshow/widgets/slideosd.cpp
@@ -283,6 +283,7 @@ SlideOSD::~SlideOSD()
 void SlideOSD::slotStart()
 {
     d->settings->suffleImages();
+    d->parent->resolveStartItem();
     d->parent->slotLoadNextItem();
     d->progressTimer->start(d->refresh);
     pause(!d->settings->autoPlayEnabled);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.