QML: drop potentially confusing shortcuts

Removed these features that make sense in a presentation slideshow
(e.g. during a talk) but that are potentially confusing during
a passive slideshow like Calamares has:
 - Using 'c' blanks the slideshow.
 - Entering a slide number + enter changes slides.
This commit is contained in:
Adriaan de Groot 2018-03-08 12:03:35 +01:00
parent c116dba2e8
commit 3d89828fe1

View file

@ -2,6 +2,11 @@
* *
* Copyright 2017, Adriaan de Groot <groot@kde.org> * Copyright 2017, Adriaan de Groot <groot@kde.org>
* - added looping, keys-instead-of-shortcut * - added looping, keys-instead-of-shortcut
* Copyright 2018, Adriaan de Groot <groot@kde.org>
* - make looping a property, drop the 'c' fade-key
* - drop navigation through entering a slide number
* (this and the 'c' key make sense in a *presentation*
* slideshow, not in a passive slideshow like Calamares)
* *
* SPDX-License-Identifier: LGPL-2.1 * SPDX-License-Identifier: LGPL-2.1
* License-Filename: LICENSES/LGPLv2.1-Presentation * License-Filename: LICENSES/LGPLv2.1-Presentation
@ -57,6 +62,8 @@ Item {
property variant slides: [] property variant slides: []
property int currentSlide: 0 property int currentSlide: 0
property bool loopSlides: true
property bool showNotes: false; property bool showNotes: false;
property bool allowDelay: true; property bool allowDelay: true;
@ -70,8 +77,6 @@ Item {
property string codeFontFamily: "Courier New" property string codeFontFamily: "Courier New"
// Private API // Private API
property bool _faded: false
property int _userNum;
property int _lastShownSlide: 0 property int _lastShownSlide: 0
Component.onCompleted: { Component.onCompleted: {
@ -85,7 +90,6 @@ Item {
} }
root.slides = slides; root.slides = slides;
root._userNum = 0;
// Make first slide visible... // Make first slide visible...
if (root.slides.length > 0) if (root.slides.length > 0)
@ -106,48 +110,21 @@ Item {
} }
function goToNextSlide() { function goToNextSlide() {
root._userNum = 0
if (_faded)
return
if (root.slides[currentSlide].delayPoints) { if (root.slides[currentSlide].delayPoints) {
if (root.slides[currentSlide]._advance()) if (root.slides[currentSlide]._advance())
return; return;
} }
if (currentSlide + 1 < root.slides.length) if (currentSlide + 1 < root.slides.length)
++currentSlide; ++currentSlide;
else else if (loopSlides)
currentSlide = 0; // Loop at the end currentSlide = 0; // Loop at the end
} }
function goToPreviousSlide() { function goToPreviousSlide() {
root._userNum = 0
if (root._faded)
return
if (currentSlide - 1 >= 0) if (currentSlide - 1 >= 0)
--currentSlide; --currentSlide;
} else if (loopSlides)
currentSlide = root.slides.length - 1
function goToUserSlide() {
--_userNum;
if (root._faded || _userNum >= root.slides.length)
return
if (_userNum < 0)
goToNextSlide()
else {
currentSlide = _userNum;
root.focus = true;
}
}
// directly type in the slide number: depends on root having focus
Keys.onPressed: {
if (event.key >= Qt.Key_0 && event.key <= Qt.Key_9)
_userNum = 10 * _userNum + (event.key - Qt.Key_0)
else {
if (event.key == Qt.Key_Return || event.key == Qt.Key_Enter)
goToUserSlide();
_userNum = 0;
}
} }
focus: true // Keep focus focus: true // Keep focus
@ -165,21 +142,12 @@ Item {
// presentation-specific single-key shortcuts (which interfere with normal typing) // presentation-specific single-key shortcuts (which interfere with normal typing)
Shortcut { sequence: " "; enabled: root.keyShortcutsEnabled; onActivated: goToNextSlide() } Shortcut { sequence: " "; enabled: root.keyShortcutsEnabled; onActivated: goToNextSlide() }
Shortcut { sequence: "c"; enabled: root.keyShortcutsEnabled; onActivated: root._faded = !root._faded }
// standard shortcuts // standard shortcuts
Shortcut { sequence: StandardKey.MoveToNextPage; onActivated: goToNextSlide() } Shortcut { sequence: StandardKey.MoveToNextPage; onActivated: goToNextSlide() }
Shortcut { sequence: StandardKey.MoveToPreviousPage; onActivated: goToPreviousSlide() } Shortcut { sequence: StandardKey.MoveToPreviousPage; onActivated: goToPreviousSlide() }
Shortcut { sequence: StandardKey.Quit; onActivated: Qt.quit() } Shortcut { sequence: StandardKey.Quit; onActivated: Qt.quit() }
Rectangle {
z: 1000
color: "black"
anchors.fill: parent
opacity: root._faded ? 1 : 0
Behavior on opacity { NumberAnimation { duration: 250 } }
}
MouseArea { MouseArea {
id: mouseArea id: mouseArea
anchors.fill: parent anchors.fill: parent