From 0152ba7cb8229d69850312b54b8aa5030c4ba9db Mon Sep 17 00:00:00 2001 From: Patrizio Bekerle Date: Tue, 6 Jun 2017 12:10:27 +0200 Subject: [PATCH 1/4] added paste-from-skype-history script --- paste-from-skype-history/info.json | 9 +++++ .../paste-from-skype-history.qml | 39 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 paste-from-skype-history/info.json create mode 100644 paste-from-skype-history/paste-from-skype-history.qml diff --git a/paste-from-skype-history/info.json b/paste-from-skype-history/info.json new file mode 100644 index 0000000..44d2b5c --- /dev/null +++ b/paste-from-skype-history/info.json @@ -0,0 +1,9 @@ +{ + "name": "Paste text from Skype history", + "identifier": "paste-from-skype-history", + "script": "paste-from-skype-history.qml", + "authors": ["@pbek"], + "version": "0.0.1", + "minAppVersion": "17.05.6", + "description" : "This script creates a menu item and a button that parses the text that was copied from the Skype Electron client to the clipboard and tries to extract and paste text from it." +} diff --git a/paste-from-skype-history/paste-from-skype-history.qml b/paste-from-skype-history/paste-from-skype-history.qml new file mode 100644 index 0000000..04635bd --- /dev/null +++ b/paste-from-skype-history/paste-from-skype-history.qml @@ -0,0 +1,39 @@ +import QtQml 2.0 +import QOwnNotesTypes 1.0 + +/** + * This script creates a menu item and a button that parses the text that was copied from the Skype Electron client + * to the clipboard and tries to extract and paste text from it + */ +QtObject { + /** + * Initializes the custom action + */ + function init() { + // create a menu entry with a button and a freedesktop theme icon + script.registerCustomAction("pasteFromSkypeHistory", "Paste text from Skype history", "Paste Skype Text", "edit-paste"); + } + + /** + * This function is invoked when a custom action is triggered + * in the menu or via button + * + * @param identifier string the identifier defined in registerCustomAction + */ + function customActionInvoked(identifier) { + if (identifier != "pasteFromSkypeHistory") { + return; + } + // get the text that is currently in the clipboard + var html = script.clipboard(true); + +// script.log(html); + + var textRegExp = /(.+?)<\/p>/gim; + var match; + + while ((match = textRegExp.exec(html)) !== null) { + script.noteTextEditWrite(match[1].replace(/<.+?>/gim, "") + "\n"); + } + } +} From e880663c10013daf4ca195d1760919e07fd4ee4b Mon Sep 17 00:00:00 2001 From: Patrizio Bekerle Date: Thu, 8 Jun 2017 09:47:16 +0200 Subject: [PATCH 2/4] added weather stats script --- weather-stats/info.json | 9 ++++ weather-stats/weather-stats.qml | 73 +++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 weather-stats/info.json create mode 100644 weather-stats/weather-stats.qml diff --git a/weather-stats/info.json b/weather-stats/info.json new file mode 100644 index 0000000..fe125ce --- /dev/null +++ b/weather-stats/info.json @@ -0,0 +1,9 @@ +{ + "name": "Weather stats", + "identifier": "weather-stats", + "script": "weather-stats.qml", + "version": "0.0.1", + "minAppVersion": "17.06.4", + "authors": ["@pbek"], + "description" : "This script shows the current weather in the Scripting widget. You can configure the city in the Scripting Settings. The Yahoo weather service is used to fetch the weather. The information is updated every 10min." +} diff --git a/weather-stats/weather-stats.qml b/weather-stats/weather-stats.qml new file mode 100644 index 0000000..6d62dd1 --- /dev/null +++ b/weather-stats/weather-stats.qml @@ -0,0 +1,73 @@ +import QtQml 2.0 +import QOwnNotesTypes 1.0 + +/** + * This script shows current weather statistics in a "scripting label" + */ + +Script { + // you have to define your registered variables so you can access them later + property string city; + property bool useFahrenheit; + + // register your settings variables so the user can set them in the script settings + // use this property if you don't need + property variant settingsVariables: [ + { + "identifier": "city", + "name": "City", + "description": "Please enter your city:", + "type": "string", + "default": "Graz", + }, + { + "identifier": "useFahrenheit", + "name": "Unit", + "description": "Use Fahrenheit instead of Celsius", + "type": "boolean", + "default": false, + }, + ]; + + function init() { + script.registerLabel("weather stats") + weatherStats(); + } + + function weatherStats() { + script.log(useFahrenheit); + var unitString = useFahrenheit ? "f" : "c" + var json = script.downloadUrlToString("https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22" + city + "%22)%20and%20u%3D%27" + unitString + "%27&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys"); + var weatherInfo = JSON.parse(json); + + var temp = weatherInfo.query.results.channel.item.condition.temp + var unit = weatherInfo.query.results.channel.units.temperature; + var conditionText = weatherInfo.query.results.channel.item.condition.text + + if (!useFahrenheit) { + unit = "°" + unit; + } + + script.setLabelText("weather stats", + " + + +
Weather in " + city + ": " + conditionText + " at " + temp + " " + unit + " +
") + } + + /** + * This starts a timer that triggers every 10min + */ + property QtObject timer: Timer { + interval: 600000 + repeat: true + running: true + + property int count: 0 + + onTriggered: { + weatherStats(); + } + } +} From de6dcdb75ed609ad344dc7547ca4a4bc7eae7a83 Mon Sep 17 00:00:00 2001 From: Patrizio Bekerle Date: Thu, 8 Jun 2017 17:43:19 +0200 Subject: [PATCH 3/4] updated weather-stats.qml script --- weather-stats/info.json | 2 +- weather-stats/weather-stats.qml | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/weather-stats/info.json b/weather-stats/info.json index fe125ce..dc0073b 100644 --- a/weather-stats/info.json +++ b/weather-stats/info.json @@ -2,7 +2,7 @@ "name": "Weather stats", "identifier": "weather-stats", "script": "weather-stats.qml", - "version": "0.0.1", + "version": "0.0.2", "minAppVersion": "17.06.4", "authors": ["@pbek"], "description" : "This script shows the current weather in the Scripting widget. You can configure the city in the Scripting Settings. The Yahoo weather service is used to fetch the weather. The information is updated every 10min." diff --git a/weather-stats/weather-stats.qml b/weather-stats/weather-stats.qml index 6d62dd1..25f3c76 100644 --- a/weather-stats/weather-stats.qml +++ b/weather-stats/weather-stats.qml @@ -3,6 +3,9 @@ import QOwnNotesTypes 1.0 /** * This script shows current weather statistics in a "scripting label" + * + * The Yahoo weather api is used for fetching the weather data + * https://developer.yahoo.com/weather/ */ Script { @@ -11,7 +14,6 @@ Script { property bool useFahrenheit; // register your settings variables so the user can set them in the script settings - // use this property if you don't need property variant settingsVariables: [ { "identifier": "city", @@ -41,17 +43,23 @@ Script { var weatherInfo = JSON.parse(json); var temp = weatherInfo.query.results.channel.item.condition.temp - var unit = weatherInfo.query.results.channel.units.temperature; + var tempUnit = weatherInfo.query.results.channel.units.temperature; var conditionText = weatherInfo.query.results.channel.item.condition.text + var weatherCity = weatherInfo.query.results.channel.location.city + var windSpeed = weatherInfo.query.results.channel.wind.speed + var windUnit = weatherInfo.query.results.channel.units.speed; if (!useFahrenheit) { - unit = "°" + unit; + tempUnit = "°" + tempUnit; } script.setLabelText("weather stats", - " + "
-
Weather in " + city + ": " + conditionText + " at " + temp + " " + unit + " + + Weather in " + weatherCity + ": " + conditionText + " at " + temp + " " + tempUnit + " + (" + windSpeed + " " + windUnit + " wind) +
") } From 9a3be00a4ff9458191d3aecd2b50d35ad0f81885 Mon Sep 17 00:00:00 2001 From: Patrizio Bekerle Date: Fri, 9 Jun 2017 08:22:54 +0200 Subject: [PATCH 4/4] removed a log message --- weather-stats/info.json | 2 +- weather-stats/weather-stats.qml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/weather-stats/info.json b/weather-stats/info.json index dc0073b..5abb41a 100644 --- a/weather-stats/info.json +++ b/weather-stats/info.json @@ -2,7 +2,7 @@ "name": "Weather stats", "identifier": "weather-stats", "script": "weather-stats.qml", - "version": "0.0.2", + "version": "0.0.3", "minAppVersion": "17.06.4", "authors": ["@pbek"], "description" : "This script shows the current weather in the Scripting widget. You can configure the city in the Scripting Settings. The Yahoo weather service is used to fetch the weather. The information is updated every 10min." diff --git a/weather-stats/weather-stats.qml b/weather-stats/weather-stats.qml index 25f3c76..f104498 100644 --- a/weather-stats/weather-stats.qml +++ b/weather-stats/weather-stats.qml @@ -37,7 +37,6 @@ Script { } function weatherStats() { - script.log(useFahrenheit); var unitString = useFahrenheit ? "f" : "c" var json = script.downloadUrlToString("https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22" + city + "%22)%20and%20u%3D%27" + unitString + "%27&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys"); var weatherInfo = JSON.parse(json);