Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / ground / gcs / src / plugins / welcome / qml / NewsPanel.qml
blob009ba2d70b5d82e6927afe1ea80cb9f475dc24c5
1 // import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
2 import QtQuick 2.0
3 import QtQuick.XmlListModel 2.0
5 Item {
6     id: container
7     width: 100
8     height: 62
10     signal clicked(string url)
12     Text {
13         id: header
14         text: qsTr("Project News")
15         width: parent.width
16         color: "#44515c"
17         font {
18             pointSize: 14
19             weight: Font.Bold
20         }
21     }
23     ListView {
24         id: view
25         width: parent.width
26         anchors { top: header.bottom; topMargin: 14; bottom: parent.bottom }
27         model: xmlModel
28         delegate: listDelegate
29         clip: true
30     }
32     ScrollDecorator {
33         flickableItem: view
34     }
36     XmlListModel {
37         id: xmlModel
38         source: "http://forum.librepilot.org/index.php?board=11.0&action=.xml&type=atom&sa=news"
39         query: "/feed/entry"
40         namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';"
42         XmlRole { name: "title"; query: "title/string()" }
43         XmlRole { name: "description"; query: "summary/string()" }
44         XmlRole { name: "link"; query: "link/@href/string()" }
45     }
47     Component {
48         id: listDelegate
49         Item {
50             width: view.width
51             height: column.height + 16
53             Column {
54                 id: column
55                 spacing: 4
56                 Text {
57                     text: title
58                     width: view.width - 4
59                     textFormat: text.indexOf("&") > 0 ? Text.StyledText : Text.PlainText
60                     elide: Text.ElideRight
61                     font.bold: true
62                     color: mouseArea.containsMouse ? "#224d81" : "black"
63                 }
65                 Text {
66                     text: description
67                     width: view.width - 4
68                     textFormat: Text.RichText
69                     maximumLineCount: 3
70                     wrapMode: Text.WordWrap
71                     elide: Text.ElideRight
72                     color: mouseArea.containsMouse ? "#224d81" : "black"
73                 }
74             }
76             MouseArea {
77                 id: mouseArea
78                 anchors.fill: parent
79                 hoverEnabled: true
80                 onClicked: {
81                     console.log(link)
82                     container.clicked(link)
83                 }
84             }
85         }
86     }