Skip to content
Snippets Groups Projects
Commit 719d2198 authored by Shawn Rutledge's avatar Shawn Rutledge
Browse files

(mostly) use Shortcut rather than Keys


Thus it's not required for the root Presentation to retain key focus.
That way each slide can also use the keyboard as long as those uses
don't interefere with the global shortcuts.  The shortcuts can also be
disabled in case they interfere (e.g. using arrow navigation globally
prevents using it for navigating within a slide).

The remaining exception is for directly entering slide numbers.
IMO this is impractical anyway; but if you need to do that, then
you also need to give the Presentation keyboard focus, as before.

The shortcut which used Esc to quit is removed, and replaced with
the more-standard Control-Q.  Enter and Backspace are also no longer
used for slide navigation: there seem to be enough keys for that.

Change-Id: I0a54ae62305aa28b0ffef15b5ec010058c36fb8e
Reviewed-by: default avatarFrederik Gladhorn <frederik.gladhorn@qt.io>
parent 04555d2d
No related branches found
No related tags found
No related merge requests found
......@@ -40,7 +40,7 @@
****************************************************************************/
import QtQuick 2.0
import QtQuick 2.5
import QtQuick.Window 2.0
Item {
......@@ -52,6 +52,8 @@ Item {
property bool showNotes: false;
property bool allowDelay: true;
property alias mouseNavigation: mouseArea.enabled
property bool arrowNavigation: true
property bool keyShortcutsEnabled: true
property color titleColor: textColor;
property color textColor: "black"
......@@ -100,20 +102,16 @@ Item {
if (root.slides[currentSlide]._advance())
return;
}
if (currentSlide + 1 < root.slides.length) {
if (currentSlide + 1 < root.slides.length)
++currentSlide;
root.focus = true;
}
}
function goToPreviousSlide() {
root._userNum = 0
if (root._faded)
return
if (currentSlide - 1 >= 0) {
if (currentSlide - 1 >= 0)
--currentSlide;
root.focus = true;
}
}
function goToUserSlide() {
......@@ -128,28 +126,32 @@ Item {
}
}
focus: true
Keys.onSpacePressed: goToNextSlide()
Keys.onRightPressed: goToNextSlide()
Keys.onDownPressed: goToNextSlide()
Keys.onLeftPressed: goToPreviousSlide()
Keys.onUpPressed: goToPreviousSlide()
Keys.onEscapePressed: Qt.quit()
// 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();
else if (event.key == Qt.Key_Backspace)
goToPreviousSlide();
else if (event.key == Qt.Key_C)
root._faded = !root._faded;
_userNum = 0;
}
}
// navigate with arrow keys
Shortcut { sequence: StandardKey.MoveToNextLine; enabled: root.arrowNavigation; onActivated: goToNextSlide() }
Shortcut { sequence: StandardKey.MoveToPreviousLine; enabled: root.arrowNavigation; onActivated: goToPreviousSlide() }
Shortcut { sequence: StandardKey.MoveToNextChar; enabled: root.arrowNavigation; onActivated: goToNextSlide() }
Shortcut { sequence: StandardKey.MoveToPreviousChar; enabled: root.arrowNavigation; onActivated: goToPreviousSlide() }
// presentation-specific single-key shortcuts (which interfere with normal typing)
Shortcut { sequence: " "; enabled: root.keyShortcutsEnabled; onActivated: goToNextSlide() }
Shortcut { sequence: "c"; enabled: root.keyShortcutsEnabled; onActivated: root._faded = !root._faded }
// standard shortcuts
Shortcut { sequence: StandardKey.MoveToNextPage; onActivated: goToNextSlide() }
Shortcut { sequence: StandardKey.MoveToPreviousPage; onActivated: goToPreviousSlide() }
Shortcut { sequence: StandardKey.Quit; onActivated: Qt.quit() }
Rectangle {
z: 1000
color: "black"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment