QML: add navigation items

- Add a NavButton, which shows a directional arrow, and fades in on hover.
   It can be used left- or right- by setting an image source
   and click handler.
 - Specialize NavButton to Forward and BackButton.
 - Add a SlideCounter navigation aid.
This commit is contained in:
Adriaan de Groot 2018-03-07 23:07:15 +01:00
parent 8a9baf6e11
commit c116dba2e8
5 changed files with 158 additions and 0 deletions

View File

@ -0,0 +1,24 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2018, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
NavButton {
id: backButton
anchors.left: parent.left
visible: parent.currentSlide > 0
isForward: false
}

View File

@ -0,0 +1,23 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2018, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
NavButton {
id: forwardButton
anchors.right: parent.right
visible: parent.currentSlide + 1 < parent.slides.length;
}

View File

@ -0,0 +1,68 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2018, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
/* This is a navigation (arrow) button that fades in on hover, and
* which calls forward / backward navigation on the presentation it
* is in. It should be a child item of the presentation (not of a
* single slide). Use the ForwardButton or BackButton for a pre-
* configured instance that interacts with the presentation.
*/
import QtQuick 2.2;
Image {
id: fade
property bool isForward : true
width: 100
height: 100
anchors.verticalCenter: parent.verticalCenter
opacity: 0.3
OpacityAnimator {
id: fadeIn
target: fade
from: fade.opacity
to: 1.0
duration: 500
running: false
}
OpacityAnimator {
id: fadeOut
target: fade
from: fade.opacity
to: 0.3
duration: 250
running: false
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onEntered: { fadeOut.running = false; fadeIn.running = true }
onExited: { fadeIn.running = false ; fadeOut.running = true }
onClicked: {
if (isForward)
fade.parent.goToNextSlide()
else
fade.parent.goToPreviousSlide()
}
}
}

View File

@ -0,0 +1,37 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2018, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
/* This control just shows a (non-translated) count of the slides
* in the slideshow in the format "n / total".
*/
import QtQuick 2.2;
Rectangle {
id: slideCounter
anchors.right: parent.right
anchors.bottom: parent.bottom
width: 100
height: 50
Text {
id: slideCounterText
anchors.centerIn: parent
text: ( parent.parent.currentSlide + 1 ) + " / " + parent.parent.slides.length
}
}

View File

@ -1,4 +1,10 @@
module calamares.slideshow
Presentation 1.0 Presentation.qml
Slide 1.0 Slide.qml
NavButton 1.0 NavButton.qml
ForwardButton 1.0 ForwardButton.qml
BackButton 1.0 BackButton.qml
SlideCounter 1.0 SlideCounter.qml