Skip to content

Commit d96424b

Browse files
committed
will autoplay based on settings.
1 parent 05d1672 commit d96424b

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

image_in_window_screensaver/bad_practise_global.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@
99

1010
least_pause_secs = 1
1111
max_pause_secs = 1500
12-
pause_secs = 10
12+
pause_secs = 300
13+
14+
autoplay = True

image_in_window_screensaver/image_widget.py

+25-11
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ def __init__(self):
3131
self._shuffle_start_index = 0
3232
self._current_index = 0
3333
self.is_full_screen: bool = False
34-
self.is_playing: bool = False
34+
# self.is_playing: bool = False
35+
self.is_playing: bool = bpg.autoplay
3536
self._seed = time.time()
3637

3738
# timer
@@ -59,7 +60,7 @@ def initialize_images(self, mode=None, current_image_path=None,
5960
self._current_index = self.get_index_from_image_path(
6061
current_image_path)
6162
self._shuffle_start_index = self._current_index
62-
# self.image_shuffle()
63+
self.image_shuffle()
6364
self._set_image(self._current_index)
6465

6566
def is_image_landscape(self, image: QPixmap):
@@ -244,24 +245,37 @@ def keyReleaseEvent(self, event: QKeyEvent):
244245
elif key == Qt.Key_T:
245246
print("T pressed")
246247
self.increase_timer(bpg.max_pause_secs)
247-
self.pause()
248+
249+
if self.is_playing:
250+
self.play()
251+
else:
252+
self.pause()
253+
248254
self.setFocus()
249255
# self.set_title(self.get_current_image_path_str())
250256

251257
def toggle_play(self):
252-
l.log("toggle auto play is" + str(self.is_playing))
253258
self.is_playing = not self.is_playing
254-
self.play()
259+
l.log(
260+
str.format(
261+
"toggle auto play from {} to {}",
262+
(str(self.is_playing)),
263+
(str(not self.is_playing)))
264+
)
265+
if self.is_playing:
266+
self.play()
267+
else:
268+
self.pause()
255269

256270
def play(self):
257-
l.log("starting play timer")
258-
if self.is_playing:
259-
self.timer.start()
271+
l.log("slideshow running")
272+
# self.is_playing = True
273+
self.timer.start()
260274

261275
def pause(self):
262-
if not self.is_playing:
263-
l.log("pausing auto play: " + str(self.is_playing))
264-
self.timer.stop()
276+
l.log("slideshow paused")
277+
# self.is_playing = False
278+
self.timer.stop()
265279

266280
def play_image_next(self):
267281
if self.is_playing:

0 commit comments

Comments
 (0)