feat: fahrenheit option for weather (#189)
* Added Fahrenheit to Weather Service * some fixes Allow for hot reloading config opt Add opt to example config --------- Co-authored-by: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>
This commit is contained in:
parent
b8a4d1d312
commit
b053130570
5 changed files with 9 additions and 5 deletions
|
|
@ -166,7 +166,8 @@ All configuration options are in `~/.config/caelestia/shell.json`.
|
||||||
"dashboard": {
|
"dashboard": {
|
||||||
"mediaUpdateInterval": 500,
|
"mediaUpdateInterval": 500,
|
||||||
"visualiserBars": 45,
|
"visualiserBars": 45,
|
||||||
"weatherLocation": "10,10"
|
"weatherLocation": "10,10",
|
||||||
|
"useFahrenheit": false,
|
||||||
},
|
},
|
||||||
"launcher": {
|
"launcher": {
|
||||||
"actionPrefix": ">",
|
"actionPrefix": ">",
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ JsonObject {
|
||||||
property int mediaUpdateInterval: 500
|
property int mediaUpdateInterval: 500
|
||||||
property int visualiserBars: 45
|
property int visualiserBars: 45
|
||||||
property string weatherLocation: "" // A lat,long pair, e.g. "37.8267,-122.4233"
|
property string weatherLocation: "" // A lat,long pair, e.g. "37.8267,-122.4233"
|
||||||
|
property bool useFahrenheit: false
|
||||||
|
|
||||||
property JsonObject sizes: JsonObject {
|
property JsonObject sizes: JsonObject {
|
||||||
readonly property int tabIndicatorHeight: 3
|
readonly property int tabIndicatorHeight: 3
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ Item {
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
|
||||||
animate: true
|
animate: true
|
||||||
text: `${Weather.temperature}°C`
|
text: Config.dashboard.useFahrenheit ? Weather.tempF : Weather.tempC
|
||||||
color: Colours.palette.m3primary
|
color: Colours.palette.m3primary
|
||||||
font.pointSize: Appearance.font.size.extraLarge
|
font.pointSize: Appearance.font.size.extraLarge
|
||||||
font.weight: 500
|
font.weight: 500
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ RowLayout {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
animate: true
|
animate: true
|
||||||
text: `${Weather.temperature}°C`
|
text: Config.dashboard.useFahrenheit ? Weather.tempF : Weather.tempC
|
||||||
color: Colours.palette.m3primary
|
color: Colours.palette.m3primary
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
font.pointSize: Appearance.font.size.extraLarge
|
font.pointSize: Appearance.font.size.extraLarge
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,8 @@ Singleton {
|
||||||
property string loc
|
property string loc
|
||||||
property string icon
|
property string icon
|
||||||
property string description
|
property string description
|
||||||
property real temperature
|
property string tempC: "0°C"
|
||||||
|
property string tempF: "0°F"
|
||||||
|
|
||||||
function reload(): void {
|
function reload(): void {
|
||||||
if (Config.dashboard.weatherLocation)
|
if (Config.dashboard.weatherLocation)
|
||||||
|
|
@ -27,7 +28,8 @@ Singleton {
|
||||||
const json = JSON.parse(text).current_condition[0];
|
const json = JSON.parse(text).current_condition[0];
|
||||||
icon = Icons.getWeatherIcon(json.weatherCode);
|
icon = Icons.getWeatherIcon(json.weatherCode);
|
||||||
description = json.weatherDesc[0].value;
|
description = json.weatherDesc[0].value;
|
||||||
temperature = parseFloat(json.temp_C);
|
tempC = `${parseFloat(json.temp_C)}°C`;
|
||||||
|
tempF = `${parseFloat(json.temp_F)}°F`;
|
||||||
})
|
})
|
||||||
|
|
||||||
Component.onCompleted: reload()
|
Component.onCompleted: reload()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue