Presentation: re-implement looping, keyboard-nav

This commit is contained in:
Adriaan de Groot 2017-09-25 13:52:55 +02:00
parent 6f00dd761b
commit 2a4d8faa3b

View file

@ -1,4 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2017, Adriaan de Groot <groot@kde.org>
* - added looping, keys-instead-of-shortcut
*
* SPDX-License-Identifier: LGPL-2.1
* License-Filename: LICENSES/LGPLv2.1-Presentation
@ -98,6 +101,8 @@ Item {
onCurrentSlideChanged: {
switchSlides(root.slides[_lastShownSlide], root.slides[currentSlide], currentSlide > _lastShownSlide)
_lastShownSlide = currentSlide
// Always keep focus on the slideshow
root.focus = true
}
function goToNextSlide() {
@ -110,6 +115,8 @@ Item {
}
if (currentSlide + 1 < root.slides.length)
++currentSlide;
else
currentSlide = 0; // Loop at the end
}
function goToPreviousSlide() {
@ -143,6 +150,13 @@ Item {
}
}
focus: true // Keep focus
// Navigation through key events, too
Keys.onSpacePressed: goToNextSlide()
Keys.onRightPressed: goToNextSlide()
Keys.onLeftPressed: goToPreviousSlide()
// navigate with arrow keys
Shortcut { sequence: StandardKey.MoveToNextLine; enabled: root.arrowNavigation; onActivated: goToNextSlide() }
Shortcut { sequence: StandardKey.MoveToPreviousLine; enabled: root.arrowNavigation; onActivated: goToPreviousSlide() }