diff --git a/Content/wallpaper_html/index.html b/Content/wallpaper_html/index.html new file mode 100644 index 00000000..91e09dfb --- /dev/null +++ b/Content/wallpaper_html/index.html @@ -0,0 +1,63 @@ + + + + + + + + + + + + +
+

This is my HTML Wallpaper 🚀

+
+ Hover over me! +
+
+ + diff --git a/Content/wallpaper_html/preview.png b/Content/wallpaper_html/preview.png new file mode 100644 index 00000000..06248e11 Binary files /dev/null and b/Content/wallpaper_html/preview.png differ diff --git a/Content/wallpaper_html/project.json b/Content/wallpaper_html/project.json new file mode 100644 index 00000000..0d7ed9a4 --- /dev/null +++ b/Content/wallpaper_html/project.json @@ -0,0 +1,10 @@ +{ + "createdBy": "", + "file": "index.html", + "preview": "preview.png", + "license": "Creative Commons - Attribution-ShareAlike 4.0", + "tags": [ + ], + "title": "test", + "type": "HTMLWallpaper" +} diff --git a/Content/wallpaper_interactive/main.qml b/Content/wallpaper_interactive/main.qml index d38c8277..475be5a1 100644 --- a/Content/wallpaper_interactive/main.qml +++ b/Content/wallpaper_interactive/main.qml @@ -1,6 +1,7 @@ -// SPDX-License-Identifier: BSD-3-Clause +// SPDX-License-Identifier: BSD-3-Clause import QtQuick +import QtQuick.Layouts import QtQuick.Controls import QtQuick.Controls.Material @@ -8,9 +9,20 @@ Rectangle { id: root color: "#333333" anchors.fill: parent - - Button { + property int counter: 0 + ColumnLayout { anchors.centerIn: parent - text: "Click me!" + Text { + Layout.fillWidth: true + color: "white" + font.pointSize: 14 + text: "🎉 Qml Button clicked: " + root.counter + horizontalAlignment: Text.AlignHCenter + } + Button { + text: "Click me!" + Layout.fillWidth: true + onClicked: root.counter++ + } } } diff --git a/Content/wallpaper_interactive/preview.png b/Content/wallpaper_interactive/preview.png index 43d2f32a..d00ba04a 100644 Binary files a/Content/wallpaper_interactive/preview.png and b/Content/wallpaper_interactive/preview.png differ diff --git a/Content/wallpaper_particles/main.qml b/Content/wallpaper_particles/main.qml index 6b6fd110..35febbda 100644 --- a/Content/wallpaper_particles/main.qml +++ b/Content/wallpaper_particles/main.qml @@ -1,5 +1,4 @@ // SPDX-License-Identifier: BSD-3-Clause - import QtQuick import QtQuick.Effects import QtQuick.Particles @@ -43,33 +42,22 @@ Item { anchors.fill: parent hoverEnabled: true Component.onCompleted: { - attractor.pointX = parent.width * .5; - attractor.pointY = 0; + attractor.pointX = parent.width * .5 + attractor.pointY = 0 } - onPressed: - //attractor.enabled = true - { + onPressed: { + attractor.enabled = true } onPositionChanged: { - attractor.pointX = mouseX; - attractor.pointY = mouseY; - rct.x = mouseX; - rct.y = mouseY; + attractor.pointX = mouseX + attractor.pointY = mouseY } - onReleased: - //attractor.enabled = false - { + onReleased: { + attractor.enabled = false } } - Rectangle { - id: rct - color: "orange" - width: 40 - height: 40 - } - Attractor { id: attractor system: particleSystem @@ -131,7 +119,7 @@ Item { bottom: parent.bottom bottomMargin: -width * .65 } - SequentialAnimation on opacity { + SequentialAnimation on opacity { loops: Animation.Infinite OpacityAnimator { diff --git a/Content/wallpaper_particles/preview.png b/Content/wallpaper_particles/preview.png index 43d2f32a..cef23ff7 100644 Binary files a/Content/wallpaper_particles/preview.png and b/Content/wallpaper_particles/preview.png differ diff --git a/Content/widget_analogClock/Clock.qml b/Content/widget_analog_clock/Clock.qml similarity index 100% rename from Content/widget_analogClock/Clock.qml rename to Content/widget_analog_clock/Clock.qml diff --git a/Content/widget_analogClock/Readme.md b/Content/widget_analog_clock/Readme.md similarity index 100% rename from Content/widget_analogClock/Readme.md rename to Content/widget_analog_clock/Readme.md diff --git a/Content/widget_analogClock/center.png b/Content/widget_analog_clock/center.png similarity index 100% rename from Content/widget_analogClock/center.png rename to Content/widget_analog_clock/center.png diff --git a/Content/widget_analogClock/hour.png b/Content/widget_analog_clock/hour.png similarity index 100% rename from Content/widget_analogClock/hour.png rename to Content/widget_analog_clock/hour.png diff --git a/Content/widget_analogClock/ic_close_white_64px.svg b/Content/widget_analog_clock/ic_close_white_64px.svg similarity index 100% rename from Content/widget_analogClock/ic_close_white_64px.svg rename to Content/widget_analog_clock/ic_close_white_64px.svg diff --git a/Content/widget_analogClock/main.qml b/Content/widget_analog_clock/main.qml similarity index 100% rename from Content/widget_analogClock/main.qml rename to Content/widget_analog_clock/main.qml diff --git a/Content/widget_analogClock/minute.png b/Content/widget_analog_clock/minute.png similarity index 100% rename from Content/widget_analogClock/minute.png rename to Content/widget_analog_clock/minute.png diff --git a/Content/widget_analogClock/preview.png b/Content/widget_analog_clock/preview.png similarity index 100% rename from Content/widget_analogClock/preview.png rename to Content/widget_analog_clock/preview.png diff --git a/Content/widget_analogClock/project.json b/Content/widget_analog_clock/project.json similarity index 100% rename from Content/widget_analogClock/project.json rename to Content/widget_analog_clock/project.json diff --git a/Content/widget_digitalClock/Readme.md b/Content/widget_digital_clock/Readme.md similarity index 100% rename from Content/widget_digitalClock/Readme.md rename to Content/widget_digital_clock/Readme.md diff --git a/Content/widget_digitalClock/ic_close_white_64px.svg b/Content/widget_digital_clock/ic_close_white_64px.svg similarity index 100% rename from Content/widget_digitalClock/ic_close_white_64px.svg rename to Content/widget_digital_clock/ic_close_white_64px.svg diff --git a/Content/widget_digitalClock/main.qml b/Content/widget_digital_clock/main.qml similarity index 76% rename from Content/widget_digitalClock/main.qml rename to Content/widget_digital_clock/main.qml index 8af90611..42fab09e 100644 --- a/Content/widget_digitalClock/main.qml +++ b/Content/widget_digital_clock/main.qml @@ -8,31 +8,32 @@ Item { implicitHeight: 100 function timeChanged() { - var date = new Date; - var hours = ""; - var minutes = ""; - var seconds = ""; + var date = new Date + var hours = "" + var minutes = "" + var seconds = "" if (date.getHours() < 10) { - hours = "0" + date.getHours().toString(); + hours = "0" + date.getHours().toString() } else { - hours = date.getHours().toString(); + hours = date.getHours().toString() } if (date.getMinutes() < 10) { - minutes = "0" + date.getMinutes().toString(); + minutes = "0" + date.getMinutes().toString() } else { - minutes = date.getMinutes().toString(); + minutes = date.getMinutes().toString() } if (date.getSeconds() < 10) { - seconds = "0" + date.getSeconds().toString(); + seconds = "0" + date.getSeconds().toString() } else { - seconds = date.getSeconds().toString(); + seconds = date.getSeconds().toString() } - var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; - var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; - var day = days[date.getDay()]; - var month = months[date.getMonth()]; - txtClock.text = hours + ":" + minutes + ":" + seconds; - txtDate.text = day + ", " + date.getDay() + " " + month + ", " + date.getFullYear(); + var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] + var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] + var day = days[date.getDay()] + var month = months[date.getMonth()] + txtClock.text = hours + ":" + minutes + ":" + seconds + txtDate.text = day + ", " + date.getDay( + ) + " " + month + ", " + date.getFullYear() } Timer { diff --git a/Content/widget_digitalClock/preview.png b/Content/widget_digital_clock/preview.png similarity index 100% rename from Content/widget_digitalClock/preview.png rename to Content/widget_digital_clock/preview.png diff --git a/Content/widget_digitalClock/project.json b/Content/widget_digital_clock/project.json similarity index 100% rename from Content/widget_digitalClock/project.json rename to Content/widget_digital_clock/project.json diff --git a/Content/widget_rss_dw_news/PostDelegate.qml b/Content/widget_rss_dw_news/PostDelegate.qml deleted file mode 100644 index bef8874f..00000000 --- a/Content/widget_rss_dw_news/PostDelegate.qml +++ /dev/null @@ -1,47 +0,0 @@ -// 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/preview.png b/Content/widget_rss_dw_news/preview.png deleted file mode 100644 index f5fa6037..00000000 Binary files a/Content/widget_rss_dw_news/preview.png and /dev/null differ diff --git a/Content/widget_rss_guardian_news/PostDelegate.qml b/Content/widget_rss_guardian_news/PostDelegate.qml new file mode 100644 index 00000000..5e3b1d61 --- /dev/null +++ b/Content/widget_rss_guardian_news/PostDelegate.qml @@ -0,0 +1,57 @@ + +// SPDX-License-Identifier: BSD-3-Clause +import QtQuick +import QtQuick.Layouts + +Item { + id: root + + implicitHeight: 80 + implicitWidth: 300 + + property string published + property string rights + property string updated + property string category + property string title + property string link + property string mediaContent + onMediaContentChanged: { + print("src") + const src = parseItem(model.mediaContent, 'url="', '"') + print("src", src) + //img.source = src; + } + + function parseItem(raw, startTag, endTag) { + var startIdx = raw.indexOf(startTag) + startTag.length + var endIdx = raw.indexOf(endTag, startIdx) + return raw.substring(startIdx, endIdx) + } + + RowLayout { + anchors.fill: parent + Image { + id: img + Layout.fillWidth: true + Layout.fillHeight: true + } + Text { + Layout.fillHeight: true + Layout.fillWidth: true + font.pointSize: 12 + wrapMode: Text.Wrap + text: model.title + height: 20 + color: "white" + } + } + MouseArea { + anchors.fill: parent + onClicked: { + print(model.category) + print(model.mediaContent) + //Qt.openUrlExternally(model.link); + } + } +} diff --git a/Content/widget_rss_dw_news/Readme.md b/Content/widget_rss_guardian_news/Readme.md similarity index 100% rename from Content/widget_rss_dw_news/Readme.md rename to Content/widget_rss_guardian_news/Readme.md diff --git a/Content/widget_rss_dw_news/main.qml b/Content/widget_rss_guardian_news/main.qml similarity index 60% rename from Content/widget_rss_dw_news/main.qml rename to Content/widget_rss_guardian_news/main.qml index 91420fd5..e54e55e4 100644 --- a/Content/widget_rss_dw_news/main.qml +++ b/Content/widget_rss_guardian_news/main.qml @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: BSD-3-Clause +// SPDX-License-Identifier: BSD-3-Clause import QtQuick import QtQuick.Controls import QtQuick.Controls.Material @@ -14,36 +14,14 @@ Item { XmlListModel { id: feedModel - source: "https://rss.dw.com/atom/rss-en-all" - query: "/feed/entry" - onCountChanged: { - console.log("count ", count); - } + source: "https://www.theguardian.com/world/rss" + query: "/rss/channel/item" onStatusChanged: { - print("status ", status); - console.log("count ", count); if (status === XmlListModel.Error) { - console.log("Error: " + errorString); + 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" @@ -51,11 +29,36 @@ Item { XmlListModelRole { name: "link" elementName: "link" - attributeName: "href" } XmlListModelRole { - name: "summary" - elementName: "summary" + name: "description" + elementName: "description" + } + XmlListModelRole { + name: "category" + elementName: "category" + attributeName: "domain" + } + XmlListModelRole { + name: "pubDate" + elementName: "pubDate" + } + XmlListModelRole { + name: "guid" + elementName: "guid" + } + XmlListModelRole { + name: "creator" + elementName: "dc:creator" + } + XmlListModelRole { + name: "date" + elementName: "dc:date" + } + XmlListModelRole { + name: "mediaContent" + elementName: "media:content" + attributeName: "url" } } @@ -67,7 +70,7 @@ Item { spacing: 10 model: feedModel delegate: PostDelegate { - width: parent.width + width: root.width } } } diff --git a/Content/widget_rss_guardian_news/preview.png b/Content/widget_rss_guardian_news/preview.png new file mode 100644 index 00000000..a275945c Binary files /dev/null and b/Content/widget_rss_guardian_news/preview.png differ diff --git a/Content/widget_rss_dw_news/project.json b/Content/widget_rss_guardian_news/project.json similarity index 100% rename from Content/widget_rss_dw_news/project.json rename to Content/widget_rss_guardian_news/project.json diff --git a/Content/widget_rss_hackernews/PostDelegate.qml b/Content/widget_rss_hackernews/PostDelegate.qml new file mode 100644 index 00000000..275823d5 --- /dev/null +++ b/Content/widget_rss_hackernews/PostDelegate.qml @@ -0,0 +1,94 @@ +// SPDX-License-Identifier: BSD-3-Clause +import QtQuick +import QtQuick.Layouts +import ScreenPlayAssets + +Item { + id: root + height: wrapper.childrenRect.height + + property string points + property string commentCount + property string pubDate + property string pubDateFormatted + onPubDateChanged: { + var date = new Date(pubDate) + root.pubDateFormatted = date.toLocaleDateString( + Qt.locale(), + "ddd, dd MMM yyyy") + ' ' + date.toLocaleTimeString( + Qt.locale(), "HH:mm:ss") + } + property string description + onDescriptionChanged: { + print("description") + // See https://hnrss.org/frontpage content + // We need to manually parse it here to get the points and comments + points = parsePoints(description) + commentCount = parseCommentCount(description) + print(points, commentCount) + } + + function parseCommentCount(raw) { + var commentPrefix = "

