Changeset View
Changeset View
Standalone View
Standalone View
ubiquity-slideshow/slides/UbiquitySlide.qml
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | Copyright 2019 Harald Sitter <sitter@kde.org> | ||||
3 | | ||||
4 | This program is free software; you can redistribute it and/or | ||||
5 | modify it under the terms of the GNU General Public License as | ||||
6 | published by the Free Software Foundation; either version 3 of | ||||
7 | the License or any later version accepted by the membership of | ||||
8 | KDE e.V. (or its successor approved by the membership of KDE | ||||
9 | e.V.), which shall act as a proxy defined in Section 14 of | ||||
10 | version 3 of the license. | ||||
11 | | ||||
12 | This program is distributed in the hope that it will be useful, | ||||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
15 | GNU General Public License for more details. | ||||
16 | | ||||
17 | You should have received a copy of the GNU General Public License | ||||
18 | along with this program. If not, see <https://www.gnu.org/licenses/>. | ||||
19 | */ | ||||
20 | | ||||
21 | import QtQuick 2.0 | ||||
22 | import QtQuick.Controls 2.5 | ||||
23 | import QtQuick.XmlListModel 2.0 | ||||
24 | | ||||
25 | import calamares.slideshow 1.0 | ||||
26 | import org.kde.kirigami 2.4 as Kirigami | ||||
27 | import org.kde.neon.calamares.slideshow.context 1.0 | ||||
28 | | ||||
29 | Slide { | ||||
30 | id: slide | ||||
31 | anchors.fill: parent | ||||
32 | | ||||
33 | property string name | ||||
34 | property string textColor | ||||
35 | | ||||
36 | // Extract the actual string out of the html. This requires all html | ||||
37 | // pages to have a standard div/h2 nexting and is somewhat abusing | ||||
38 | // the fact that xhtml and html are just about the same. | ||||
39 | XmlListModel { | ||||
40 | id: xmlModel | ||||
41 | query: "/div" | ||||
42 | source: slide.name + ".html" | ||||
43 | | ||||
44 | XmlRole { name: "title"; query: "h2/string()" } | ||||
45 | XmlRole { name: "image"; query: "img/@src/string()" } | ||||
46 | | ||||
47 | onCountChanged:{ | ||||
48 | var item = get(0) | ||||
49 | background.source = item.image | ||||
50 | header.text = i18n(item.title) | ||||
51 | } | ||||
52 | } | ||||
53 | | ||||
54 | Image { | ||||
55 | id: background | ||||
56 | anchors.fill: parent | ||||
57 | // Cropping would be nicer IMO. but it severely messes with my size | ||||
58 | // calculation | ||||
59 | fillMode: Image.PreserveAspectFit | ||||
60 | } | ||||
61 | | ||||
62 | Item { | ||||
63 | id: headerContainer | ||||
64 | x: (background.width - background.paintedWidth) / 2.0 | ||||
65 | y: (background.height - background.paintedHeight) / 2.0 | ||||
66 | width: background.paintedWidth | ||||
67 | height: background.paintedHeight | ||||
68 | | ||||
69 | Kirigami.Heading { | ||||
70 | id: header | ||||
71 | | ||||
72 | anchors.left: headerContainer.left | ||||
73 | anchors.top: headerContainer.top | ||||
74 | anchors.right: headerContainer.right | ||||
75 | anchors.margins: Kirigami.Units.largeSpacing | ||||
76 | | ||||
77 | wrapMode: Text.Wrap | ||||
78 | level: 1 | ||||
79 | color: textColor | ||||
80 | } | ||||
81 | } | ||||
82 | } |