@@ -169,7 +169,7 @@ void AscentViewer::connectUI()
169
169
connect (nextPhotoButton, &QToolButton::clicked, this , &AscentViewer::handle_nextPhoto);
170
170
connect (lastPhotoButton, &QToolButton::clicked, this , &AscentViewer::handle_lastPhoto);
171
171
// Slideshow
172
- connect (slideshowStartStopButton, &QToolButton::clicked, this , &AscentViewer::handle_startStopSlideshow );
172
+ connect (slideshowStartStopButton, &QToolButton::clicked, this , &AscentViewer::handle_toggleSlideshow );
173
173
connect (slideshowIntervalSpinner, &QSpinBox::valueChanged, this , &AscentViewer::handle_slideshowIntervalChanged);
174
174
// Changing photos
175
175
connect (movePhotoLeftButton, &QToolButton::clicked, this , &AscentViewer::handle_movePhotoLeft);
@@ -251,7 +251,7 @@ void AscentViewer::setupSlideshow()
251
251
*/
252
252
void AscentViewer::changeToAscent (ViewRowIndex viewRowIndex)
253
253
{
254
- stopSlideshowIfRunning ();
254
+ stopSlideshow ();
255
255
256
256
saveDescription ();
257
257
savePhotoDescription ();
@@ -270,7 +270,7 @@ void AscentViewer::changeToAscent(ViewRowIndex viewRowIndex)
270
270
updateAscentNavigationNumbers ();
271
271
272
272
if (slideshowAutostartCheckbox->isChecked () && photos.size () > 1 ) {
273
- handle_startStopSlideshow ( );
273
+ handle_startSlideshow ( false );
274
274
}
275
275
}
276
276
@@ -670,15 +670,6 @@ void AscentViewer::restartSlideshowTimerIfRunning()
670
670
slideshowTimer.start (slideshowIntervalSpinner->value () * 1000 );
671
671
}
672
672
673
- /* *
674
- * Stops the slideshow if it is running, else does nothing.
675
- */
676
- void AscentViewer::stopSlideshowIfRunning ()
677
- {
678
- if (!slideshowRunning) return ;
679
- handle_startStopSlideshow ();
680
- }
681
-
682
673
683
674
684
675
// EDITING PHOTOS
@@ -952,33 +943,54 @@ void AscentViewer::handle_lastPhoto()
952
943
// SLIDESHOW
953
944
954
945
/* *
955
- * Starts or stops the slideshow.
946
+ * Starts the slideshow unless it is already running.
947
+ *
948
+ * Disables editing of the photo description, changes the slideshow button icon and starts the timer.
956
949
*
957
- * Disabled editing of the photo description, changes the slideshow button icon and starts or stops
958
- * the timer.
950
+ * @param nextPhotoImmediately Whether to change to the next photo immediately, skipping the first waiting interval.
959
951
*/
960
- void AscentViewer::handle_startStopSlideshow ( )
952
+ void AscentViewer::handle_startSlideshow ( bool nextPhotoImmediately )
961
953
{
954
+ if (slideshowRunning) return ;
955
+
962
956
if (photoDescriptionEditable) {
963
957
editPhotoDescriptionButton->setChecked (false );
964
958
handle_photoDescriptionEditableChanged ();
965
959
}
966
960
967
- QStyle::StandardPixmap newIcon;
961
+ slideshowTimer.start (slideshowIntervalSpinner->value () * 1000 );
962
+ slideshowStartStopButton->setIcon (style ()->standardIcon (QStyle::SP_MediaStop));
963
+ slideshowRunning = true ;
968
964
969
- if (!slideshowRunning) {
970
- // Slideshow not running, START
971
- slideshowTimer.start (slideshowIntervalSpinner->value () * 1000 );
972
- newIcon = QStyle::SP_MediaStop;
973
- }
974
- else {
975
- // Slideshow running, STOP
976
- slideshowTimer.stop ();
977
- newIcon = QStyle::SP_MediaPlay;
978
- }
965
+ if (nextPhotoImmediately) handle_slideshowTimerTrigger ();
966
+ }
967
+
968
+ /* *
969
+ * Stops the slideshow if it is running.
970
+ *
971
+ * Changes the slideshow button icon and stops the timer.
972
+ */
973
+ void AscentViewer::handle_stopSlideshow ()
974
+ {
975
+ if (!slideshowRunning) return ;
979
976
980
- slideshowStartStopButton->setIcon (style ()->standardIcon (newIcon));
981
- slideshowRunning = !slideshowRunning;
977
+ slideshowTimer.stop ();
978
+ slideshowStartStopButton->setIcon (style ()->standardIcon (QStyle::SP_MediaPlay));
979
+ slideshowRunning = false ;
980
+ }
981
+
982
+ /* *
983
+ * Starts the slideshow if it is not running and stops it otherwise.
984
+ *
985
+ * @param nextPhotoImmediately Whether to change to the next photo immediately when starting the slideshow.
986
+ */
987
+ void AscentViewer::handle_toggleSlideshow (bool nextPhotoImmediately)
988
+ {
989
+ if (slideshowRunning) {
990
+ stopSlideshow ();
991
+ } else {
992
+ startSlideshow (nextPhotoImmediately);
993
+ }
982
994
}
983
995
984
996
/* *
@@ -1005,7 +1017,7 @@ void AscentViewer::handle_slideshowIntervalChanged()
1005
1017
*/
1006
1018
void AscentViewer::handle_userInteractedWithImageLabel ()
1007
1019
{
1008
- stopSlideshowIfRunning ();
1020
+ stopSlideshow ();
1009
1021
}
1010
1022
1011
1023
@@ -1034,7 +1046,7 @@ void AscentViewer::handle_movePhotoRight()
1034
1046
*/
1035
1047
void AscentViewer::handle_addPhotos ()
1036
1048
{
1037
- stopSlideshowIfRunning ();
1049
+ stopSlideshow ();
1038
1050
addPhotosFromDialog ();
1039
1051
}
1040
1052
@@ -1051,7 +1063,7 @@ void AscentViewer::handle_removePhoto()
1051
1063
*/
1052
1064
void AscentViewer::handle_replacePhoto ()
1053
1065
{
1054
- stopSlideshowIfRunning ();
1066
+ stopSlideshow ();
1055
1067
replaceCurrentPhoto ();
1056
1068
}
1057
1069
@@ -1061,7 +1073,7 @@ void AscentViewer::handle_replacePhoto()
1061
1073
void AscentViewer::handle_relocatePhotos ()
1062
1074
{
1063
1075
savePhotoDescription ();
1064
- stopSlideshowIfRunning ();
1076
+ stopSlideshow ();
1065
1077
RelocatePhotosDialog (this , db).exec ();
1066
1078
loadPhotosList ();
1067
1079
changeToPhoto (currentPhotoIndex, false );
@@ -1120,7 +1132,7 @@ void AscentViewer::handle_photoDescriptionEditableChanged()
1120
1132
} else {
1121
1133
photoDescriptionLineEdit->setText (photoDescriptionLabel->text ());
1122
1134
1123
- stopSlideshowIfRunning ();
1135
+ stopSlideshow ();
1124
1136
}
1125
1137
1126
1138
photoDescriptionEditable = editPhotoDescriptionButton->isChecked ();
0 commit comments