# Comments: " + var commentSuffix = "

" + var startIdx = raw.indexOf(commentPrefix) + if (startIdx === -1) + return "N/A" // return "N/A" if comment count is not found in the description + startIdx += commentPrefix.length + var endIdx = raw.indexOf(commentSuffix, startIdx) + return raw.substring(startIdx, endIdx) + } + function parsePoints(raw) { + var pointsPrefix = "

Points: " + var pointsSuffix = "

" + var startIdx = raw.indexOf(pointsPrefix) + if (startIdx === -1) + return "N/A" // return "N/A" if points are not found in the description + startIdx += pointsPrefix.length + var endIdx = raw.indexOf(pointsSuffix, startIdx) + return raw.substring(startIdx, endIdx) + } + RowLayout { + id: wrapper + width: root.width + spacing: 5 + ColumnLayout { + Layout.fillHeight: true + Layout.fillWidth: true + + Text { + id: titleText + text: model.title + wrapMode: Text.WordWrap + font.pointSize: 14 + font.bold: true + color: "white" + Layout.maximumWidth: wrapper.width * .9 + MouseArea { + anchors.fill: parent + cursorShape: Qt.PointingHandCursor + onClicked: { + Qt.openUrlExternally(model.link) + } + } + } + + Text { + id: descriptionText + text: root.points + " Points • " + root.commentCount + + " Comments 🔗 " + "• Published: " + root.pubDateFormatted + wrapMode: Text.WordWrap + font.pointSize: 10 + opacity: .7 + color: "white" + MouseArea { + anchors.fill: parent + cursorShape: Qt.PointingHandCursor + onClicked: { + Qt.openUrlExternally(model.commentsLink) + } + } + } + } + } +} diff --git a/Content/widget_rss_hackernews/Readme.md b/Content/widget_rss_hackernews/Readme.md new file mode 100644 index 00000000..ec528c58 --- /dev/null +++ b/Content/widget_rss_hackernews/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_hackernews/main.qml b/Content/widget_rss_hackernews/main.qml new file mode 100644 index 00000000..87708c2c --- /dev/null +++ b/Content/widget_rss_hackernews/main.qml @@ -0,0 +1,117 @@ + +// SPDX-License-Identifier: BSD-3-Clause +import QtQuick +import QtQuick.Layouts +import QtQuick.Controls +import QtQuick.Controls.Material +import QtQml.XmlListModel +import ScreenPlayAssets + +Item { + id: root + implicitWidth: 480 + implicitHeight: 480 + ColumnLayout { + anchors.fill: parent + anchors.margins: 10 + + RowLayout { + Layout.fillWidth: true + ComboBox { + id: combo + Layout.fillWidth: true + Layout.preferredWidth: 1 + Layout.preferredHeight: 50 + valueRole: "rssurl" + textRole: "text" + Material.foreground: "white" + model: ListModel { + ListElement { + text: "Best" + rssurl: "https://hnrss.org/best" + } + ListElement { + text: "Front Page" + rssurl: "https://hnrss.org/frontpage" + } + ListElement { + text: "Jobs" + rssurl: "https://hnrss.org/jobs" + } + ListElement { + text: "Newest > 100 pts" + rssurl: "https://hnrss.org/newest?points=100" + } + } + onActivated: { + rssModel.source = combo.currentValue + } + } + ToolButton { + text: "Reload" + Material.foreground: "white" + onPressed: rssModel.load() + } + } + + ListView { + id: list + Layout.fillWidth: true + Layout.fillHeight: true + spacing: 10 + clip: true + model: rssModel + delegate: PostDelegate { + width: root.width + description: model.description + pubDate: model.pubDate + } + } + } + Timer { + interval: 15 * 60 * 1000 // 15 minutes + running: true + repeat: true + onTriggered: rssModel.load() + } + XmlListModel { + id: rssModel + source: combo.currentValue + query: "/rss/channel/item" + function load() { + print(":load") + var tempSource = rssModel.source + rssModel.source = "" + rssModel.source = tempSource + } + + XmlListModelRole { + name: "title" + elementName: "title" + } + XmlListModelRole { + name: "link" + elementName: "link" + } + XmlListModelRole { + name: "creator" + elementName: "dc:creator" + } + XmlListModelRole { + name: "commentsLink" + elementName: "comments" + } + XmlListModelRole { + name: "guid" + elementName: "guid" + } + XmlListModelRole { + name: "description" + elementName: "description" + } + XmlListModelRole { + name: "pubDate" + elementName: "pubDate" + } + } +} diff --git a/Content/widget_rss_hackernews/preview.png b/Content/widget_rss_hackernews/preview.png new file mode 100644 index 00000000..022b7d37 Binary files /dev/null and b/Content/widget_rss_hackernews/preview.png differ diff --git a/Content/widget_rss_hackernews/project.json b/Content/widget_rss_hackernews/project.json new file mode 100644 index 00000000..2811afff --- /dev/null +++ b/Content/widget_rss_hackernews/project.json @@ -0,0 +1,12 @@ +{ + "description": "Widget that shows the latest hackernews feed", + "file": "main.qml", + "preview": "preview.png", + "tags": [ + "hackernews", + "rss", + "feed" + ], + "title": "hackernews", + "type": "qmlWidget" +} \ No newline at end of file diff --git a/Content/widget_rss_reddit/PostDelegate.qml b/Content/widget_rss_reddit/PostDelegate.qml deleted file mode 100644 index 0a1d2dc6..00000000 --- a/Content/widget_rss_reddit/PostDelegate.qml +++ /dev/null @@ -1,69 +0,0 @@ -// 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 deleted file mode 100644 index cbc8e706..00000000 --- a/Content/widget_rss_reddit/Readme.md +++ /dev/null @@ -1 +0,0 @@ -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 deleted file mode 100644 index 3e2d0ddd..00000000 --- a/Content/widget_rss_reddit/main.qml +++ /dev/null @@ -1,60 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause - -import QtQuick -import QtQuick.Controls -import QtQuick.Controls.Material -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 deleted file mode 100644 index bf792d29..00000000 Binary files a/Content/widget_rss_reddit/preview.png and /dev/null differ diff --git a/Content/widget_rss_reddit/project.json b/Content/widget_rss_reddit/project.json deleted file mode 100644 index 9f805672..00000000 --- a/Content/widget_rss_reddit/project.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "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/Content/widget_system_stats/main.qml b/Content/widget_system_stats/main.qml index d621a1bc..abe23e9a 100644 --- a/Content/widget_system_stats/main.qml +++ b/Content/widget_system_stats/main.qml @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: BSD-3-Clause +// SPDX-License-Identifier: BSD-3-Clause import QtQuick import QtQuick.Layouts import QtQuick.Controls @@ -28,11 +28,11 @@ Item { } function stringListToString(list) { - let out = ""; + let out = "" for (var i = 0; i < list.length; i++) { - out += "\n" + list[i]; + out += "\n" + list[i] } - return out; + return out } RowLayout { @@ -57,7 +57,8 @@ Item { } } Text { - text: root.stringListToString(ipAddress.privateIpV4AddressList) + text: root.stringListToString( + ipAddress.privateIpV4AddressList) color: root.accentColor font { pointSize: 16 @@ -65,7 +66,8 @@ Item { } } Text { - text: root.stringListToString(ipAddress.privateIpV6AddressList) + text: root.stringListToString( + ipAddress.privateIpV6AddressList) color: root.accentColor font { pointSize: 16 diff --git a/Content/widget_weather/main.qml b/Content/widget_weather/main.qml index c5e2c180..4f934ada 100644 --- a/Content/widget_weather/main.qml +++ b/Content/widget_weather/main.qml @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: BSD-3-Clause +// SPDX-License-Identifier: BSD-3-Clause import QtQuick import QtQuick.Layouts import QtQuick.Controls @@ -20,56 +20,56 @@ Item { id: weather city: "Friedrichshafen" onReady: { - rp.model = weather.days; + rp.model = weather.days // Qt bug https://bugreports.qt.io/browse/QTBUG-105137 - test(); + test() } } - function test() { - } + function test() {} function mapWeatherCode(code) { - const weather_time = ""; // or "-day", "-night" - const weather_prefix = "wi" + weather_time + "-"; + const weather_time = "" + // or "-day", "-night" + const weather_prefix = "wi" + weather_time + "-" // https://open-meteo.com/en/docs // WMO Weather interpretation codes (WW) // to https://erikflowers.github.io/weather-icons/ switch (code) { case 0: - return weather_prefix + "day-sunny"; + return weather_prefix + "day-sunny" case 1: case 2: case 3: - return weather_prefix + "cloud"; + return weather_prefix + "cloud" case 45: case 48: - return weather_prefix + "day-sunny"; + return weather_prefix + "day-sunny" case 51: case 53: case 55: - return weather_prefix + "rain-mix"; + return weather_prefix + "rain-mix" case 61: case 63: case 65: - return weather_prefix + "rain-mix"; + return weather_prefix + "rain-mix" case 71: case 73: case 75: - return weather_prefix + "snow"; + return weather_prefix + "snow" case 77: - return weather_prefix + "snow"; + return weather_prefix + "snow" case 80: case 81: case 82: - return weather_prefix + "snow"; + return weather_prefix + "snow" case 85: case 86: - return weather_prefix + "snow"; + return weather_prefix + "snow" case 95: - return weather_prefix + "thunderstorm"; + return weather_prefix + "thunderstorm" case 96: case 99: - return weather_prefix + "storm-showers"; + return weather_prefix + "storm-showers" } } @@ -89,7 +89,9 @@ Item { Layout.alignment: Qt.AlignCenter horizontalAlignment: Text.AlignHCenter color: Material.primaryTextColor - text: "longtitude: " + weather.longtitude + " - latitude: " + weather.latitude + " - elevation: " + weather.elevation + "m - population: " + weather.population + text: "longtitude: " + weather.longtitude + " - latitude: " + + weather.latitude + " - elevation: " + weather.elevation + + "m - population: " + weather.population } RowLayout { @@ -127,7 +129,8 @@ Item { } Layout.alignment: Qt.AlignCenter horizontalAlignment: Image.AlignHCenter - source: "qrc:/qml/ScreenPlayWeather/assets/icons/" + root.mapWeatherCode(weatherCode) + ".svg" + source: "qrc:/qml/ScreenPlayWeather/assets/icons/" + root.mapWeatherCode( + weatherCode) + ".svg" } TextItem { text: "Weather Code" diff --git a/Content/widget_xkcd/main.qml b/Content/widget_xkcd/main.qml index 2142ce05..377b6706 100644 --- a/Content/widget_xkcd/main.qml +++ b/Content/widget_xkcd/main.qml @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: BSD-3-Clause +// SPDX-License-Identifier: BSD-3-Clause import QtQuick import QtQuick.Controls import QtQuick.Controls.Material @@ -8,45 +8,84 @@ import QtQuick.Particles Item { id: root - implicitWidth: 360 - implicitHeight: 360 + state: "normal" + implicitWidth: defaultWidth + implicitHeight: defaultHeight + property int defaultWidth: 200 + property int defaultHeight: 200 - Image { - id: img - anchors.fill: parent - onStatusChanged: { - if (img.status !== Image.Ready) - return; - if (img.sourceSize.width === 0 || img.sourceSize.height === 0) - return; - root.implicitHeight = img.sourceSize.height; - root.implicitWidth = img.sourceSize.width; - } - - fillMode: Image.PreserveAspectCrop + function request(url, callback) { + var xhr = new XMLHttpRequest() + xhr.onreadystatechange = (function (myxhr) { + return function () { + if (myxhr.readyState === 4) + callback(myxhr) + } + })(xhr) + xhr.open('GET', url) + xhr.send('') } Component.onCompleted: { request("http://xkcd.com/info.0.json", function (o) { - if (o.status === 200) { - var d = eval('new Object(' + o.responseText + ')'); - console.log(o.responseText); - img.source = d.img; - } else { - console.log("Some error has occurred"); - } - }); + if (o.status === 200) { + var d = eval('new Object(' + o.responseText + ')') + console.log(o.responseText) + img.source = d.img + } else { + console.log("Some error has occurred") + } + }) } - function request(url, callback) { - var xhr = new XMLHttpRequest(); - xhr.onreadystatechange = (function (myxhr) { - return function () { - if (myxhr.readyState === 4) - callback(myxhr); - }; - })(xhr); - xhr.open('GET', url); - xhr.send(''); + Image { + id: img + anchors.fill: parent + fillMode: Image.PreserveAspectCrop + property size imgSize: Qt.size(root.defaultWidth, defaultHeight) + onStatusChanged: { + if (img.status !== Image.Ready) + return + if (img.sourceSize.width === 0 || img.sourceSize.height === 0) + return + root.implicitWidth = img.sourceSize.width + root.implicitHeight = img.sourceSize.height + print(img.status, img.sourceSize.width, img.sourceSize.height) + img.imgSize = Qt.size(img.sourceSize.width, img.sourceSize.height) + print("img.size", img.imgSize) + } } + + MouseArea { + anchors.fill: parent + onClicked: { + root.state = root.state === "expanded" ? "normal" : "expanded" + print(root.state, root.implicitHeight, root.implicitWidth) + } + } + + states: [ + State { + PropertyChanges { + name: "normal" + root { + width: root.defaultWidth + height: root.defaultHeight + implicitWidth: root.defaultWidth + implicitHeight: root.defaultHeight + } + } + }, + State { + name: "expanded" + PropertyChanges { + root { + width: img.imgSize.width + height: img.imgSize.height + implicitWidth: img.imgSize.width + implicitHeight: img.imgSize.height + } + } + } + ] } diff --git a/Content/widget_countDown/main.qml b/Content/widget_year_count_down/main.qml similarity index 58% rename from Content/widget_countDown/main.qml rename to Content/widget_year_count_down/main.qml index 39fab9d4..dfddb45e 100644 --- a/Content/widget_countDown/main.qml +++ b/Content/widget_year_count_down/main.qml @@ -11,9 +11,17 @@ Item { implicitWidth: 240 implicitHeight: 120 property int totalHours: 24 - property int remainingHours: Math.max(0, Math.floor((new Date().setHours(24, 0, 0, 0) - new Date()) / 3600000)) - property int totalDays: new Date(new Date().getFullYear() + 1, 0, 1) - new Date() / (24 * 60 * 60 * 1000) - property int remainingDays: Math.max(0, Math.floor((new Date(new Date().getFullYear() + 1, 0, 1) - new Date()) / (24 * 60 * 60 * 1000))) + property int remainingHours: Math.max(0, Math.floor( + (new Date().setHours( + 24, 0, 0, + 0) - new Date()) / 3600000)) + property int totalDays: new Date(new Date().getFullYear() + 1, 0, + 1) - new Date() / (24 * 60 * 60 * 1000) + property int remainingDays: Math.max( + 0, Math.floor( + (new Date(new Date().getFullYear() + 1, + 0, + 1) - new Date()) / (24 * 60 * 60 * 1000))) Material.theme: Material.Dark Material.accent: Material.DeepOrange @@ -42,7 +50,11 @@ Item { running: true repeat: true onTriggered: { - remainingHours = Math.max(0, Math.floor((new Date().setHours(24, 0, 0, 0) - new Date()) / 3600000)); + remainingHours = Math.max( + 0, + Math.floor((new Date().setHours( + 24, 0, 0, + 0) - new Date()) / 3600000)) } } } @@ -69,7 +81,11 @@ Item { running: true repeat: true onTriggered: { - remainingDays = Math.max(0, Math.floor((new Date(new Date().getFullYear() + 1, 0, 1) - new Date()) / (24 * 60 * 60 * 1000))); + remainingDays = Math.max(0, + Math.floor((new Date(new Date().getFullYear( + ) + 1, + 0, 1) + - new Date()) / (24 * 60 * 60 * 1000))) } } } diff --git a/Content/widget_countDown/preview.png b/Content/widget_year_count_down/preview.png similarity index 100% rename from Content/widget_countDown/preview.png rename to Content/widget_year_count_down/preview.png diff --git a/Content/widget_countDown/project.json b/Content/widget_year_count_down/project.json similarity index 100% rename from Content/widget_countDown/project.json rename to Content/widget_year_count_down/project.json