From 93536aa33906895760d87c79da5f74471fcf0696 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Tue, 10 Oct 2017 13:18:53 -0400 Subject: Change the layout of the screensaver files directory a bit. This adds the formalization of a JSON manifest for determining which screensavers are valid and how to launch them, as well as all sorts of other legal/author information as desired. --- .../extrafiles/screensavers/Fireflies.json | 26 +++++++ .../extrafiles/screensavers/Fireflies.qml | 19 ------ .../extrafiles/screensavers/Firefly.qml | 63 ----------------- .../extrafiles/screensavers/README.md | 79 ++++++++++++++++++++++ .../screensavers/qml_scripts/Fireflies.qml | 19 ++++++ .../screensavers/qml_scripts/Firefly.qml | 63 +++++++++++++++++ 6 files changed, 187 insertions(+), 82 deletions(-) create mode 100644 src-qt5/core/lumina-desktop-unified/extrafiles/screensavers/Fireflies.json delete mode 100644 src-qt5/core/lumina-desktop-unified/extrafiles/screensavers/Fireflies.qml delete mode 100644 src-qt5/core/lumina-desktop-unified/extrafiles/screensavers/Firefly.qml create mode 100644 src-qt5/core/lumina-desktop-unified/extrafiles/screensavers/README.md create mode 100644 src-qt5/core/lumina-desktop-unified/extrafiles/screensavers/qml_scripts/Fireflies.qml create mode 100644 src-qt5/core/lumina-desktop-unified/extrafiles/screensavers/qml_scripts/Firefly.qml (limited to 'src-qt5/core/lumina-desktop-unified') diff --git a/src-qt5/core/lumina-desktop-unified/extrafiles/screensavers/Fireflies.json b/src-qt5/core/lumina-desktop-unified/extrafiles/screensavers/Fireflies.json new file mode 100644 index 00000000..e01d6d2b --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/extrafiles/screensavers/Fireflies.json @@ -0,0 +1,26 @@ +{ + "name" : { + "default" : "Fireflies" + }, + "description" : { + "default" : "Dancing balls of light on the screen" + }, + "author" : { + "name" : "Ken Moore", + "email" : "ken@ixsystems.com", + "website" : "https://github.com/beanpole135", + "company" : "iXsystems", + "company_website" : "http://ixsystems.com" + }, + "meta" : { + "license" : "3-clause BSD", + "license_url" : "https://github.com/trueos/lumina/blob/master/LICENSE", + "copyright" : "Copyright (c) 2017, Ken Moore (ken@ixsystems.com)", + "date_created" : "20171010", + "version" : "1.0" + } + "qml" : { + "qml_file" : "qml_scripts/Fireflies.qml", + "additional_files" : ["qml_scripts/Firefly.qml"] + } +} diff --git a/src-qt5/core/lumina-desktop-unified/extrafiles/screensavers/Fireflies.qml b/src-qt5/core/lumina-desktop-unified/extrafiles/screensavers/Fireflies.qml deleted file mode 100644 index d8dcc1ed..00000000 --- a/src-qt5/core/lumina-desktop-unified/extrafiles/screensavers/Fireflies.qml +++ /dev/null @@ -1,19 +0,0 @@ -import QtQuick 2.0 -import QtGraphicalEffects 1.0 -import "." as QML - -Rectangle { - id : canvas - anchors.fill: parent - color: "black" - - Repeater { - model: Math.round(Math.random()*canvas.width/10)+100 - QML.Firefly { - parent: canvas - x: Math.round(Math.random()*canvas.width) - y: Math.round(Math.random()*canvas.height) - } - } //end of Repeater - -} //end of canvas rectangle diff --git a/src-qt5/core/lumina-desktop-unified/extrafiles/screensavers/Firefly.qml b/src-qt5/core/lumina-desktop-unified/extrafiles/screensavers/Firefly.qml deleted file mode 100644 index 7b65d8ec..00000000 --- a/src-qt5/core/lumina-desktop-unified/extrafiles/screensavers/Firefly.qml +++ /dev/null @@ -1,63 +0,0 @@ -import QtQuick 2.0 -import QtQuick.Window 2.2 -import QtGraphicalEffects 1.0 - -Item { - - RectangularGlow { - anchors.fill: fly - glowRadius: Math.round(fly.radius /2) - spread: 0.5 - color: Qt.rgba(1,1,1,0.3) - cornerRadius: fly.radius + glowRadius - } - - Rectangle { - id: fly - width: Math.round(Math.random()*canvas.width/200)+2 - height: width - x: parent.x - y: parent.y - color: Qt.rgba(Math.random(),Math.random(),0,0.5) - radius: Math.floor(width/2) - property int jitterX: Math.round(Math.random()*100)+10 - property int jitterY: Math.round(Math.random()*100)+10 - - Behavior on color { - ColorAnimation { - duration: 500 - } - } - Behavior on x { - SmoothedAnimation { - velocity: 10+Math.random()*canvas.width/100 - } - } - Behavior on y { - SmoothedAnimation { - velocity: 10+Math.random()*canvas.height/100 - } - } - - } - - - - Timer { - interval: 5 - repeat: true - running: true - property bool starting: true - onTriggered: { - if(starting){ interval = Math.round(Math.random()*1000)+500; starting = false; } - if ( (fly.x+fly.jitterX)>parent.width || (fly.x+fly.jitterX)<0 ){ fly.jitterX = 0-fly.jitterX } - fly.x = fly.x+fly.jitterX - if( (fly.y+fly.jitterY)>parent.height || (fly.y+fly.jitterY)<0 ){ fly.jitterY = 0-fly.jitterY } - fly.y = fly.y+fly.jitterY - fly.jitterX = (Math.round(Math.random())*2 - 1) *fly.jitterX - fly.jitterY = (Math.round(Math.random())*2 - 1) *fly.jitterY - fly.color = Qt.rgba(Math.random(),Math.random(),Math.random(),0.5) - - } - } //end of timer -} //end of item diff --git a/src-qt5/core/lumina-desktop-unified/extrafiles/screensavers/README.md b/src-qt5/core/lumina-desktop-unified/extrafiles/screensavers/README.md new file mode 100644 index 00000000..768f0e14 --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/extrafiles/screensavers/README.md @@ -0,0 +1,79 @@ +## Screensaver Format +The screensaver system for the Lumina desktop allows for the creation and use of scripts written in the QML language, with a number of screensavers and other examples installed out-of-box. There are only a couple warnings/caveats to consider when developing a new screensaver: + +1. The root object in your QML script will be automatically sized to fit the screen as needed. Avoid trying to hard-code specific screen dimensions within your script as it will not work properly. +2. A JSON manifest file must be created (format listed below) and placed into one of the screensaver plugin directories for it to be recognized as a valid screensaver by the desktop. + + +### JSON Manifest +The manifest file contains all the information needed to actually validate/launch the screensaver, as well as additional information about the author and/or the screensaver itself. + +Example JSON manifest file (sample.json): +``` +{ + "name" : { + "default" : "sample", + "en_US" : "US English localization of the name" + "en" : "Generic english localization of the name" + } + + "description" : { + "default" : "sample screensaver", + "en_US" : "US English Localization of the description" + } + + "author" : { + "name" : "Me", + "email" : "Me@myself.net", + "website" : "http://mywebsite.net", + "company" : "iXsystems" + "company_website" : "http://ixsystems.com" + } + + "meta" : { + "license" : "3-clause BSD", + "license_url" : "https://github.com/trueos/lumina/blob/master/LICENSE", + "copyright" : "Copyright (c) 2017, Ken Moore (ken@ixsystems.com)", + "date_created" : "20171010", + "date_updated" : "20171011", + "version" : "1.0" + } + + "qml" : { + "exec" : "absolute/or/relative/path/to/script.qml", + "additional_files" : ["file/which/must/exist.png"], + "qt_min_version" : "5.0", + "qt_max_version" : "6.0" + } +} +``` + +Details of the individual items in the manifest: +* NOTE: for locale codes, both long and short version are acceptable: + Example 1: If the current locale is "en_GB", but the JSON manifest lists translations for "en_US" and "en", then the "en" translation will be used. + Example 2: If the current locale is "en_GB", but neither "en_GB" nor "en" translations exist, then the "default" version will be used. + +* **name** : (required) This is the official name of the screensaver to show to users + * *default* : (required) Non-translated name of the screensaver + * *[locale]* : (optional) Translated name for specific [locale] +* **description** : (required) This is a short description of the screensaver to show to users + * *default* : (required) Non-translated description of the screensaver + * *[locale]* : (optional) Translated description for specific [locale] +* **author** : (all optional) Additional information about the author(s) of the screensaver + * *name* : Name of the author + * *email* : Email to contact the author (useful for licensing questions and such) + * *website* : Personal website for the author (github/facebook/twitter profile, etc) + * *company* : Company for which the author is creating this screensaver + * *company_website* : Website for the company +* **meta** : (all optional) Additional information about the screensaver itself + * *license* : License the screensaver is released under + * *license_url* : Website which contains the full text of the license + * *copyright* : Copyright notice for this screensaver + * *date_created* : (yyyyMMdd) Date the screensaver was initially created + * *date_updated* : (yyyyMMdd) Date the screensaver was last updated + * *version* : Current version of the screensaver (typically updated every time "date_updated" is changed) +* **qml** : (required) Information about launching the screensaver and checking validity + * *exec* : (required) Absolute or relative path to the QML script (relative to the directory which contains the JSON manifest) + * *additional_files* : (optional) Array of paths for other files/scripts which must exist for the screensaver to work properly. + * *qt_min_version* : (optional) Minimum version of the Qt libraries that this screensaver supports + * *qt_max_version* : (optional) Maximum version of the Qt libraries that this screensaver supports diff --git a/src-qt5/core/lumina-desktop-unified/extrafiles/screensavers/qml_scripts/Fireflies.qml b/src-qt5/core/lumina-desktop-unified/extrafiles/screensavers/qml_scripts/Fireflies.qml new file mode 100644 index 00000000..d8dcc1ed --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/extrafiles/screensavers/qml_scripts/Fireflies.qml @@ -0,0 +1,19 @@ +import QtQuick 2.0 +import QtGraphicalEffects 1.0 +import "." as QML + +Rectangle { + id : canvas + anchors.fill: parent + color: "black" + + Repeater { + model: Math.round(Math.random()*canvas.width/10)+100 + QML.Firefly { + parent: canvas + x: Math.round(Math.random()*canvas.width) + y: Math.round(Math.random()*canvas.height) + } + } //end of Repeater + +} //end of canvas rectangle diff --git a/src-qt5/core/lumina-desktop-unified/extrafiles/screensavers/qml_scripts/Firefly.qml b/src-qt5/core/lumina-desktop-unified/extrafiles/screensavers/qml_scripts/Firefly.qml new file mode 100644 index 00000000..7b65d8ec --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/extrafiles/screensavers/qml_scripts/Firefly.qml @@ -0,0 +1,63 @@ +import QtQuick 2.0 +import QtQuick.Window 2.2 +import QtGraphicalEffects 1.0 + +Item { + + RectangularGlow { + anchors.fill: fly + glowRadius: Math.round(fly.radius /2) + spread: 0.5 + color: Qt.rgba(1,1,1,0.3) + cornerRadius: fly.radius + glowRadius + } + + Rectangle { + id: fly + width: Math.round(Math.random()*canvas.width/200)+2 + height: width + x: parent.x + y: parent.y + color: Qt.rgba(Math.random(),Math.random(),0,0.5) + radius: Math.floor(width/2) + property int jitterX: Math.round(Math.random()*100)+10 + property int jitterY: Math.round(Math.random()*100)+10 + + Behavior on color { + ColorAnimation { + duration: 500 + } + } + Behavior on x { + SmoothedAnimation { + velocity: 10+Math.random()*canvas.width/100 + } + } + Behavior on y { + SmoothedAnimation { + velocity: 10+Math.random()*canvas.height/100 + } + } + + } + + + + Timer { + interval: 5 + repeat: true + running: true + property bool starting: true + onTriggered: { + if(starting){ interval = Math.round(Math.random()*1000)+500; starting = false; } + if ( (fly.x+fly.jitterX)>parent.width || (fly.x+fly.jitterX)<0 ){ fly.jitterX = 0-fly.jitterX } + fly.x = fly.x+fly.jitterX + if( (fly.y+fly.jitterY)>parent.height || (fly.y+fly.jitterY)<0 ){ fly.jitterY = 0-fly.jitterY } + fly.y = fly.y+fly.jitterY + fly.jitterX = (Math.round(Math.random())*2 - 1) *fly.jitterX + fly.jitterY = (Math.round(Math.random())*2 - 1) *fly.jitterY + fly.color = Qt.rgba(Math.random(),Math.random(),Math.random(),0.5) + + } + } //end of timer +} //end of item -- cgit