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:
parent
8a9baf6e11
commit
c116dba2e8
24
src/qml/calamares/slideshow/BackButton.qml
Normal file
24
src/qml/calamares/slideshow/BackButton.qml
Normal 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
|
||||
}
|
23
src/qml/calamares/slideshow/ForwardButton.qml
Normal file
23
src/qml/calamares/slideshow/ForwardButton.qml
Normal 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;
|
||||
}
|
68
src/qml/calamares/slideshow/NavButton.qml
Normal file
68
src/qml/calamares/slideshow/NavButton.qml
Normal 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()
|
||||
}
|
||||
}
|
||||
}
|
37
src/qml/calamares/slideshow/SlideCounter.qml
Normal file
37
src/qml/calamares/slideshow/SlideCounter.qml
Normal 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
|
||||
}
|
||||
}
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user