diff --git a/Content/widget_rss_dw_news/PostDelegate.qml b/Content/widget_rss_dw_news/PostDelegate.qml new file mode 100644 index 00000000..36dc71a8 --- /dev/null +++ b/Content/widget_rss_dw_news/PostDelegate.qml @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: BSD-3-Clause + +import QtQuick +import QtQuick.Layouts + +Item { + id: root + + implicitHeight: 100 + implicitWidth: 300 + + property string published + property string rights + property string updated + property string category + property string title + property string link + property string summary + + ColumnLayout { + anchors.fill: parent + Text { + Layout.fillWidth: true + font.pointSize: 14 + wrapMode: Text.Wrap + text: model.title + height: 20 + color: "white" + } + + Text { + Layout.fillWidth: true + wrapMode: Text.Wrap + text: model.summary + font.pointSize: 10 + height: 20 + color: "white" + } + } + MouseArea { + anchors.fill: parent + onClicked: { + print(model.link) + Qt.openUrlExternally(model.link) + } + } +} diff --git a/Content/widget_rss_dw_news/Readme.md b/Content/widget_rss_dw_news/Readme.md new file mode 100644 index 00000000..ec528c58 --- /dev/null +++ b/Content/widget_rss_dw_news/Readme.md @@ -0,0 +1,3 @@ +Widget that shows the latest dw feed + +https://corporate.dw.com/en/rss/s-31500 \ No newline at end of file diff --git a/Content/widget_rss_dw_news/main.qml b/Content/widget_rss_dw_news/main.qml new file mode 100644 index 00000000..8521c87b --- /dev/null +++ b/Content/widget_rss_dw_news/main.qml @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: BSD-3-Clause + +import QtQuick +import QtQuick.Controls +import QtQuick.Effects +import QtQuick.Particles +import QtQml.XmlListModel + +Item { + id: root + implicitWidth: 480 + implicitHeight: 480 + + XmlListModel { + id: feedModel + source: "https://rss.dw.com/atom/rss-en-all" + query: "/feed/entry" + onCountChanged: { + console.log("count ",count) + } + onStatusChanged: { + print("status ",status) + console.log("count ",count) + + if (status === XmlListModel.Error) { + console.log("Error: " + errorString); + } + } + + XmlListModelRole { name: "published"; elementName: "published" } + XmlListModelRole { name: "rights"; elementName: "rights" } + XmlListModelRole { name: "updated"; elementName: "updated" } + XmlListModelRole { name: "category"; elementName: "category"; attributeName: "term" } + XmlListModelRole { name: "title"; elementName: "title"} + XmlListModelRole { name: "link"; elementName: "link"; attributeName: "href" } + XmlListModelRole { name: "summary"; elementName: "summary"} + + } + + ListView { + id: list + anchors.fill: parent + anchors.margins: 10 + anchors.topMargin: 20 + spacing: 10 + model: feedModel + delegate: PostDelegate { + width: parent.width + } + } +} diff --git a/Content/widget_rss_dw_news/preview.png b/Content/widget_rss_dw_news/preview.png new file mode 100644 index 00000000..f5fa6037 Binary files /dev/null and b/Content/widget_rss_dw_news/preview.png differ diff --git a/Content/widget_rss_dw_news/project.json b/Content/widget_rss_dw_news/project.json new file mode 100644 index 00000000..0f6adfa6 --- /dev/null +++ b/Content/widget_rss_dw_news/project.json @@ -0,0 +1,10 @@ +{ + "description": "Widget that shows the latest Detusche Welle feed", + "file": "main.qml", + "preview": "preview.png", + "tags": [ + "dw" + ], + "title": "dw", + "type": "qmlWidget" +} diff --git a/Content/widget_rss_reddit/PostDelegate.qml b/Content/widget_rss_reddit/PostDelegate.qml new file mode 100644 index 00000000..18008df1 --- /dev/null +++ b/Content/widget_rss_reddit/PostDelegate.qml @@ -0,0 +1,64 @@ +// SPDX-License-Identifier: BSD-3-Clause + +import QtQuick +import QtQuick.Layouts + +Item { + id: root + + implicitHeight: 300 + implicitWidth: 300 + + property string contentRaw: model.content + property url href + onContentRawChanged: { + // Define the regular expression to match the image URL + var regex = /\[link\]<\/a>/i; + + // Parse the image URL from the HTML content + var match = regex.exec(contentRaw); + if (match != null) { + var imageUrl = match[1]; + var href = match[2]; + img.source = "" + imageUrl + root.href = "" + href + } + } + + Image { + id: img + asynchronous: true + anchors.fill: parent + clip:true + fillMode: Image.PreserveAspectCrop + + } + Rectangle { + anchors.fill: img + gradient: Gradient { + GradientStop { position: 0; color: "#00333333" } + GradientStop { position: 1; color: "#ff333333" } + } + } + + Text { + anchors { + right: parent.right + bottom: parent.bottom + left: parent.left + leftMargin: 10 + } + wrapMode: Text.Wrap + width: parent.width + text: model.title + height: 20 + color: "white" + } + MouseArea { + anchors.fill: parent + onClicked: { + print(model.link) + Qt.openUrlExternally(model.link) + } + } +} diff --git a/Content/widget_rss_reddit/Readme.md b/Content/widget_rss_reddit/Readme.md new file mode 100644 index 00000000..cbc8e706 --- /dev/null +++ b/Content/widget_rss_reddit/Readme.md @@ -0,0 +1 @@ +Widget that shows the latest reddit feed \ No newline at end of file diff --git a/Content/widget_rss_reddit/main.qml b/Content/widget_rss_reddit/main.qml new file mode 100644 index 00000000..68918d54 --- /dev/null +++ b/Content/widget_rss_reddit/main.qml @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: BSD-3-Clause + +import QtQuick +import QtQuick.Controls +import QtQuick.Effects +import QtQuick.Particles +import QtQml.XmlListModel + +Item { + id: root + implicitWidth: 480 + implicitHeight: 480 + + property string subreddit: "funny" + + XmlListModel { + id: feedModel + onStatusChanged: { + print("status ",status) + + if (status === XmlListModel.Error) { + console.log("Error: " + errorString); + } + } + + source: "https://www.reddit.com/r/" + root.subreddit + "/.rss" + query: "/feed/entry" + + XmlListModelRole { name: "updated"; elementName: "updated" } + XmlListModelRole { name: "subtitle"; elementName: "subtitle"} + XmlListModelRole { name: "content"; elementName: "content"} + XmlListModelRole { name: "link"; elementName: "link"; attributeName: "href" } + XmlListModelRole { name: "title"; elementName: "title"} + + } + + ListView { + id: list + anchors.fill: parent + model: feedModel + delegate: PostDelegate { + width: parent.width + } + } +} diff --git a/Content/widget_rss_reddit/preview.png b/Content/widget_rss_reddit/preview.png new file mode 100644 index 00000000..bf792d29 Binary files /dev/null and b/Content/widget_rss_reddit/preview.png differ diff --git a/Content/widget_rss_reddit/project.json b/Content/widget_rss_reddit/project.json new file mode 100644 index 00000000..9f805672 --- /dev/null +++ b/Content/widget_rss_reddit/project.json @@ -0,0 +1,16 @@ +{ + "description": "Widget that shows the latest reddit feed", + "file": "main.qml", + "preview": "preview.png", + "tags": [ + "reddit" + ], + "title": "reddit", + "type": "qmlWidget", + "properties": { + "subreddit": { + "type": "string", + "value": "funny" + } + } +} diff --git a/ScreenPlayWidget/main.cpp b/ScreenPlayWidget/main.cpp index 69dd8a48..e7ab316e 100644 --- a/ScreenPlayWidget/main.cpp +++ b/ScreenPlayWidget/main.cpp @@ -42,6 +42,8 @@ int main(int argc, char* argv[]) QStringList contentFolder = { "/widget_analogClock", "/widget_digitalClock", + "/widget_rss_reddit", + "/widget_rss_dw_news", "/widget_xkcd" }; QString projectPath = exampleContentPath + contentFolder.at(0);