diff options
-rw-r--r-- | examples/notes/SlideDeck.qml | 75 | ||||
-rw-r--r-- | examples/tutorial/SlideDeck.qml | 20 | ||||
-rw-r--r-- | src/CodeSlide.qml | 6 | ||||
-rw-r--r-- | src/Presentation.qml | 65 | ||||
-rw-r--r-- | src/Slide.qml | 14 |
5 files changed, 155 insertions, 25 deletions
diff --git a/examples/notes/SlideDeck.qml b/examples/notes/SlideDeck.qml new file mode 100644 index 0000000..2945f9f --- /dev/null +++ b/examples/notes/SlideDeck.qml @@ -0,0 +1,75 @@ +import QtQuick 2.0 +import Qt.labs.presentation 1.0 + +Presentation { + + width: 1280 + height: 720 + + Rectangle { + anchors.fill: parent + gradient: Gradient { + GradientStop { position: 0.16; color: "black" } + GradientStop { position: 0.17; color: "white" } + GradientStop { position: 0.92; color: "white" } + GradientStop { position: 0.93; color: "black" } + } + } + + Clock { textColor: "white" } + SlideCounter { textColor: "white" } + + property string titleColor: "white" + + showNotes: true + + Slide { + id: firstSlide; + centeredText: "Using Notes..." + fontScale: 2 + notes: "In this window you will see the notes for the very first slide..." + } + + CodeSlide { + title: "Enable using Presentation.showNotes" + notes: "Here you can see the code required to enable the slides view. + +It is as simple as setting 'showNotes: true' in the Presentation {} element and then add a text to the 'notes' property of the Slide. + +The text will then update automatically as you go from slide to slide." + code: +"Presentation { + showNotes: true; + + Slide { + title: 'Slide One' + content: ['bullet point', 'bullet point']; + notes: 'Here cometh the notes...' + } +" + } + + Slide { + title: "Example Slide" + content: [ + "There should be a second window on your desktop", + "It should read 'once upon a time'", + "", + "Try changing the slide..." + ] + notes: "once upon a time..." + } + + Slide { + title: "Second Example Slide" + content: [ + "The text on the second window should now change", + "The notes window shows plain text with plain line brakes only" + ] + notes: +"This is the second example slide... + +This notes system uses the QtQuick.Window element to pop up a second window. Quite simple and quite convenient..." + } + +} diff --git a/examples/tutorial/SlideDeck.qml b/examples/tutorial/SlideDeck.qml index 7171e43..9b3a87b 100644 --- a/examples/tutorial/SlideDeck.qml +++ b/examples/tutorial/SlideDeck.qml @@ -300,6 +300,26 @@ int main(int argc, char **argv) { ] } + CodeSlide { + title: "Slide Notes in Another Window" + code: +"Presentation { + showNotes: true; + + Slide { + title: 'Slide One' + content: ['bullet point', 'bullet point']; + notes: 'Here cometh the notes...' + } + + ... + + // Check out examples/notes for a running example +} +" + } + + Slide { centeredText: "Now go make our own presentations\n\nEnjoy!" } diff --git a/src/CodeSlide.qml b/src/CodeSlide.qml index 419bc7e..93bc071 100644 --- a/src/CodeSlide.qml +++ b/src/CodeSlide.qml @@ -39,7 +39,7 @@ import QtQuick 2.0 Slide { id: slide; - property string codeFontFamily: "Courier New" + property string codeFontFamily: parent.codeFontFamily; property string code; property real codeFontSize: baseFontSize * 0.6; @@ -123,7 +123,7 @@ Slide { font.family: slide.codeFontFamily font.pixelSize: slide.codeFontSize font.bold: itemDelegate.ListView.isCurrentItem; - opacity: itemDelegate.ListView.isCurrentItem ? 1 : 0.8; + opacity: itemDelegate.ListView.isCurrentItem ? 1 : 0.9; } @@ -146,7 +146,7 @@ Slide { font.family: slide.codeFontFamily font.pixelSize: slide.codeFontSize font.bold: itemDelegate.ListView.isCurrentItem; - opacity: itemDelegate.ListView.isCurrentItem ? 1 : 0.8; + opacity: itemDelegate.ListView.isCurrentItem ? 1 : 0.9; } } } diff --git a/src/Presentation.qml b/src/Presentation.qml index c850408..871ba69 100644 --- a/src/Presentation.qml +++ b/src/Presentation.qml @@ -35,6 +35,7 @@ **************************************************************************/ import QtQuick 2.0 +import QtQuick.Window 2.0 Item { id: root @@ -42,9 +43,16 @@ Item { property variant slides: [] property int currentSlide; - property bool faded: false + property bool showNotes: false; - property int userNum; + property color titleColor: "black" + property color textColor: "black" + property string fontFamily: "Helvetica" + property string codeFontFamily: "Courier New" + + // Private API + property bool _faded: false + property int _userNum; Component.onCompleted: { var slideCount = 0; @@ -57,7 +65,7 @@ Item { } root.slides = slides; - root.userNum = 0; + root._userNum = 0; // Make first slide visible... if (root.slides.length > 0) { @@ -73,8 +81,8 @@ Item { } function goToNextSlide() { - root.userNum = 0 - if (faded) + root._userNum = 0 + if (_faded) return if (root.currentSlide + 1 < root.slides.length) { var from = slides[currentSlide] @@ -87,8 +95,8 @@ Item { } function goToPreviousSlide() { - root.userNum = 0 - if (root.faded) + root._userNum = 0 + if (root._faded) return if (root.currentSlide - 1 >= 0) { var from = slides[currentSlide] @@ -101,16 +109,16 @@ Item { } function goToUserSlide() { - --userNum; - if (root.faded || userNum >= root.slides.length) + --_userNum; + if (root._faded || _userNum >= root.slides.length) return - if (userNum < 0) + if (_userNum < 0) goToNextSlide() - else if (root.currentSlide != userNum) { + else if (root.currentSlide != _userNum) { var from = slides[currentSlide] - var to = slides[userNum] - if (switchSlides(from, to, userNum > currentSlide)) { - currentSlide = userNum; + var to = slides[_userNum] + if (switchSlides(from, to, _userNum > currentSlide)) { + currentSlide = _userNum; root.focus = true; } } @@ -126,15 +134,15 @@ Item { Keys.onEscapePressed: Qt.quit() Keys.onPressed: { if (event.key >= Qt.Key_0 && event.key <= Qt.Key_9) - userNum = 10 * userNum + (event.key - Qt.Key_0) + _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; + root._faded = !root._faded; + _userNum = 0; } } @@ -142,7 +150,7 @@ Item { z: 1000 color: "black" anchors.fill: parent - opacity: root.faded ? 1 : 0 + opacity: root._faded ? 1 : 0 Behavior on opacity { NumberAnimation { duration: 250 } } } @@ -157,4 +165,25 @@ Item { goToNextSlide() } } + + Window { + id: notesWindow; + width: 400 + height: 300 + + windowTitle: "QML Presentation: Notes" + visible: root.showNotes + + Text { + anchors.fill: parent + anchors.margins: parent.height * 0.1; + + font.pixelSize: 16 + wrapMode: Text.WordWrap + + property string notes: root.slides[root.currentSlide].notes; + text: notes == "" ? "Slide has no notes..." : notes; + font.italic: notes == ""; + } + } } diff --git a/src/Slide.qml b/src/Slide.qml index b00a0d7..cf80d02 100644 --- a/src/Slide.qml +++ b/src/Slide.qml @@ -37,6 +37,11 @@ import QtQuick 2.0 Item { + /* + Slides can only be instantiated as a direct child of a Presentation {} as they rely on + several properties there. + */ + id: slide property bool isSlide: true; @@ -45,6 +50,7 @@ Item { property variant content: [] property string centeredText property string writeInText; + property string notes; property real fontSize: parent.height * 0.05 property real fontScale: 1 @@ -64,9 +70,9 @@ Item { property real masterWidth: parent.width property real masterHeight: parent.height - property color titleColor: parent.titleColor != undefined ? parent.titleColor : textColor; - property color textColor: parent.textColor != undefined ? parent.textColor : "black" - property string fontFamily: parent.fontFamily != undefined ? parent.fontFamily : "Helvetica" + property color titleColor: parent.titleColor; + property color textColor: parent.textColor; + property string fontFamily: parent.fontFamily; visible: false @@ -113,7 +119,7 @@ Item { from: 0; to: slide.writeInText.length; duration: slide.writeInText.length * 50; - running: slide.visible && parent.visible && writeInTextId.length + running: slide.visible && parent.visible && slide.writeInText.length > 0 } visible: slide.writeInText != undefined; |