<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>509711</bug_id>
          
          <creation_ts>2025-09-20 13:03:20 +0000</creation_ts>
          <short_desc>Random wallpaper order: Non-ideal solution for avoiding a duplicate item when slideshow restarts</short_desc>
          <delta_ts>2025-10-06 15:06:18 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>4</classification_id>
          <classification>Plasma</classification>
          <product>plasmashell</product>
          <component>Image &amp; Slideshow wallpaper plugins</component>
          <version>6.4.90</version>
          <rep_platform>Other</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>wishlist</bug_severity>
          <target_milestone>1.0</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>bastimeyer123</reporter>
          <assigned_to name="Plasma Bugs List">plasma-bugs-null</assigned_to>
          <cc>kde</cc>
    
    <cc>kdedev</cc>
    
    <cc>nate</cc>
    
    <cc>notmart</cc>
    
    <cc>qydwhotmail</cc>
          
          <cf_commitlink>https://invent.kde.org/plasma/plasma-workspace/-/commit/c0d2abe1e9dd2fa046ad82aef85894e26c1da2fa</cf_commitlink>
          <cf_versionfixedin>6.6.0</cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2456066</commentid>
    <comment_count>0</comment_count>
    <who name="">bastimeyer123</who>
    <bug_when>2025-09-20 13:03:20 +0000</bug_when>
    <thetext>SUMMARY
In the image slideshow, when a random order is selected and all items of the current list were consumed and the next set of items is queued, the solution for avoiding a duplicate item selection in the transition is not ideal and leads to skipping one of the items.

The `ImageBackend::nextSlide()` function currently does this:
https://invent.kde.org/plasma/plasma-workspace/-/blob/v6.4.90/wallpapers/image/plugin/imagebackend.cpp#L411-420
- When the end of the slideshow has been reached (index is 0 again), reshuffle it (`invalidate()`)
- Set the next item to the item with index 0
- If the previous item is the same as the next item, increase the index by 1 and set next that instead

This means that the item with index 0 will not be shown in this case, as it&apos;s simply skipped due to it being the same as the previous one, as a valid wallpaper transition needs to be ensured.

A more sensible idea would be swapping the first item with item [2...n] of the reshuffled list, so that no item is skipped and every item will be shown.

From looking at the code (I&apos;m neither familiar with C++/Qt nor with the plugin&apos;s implementation), it seems like this was the simplest solution, as there&apos;s no interface on the `SlideFilterModel` class for swapping specific items:
https://invent.kde.org/plasma/plasma-workspace/-/blob/v6.4.90/wallpapers/image/plugin/slidefiltermodel.h#L17

Alternatively, the slideshow could be reshuffled again until the first item is not the previous one, but this of course doesn&apos;t work in constant time.

STEPS TO REPRODUCE
Have a wallpaper image slideshow in random order with at least 3 items

OBSERVED RESULT
Current slideshow:
A B C
Potential next slideshows:
A B C
A C B
B A C
B C A
A B (C was skipped)
B A (C was skipped)

