@@ -2672,11 +2672,12 @@ void Phototonic::toggleSlideShow() {
2672
2672
}
2673
2673
2674
2674
if (Settings::layoutMode == ThumbViewWidget) {
2675
- QModelIndexList indexesList = thumbsViewer->selectionModel ()->selectedIndexes ();
2676
- if (indexesList .size () != 1 ) {
2675
+ QModelIndexList selection = thumbsViewer->selectionModel ()->selectedIndexes ();
2676
+ if (selection .size () < 2 ) {
2677
2677
loadImage (Phototonic::First);
2678
2678
} else {
2679
- thumbsViewer->setCurrentIndex (indexesList.first ());
2679
+ thumbsViewer->selectionModel ()->setCurrentIndex (selection.first (), QItemSelectionModel::NoUpdate);
2680
+ // thumbsViewer->setCurrentIndex(selection.first());
2680
2681
}
2681
2682
2682
2683
showViewer ();
@@ -2715,29 +2716,55 @@ void Phototonic::slideShowHandler() {
2715
2716
return ;
2716
2717
}
2717
2718
2718
- if (next > -1 && next < thumbsViewer->model ()->rowCount () && last == thumbsViewer->currentIndex ().row ())
2719
- thumbsViewer->setCurrentIndex (next);
2719
+ QModelIndexList selection = thumbsViewer->selectionModel ()->selectedIndexes ();
2720
+ QStandardItemModel *thumbModel = static_cast <QStandardItemModel*>(thumbsViewer->model ());
2721
+ if (next > -1 && next < thumbModel->rowCount () && last == thumbsViewer->currentIndex ().row ()) {
2722
+ if (selection.size () > 1 ) {
2723
+ QModelIndex idx = thumbModel->indexFromItem (thumbModel->item (next));
2724
+ if (idx.isValid ())
2725
+ thumbsViewer->selectionModel ()->setCurrentIndex (idx, QItemSelectionModel::NoUpdate);
2726
+ } else {
2727
+ thumbsViewer->setCurrentIndex (next);
2728
+ }
2729
+ }
2720
2730
last = thumbsViewer->currentIndex ().row ();
2721
2731
2722
- if (Settings::slideShowRandom) {
2723
- next = QRandomGenerator::global ()->bounded (thumbsViewer->visibleThumbs ());
2724
- if (thumbsViewer->visibleThumbs () != thumbsViewer->model ()->rowCount ()) {
2725
- // for the filtered case we've to figure the nth non-hidden thumb, naively picking some
2726
- // number and moving to the next visible will cause less than random results if a huge
2727
- // block is hidden because we'll often end at its adjacent indexes
2728
- int n = next;
2729
- for (next = 0 ; next < thumbsViewer->model ()->rowCount (); ++next) {
2730
- if (!thumbsViewer->isRowHidden (next) && --n < 0 )
2732
+ if (selection.size () > 1 ) { // use only selected images
2733
+ if (Settings::slideShowRandom) {
2734
+ next = QRandomGenerator::global ()->bounded (selection.size ());
2735
+ next = selection.at (next).row ();
2736
+ } else {
2737
+ next = -1 ;
2738
+ for (int i = 0 ; i < selection.size (); ++i) {
2739
+ if (selection.at (i).row () == last) {
2740
+ if (i < selection.size () - 1 )
2741
+ next = selection.at (i+1 ).row ();
2742
+ else if (Settings::wrapImageList)
2743
+ next = selection.at (0 ).row ();
2731
2744
break ;
2745
+ }
2732
2746
}
2733
2747
}
2734
-
2735
- } else {
2736
- next = thumbsViewer->nextRow ();
2748
+ } else { // use all visible images
2749
+ if (Settings::slideShowRandom) {
2750
+ next = QRandomGenerator::global ()->bounded (thumbsViewer->visibleThumbs ());
2751
+ if (thumbsViewer->visibleThumbs () != thumbsViewer->model ()->rowCount ()) {
2752
+ // for the filtered case we've to figure the n-th non-hidden thumb, naively picking some
2753
+ // number and moving to the next visible will cause less than random results if a huge
2754
+ // block is hidden because we'll often end at its adjacent indexes
2755
+ int n = next;
2756
+ for (next = 0 ; next < thumbsViewer->model ()->rowCount (); ++next) {
2757
+ if (!thumbsViewer->isRowHidden (next) && --n < 0 )
2758
+ break ;
2759
+ }
2760
+ }
2761
+ } else {
2762
+ next = thumbsViewer->nextRow ();
2763
+ }
2737
2764
}
2738
2765
2739
2766
if (next < 0 )
2740
- next = Settings::wrapImageList ? 0 : -2 ;
2767
+ next = Settings::wrapImageList ? - 1 : -2 ;
2741
2768
2742
2769
if (next > -1 && next < thumbsViewer->model ()->rowCount ())
2743
2770
QTimer::singleShot (500 , this , [=]() {imageViewer->preload (thumbsViewer->fullPathOf (next));});
0 commit comments