mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-22 02:32:29 +01:00
Add stats, weather and cuntdown widgets
This commit is contained in:
parent
6a4cae4e24
commit
1689931060
@ -3,7 +3,7 @@
|
||||
"description": "",
|
||||
"file": "main.qml",
|
||||
"preview": "preview.png",
|
||||
"type": "qmlScene",
|
||||
"type": "qmlWallpaper",
|
||||
"tags": [
|
||||
"example",
|
||||
"empty"
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Controls.Material
|
||||
import QtQuick.Effects
|
||||
import QtQuick.Particles
|
||||
|
||||
|
78
Content/widget_countDown/main.qml
Normal file
78
Content/widget_countDown/main.qml
Normal file
@ -0,0 +1,78 @@
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Controls.Material
|
||||
import QtQuick.Effects
|
||||
import QtQuick.Particles
|
||||
|
||||
Item {
|
||||
id: root
|
||||
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)))
|
||||
|
||||
Material.theme: Material.Dark
|
||||
Material.accent: Material.DeepOrange
|
||||
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 10
|
||||
ColumnLayout {
|
||||
|
||||
Layout.fillWidth: true
|
||||
Text {
|
||||
id: countdownTextHours
|
||||
color: Material.primaryTextColor
|
||||
text: remainingHours + " hours left today"
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
ProgressBar {
|
||||
id: countdownProgressHours
|
||||
Layout.fillWidth: true
|
||||
height: 10
|
||||
value: totalHours - remainingHours
|
||||
to: totalHours
|
||||
Timer {
|
||||
interval: 1000
|
||||
running: true
|
||||
repeat: true
|
||||
onTriggered: {
|
||||
remainingHours = Math.max(0, Math.floor((new Date().setHours(24, 0, 0, 0) - new Date()) / 3600000));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
|
||||
Text {
|
||||
id: countdownTextDays
|
||||
color: Material.primaryTextColor
|
||||
text: remainingDays + " days left this year"
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
ProgressBar {
|
||||
id: countdownProgressDays
|
||||
Layout.fillWidth: true
|
||||
height: 10
|
||||
value: totalDays - remainingDays
|
||||
to: totalDays
|
||||
|
||||
Timer {
|
||||
interval: 1000 * 60
|
||||
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)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
BIN
Content/widget_countDown/preview.png
Normal file
BIN
Content/widget_countDown/preview.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 116 KiB |
12
Content/widget_countDown/project.json
Normal file
12
Content/widget_countDown/project.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"description": "Widget that counts down",
|
||||
"file": "main.qml",
|
||||
"preview": "preview.png",
|
||||
"tags": [
|
||||
"countdown",
|
||||
"year",
|
||||
"day"
|
||||
],
|
||||
"title": "Countdown",
|
||||
"type": "qmlWidget"
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls.Material
|
||||
import QtQuick.Window
|
||||
|
||||
Item {
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Controls.Material
|
||||
import QtQuick.Effects
|
||||
import QtQuick.Particles
|
||||
import QtQml.XmlListModel
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Controls.Material
|
||||
import QtQuick.Effects
|
||||
import QtQuick.Particles
|
||||
import QtQml.XmlListModel
|
||||
|
259
Content/widget_system_stats/main.qml
Normal file
259
Content/widget_system_stats/main.qml
Normal file
@ -0,0 +1,259 @@
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Controls.Material
|
||||
import QtQuick.Controls.Material.impl
|
||||
import ScreenPlaySysInfo
|
||||
|
||||
Item {
|
||||
id: root
|
||||
implicitWidth: 1200
|
||||
implicitHeight: 600
|
||||
|
||||
|
||||
Material.theme: Material.Dark
|
||||
Material.accent: Material.DeepOrange
|
||||
|
||||
property color accentColor: Material.secondaryTextColor
|
||||
property string fontFamily: "Arial"
|
||||
property int fontPointSize: 14
|
||||
|
||||
SysInfo {
|
||||
id: sysInfo
|
||||
}
|
||||
|
||||
IpAddress {
|
||||
id: ipAddress
|
||||
}
|
||||
|
||||
function stringListToString(list) {
|
||||
let out = "";
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
out += "\n" + list[i];
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
RowLayout {
|
||||
id: wrapper
|
||||
spacing: 40
|
||||
anchors.centerIn: parent
|
||||
ColumnLayout {
|
||||
id: wrapperLeft
|
||||
Layout.preferredWidth: 500
|
||||
|
||||
ColumnLayout {
|
||||
spacing: 10
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
Text {
|
||||
text: "Private Addresses"
|
||||
color: root.accentColor
|
||||
font {
|
||||
pointSize: 24
|
||||
family: root.fontFamily
|
||||
}
|
||||
}
|
||||
Text {
|
||||
text: root.stringListToString(ipAddress.privateIpV4AddressList)
|
||||
color: root.accentColor
|
||||
font {
|
||||
pointSize: 16
|
||||
family: "Fira Code"
|
||||
}
|
||||
}
|
||||
Text {
|
||||
text: root.stringListToString(ipAddress.privateIpV6AddressList)
|
||||
color: root.accentColor
|
||||
font {
|
||||
pointSize: 16
|
||||
family: "Fira Code"
|
||||
}
|
||||
}
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
color: root.accentColor
|
||||
Layout.preferredHeight: 3
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
Text {
|
||||
text: "Public Addresses"
|
||||
color: root.accentColor
|
||||
font {
|
||||
pointSize: 24
|
||||
family: root.fontFamily
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
text: ipAddress.publicIpV4Address
|
||||
color: root.accentColor
|
||||
font {
|
||||
pointSize: 16
|
||||
family: root.fontFamily
|
||||
}
|
||||
}
|
||||
Text {
|
||||
text: ipAddress.publicIpV6Address
|
||||
color: root.accentColor
|
||||
font {
|
||||
pointSize: 16
|
||||
family: root.fontFamily
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Rectangle {
|
||||
color: root.accentColor
|
||||
Layout.preferredHeight: 600
|
||||
width: 3
|
||||
}
|
||||
ColumnLayout {
|
||||
id: wrapperRight
|
||||
spacing: 20
|
||||
Layout.preferredWidth: 500
|
||||
Text {
|
||||
id: txtGPU
|
||||
text: "GPU"
|
||||
color: root.accentColor
|
||||
font.family: root.fontFamily
|
||||
font.pointSize: 36
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Text {
|
||||
text: sysInfo.gpu.vendor
|
||||
color: root.accentColor
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
font {
|
||||
pointSize: 16
|
||||
family: "Fira Code"
|
||||
}
|
||||
}
|
||||
Text {
|
||||
text: sysInfo.gpu.name
|
||||
color: root.accentColor
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
font {
|
||||
pointSize: 16
|
||||
family: root.fontFamily
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
id: txtUptime
|
||||
text: "UPTIME"
|
||||
color: root.accentColor
|
||||
font.family: root.fontFamily
|
||||
font.pointSize: 36
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
id: valuesLayout
|
||||
spacing: 20
|
||||
Text {
|
||||
text: "DAYS " + sysInfo.uptime.days
|
||||
color: root.accentColor
|
||||
font.family: root.fontFamily
|
||||
font.pointSize: root.fontPointSize
|
||||
}
|
||||
Text {
|
||||
text: "HOURS " + sysInfo.uptime.hours
|
||||
color: root.accentColor
|
||||
font.family: root.fontFamily
|
||||
font.pointSize: root.fontPointSize
|
||||
}
|
||||
Text {
|
||||
text: "MINUTES " + sysInfo.uptime.minutes
|
||||
color: root.accentColor
|
||||
font.family: root.fontFamily
|
||||
font.pointSize: root.fontPointSize
|
||||
}
|
||||
|
||||
Text {
|
||||
id: txtSeconds
|
||||
text: "SECONDS " + sysInfo.uptime.seconds
|
||||
color: root.accentColor
|
||||
font.family: root.fontFamily
|
||||
font.pointSize: root.fontPointSize
|
||||
}
|
||||
}
|
||||
Text {
|
||||
id: txtCPU
|
||||
text: "CPU"
|
||||
color: root.accentColor
|
||||
font.family: root.fontFamily
|
||||
font.pointSize: 36
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
}
|
||||
RowLayout {
|
||||
spacing: 10
|
||||
Layout.preferredWidth: 300
|
||||
Text {
|
||||
id: txtCPUValue
|
||||
text: Math.floor(sysInfo.cpu.usage)
|
||||
color: root.accentColor
|
||||
font.family: root.fontFamily
|
||||
width: 70
|
||||
}
|
||||
ProgressBar {
|
||||
from: 0
|
||||
to: 100
|
||||
value: Math.floor(sysInfo.cpu.usage)
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
id: txtStorage
|
||||
text: "STORAGE"
|
||||
color: root.accentColor
|
||||
font.family: root.fontFamily
|
||||
font.pointSize: 36
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
}
|
||||
|
||||
ListView {
|
||||
id: storageListView
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 100
|
||||
model: sysInfo.storage
|
||||
delegate: Item {
|
||||
width: 500
|
||||
height: 40
|
||||
RowLayout {
|
||||
spacing: 10
|
||||
width: 500
|
||||
|
||||
Text {
|
||||
id: txtStorageName
|
||||
text: name
|
||||
color: root.accentColor
|
||||
font.family: root.fontFamily
|
||||
width: 70
|
||||
}
|
||||
ProgressBar {
|
||||
from: 0
|
||||
to: bytesTotal
|
||||
value: bytesAvailable
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
BIN
Content/widget_system_stats/preview.png
Normal file
BIN
Content/widget_system_stats/preview.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 303 KiB |
10
Content/widget_system_stats/project.json
Normal file
10
Content/widget_system_stats/project.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"description": "system_stats",
|
||||
"file": "main.qml",
|
||||
"preview": "preview.png",
|
||||
"tags": [
|
||||
"system_stats"
|
||||
],
|
||||
"title": "system_stats",
|
||||
"type": "qmlWidget"
|
||||
}
|
1
Content/widget_weather/Readme.md
Normal file
1
Content/widget_weather/Readme.md
Normal file
@ -0,0 +1 @@
|
||||
Widget that shows the latest xkcd
|
178
Content/widget_weather/main.qml
Normal file
178
Content/widget_weather/main.qml
Normal file
@ -0,0 +1,178 @@
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Controls.Material
|
||||
import QtQuick.Controls.Material.impl
|
||||
import Qt5Compat.GraphicalEffects
|
||||
import ScreenPlayWeather
|
||||
|
||||
Item {
|
||||
id: root
|
||||
implicitWidth: 900
|
||||
implicitHeight: 650
|
||||
|
||||
|
||||
Material.theme: Material.Dark
|
||||
Material.accent: Material.DeepOrange
|
||||
|
||||
ScreenPlayWeather {
|
||||
id: weather
|
||||
city: "Friedrichshafen"
|
||||
onReady: {
|
||||
rp.model = weather.days;
|
||||
// Qt bug https://bugreports.qt.io/browse/QTBUG-105137
|
||||
test();
|
||||
}
|
||||
}
|
||||
function test() {
|
||||
}
|
||||
|
||||
function mapWeatherCode(code) {
|
||||
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";
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
return weather_prefix + "cloud";
|
||||
case 45:
|
||||
case 48:
|
||||
return weather_prefix + "day-sunny";
|
||||
case 51:
|
||||
case 53:
|
||||
case 55:
|
||||
return weather_prefix + "rain-mix";
|
||||
case 61:
|
||||
case 63:
|
||||
case 65:
|
||||
return weather_prefix + "rain-mix";
|
||||
case 71:
|
||||
case 73:
|
||||
case 75:
|
||||
return weather_prefix + "snow";
|
||||
case 77:
|
||||
return weather_prefix + "snow";
|
||||
case 80:
|
||||
case 81:
|
||||
case 82:
|
||||
return weather_prefix + "snow";
|
||||
case 85:
|
||||
case 86:
|
||||
return weather_prefix + "snow";
|
||||
case 95:
|
||||
return weather_prefix + "thunderstorm";
|
||||
case 96:
|
||||
case 99:
|
||||
return weather_prefix + "storm-showers";
|
||||
}
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
id: wrapper
|
||||
anchors.centerIn: parent
|
||||
width: implicitWidth + 100
|
||||
height: implicitHeight + 100
|
||||
TextField {
|
||||
Layout.alignment: Qt.AlignCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
color: Material.primaryTextColor
|
||||
onEditingFinished: weather.setCity(text)
|
||||
text: "Friedrichshafen"
|
||||
}
|
||||
Text {
|
||||
Layout.alignment: Qt.AlignCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
color: Material.primaryTextColor
|
||||
text: "longtitude: " + weather.longtitude + " - latitude: " + weather.latitude + " - elevation: " + weather.elevation + "m - population: " + weather.population
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
Repeater {
|
||||
id: rp
|
||||
onModelChanged: print("MODEL CHANGED")
|
||||
onCountChanged: print(count)
|
||||
ColumnLayout {
|
||||
id: cl
|
||||
spacing: 20
|
||||
Layout.preferredWidth: 120
|
||||
TextItem {
|
||||
text: "Day"
|
||||
value: day
|
||||
}
|
||||
TextItem {
|
||||
text: "Sunrise"
|
||||
value: sunrise
|
||||
}
|
||||
TextItem {
|
||||
text: "Sunset"
|
||||
value: sunset
|
||||
}
|
||||
|
||||
Image {
|
||||
height: 64
|
||||
width: height
|
||||
sourceSize: Qt.size(height, height)
|
||||
layer {
|
||||
enabled: true
|
||||
effect: ColorOverlay {
|
||||
color: Material.primaryColor
|
||||
}
|
||||
}
|
||||
Layout.alignment: Qt.AlignCenter
|
||||
horizontalAlignment: Image.AlignHCenter
|
||||
source: "qrc:/qml/ScreenPlayWeather/assets/icons/" + root.mapWeatherCode(weatherCode) + ".svg"
|
||||
}
|
||||
TextItem {
|
||||
text: "Weather Code"
|
||||
value: weatherCode
|
||||
}
|
||||
TextItem {
|
||||
text: "Temperature min"
|
||||
value: temperature_2m_min
|
||||
}
|
||||
TextItem {
|
||||
text: "Temperature max"
|
||||
value: temperature_2m_max
|
||||
}
|
||||
|
||||
// TextItem {
|
||||
// text: "Precipitation Sum"
|
||||
// value: precipitationSum
|
||||
// }
|
||||
|
||||
// TextItem {
|
||||
// text: "Precipitation Hours"
|
||||
// value: precipitationHours
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
component TextItem: Column {
|
||||
property alias value: value.text
|
||||
property alias text: description.text
|
||||
Layout.preferredWidth: 120
|
||||
Text {
|
||||
id: value
|
||||
width: 120
|
||||
font.pointSize: 16
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
color: Material.primaryTextColor
|
||||
}
|
||||
Text {
|
||||
id: description
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
color: Material.secondaryTextColor
|
||||
width: 120
|
||||
}
|
||||
}
|
||||
}
|
BIN
Content/widget_weather/preview.png
Normal file
BIN
Content/widget_weather/preview.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 244 KiB |
10
Content/widget_weather/project.json
Normal file
10
Content/widget_weather/project.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"description": "weather",
|
||||
"file": "main.qml",
|
||||
"preview": "preview.png",
|
||||
"tags": [
|
||||
"weather"
|
||||
],
|
||||
"title": "weather",
|
||||
"type": "qmlWidget"
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Controls.Material
|
||||
import QtQuick.Effects
|
||||
import QtQuick.Particles
|
||||
|
||||
|
@ -54,9 +54,9 @@ int main(int argc, char* argv[])
|
||||
if (argumentList.length() == 1) {
|
||||
QString exampleContentPath = QString(SCREENPLAY_SOURCE_DIR) + "/Content";
|
||||
QStringList contentFolder = {
|
||||
"/wallpaper_landscape",
|
||||
"/wallpaper_video_nebula",
|
||||
"/wallpaper_particles",
|
||||
"/wallpaper_landscape"
|
||||
"/wallpaper_particles"
|
||||
};
|
||||
QString projectPath = exampleContentPath + contentFolder.at(0);
|
||||
|
||||
@ -67,7 +67,7 @@ int main(int argc, char* argv[])
|
||||
window.setFillMode("cover");
|
||||
window.setType(ScreenPlay::InstalledType::InstalledType::VideoWallpaper);
|
||||
window.setCheckWallpaperVisible(true);
|
||||
window.setDebugMode(true);
|
||||
window.setDebugMode(false);
|
||||
} else {
|
||||
// 8 parameter + 1 OS working directory as the first default paramter
|
||||
if (argumentList.length() != 9) {
|
||||
|
@ -40,6 +40,9 @@ int main(int argc, char* argv[])
|
||||
|
||||
QString exampleContentPath = QString(SCREENPLAY_SOURCE_DIR) + "/Content";
|
||||
QStringList contentFolder = {
|
||||
"/widget_system_stats", // Note: Windows only
|
||||
"/widget_countDown",
|
||||
"/widget_weather",
|
||||
"/widget_analogClock",
|
||||
"/widget_digitalClock",
|
||||
"/widget_rss_reddit",
|
||||
|
Loading…
Reference in New Issue
Block a user