EXPECTED RESULT
Current slideshow:
A B C
Potential next slideshows:
A B C
A C B
B A C
B C A
A C B (via C A B)
B A C (via C A B)
B C A (via C B A)
A B C (via C B A)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2456367</commentid>
    <comment_count>1</comment_count>
    <who name="David Redondo">kde</who>
    <bug_when>2025-09-22 09:11:17 +0000</bug_when>
    <thetext>Is it a real problem? C will shown in the next round</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2456383</commentid>
    <comment_count>2</comment_count>
    <who name="">bastimeyer123</who>
    <bug_when>2025-09-22 10:21:00 +0000</bug_when>
    <thetext>(In reply to David Redondo from comment #1)
&gt; Is it a real problem? C will shown in the next round

No, it&apos;s a very minor issue, but I think that this still deserves a fix, if it&apos;s trivial to fix.

Skipping an item in the queue means that the queue size is reduced by one, so if a user expects their wallpaper slideshow to repeat in strict cycles, even though the order of items is randomized, then this cycle shifts over time, which can be annoying. (Yes, I do actually notice this from time to time, otherwise I wouldn&apos;t have posted this)

So, as said, if it&apos;s trivial to fix by swapping items in the `SlideFilterModel : QSortFilterProxyModel` instead of increasing the index by one, or maybe just reversing the random order, then there&apos;s no reason not to do that. If I was more familiar with the code, I&apos;d submit a MR, but unfortunately, I am not.

Thanks for your consideration.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2456463</commentid>
    <comment_count>3</comment_count>
    <who name="TraceyC">kdedev</who>
    <bug_when>2025-09-22 17:11:25 +0000</bug_when>
    <thetext>Sending along for consideration</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2456788</commentid>
    <comment_count>4</comment_count>
    <who name="Nate Graham">nate</who>
    <bug_when>2025-09-23 16:59:42 +0000</bug_when>
    <thetext>The code for random wallpaper slideshows is already very complex; surprisingly so, even. I think adding additional complexity for something quite minor is unfortunately not worth the risk. Thanks for the idea anyway, though!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2456890</commentid>
    <comment_count>5</comment_count>
    <who name="">bastimeyer123</who>
    <bug_when>2025-09-23 19:19:15 +0000</bug_when>
    <thetext>(In reply to Nate Graham from comment #4)
&gt; The code for random wallpaper slideshows is already very complex;
&gt; surprisingly so, even. I think adding additional complexity for something
&gt; quite minor is unfortunately not worth the risk. Thanks for the idea anyway,
&gt; though!

Would you still accept a merge request which adds a very simple `SlideFilterModel::reverse()` for reversing the `QList&lt;int&gt; m_randomOrder` instead of the `m_currentSlide += 1` increment? I don&apos;t think this is very complex at all.

$ git diff --shortstat wallpapers/
 3 files changed, 9 insertions(+), 1 deletion(-)

I tested this with added debug log messages and it&apos;s working fine. If you don&apos;t want a MR for this, then I can keep this patch in my own plasma-workspace builds, but I don&apos;t see a reason not to upstream this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2457168</commentid>
    <comment_count>6</comment_count>
    <who name="TraceyC">kdedev</who>
    <bug_when>2025-09-24 15:51:37 +0000</bug_when>
    <thetext>(In reply to bastimeyer123 from comment #5)
&gt; Would you still accept a merge request which adds a very simple
&gt; `SlideFilterModel::reverse()` for reversing the `QList&lt;int&gt; m_randomOrder`
&gt; instead of the `m_currentSlide += 1` increment? I don&apos;t think this is very
&gt; complex at all.

The best thing to do would be to create the MR and let the development community review it. They don&apos;t read individual bug reports for patch suggestions. The worst that can happen is it isn&apos;t accepted. Since it&apos;s a small change, they might be open to it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2457216</commentid>
    <comment_count>7</comment_count>
    <who name="Nate Graham">nate</who>
    <bug_when>2025-09-24 18:28:22 +0000</bug_when>
    <thetext>If you have a simple patch that you think doesn&apos;t present risk, I&apos;d agree that you can go ahead and submit it, and we&apos;ll see where it goes.

Make sure to put &quot;BUG: 509711&quot; on its own line somewhere in the commit message, so this bug report changes from RESOLVED INTENTIONAL to RESOLVED FIXED if and when the patch gets merged.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2459872</commentid>
    <comment_count>8</comment_count>
    <who name="Nate Graham">nate</who>
    <bug_when>2025-10-06 15:06:18 +0000</bug_when>
    <thetext>Git commit c0d2abe1e9dd2fa046ad82aef85894e26c1da2fa by Nate Graham, on behalf of Sebastian Meyer.
Committed on 06/10/2025 at 15:06.
Pushed by ngraham into branch &apos;master&apos;.

wallpapers/image: swap first image on duplicate

When reaching the end of the randomized image slideshow,  
don&apos;t skip the first item after shuffling the randomOrder if it&apos;s  
the same as the previous one.

Instead, swap the item at index 0 with a random item at index 1..n-1,  
so that no items are skipped and the slideshow size remains the same.
FIXED-IN: 6.6.0

M  +1    -1    wallpapers/image/plugin/imagebackend.cpp
M  +20   -0    wallpapers/image/plugin/slidefiltermodel.cpp
M  +1    -0    wallpapers/image/plugin/slidefiltermodel.h

https://invent.kde.org/plasma/plasma-workspace/-/commit/c0d2abe1e9dd2fa046ad82aef85894e26c1da2fa</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>