source: calamares/trunk/fuentes/src/qml/calamares/slideshow/Slide.qml @ 7538

Last change on this file since 7538 was 7538, checked in by kbut, 17 months ago

sync with github

File size: 6.7 KB
Line 
1/* === This file is part of Calamares - <https://github.com/calamares> ===
2 *
3 *   SPDX-License-Identifier: LGPL-2.1
4 *   License-Filename: LICENSES/LGPLv2.1-Presentation
5 */
6
7/****************************************************************************
8**
9** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
10** Contact: http://www.qt-project.org/legal
11**
12** This file is part of the QML Presentation System.
13**
14** $QT_BEGIN_LICENSE:LGPL$
15** Commercial License Usage
16** Licensees holding valid commercial Qt licenses may use this file in
17** accordance with the commercial license agreement provided with the
18** Software or, alternatively, in accordance with the terms contained in
19** a written agreement between you and Digia.  For licensing terms and
20** conditions see http://qt.digia.com/licensing.  For further information
21** use the contact form at http://qt.digia.com/contact-us.
22**
23** GNU Lesser General Public License Usage
24** Alternatively, this file may be used under the terms of the GNU Lesser
25** General Public License version 2.1 as published by the Free Software
26** Foundation and appearing in the file LICENSE.LGPL included in the
27** packaging of this file.  Please review the following information to
28** ensure the GNU Lesser General Public License version 2.1 requirements
29** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
30**
31** In addition, as a special exception, Digia gives you certain additional
32** rights.  These rights are described in the Digia Qt LGPL Exception
33** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
34**
35** GNU General Public License Usage
36** Alternatively, this file may be used under the terms of the GNU
37** General Public License version 3.0 as published by the Free Software
38** Foundation and appearing in the file LICENSE.GPL included in the
39** packaging of this file.  Please review the following information to
40** ensure the GNU General Public License version 3.0 requirements will be
41** met: http://www.gnu.org/copyleft/gpl.html.
42**
43**
44** $QT_END_LICENSE$
45**
46****************************************************************************/
47
48
49import QtQuick 2.5
50
51Item {
52    /*
53      Slides can only be instantiated as a direct child of a Presentation {} as they rely on
54      several properties there.
55     */
56
57    id: slide
58
59    property bool isSlide: true;
60
61    property bool delayPoints: false;
62    property int _pointCounter: 0;
63    function _advance() {
64        if (!parent.allowDelay)
65            return false;
66
67        _pointCounter = _pointCounter + 1;
68        if (_pointCounter < content.length)
69            return true;
70        _pointCounter = 0;
71        return false;
72    }
73
74    property string title;
75    property variant content: []
76    property string centeredText
77    property string writeInText;
78    property string notes;
79
80    property real fontSize: parent.height * 0.05
81    property real fontScale: 1
82
83    property real baseFontSize: fontSize * fontScale
84    property real titleFontSize: fontSize * 1.2 * fontScale
85    property real bulletSpacing: 1
86
87    property real contentWidth: width
88
89    // Define the slide to be the "content area"
90    x: parent.width * 0.05
91    y: parent.height * 0.2
92    width: parent.width * 0.9
93    height: parent.height * 0.7
94
95    property real masterWidth: parent.width
96    property real masterHeight: parent.height
97
98    property color titleColor: parent.titleColor;
99    property color textColor: parent.textColor;
100    property string fontFamily: parent.fontFamily;
101    property int textFormat: Text.PlainText
102
103    visible: false
104
105    Text {
106        id: titleText
107        font.pixelSize: titleFontSize
108        text: title;
109        anchors.horizontalCenter: parent.horizontalCenter
110        anchors.bottom: parent.top
111        anchors.bottomMargin: parent.fontSize * 1.5
112        font.bold: true;
113        font.family: slide.fontFamily
114        color: slide.titleColor
115        horizontalAlignment: Text.Center
116        z: 1
117    }
118
119    Text {
120        id: centeredId
121        width: parent.width
122        anchors.centerIn: parent
123        anchors.verticalCenterOffset: - parent.y / 3
124        text: centeredText
125        horizontalAlignment: Text.Center
126        font.pixelSize: baseFontSize
127        font.family: slide.fontFamily
128        color: slide.textColor
129        wrapMode: Text.Wrap
130    }
131
132    Text {
133        id: writeInTextId
134        property int length;
135        font.family: slide.fontFamily
136        font.pixelSize: baseFontSize
137        color: slide.textColor
138
139        anchors.fill: parent;
140        wrapMode: Text.Wrap
141
142        text: slide.writeInText.substring(0, length);
143
144        NumberAnimation on length {
145            from: 0;
146            to: slide.writeInText.length;
147            duration: slide.writeInText.length * 30;
148            running: slide.visible && parent.visible && slide.writeInText.length > 0
149        }
150
151        visible: slide.writeInText != undefined;
152    }
153
154
155    Column {
156        id: contentId
157        anchors.fill: parent
158
159        Repeater {
160            model: content.length
161
162            Row {
163                id: row
164
165                function decideIndentLevel(s) { return s.charAt(0) == " " ? 1 + decideIndentLevel(s.substring(1)) : 0 }
166                property int indentLevel: decideIndentLevel(content[index])
167                property int nextIndentLevel: index < content.length - 1 ? decideIndentLevel(content[index+1]) : 0
168                property real indentFactor: (10 - row.indentLevel * 2) / 10;
169
170                height: text.height + (nextIndentLevel == 0 ? 1 : 0.3) * slide.baseFontSize * slide.bulletSpacing
171                x: slide.baseFontSize * indentLevel
172                visible: (!slide.parent.allowDelay || !delayPoints) || index <= _pointCounter
173
174                Rectangle {
175                    id: dot
176                    anchors.baseline: text.baseline
177                    anchors.baselineOffset: -text.font.pixelSize / 2
178                    width: text.font.pixelSize / 3
179                    height: text.font.pixelSize / 3
180                    color: slide.textColor
181                    radius: width / 2
182                    opacity: text.text.length == 0 ? 0 : 1
183                }
184
185                Item {
186                    id: space
187                    width: dot.width * 1.5
188                    height: 1
189                }
190
191                Text {
192                    id: text
193                    width: slide.contentWidth - parent.x - dot.width - space.width
194                    font.pixelSize: baseFontSize * row.indentFactor
195                    text: content[index]
196                    textFormat: slide.textFormat
197                    wrapMode: Text.WordWrap
198                    color: slide.textColor
199                    horizontalAlignment: Text.AlignLeft
200                    font.family: slide.fontFamily
201                }
202            }
203        }
204    }
205
206}
Note: See TracBrowser for help on using the repository browser.