Warning, /graphics/koko/src/qml/SlideshowManager.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: (C) 2021 Mikel Johnson <mikel5764@gmail.com> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 2.15 0008 import QtQuick.Window 2.15 0009 import org.kde.koko.private 0.1 as KokoPrivate 0010 0011 // This object manages slideshows. 0012 // It abstract the implementation with a clean and simple API, 0013 // so you only need to bother about *what* to do, not *how* 0014 0015 Item { 0016 // this property indicates whether slideshow is running 0017 // this includes external media even while the timer is paused 0018 // *read only* (not programmatically but this will break if you write to this) 0019 property bool running: false 0020 0021 // this property indicates whether external media is running 0022 // *read only* 0023 property bool externalMediaRunning: false 0024 0025 // save last window state before running slideshow 0026 property int lastWindowVisibility: applicationWindow().visibility 0027 property bool lastControlsVisible: applicationWindow().controlsVisible 0028 0029 // start the slideshow 0030 // don't use these function for anything else 0031 // besides actually starting and stopping the presentation 0032 // since this is reflected in UI unlike functions below these 0033 function start() { 0034 running = true; 0035 lastWindowVisibility = applicationWindow().visibility 0036 lastControlsVisible = applicationWindow().controlsVisible 0037 KokoPrivate.Controller.saveWindowGeometry(applicationWindow()); 0038 applicationWindow().visibility = Window.FullScreen; 0039 applicationWindow().controlsVisible = false; 0040 slideshowTimer.restart(); 0041 } 0042 0043 // stop the slideshow 0044 function stop() { 0045 running = false; 0046 externalMediaRunning = false; 0047 applicationWindow().visibility = lastWindowVisibility 0048 applicationWindow().controlsVisible = lastControlsVisible 0049 slideshowTimer.stop(); 0050 } 0051 0052 // since all the logic is done by using the following functions 0053 // it's pretty easy to plop log() here to simplify debugging 0054 0055 // call this when you need show media that isn't static (i.e. video) to pause the timer 0056 function externalPlaybackStarted() { 0057 externalMediaRunning = true; 0058 slideshowTimer.stop(); 0059 } 0060 0061 // call this when when your playback has finished to move immediately to the next slide 0062 // and resume the timer 0063 function externalPlaybackFinished() { 0064 externalMediaRunning = false; 0065 triggered(); 0066 slideshowTimer.restart(); 0067 } 0068 0069 // call this when when your playback has unloaded to resume the timer 0070 // without immediately moving to the next slide 0071 function externalPlaybackUnloaded() { 0072 externalMediaRunning = false; 0073 slideshowTimer.restart(); 0074 } 0075 0076 // this will be called whenever new slide is required 0077 signal triggered() 0078 0079 // internal object, do *not* call from outside 0080 Timer { 0081 id: slideshowTimer 0082 interval: kokoConfig.nextImageInterval * 1000 0083 repeat: true 0084 onTriggered: { 0085 if (parent.externalMediaRunning) { 0086 stop(); 0087 return; 0088 } 0089 parent.triggered(); 0090 } 0091 } 0092 }